damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 300cd87fc2242ead441338c8e2f77b38cc3ff9c3
parent bff3c0dd522e90748888b2371175d024572d2ae8
Author: William Casarin <jb55@jb55.com>
Date:   Tue, 18 Apr 2023 10:42:56 -0700

Remove EmbeddedEventView

All embedded events are now just regular event views

Diffstat:
Mdamus.xcodeproj/project.pbxproj | 4----
Mdamus/Views/Events/BuilderEventView.swift | 8++------
Ddamus/Views/Events/EmbeddedEventView.swift | 47-----------------------------------------------
Mdamus/Views/Events/MutedEventView.swift | 6++----
Mdamus/Views/Events/TextEvent.swift | 8++++++--
Mdamus/Views/Profile/MaybeAnonPfpView.swift | 13++++++++-----
Mdamus/Views/ThreadView.swift | 3---
7 files changed, 18 insertions(+), 71 deletions(-)

diff --git a/damus.xcodeproj/project.pbxproj b/damus.xcodeproj/project.pbxproj @@ -182,7 +182,6 @@ 4CC7AAEB297F0AEC00430951 /* BuilderEventView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CC7AAEA297F0AEC00430951 /* BuilderEventView.swift */; }; 4CC7AAED297F0B9E00430951 /* Highlight.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CC7AAEC297F0B9E00430951 /* Highlight.swift */; }; 4CC7AAF0297F11C700430951 /* SelectedEventView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CC7AAEF297F11C700430951 /* SelectedEventView.swift */; }; - 4CC7AAF2297F129C00430951 /* EmbeddedEventView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CC7AAF1297F129C00430951 /* EmbeddedEventView.swift */; }; 4CC7AAF4297F18B400430951 /* ReplyDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CC7AAF3297F18B400430951 /* ReplyDescription.swift */; }; 4CC7AAF6297F1A6A00430951 /* EventBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CC7AAF5297F1A6A00430951 /* EventBody.swift */; }; 4CC7AAF8297F1CEE00430951 /* EventProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CC7AAF7297F1CEE00430951 /* EventProfile.swift */; }; @@ -590,7 +589,6 @@ 4CC7AAEA297F0AEC00430951 /* BuilderEventView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BuilderEventView.swift; sourceTree = "<group>"; }; 4CC7AAEC297F0B9E00430951 /* Highlight.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Highlight.swift; sourceTree = "<group>"; }; 4CC7AAEF297F11C700430951 /* SelectedEventView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectedEventView.swift; sourceTree = "<group>"; }; - 4CC7AAF1297F129C00430951 /* EmbeddedEventView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmbeddedEventView.swift; sourceTree = "<group>"; }; 4CC7AAF3297F18B400430951 /* ReplyDescription.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReplyDescription.swift; sourceTree = "<group>"; }; 4CC7AAF5297F1A6A00430951 /* EventBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventBody.swift; sourceTree = "<group>"; }; 4CC7AAF7297F1CEE00430951 /* EventProfile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventProfile.swift; sourceTree = "<group>"; }; @@ -1067,7 +1065,6 @@ isa = PBXGroup; children = ( 4CC7AAEF297F11C700430951 /* SelectedEventView.swift */, - 4CC7AAF1297F129C00430951 /* EmbeddedEventView.swift */, 4CC7AAF3297F18B400430951 /* ReplyDescription.swift */, 4CC7AAF5297F1A6A00430951 /* EventBody.swift */, 4CC7AAEA297F0AEC00430951 /* BuilderEventView.swift */, @@ -1582,7 +1579,6 @@ 4CCEB7AE29B53D260078AA28 /* SearchingEventView.swift in Sources */, 4CF0ABE929844AF100D66079 /* AnyCodable.swift in Sources */, 4C0A3F8F280F640A000448DE /* ThreadModel.swift in Sources */, - 4CC7AAF2297F129C00430951 /* EmbeddedEventView.swift in Sources */, 4C3AC79F2833115300E1F516 /* FollowButtonView.swift in Sources */, 4CC7AAE7297EFA7B00430951 /* Zap.swift in Sources */, 4C3BEFD22819DB9B00B3DE84 /* ProfileModel.swift in Sources */, diff --git a/damus/Views/Events/BuilderEventView.swift b/damus/Views/Events/BuilderEventView.swift @@ -48,10 +48,6 @@ struct BuilderEventView: View { return } - guard nostr_event.known_kind == .text else { - return - } - if event != nil { return } @@ -78,8 +74,8 @@ struct BuilderEventView: View { let thread = ThreadModel(event: ev, damus_state: damus) let dest = ThreadView(state: damus, thread: thread) NavigationLink(destination: dest) { - EmbeddedEventView(damus_state: damus, event: event) - .padding(8) + EventView(damus: damus, event: event, options: .embedded) + .padding([.top, .bottom], 8) }.buttonStyle(.plain) } else { ProgressView().padding() diff --git a/damus/Views/Events/EmbeddedEventView.swift b/damus/Views/Events/EmbeddedEventView.swift @@ -1,47 +0,0 @@ -// -// EmbeddedEventView.swift -// damus -// -// Created by William Casarin on 2023-01-23. -// - -import SwiftUI - -struct EmbeddedEventView: View { - let damus_state: DamusState - let event: NostrEvent - - var pubkey: String { - event.pubkey - } - - var body: some View { - VStack(alignment: .leading) { - let profile = damus_state.profiles.lookup(id: pubkey) - HStack { - EventProfile(damus_state: damus_state, pubkey: pubkey, profile: profile, size: .small) - - Spacer() - - EventMenuContext(event: event, keypair: damus_state.keypair, target_pubkey: event.pubkey, bookmarks: damus_state.bookmarks, muted_threads: damus_state.muted_threads) - .padding([.bottom], 4) - - } - .minimumScaleFactor(0.75) - .lineLimit(1) - - if event_is_reply(event, privkey: damus_state.keypair.privkey) { - ReplyDescription(event: event, profiles: damus_state.profiles) - } - - EventBody(damus_state: damus_state, event: event, size: .small, options: [.truncate_content]) - } - } -} - -struct EmbeddedEventView_Previews: PreviewProvider { - static var previews: some View { - EmbeddedEventView(damus_state: test_damus_state(), event: test_event) - .padding() - } -} diff --git a/damus/Views/Events/MutedEventView.swift b/damus/Views/Events/MutedEventView.swift @@ -10,15 +10,13 @@ import SwiftUI struct MutedEventView: View { let damus_state: DamusState let event: NostrEvent - let scroller: ScrollViewProxy? let selected: Bool @State var shown: Bool - init(damus_state: DamusState, event: NostrEvent, scroller: ScrollViewProxy?, selected: Bool) { + init(damus_state: DamusState, event: NostrEvent, selected: Bool) { self.damus_state = damus_state self.event = event - self.scroller = scroller self.selected = selected self._shown = State(initialValue: should_show_event(contacts: damus_state.contacts, ev: event)) } @@ -89,7 +87,7 @@ struct MutedEventView_Previews: PreviewProvider { static var previews: some View { - MutedEventView(damus_state: test_damus_state(), event: test_event, scroller: nil, selected: false) + MutedEventView(damus_state: test_damus_state(), event: test_event, selected: false) .frame(width: .infinity, height: 50) } } diff --git a/damus/Views/Events/TextEvent.swift b/damus/Views/Events/TextEvent.swift @@ -8,7 +8,8 @@ import SwiftUI struct EventViewOptions: OptionSet { - let rawValue: UInt8 + let rawValue: UInt32 + static let no_action_bar = EventViewOptions(rawValue: 1 << 0) static let no_replying_to = EventViewOptions(rawValue: 1 << 1) static let no_images = EventViewOptions(rawValue: 1 << 2) @@ -16,6 +17,9 @@ struct EventViewOptions: OptionSet { static let truncate_content = EventViewOptions(rawValue: 1 << 4) static let pad_content = EventViewOptions(rawValue: 1 << 5) static let no_translate = EventViewOptions(rawValue: 1 << 6) + static let small_pfp = EventViewOptions(rawValue: 1 << 7) + + static let embedded: EventViewOptions = [.no_action_bar, .small_pfp, .wide, .truncate_content] } struct TextEvent: View { @@ -43,7 +47,7 @@ struct TextEvent: View { } func Pfp(is_anon: Bool) -> some View { - MaybeAnonPfpView(state: damus, is_anon: is_anon, pubkey: pubkey) + MaybeAnonPfpView(state: damus, is_anon: is_anon, pubkey: pubkey, size: options.contains(.small_pfp) ? eventview_pfp_size(.small) : PFP_SIZE ) } func TopPart(is_anon: Bool) -> some View { diff --git a/damus/Views/Profile/MaybeAnonPfpView.swift b/damus/Views/Profile/MaybeAnonPfpView.swift @@ -11,17 +11,20 @@ struct MaybeAnonPfpView: View { let state: DamusState let is_anon: Bool let pubkey: String + let size: CGFloat - init(state: DamusState, event: NostrEvent, pubkey: String) { + init(state: DamusState, event: NostrEvent, pubkey: String, size: CGFloat) { self.state = state self.is_anon = event_is_anonymous(ev: event) self.pubkey = pubkey + self.size = size } - init(state: DamusState, is_anon: Bool, pubkey: String) { + init(state: DamusState, is_anon: Bool, pubkey: String, size: CGFloat) { self.state = state self.is_anon = is_anon self.pubkey = pubkey + self.size = size } var body: some View { @@ -29,10 +32,10 @@ struct MaybeAnonPfpView: View { if is_anon { Image(systemName: "person.fill.questionmark") .font(.largeTitle) - .frame(width: PFP_SIZE, height: PFP_SIZE) + .frame(width: size, height: size) } else { NavigationLink(destination: ProfileView(damus_state: state, pubkey: pubkey)) { - ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: .none, profiles: state.profiles) + ProfilePicView(pubkey: pubkey, size: size, highlight: .none, profiles: state.profiles) } } } @@ -41,6 +44,6 @@ struct MaybeAnonPfpView: View { struct MaybeAnonPfpView_Previews: PreviewProvider { static var previews: some View { - MaybeAnonPfpView(state: test_damus_state(), is_anon: true, pubkey: "anon") + MaybeAnonPfpView(state: test_damus_state(), is_anon: true, pubkey: "anon", size: PFP_SIZE) } } diff --git a/damus/Views/ThreadView.swift b/damus/Views/ThreadView.swift @@ -29,7 +29,6 @@ struct ThreadView: View { ForEach(parent_events, id: \.id) { parent_event in MutedEventView(damus_state: state, event: parent_event, - scroller: reader, selected: false) .padding(.horizontal) .onTapGesture { @@ -56,7 +55,6 @@ struct ThreadView: View { MutedEventView( damus_state: state, event: self.thread.event, - scroller: reader, selected: true ) .id(self.thread.event.id) @@ -65,7 +63,6 @@ struct ThreadView: View { MutedEventView( damus_state: state, event: child_event, - scroller: nil, selected: false ) .padding(.horizontal)