refactor: Break EventView into 3 separate views
SelectedEventView EmbeddedEventView EventView
This commit is contained in:
@@ -128,6 +128,11 @@
|
|||||||
4CBCA930297DB57F00EC6B2F /* WebsiteLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CBCA92F297DB57F00EC6B2F /* WebsiteLink.swift */; };
|
4CBCA930297DB57F00EC6B2F /* WebsiteLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CBCA92F297DB57F00EC6B2F /* WebsiteLink.swift */; };
|
||||||
4CC7AAEB297F0AEC00430951 /* BuilderEventView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CC7AAEA297F0AEC00430951 /* BuilderEventView.swift */; };
|
4CC7AAEB297F0AEC00430951 /* BuilderEventView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CC7AAEA297F0AEC00430951 /* BuilderEventView.swift */; };
|
||||||
4CC7AAED297F0B9E00430951 /* Highlight.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CC7AAEC297F0B9E00430951 /* Highlight.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 */; };
|
||||||
4CD7641B28A1641400B6928F /* EndBlock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CD7641A28A1641400B6928F /* EndBlock.swift */; };
|
4CD7641B28A1641400B6928F /* EndBlock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CD7641A28A1641400B6928F /* EndBlock.swift */; };
|
||||||
4CE4F8CD281352B30009DFBB /* Notifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4F8CC281352B30009DFBB /* Notifications.swift */; };
|
4CE4F8CD281352B30009DFBB /* Notifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4F8CC281352B30009DFBB /* Notifications.swift */; };
|
||||||
4CE4F9DE2852768D00C00DD9 /* ConfigView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4F9DD2852768D00C00DD9 /* ConfigView.swift */; };
|
4CE4F9DE2852768D00C00DD9 /* ConfigView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4F9DD2852768D00C00DD9 /* ConfigView.swift */; };
|
||||||
@@ -351,6 +356,11 @@
|
|||||||
4CBCA92F297DB57F00EC6B2F /* WebsiteLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebsiteLink.swift; sourceTree = "<group>"; };
|
4CBCA92F297DB57F00EC6B2F /* WebsiteLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebsiteLink.swift; sourceTree = "<group>"; };
|
||||||
4CC7AAEA297F0AEC00430951 /* BuilderEventView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BuilderEventView.swift; sourceTree = "<group>"; };
|
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>"; };
|
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>"; };
|
||||||
4CD7641A28A1641400B6928F /* EndBlock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EndBlock.swift; sourceTree = "<group>"; };
|
4CD7641A28A1641400B6928F /* EndBlock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EndBlock.swift; sourceTree = "<group>"; };
|
||||||
4CE4F8CC281352B30009DFBB /* Notifications.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notifications.swift; sourceTree = "<group>"; };
|
4CE4F8CC281352B30009DFBB /* Notifications.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notifications.swift; sourceTree = "<group>"; };
|
||||||
4CE4F9DD2852768D00C00DD9 /* ConfigView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigView.swift; sourceTree = "<group>"; };
|
4CE4F9DD2852768D00C00DD9 /* ConfigView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigView.swift; sourceTree = "<group>"; };
|
||||||
@@ -524,6 +534,7 @@
|
|||||||
4C75EFA227FA576C0006080F /* Views */ = {
|
4C75EFA227FA576C0006080F /* Views */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
4CC7AAEE297F11B300430951 /* Events */,
|
||||||
4CB88394296F7F8100DC99E7 /* Reactions */,
|
4CB88394296F7F8100DC99E7 /* Reactions */,
|
||||||
4CB88387296AF97C00DC99E7 /* ActionBar */,
|
4CB88387296AF97C00DC99E7 /* ActionBar */,
|
||||||
4CE4F9E228528C5200C00DD9 /* AddRelayView.swift */,
|
4CE4F9E228528C5200C00DD9 /* AddRelayView.swift */,
|
||||||
@@ -614,7 +625,6 @@
|
|||||||
4C3A1D3629637E0500558C0F /* PreviewCache.swift */,
|
4C3A1D3629637E0500558C0F /* PreviewCache.swift */,
|
||||||
64FBD06E296255C400D9D3B2 /* Theme.swift */,
|
64FBD06E296255C400D9D3B2 /* Theme.swift */,
|
||||||
4CB8838529656C8B00DC99E7 /* NIP05.swift */,
|
4CB8838529656C8B00DC99E7 /* NIP05.swift */,
|
||||||
4CC7AAEA297F0AEC00430951 /* BuilderEventView.swift */,
|
|
||||||
);
|
);
|
||||||
path = Util;
|
path = Util;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -636,6 +646,19 @@
|
|||||||
path = Reactions;
|
path = Reactions;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
4CC7AAEE297F11B300430951 /* Events */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
4CC7AAEF297F11C700430951 /* SelectedEventView.swift */,
|
||||||
|
4CC7AAF1297F129C00430951 /* EmbeddedEventView.swift */,
|
||||||
|
4CC7AAF3297F18B400430951 /* ReplyDescription.swift */,
|
||||||
|
4CC7AAF5297F1A6A00430951 /* EventBody.swift */,
|
||||||
|
4CC7AAEA297F0AEC00430951 /* BuilderEventView.swift */,
|
||||||
|
4CC7AAF7297F1CEE00430951 /* EventProfile.swift */,
|
||||||
|
);
|
||||||
|
path = Events;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
4CE4F9DF285287A000C00DD9 /* Components */ = {
|
4CE4F9DF285287A000C00DD9 /* Components */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@@ -960,11 +983,14 @@
|
|||||||
4C3BEFE0281DE1ED00B3DE84 /* DamusState.swift in Sources */,
|
4C3BEFE0281DE1ED00B3DE84 /* DamusState.swift in Sources */,
|
||||||
7C45AE71297353390031D7BC /* KFImageModel.swift in Sources */,
|
7C45AE71297353390031D7BC /* KFImageModel.swift in Sources */,
|
||||||
4C0A3F8F280F640A000448DE /* ThreadModel.swift in Sources */,
|
4C0A3F8F280F640A000448DE /* ThreadModel.swift in Sources */,
|
||||||
|
4CC7AAF2297F129C00430951 /* EmbeddedEventView.swift in Sources */,
|
||||||
4C3AC79F2833115300E1F516 /* FollowButtonView.swift in Sources */,
|
4C3AC79F2833115300E1F516 /* FollowButtonView.swift in Sources */,
|
||||||
4C3BEFD22819DB9B00B3DE84 /* ProfileModel.swift in Sources */,
|
4C3BEFD22819DB9B00B3DE84 /* ProfileModel.swift in Sources */,
|
||||||
4C0A3F93280F66F5000448DE /* ReplyMap.swift in Sources */,
|
4C0A3F93280F66F5000448DE /* ReplyMap.swift in Sources */,
|
||||||
BAB68BED29543FA3007BA466 /* SelectWalletView.swift in Sources */,
|
BAB68BED29543FA3007BA466 /* SelectWalletView.swift in Sources */,
|
||||||
3169CAE6294E69C000EE4006 /* EmptyTimelineView.swift in Sources */,
|
3169CAE6294E69C000EE4006 /* EmptyTimelineView.swift in Sources */,
|
||||||
|
4CC7AAF0297F11C700430951 /* SelectedEventView.swift in Sources */,
|
||||||
|
4CC7AAF8297F1CEE00430951 /* EventProfile.swift in Sources */,
|
||||||
64FBD06F296255C400D9D3B2 /* Theme.swift in Sources */,
|
64FBD06F296255C400D9D3B2 /* Theme.swift in Sources */,
|
||||||
4C3EA64928FF597700C48A62 /* bech32.c in Sources */,
|
4C3EA64928FF597700C48A62 /* bech32.c in Sources */,
|
||||||
4C90BD162839DB54008EE7EF /* NostrMetadata.swift in Sources */,
|
4C90BD162839DB54008EE7EF /* NostrMetadata.swift in Sources */,
|
||||||
@@ -1001,6 +1027,7 @@
|
|||||||
4C3BEFD6281D995700B3DE84 /* ActionBarModel.swift in Sources */,
|
4C3BEFD6281D995700B3DE84 /* ActionBarModel.swift in Sources */,
|
||||||
4C363AA428296DEE006E126D /* SearchModel.swift in Sources */,
|
4C363AA428296DEE006E126D /* SearchModel.swift in Sources */,
|
||||||
4CEE2AF3280B25C500AB5EEF /* ProfilePicView.swift in Sources */,
|
4CEE2AF3280B25C500AB5EEF /* ProfilePicView.swift in Sources */,
|
||||||
|
4CC7AAF6297F1A6A00430951 /* EventBody.swift in Sources */,
|
||||||
4CEE2AF9280B2EAC00AB5EEF /* PowView.swift in Sources */,
|
4CEE2AF9280B2EAC00AB5EEF /* PowView.swift in Sources */,
|
||||||
3165648B295B70D500C64604 /* LinkView.swift in Sources */,
|
3165648B295B70D500C64604 /* LinkView.swift in Sources */,
|
||||||
4C3BEFD42819DE8F00B3DE84 /* NostrKind.swift in Sources */,
|
4C3BEFD42819DE8F00B3DE84 /* NostrKind.swift in Sources */,
|
||||||
@@ -1030,6 +1057,7 @@
|
|||||||
4C06670B28FDE64700038D2A /* damus.c in Sources */,
|
4C06670B28FDE64700038D2A /* damus.c in Sources */,
|
||||||
4FE60CDD295E1C5E00105A1F /* Wallet.swift in Sources */,
|
4FE60CDD295E1C5E00105A1F /* Wallet.swift in Sources */,
|
||||||
4C99737B28C92A9200E53835 /* ChatroomMetadata.swift in Sources */,
|
4C99737B28C92A9200E53835 /* ChatroomMetadata.swift in Sources */,
|
||||||
|
4CC7AAF4297F18B400430951 /* ReplyDescription.swift in Sources */,
|
||||||
4C75EFA427FA577B0006080F /* PostView.swift in Sources */,
|
4C75EFA427FA577B0006080F /* PostView.swift in Sources */,
|
||||||
4C75EFB528049D790006080F /* Relay.swift in Sources */,
|
4C75EFB528049D790006080F /* Relay.swift in Sources */,
|
||||||
4CEE2AF1280B216B00AB5EEF /* EventDetailView.swift in Sources */,
|
4CEE2AF1280B216B00AB5EEF /* EventDetailView.swift in Sources */,
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ struct DirectMessagesView: View {
|
|||||||
func MaybeEvent(_ tup: (String, DirectMessageModel)) -> some View {
|
func MaybeEvent(_ tup: (String, DirectMessageModel)) -> some View {
|
||||||
Group {
|
Group {
|
||||||
if let ev = tup.1.events.last {
|
if let ev = tup.1.events.last {
|
||||||
EventView(damus: damus_state, event: ev, pubkey: tup.0, show_friend_icon: true)
|
EventView(damus: damus_state, event: ev, pubkey: tup.0)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
pubkey = tup.0
|
pubkey = tup.0
|
||||||
active_model = tup.1
|
active_model = tup.1
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ struct EventDetailView: View {
|
|||||||
toggle_thread_view()
|
toggle_thread_view()
|
||||||
}
|
}
|
||||||
case .event(let ev, let highlight):
|
case .event(let ev, let highlight):
|
||||||
EventView(event: ev, highlight: highlight, has_action_bar: true, damus: damus, show_friend_icon: true)
|
EventView(event: ev, has_action_bar: true, damus: damus)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
if thread.initial_event.id == ev.id {
|
if thread.initial_event.id == ev.id {
|
||||||
toggle_thread_view()
|
toggle_thread_view()
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import SwiftUI
|
|||||||
enum EventViewKind {
|
enum EventViewKind {
|
||||||
case small
|
case small
|
||||||
case normal
|
case normal
|
||||||
case big
|
|
||||||
case selected
|
case selected
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,56 +20,40 @@ func eventviewsize_to_font(_ size: EventViewKind) -> Font {
|
|||||||
return .body
|
return .body
|
||||||
case .normal:
|
case .normal:
|
||||||
return .body
|
return .body
|
||||||
case .big:
|
|
||||||
return .headline
|
|
||||||
case .selected:
|
case .selected:
|
||||||
return .custom("selected", size: 21.0)
|
return .custom("selected", size: 21.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct EventView: View {
|
struct EventView: View {
|
||||||
let event: NostrEvent
|
let event: NostrEvent
|
||||||
let highlight: Highlight
|
|
||||||
let has_action_bar: Bool
|
let has_action_bar: Bool
|
||||||
let damus: DamusState
|
let damus: DamusState
|
||||||
let pubkey: String
|
let pubkey: String
|
||||||
let show_friend_icon: Bool
|
|
||||||
let size: EventViewKind
|
|
||||||
let embedded: Bool
|
|
||||||
|
|
||||||
@EnvironmentObject var action_bar: ActionBarModel
|
@EnvironmentObject var action_bar: ActionBarModel
|
||||||
|
|
||||||
init(event: NostrEvent, highlight: Highlight, has_action_bar: Bool, damus: DamusState, show_friend_icon: Bool, size: EventViewKind = .normal, embedded: Bool = false) {
|
init(event: NostrEvent, has_action_bar: Bool, damus: DamusState) {
|
||||||
self.event = event
|
self.event = event
|
||||||
self.highlight = highlight
|
|
||||||
self.has_action_bar = has_action_bar
|
self.has_action_bar = has_action_bar
|
||||||
self.damus = damus
|
self.damus = damus
|
||||||
self.pubkey = event.pubkey
|
self.pubkey = event.pubkey
|
||||||
self.show_friend_icon = show_friend_icon
|
|
||||||
self.size = size
|
|
||||||
self.embedded = embedded
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init(damus: DamusState, event: NostrEvent, show_friend_icon: Bool, size: EventViewKind = .normal, embedded: Bool = false) {
|
init(damus: DamusState, event: NostrEvent) {
|
||||||
self.event = event
|
self.event = event
|
||||||
self.highlight = .none
|
|
||||||
self.has_action_bar = false
|
self.has_action_bar = false
|
||||||
self.damus = damus
|
self.damus = damus
|
||||||
self.pubkey = event.pubkey
|
self.pubkey = event.pubkey
|
||||||
self.show_friend_icon = show_friend_icon
|
|
||||||
self.size = size
|
|
||||||
self.embedded = embedded
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init(damus: DamusState, event: NostrEvent, pubkey: String, show_friend_icon: Bool, size: EventViewKind = .normal, embedded: Bool = false) {
|
init(damus: DamusState, event: NostrEvent, pubkey: String) {
|
||||||
self.event = event
|
self.event = event
|
||||||
self.highlight = .none
|
|
||||||
self.has_action_bar = false
|
self.has_action_bar = false
|
||||||
self.damus = damus
|
self.damus = damus
|
||||||
self.pubkey = pubkey
|
self.pubkey = pubkey
|
||||||
self.show_friend_icon = show_friend_icon
|
|
||||||
self.size = size
|
|
||||||
self.embedded = embedded
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
@@ -101,88 +84,43 @@ struct EventView: View {
|
|||||||
|
|
||||||
return HStack(alignment: .top) {
|
return HStack(alignment: .top) {
|
||||||
let profile = damus.profiles.lookup(id: pubkey)
|
let profile = damus.profiles.lookup(id: pubkey)
|
||||||
|
|
||||||
if size != .selected {
|
VStack {
|
||||||
VStack {
|
let pmodel = ProfileModel(pubkey: pubkey, damus: damus)
|
||||||
let pmodel = ProfileModel(pubkey: pubkey, damus: damus)
|
let pv = ProfileView(damus_state: damus, profile: pmodel, followers: FollowersModel(damus_state: damus, target: pubkey))
|
||||||
let pv = ProfileView(damus_state: damus, profile: pmodel, followers: FollowersModel(damus_state: damus, target: pubkey))
|
|
||||||
|
NavigationLink(destination: pv) {
|
||||||
if !embedded {
|
ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: .none, profiles: damus.profiles)
|
||||||
NavigationLink(destination: pv) {
|
|
||||||
ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: highlight, profiles: damus.profiles)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Spacer()
|
||||||
}
|
}
|
||||||
|
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
HStack(alignment: .center) {
|
HStack(alignment: .center) {
|
||||||
if size == .selected {
|
EventProfileName(pubkey: pubkey, profile: profile, damus: damus, show_friend_confirmed: true, size: .normal)
|
||||||
VStack {
|
|
||||||
let pmodel = ProfileModel(pubkey: pubkey, damus: damus)
|
|
||||||
let pv = ProfileView(damus_state: damus, profile: pmodel, followers: FollowersModel(damus_state: damus, target: pubkey))
|
|
||||||
|
|
||||||
NavigationLink(destination: pv) {
|
|
||||||
ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: highlight, profiles: damus.profiles)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EventProfileName(pubkey: pubkey, profile: profile, damus: damus, show_friend_confirmed: show_friend_icon, size: size)
|
Text("\(format_relative_time(event.created_at))")
|
||||||
if size != .selected {
|
|
||||||
Text("\(format_relative_time(event.created_at))")
|
|
||||||
.font(eventviewsize_to_font(size))
|
|
||||||
.foregroundColor(.gray)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if event.is_reply(damus.keypair.privkey) {
|
|
||||||
Text("\(reply_desc(profiles: damus.profiles, event: event))")
|
|
||||||
.font(.footnote)
|
|
||||||
.foregroundColor(.gray)
|
.foregroundColor(.gray)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let should_show_img = should_show_images(contacts: damus.contacts, ev: event, our_pubkey: damus.pubkey, booster_pubkey: booster_pubkey)
|
|
||||||
|
|
||||||
NoteContentView(privkey: damus.keypair.privkey, event: event, profiles: damus.profiles, previews: damus.previews, show_images: should_show_img, artifacts: .just_content(content), size: self.size)
|
EventBody(damus_state: damus, event: event, size: .normal)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
|
||||||
.allowsHitTesting(!embedded)
|
|
||||||
|
|
||||||
if !embedded {
|
if let mention = first_eref_mention(ev: event, privkey: damus.keypair.privkey) {
|
||||||
if let mention = first_eref_mention(ev: event, privkey: damus.keypair.privkey) {
|
BuilderEventView(damus: damus, event_id: mention.ref.id)
|
||||||
BuilderEventView(damus: damus, event_id: mention.ref.id)
|
}
|
||||||
}
|
|
||||||
|
if has_action_bar {
|
||||||
|
Rectangle().frame(height: 2).opacity(0)
|
||||||
|
|
||||||
if has_action_bar {
|
let bar = make_actionbar_model(ev: event, damus: damus)
|
||||||
if size == .selected {
|
|
||||||
Text("\(format_date(event.created_at))")
|
EventActionBar(damus_state: damus, event: event, bar: bar)
|
||||||
.padding(.top, 10)
|
|
||||||
.font(.footnote)
|
|
||||||
.foregroundColor(.gray)
|
|
||||||
|
|
||||||
Divider()
|
|
||||||
.padding([.bottom], 4)
|
|
||||||
} else {
|
|
||||||
Rectangle().frame(height: 2).opacity(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
let bar = make_actionbar_model(ev: event, damus: damus)
|
|
||||||
|
|
||||||
if size == .selected && !bar.is_empty {
|
|
||||||
EventDetailBar(state: damus, target: event.id, bar: bar)
|
|
||||||
Divider()
|
|
||||||
}
|
|
||||||
|
|
||||||
EventActionBar(damus_state: damus, event: event, bar: bar)
|
|
||||||
.padding([.top], 4)
|
|
||||||
}
|
|
||||||
|
|
||||||
Divider()
|
|
||||||
.padding([.top], 4)
|
.padding([.top], 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Divider()
|
||||||
|
.padding([.top], 4)
|
||||||
}
|
}
|
||||||
.padding([.leading], 2)
|
.padding([.leading], 2)
|
||||||
}
|
}
|
||||||
@@ -339,31 +277,18 @@ struct EventView_Previews: PreviewProvider {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
EventView(
|
EventView(
|
||||||
event: NostrEvent(
|
event: test_event,
|
||||||
content: "hello there https://jb55.com/s/Oct12-150217.png https://jb55.com/red-me.jpg cool",
|
|
||||||
pubkey: "pk",
|
|
||||||
createdAt: Int64(Date().timeIntervalSince1970 - 100)
|
|
||||||
),
|
|
||||||
highlight: .none,
|
|
||||||
has_action_bar: true,
|
has_action_bar: true,
|
||||||
damus: test_damus_state(),
|
damus: test_damus_state()
|
||||||
show_friend_icon: true,
|
|
||||||
size: .selected
|
|
||||||
)
|
|
||||||
|
|
||||||
EventView(
|
|
||||||
event: NostrEvent(
|
|
||||||
content: "hello there https://jb55.com/s/Oct12-150217.png https://jb55.com/red-me.jpg cool",
|
|
||||||
pubkey: "pk",
|
|
||||||
createdAt: Int64(Date().timeIntervalSince1970 - 100)
|
|
||||||
),
|
|
||||||
highlight: .none,
|
|
||||||
has_action_bar: true,
|
|
||||||
damus: test_damus_state(),
|
|
||||||
show_friend_icon: true,
|
|
||||||
size: .normal
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let test_event =
|
||||||
|
NostrEvent(
|
||||||
|
content: "hello there https://jb55.com/s/Oct12-150217.png https://jb55.com/red-me.jpg cool",
|
||||||
|
pubkey: "pk",
|
||||||
|
createdAt: Int64(Date().timeIntervalSince1970 - 100)
|
||||||
|
)
|
||||||
|
|||||||
@@ -57,15 +57,16 @@ struct BuilderEventView: View {
|
|||||||
if let event = event {
|
if let event = event {
|
||||||
let ev = event.inner_event ?? event
|
let ev = event.inner_event ?? event
|
||||||
NavigationLink(destination: BuildThreadV2View(damus: damus, event_id: ev.id)) {
|
NavigationLink(destination: BuildThreadV2View(damus: damus, event_id: ev.id)) {
|
||||||
EventView(damus: damus, event: event, show_friend_icon: true, size: .small, embedded: true)
|
EmbeddedEventView(damus_state: damus, event: event)
|
||||||
|
.padding(8)
|
||||||
}.buttonStyle(.plain)
|
}.buttonStyle(.plain)
|
||||||
} else {
|
} else {
|
||||||
ProgressView().padding()
|
ProgressView().padding()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.frame(minWidth: 0, maxWidth: .infinity)
|
.frame(minWidth: 0, maxWidth: .infinity)
|
||||||
|
.cornerRadius(8)
|
||||||
.border(Color.gray.opacity(0.2), width: 1)
|
.border(Color.gray.opacity(0.2), width: 1)
|
||||||
.cornerRadius(2)
|
|
||||||
.onAppear {
|
.onAppear {
|
||||||
self.load()
|
self.load()
|
||||||
}
|
}
|
||||||
34
damus/Views/Events/EmbeddedEventView.swift
Normal file
34
damus/Views/Events/EmbeddedEventView.swift
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
//
|
||||||
|
// 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)
|
||||||
|
|
||||||
|
EventProfile(damus_state: damus_state, pubkey: pubkey, profile: profile, size: .small)
|
||||||
|
|
||||||
|
EventBody(damus_state: damus_state, event: event, size: .small)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct EmbeddedEventView_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
EmbeddedEventView(damus_state: test_damus_state(), event: test_event)
|
||||||
|
.padding()
|
||||||
|
}
|
||||||
|
}
|
||||||
35
damus/Views/Events/EventBody.swift
Normal file
35
damus/Views/Events/EventBody.swift
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
//
|
||||||
|
// EventBody.swift
|
||||||
|
// damus
|
||||||
|
//
|
||||||
|
// Created by William Casarin on 2023-01-23.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct EventBody: View {
|
||||||
|
let damus_state: DamusState
|
||||||
|
let event: NostrEvent
|
||||||
|
let size: EventViewKind
|
||||||
|
|
||||||
|
var content: String {
|
||||||
|
event.get_content(damus_state.keypair.privkey)
|
||||||
|
}
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
if event_is_reply(event, privkey: damus_state.keypair.privkey) {
|
||||||
|
ReplyDescription(event: event, profiles: damus_state.profiles)
|
||||||
|
}
|
||||||
|
|
||||||
|
let should_show_img = should_show_images(contacts: damus_state.contacts, ev: event, our_pubkey: damus_state.pubkey, booster_pubkey: nil)
|
||||||
|
|
||||||
|
NoteContentView(privkey: damus_state.keypair.privkey, event: event, profiles: damus_state.profiles, previews: damus_state.previews, show_images: should_show_img, artifacts: .just_content(content), size: size)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct EventBody_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
EventBody(damus_state: test_damus_state(), event: test_event, size: .normal)
|
||||||
|
}
|
||||||
|
}
|
||||||
51
damus/Views/Events/EventProfile.swift
Normal file
51
damus/Views/Events/EventProfile.swift
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
//
|
||||||
|
// EventProfile.swift
|
||||||
|
// damus
|
||||||
|
//
|
||||||
|
// Created by William Casarin on 2023-01-23.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
func eventview_pfp_size(_ size: EventViewKind) -> CGFloat {
|
||||||
|
switch size {
|
||||||
|
case .small:
|
||||||
|
return PFP_SIZE * 0.5
|
||||||
|
case .normal:
|
||||||
|
return PFP_SIZE
|
||||||
|
case .selected:
|
||||||
|
return PFP_SIZE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct EventProfile: View {
|
||||||
|
let damus_state: DamusState
|
||||||
|
let pubkey: String
|
||||||
|
let profile: Profile?
|
||||||
|
let size: EventViewKind
|
||||||
|
|
||||||
|
var pfp_size: CGFloat {
|
||||||
|
eventview_pfp_size(size)
|
||||||
|
}
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
HStack(alignment: .center) {
|
||||||
|
VStack {
|
||||||
|
let pmodel = ProfileModel(pubkey: pubkey, damus: damus_state)
|
||||||
|
let pv = ProfileView(damus_state: damus_state, profile: pmodel, followers: FollowersModel(damus_state: damus_state, target: pubkey))
|
||||||
|
|
||||||
|
NavigationLink(destination: pv) {
|
||||||
|
ProfilePicView(pubkey: pubkey, size: pfp_size, highlight: .none, profiles: damus_state.profiles)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EventProfileName(pubkey: pubkey, profile: profile, damus: damus_state, show_friend_confirmed: true, size: size)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct EventProfile_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
EventProfile(damus_state: test_damus_state(), pubkey: "pk", profile: nil, size: .normal)
|
||||||
|
}
|
||||||
|
}
|
||||||
27
damus/Views/Events/ReplyDescription.swift
Normal file
27
damus/Views/Events/ReplyDescription.swift
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// ReplyDescription.swift
|
||||||
|
// damus
|
||||||
|
//
|
||||||
|
// Created by William Casarin on 2023-01-23.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
// jb55 - TODO: this could be a lot better
|
||||||
|
struct ReplyDescription: View {
|
||||||
|
let event: NostrEvent
|
||||||
|
let profiles: Profiles
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
Text("\(reply_desc(profiles: profiles, event: event))")
|
||||||
|
.font(.footnote)
|
||||||
|
.foregroundColor(.gray)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ReplyDescription_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
ReplyDescription(event: test_event, profiles: test_damus_state().profiles)
|
||||||
|
}
|
||||||
|
}
|
||||||
73
damus/Views/Events/SelectedEventView.swift
Normal file
73
damus/Views/Events/SelectedEventView.swift
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
//
|
||||||
|
// SelectedEventView.swift
|
||||||
|
// damus
|
||||||
|
//
|
||||||
|
// Created by William Casarin on 2023-01-23.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct SelectedEventView: View {
|
||||||
|
let damus: DamusState
|
||||||
|
let event: NostrEvent
|
||||||
|
|
||||||
|
var pubkey: String {
|
||||||
|
event.pubkey
|
||||||
|
}
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
HStack(alignment: .top) {
|
||||||
|
let profile = damus.profiles.lookup(id: pubkey)
|
||||||
|
|
||||||
|
VStack(alignment: .leading) {
|
||||||
|
HStack(alignment: .center) {
|
||||||
|
VStack {
|
||||||
|
let pmodel = ProfileModel(pubkey: pubkey, damus: damus)
|
||||||
|
let pv = ProfileView(damus_state: damus, profile: pmodel, followers: FollowersModel(damus_state: damus, target: pubkey))
|
||||||
|
|
||||||
|
NavigationLink(destination: pv) {
|
||||||
|
ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: .none, profiles: damus.profiles)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EventProfileName(pubkey: pubkey, profile: profile, damus: damus, show_friend_confirmed: true, size: .selected)
|
||||||
|
}
|
||||||
|
|
||||||
|
EventBody(damus_state: damus, event: event, size: .selected)
|
||||||
|
|
||||||
|
if let mention = first_eref_mention(ev: event, privkey: damus.keypair.privkey) {
|
||||||
|
BuilderEventView(damus: damus, event_id: mention.ref.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
Text("\(format_date(event.created_at))")
|
||||||
|
.padding(.top, 10)
|
||||||
|
.font(.footnote)
|
||||||
|
.foregroundColor(.gray)
|
||||||
|
|
||||||
|
Divider()
|
||||||
|
.padding([.bottom], 4)
|
||||||
|
|
||||||
|
let bar = make_actionbar_model(ev: event, damus: damus)
|
||||||
|
|
||||||
|
if !bar.is_empty {
|
||||||
|
EventDetailBar(state: damus, target: event.id, bar: bar)
|
||||||
|
Divider()
|
||||||
|
}
|
||||||
|
|
||||||
|
EventActionBar(damus_state: damus, event: event, bar: bar)
|
||||||
|
.padding([.top], 4)
|
||||||
|
|
||||||
|
Divider()
|
||||||
|
.padding([.top], 4)
|
||||||
|
}
|
||||||
|
.padding([.leading], 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct SelectedEventView_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
SelectedEventView(damus: test_damus_state(), event: test_event)
|
||||||
|
.padding()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -45,7 +45,7 @@ struct ReplyView: View {
|
|||||||
ParticipantsView(damus_state: damus, references: $references, originalReferences: $originalReferences)
|
ParticipantsView(damus_state: damus, references: $references, originalReferences: $originalReferences)
|
||||||
}
|
}
|
||||||
ScrollView {
|
ScrollView {
|
||||||
EventView(event: replying_to, highlight: .none, has_action_bar: false, damus: damus, show_friend_icon: true)
|
EventView(event: replying_to, has_action_bar: false, damus: damus)
|
||||||
}
|
}
|
||||||
PostView(replying_to: replying_to, references: references)
|
PostView(replying_to: replying_to, references: references)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -255,14 +255,7 @@ struct ThreadV2View: View {
|
|||||||
// MARK: - Parents events view
|
// MARK: - Parents events view
|
||||||
VStack {
|
VStack {
|
||||||
ForEach(thread.parentEvents, id: \.id) { event in
|
ForEach(thread.parentEvents, id: \.id) { event in
|
||||||
EventView(
|
EventView(event: event, has_action_bar: true, damus: damus)
|
||||||
event: event,
|
|
||||||
highlight: .none,
|
|
||||||
has_action_bar: true,
|
|
||||||
damus: damus,
|
|
||||||
show_friend_icon: true, // TODO: change it
|
|
||||||
size: .small
|
|
||||||
)
|
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
nav_target = event.id
|
nav_target = event.id
|
||||||
navigating = true
|
navigating = true
|
||||||
@@ -285,24 +278,17 @@ struct ThreadV2View: View {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// MARK: - Actual event view
|
// MARK: - Actual event view
|
||||||
EventView(
|
SelectedEventView(
|
||||||
event: thread.current,
|
|
||||||
highlight: .none,
|
|
||||||
has_action_bar: true,
|
|
||||||
damus: damus,
|
damus: damus,
|
||||||
show_friend_icon: true, // TODO: change it
|
event: thread.current
|
||||||
size: .selected
|
|
||||||
).id("main")
|
).id("main")
|
||||||
|
|
||||||
// MARK: - Responses of the actual event view
|
// MARK: - Responses of the actual event view
|
||||||
ForEach(thread.childEvents, id: \.id) { event in
|
ForEach(thread.childEvents, id: \.id) { event in
|
||||||
EventView(
|
EventView(
|
||||||
event: event,
|
event: event,
|
||||||
highlight: .none,
|
|
||||||
has_action_bar: true,
|
has_action_bar: true,
|
||||||
damus: damus,
|
damus: damus
|
||||||
show_friend_icon: true, // TODO: change it
|
|
||||||
size: .small
|
|
||||||
)
|
)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
nav_target = event.id
|
nav_target = event.id
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ struct InnerTimelineView: View {
|
|||||||
//let is_chatroom = should_show_chatroom(ev)
|
//let is_chatroom = should_show_chatroom(ev)
|
||||||
//let tv = ThreadView(thread: tm, damus: damus, is_chatroom: is_chatroom)
|
//let tv = ThreadView(thread: tm, damus: damus, is_chatroom: is_chatroom)
|
||||||
|
|
||||||
EventView(event: ev, highlight: .none, has_action_bar: true, damus: damus, show_friend_icon: show_friend_icon)
|
EventView(event: ev, has_action_bar: true, damus: damus)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
nav_target = ev
|
nav_target = ev
|
||||||
navigating = true
|
navigating = true
|
||||||
|
|||||||
Reference in New Issue
Block a user