Add Reposts view

Changelog-Added: Reposts view
Closes: #376
This commit is contained in:
2023-01-22 23:24:10 -05:00
committed by William Casarin
parent 5daaec35a8
commit c046c7cf45
5 changed files with 163 additions and 1 deletions

View File

@@ -15,7 +15,10 @@ struct EventDetailBar: View {
var body: some View {
HStack {
if bar.boosts > 0 {
Text("\(Text("\(bar.boosts)", comment: "Number of reposts.").font(.body.bold())) \(Text(String(format: NSLocalizedString("reposts_count", comment: "Part of a larger sentence to describe how many reposts there are."), bar.boosts)).foregroundColor(.gray))", comment: "Sentence composed of 2 variables to describe how many reposts. In source English, the first variable is the number of reposts, and the second variable is 'Repost' or 'Reposts'.")
NavigationLink(destination: RepostsView(damus_state: state, model: RepostsModel(state: state, target: target))) {
Text("\(Text("\(bar.boosts)", comment: "Number of reposts.").font(.body.bold())) \(Text(String(format: NSLocalizedString("reposts_count", comment: "Part of a larger sentence to describe how many reposts there are."), bar.boosts)).foregroundColor(.gray))", comment: "Sentence composed of 2 variables to describe how many reposts. In source English, the first variable is the number of reposts, and the second variable is 'Repost' or 'Reposts'.")
}
.buttonStyle(PlainButtonStyle())
}
if bar.likes > 0 {

View File

@@ -0,0 +1,24 @@
//
// RepostView.swift
// damus
//
// Created by Terry Yiu on 1/22/23.
//
import SwiftUI
struct RepostView: View {
let damus_state: DamusState
let repost: NostrEvent
var body: some View {
FollowUserView(target: .pubkey(repost.pubkey), damus_state: damus_state)
}
}
struct RepostView_Previews: PreviewProvider {
static var previews: some View {
RepostView(damus_state: test_damus_state(), repost: NostrEvent(id: "", content: "", pubkey: ""))
}
}

View File

@@ -0,0 +1,38 @@
//
// RepostsView.swift
// damus
//
// Created by Terry Yiu on 1/22/23.
//
import SwiftUI
struct RepostsView: View {
let damus_state: DamusState
@StateObject var model: RepostsModel
var body: some View {
ScrollView {
LazyVStack {
ForEach(model.reposts, id: \.id) { ev in
RepostView(damus_state: damus_state, repost: ev)
}
}
.padding()
}
.navigationBarTitle(NSLocalizedString("Reposts", comment: "Navigation bar title for Reposts view."))
.onAppear {
model.subscribe()
}
.onDisappear {
model.unsubscribe()
}
}
}
struct RepostsView_Previews: PreviewProvider {
static var previews: some View {
let state = test_damus_state()
RepostsView(damus_state: state, model: RepostsModel(state: state, target: "pubkey"))
}
}