Files
damus/damus/Views/Zaps/ZapsView.swift
T
William Casarin 043eb5b436 Show zap comments in threads and show top zap
Changelog-Added: Top zaps
Changelog-Added: Show zap comments in threads
2023-06-09 10:11:25 +02:00

46 lines
1.1 KiB
Swift

//
// ZapsView.swift
// damus
//
// Created by William Casarin on 2023-02-10.
//
import SwiftUI
struct ZapsView: View {
let state: DamusState
var model: ZapsModel
@ObservedObject var zaps: ZapsDataModel
init(state: DamusState, target: ZapTarget) {
self.state = state
self.model = ZapsModel(state: state, target: target)
self._zaps = ObservedObject(wrappedValue: state.events.get_cache_data(target.id).zaps_model)
}
var body: some View {
ScrollView {
LazyVStack {
ForEach(zaps.zaps, id: \.request.ev.id) { zap in
ZapEvent(damus: state, zap: zap, is_top_zap: false)
.padding([.horizontal])
}
}
}
.navigationBarTitle(NSLocalizedString("Zaps", comment: "Navigation bar title for the Zaps view."))
.onAppear {
model.subscribe()
}
.onDisappear {
model.unsubscribe()
}
}
}
struct ZapsView_Previews: PreviewProvider {
static var previews: some View {
ZapsView(state: test_damus_state(), target: .profile("pk"))
}
}