Reactions View
Changelog-Added: Added Reactions View
This commit is contained in:
@@ -29,14 +29,6 @@ struct EventActionBar: View {
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
/*
|
||||
EventActionButton(img: "square.and.arrow.up") {
|
||||
print("share")
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
*/
|
||||
if damus_state.keypair.privkey != nil {
|
||||
EventActionButton(img: "bubble.left", col: nil) {
|
||||
notify(.reply, event)
|
||||
39
damus/Views/ActionBar/EventDetailBar.swift
Normal file
39
damus/Views/ActionBar/EventDetailBar.swift
Normal file
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// EventDetailBar.swift
|
||||
// damus
|
||||
//
|
||||
// Created by William Casarin on 2023-01-08.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct EventDetailBar: View {
|
||||
let state: DamusState
|
||||
let target: String
|
||||
@StateObject var bar: ActionBarModel
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
Text("\(bar.boosts)")
|
||||
.font(.body.bold())
|
||||
Text("Reposts")
|
||||
|
||||
NavigationLink(destination: ReactionsView(damus_state: state, model: ReactionsModel(state: state, target: target))) {
|
||||
Text("\(bar.likes)")
|
||||
.font(.body.bold())
|
||||
Text("Reactions")
|
||||
}
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
|
||||
Text("\(bar.tips)")
|
||||
.font(.body.bold())
|
||||
Text("Tips")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct EventDetailBar_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
EventDetailBar(state: test_damus_state(), target: "", bar: ActionBarModel.empty())
|
||||
}
|
||||
}
|
||||
@@ -251,6 +251,13 @@ struct EventView: View {
|
||||
}
|
||||
|
||||
let bar = make_actionbar_model(ev: event, damus: damus)
|
||||
|
||||
if size == .selected {
|
||||
EventDetailBar(state: damus, target: event.id, bar: bar)
|
||||
Divider()
|
||||
.padding([.bottom], 4)
|
||||
}
|
||||
|
||||
EventActionBar(damus_state: damus, event: event, bar: bar)
|
||||
}
|
||||
|
||||
|
||||
36
damus/Views/Reactions/ReactionView.swift
Normal file
36
damus/Views/Reactions/ReactionView.swift
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// ReactionView.swift
|
||||
// damus
|
||||
//
|
||||
// Created by William Casarin on 2023-01-11.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ReactionView: View {
|
||||
let damus_state: DamusState
|
||||
let reaction: NostrEvent
|
||||
|
||||
var content: String {
|
||||
if reaction.content == "" || reaction.content == "+" {
|
||||
return "❤️"
|
||||
}
|
||||
return reaction.content
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
Text(content)
|
||||
.font(Font.headline)
|
||||
.frame(width: 50, height: 50)
|
||||
|
||||
FollowUserView(target: .pubkey(reaction.pubkey), damus_state: damus_state)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ReactionView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ReactionView(damus_state: test_damus_state(), reaction: NostrEvent(id: "", content: "🤙🏼", pubkey: ""))
|
||||
}
|
||||
}
|
||||
38
damus/Views/ReactionsView.swift
Normal file
38
damus/Views/ReactionsView.swift
Normal file
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// ReactionsView.swift
|
||||
// damus
|
||||
//
|
||||
// Created by William Casarin on 2023-01-11.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ReactionsView: View {
|
||||
let damus_state: DamusState
|
||||
@StateObject var model: ReactionsModel
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
LazyVStack {
|
||||
ForEach(model.reactions, id: \.id) { ev in
|
||||
ReactionView(damus_state: damus_state, reaction: ev)
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
.navigationBarTitle("Reactions")
|
||||
.onAppear {
|
||||
model.subscribe()
|
||||
}
|
||||
.onDisappear {
|
||||
model.unsubscribe()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ReactionsView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
let state = test_damus_state()
|
||||
ReactionsView(damus_state: state, model: ReactionsModel(state: state, target: "pubkey"))
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,7 @@ struct SearchView_Previews: PreviewProvider {
|
||||
let test_state = test_damus_state()
|
||||
let filter = NostrFilter.filter_hashtag(["bitcoin"])
|
||||
let pool = test_state.pool
|
||||
|
||||
let model = SearchModel(pool: pool, search: filter)
|
||||
|
||||
SearchView(appstate: test_state, search: model)
|
||||
|
||||
Reference in New Issue
Block a user