Convert remaining navigation links
This commit is contained in:
committed by
William Casarin
parent
8258c5beb0
commit
0018e7ad57
@@ -143,6 +143,7 @@ struct ContentView: View {
|
|||||||
ZStack {
|
ZStack {
|
||||||
if let damus = self.damus_state {
|
if let damus = self.damus_state {
|
||||||
TimelineView(events: home.events, loading: .constant(false), damus: damus, show_friend_icon: false, filter: filter)
|
TimelineView(events: home.events, loading: .constant(false), damus: damus, show_friend_icon: false, filter: filter)
|
||||||
|
.environmentObject(navigationCoordinator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,10 +164,12 @@ struct ContentView: View {
|
|||||||
case .search:
|
case .search:
|
||||||
if #available(iOS 16.0, *) {
|
if #available(iOS 16.0, *) {
|
||||||
SearchHomeView(damus_state: damus_state!, model: SearchHomeModel(damus_state: damus_state!))
|
SearchHomeView(damus_state: damus_state!, model: SearchHomeModel(damus_state: damus_state!))
|
||||||
|
.environmentObject(navigationCoordinator)
|
||||||
.scrollDismissesKeyboard(.immediately)
|
.scrollDismissesKeyboard(.immediately)
|
||||||
} else {
|
} else {
|
||||||
// Fallback on earlier versions
|
// Fallback on earlier versions
|
||||||
SearchHomeView(damus_state: damus_state!, model: SearchHomeModel(damus_state: damus_state!))
|
SearchHomeView(damus_state: damus_state!, model: SearchHomeModel(damus_state: damus_state!))
|
||||||
|
.environmentObject(navigationCoordinator)
|
||||||
}
|
}
|
||||||
|
|
||||||
case .home:
|
case .home:
|
||||||
@@ -174,9 +177,11 @@ struct ContentView: View {
|
|||||||
|
|
||||||
case .notifications:
|
case .notifications:
|
||||||
NotificationsView(state: damus, notifications: home.notifications)
|
NotificationsView(state: damus, notifications: home.notifications)
|
||||||
|
.environmentObject(navigationCoordinator)
|
||||||
|
|
||||||
case .dms:
|
case .dms:
|
||||||
DirectMessagesView(damus_state: damus_state!, model: damus_state!.dms, settings: damus_state!.settings)
|
DirectMessagesView(damus_state: damus_state!, model: damus_state!.dms, settings: damus_state!.settings)
|
||||||
|
.environmentObject(navigationCoordinator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.navigationBarTitle(timeline_name(selected_timeline), displayMode: .inline)
|
.navigationBarTitle(timeline_name(selected_timeline), displayMode: .inline)
|
||||||
@@ -483,8 +488,8 @@ struct ContentView: View {
|
|||||||
switch local.type {
|
switch local.type {
|
||||||
case .dm:
|
case .dm:
|
||||||
selected_timeline = .dms
|
selected_timeline = .dms
|
||||||
damus_state.dms.open_dm_by_pk(target.pubkey)
|
damus_state.dms.set_active_dm(target.pubkey)
|
||||||
|
navigationCoordinator.push(route: Route.DMChat(dms: damus_state.dms.active_model))
|
||||||
case .like: fallthrough
|
case .like: fallthrough
|
||||||
case .zap: fallthrough
|
case .zap: fallthrough
|
||||||
case .mention: fallthrough
|
case .mention: fallthrough
|
||||||
|
|||||||
@@ -30,16 +30,6 @@ class DirectMessagesModel: ObservableObject {
|
|||||||
self.active_model = model
|
self.active_model = model
|
||||||
}
|
}
|
||||||
|
|
||||||
func open_dm_by_pk(_ pubkey: String) {
|
|
||||||
self.set_active_dm(pubkey)
|
|
||||||
self.open_dm = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func open_dm_by_model(_ model: DirectMessageModel) {
|
|
||||||
self.set_active_dm_model(model)
|
|
||||||
self.open_dm = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func set_active_dm(_ pubkey: String) {
|
func set_active_dm(_ pubkey: String) {
|
||||||
for model in self.dms where model.pubkey == pubkey {
|
for model in self.dms where model.pubkey == pubkey {
|
||||||
self.set_active_dm_model(model)
|
self.set_active_dm_model(model)
|
||||||
|
|||||||
@@ -22,10 +22,11 @@ enum Route: Hashable {
|
|||||||
case DMChat(dms: DirectMessageModel)
|
case DMChat(dms: DirectMessageModel)
|
||||||
case UserRelays(relays: [String])
|
case UserRelays(relays: [String])
|
||||||
case KeySettings(keypair: Keypair)
|
case KeySettings(keypair: Keypair)
|
||||||
case AppearanceSettings(settings: UserSettingsStore) // Observed object.. is this an issue?
|
case AppearanceSettings(settings: UserSettingsStore)
|
||||||
case NotificationSettings(settings: UserSettingsStore) // Observed object.. is this an issue?
|
case NotificationSettings(settings: UserSettingsStore)
|
||||||
case ZapSettings(settings: UserSettingsStore) // Observed object.. is this an issue?
|
case ZapSettings(settings: UserSettingsStore)
|
||||||
case TranslationSettings(settings: UserSettingsStore) // Observed object.. is this an issue?
|
case TranslationSettings(settings: UserSettingsStore)
|
||||||
|
case SearchSettings(settings: UserSettingsStore)
|
||||||
case Thread(thread: ThreadModel)
|
case Thread(thread: ThreadModel)
|
||||||
case Reposts(reposts: RepostsModel)
|
case Reposts(reposts: RepostsModel)
|
||||||
case Reactions(reactions: ReactionsModel)
|
case Reactions(reactions: ReactionsModel)
|
||||||
@@ -43,8 +44,10 @@ enum Route: Hashable {
|
|||||||
switch self {
|
switch self {
|
||||||
case .ProfileByKey(let pubkey):
|
case .ProfileByKey(let pubkey):
|
||||||
ProfileView(damus_state: damusState, pubkey: pubkey)
|
ProfileView(damus_state: damusState, pubkey: pubkey)
|
||||||
|
.environmentObject(navigationCordinator)
|
||||||
case .Profile(let profile, let followers):
|
case .Profile(let profile, let followers):
|
||||||
ProfileView(damus_state: damusState, profile: profile, followers: followers)
|
ProfileView(damus_state: damusState, profile: profile, followers: followers)
|
||||||
|
.environmentObject(navigationCordinator)
|
||||||
case .Followers(let environmentObject):
|
case .Followers(let environmentObject):
|
||||||
FollowersView(damus_state: damusState)
|
FollowersView(damus_state: damusState)
|
||||||
.environmentObject(environmentObject)
|
.environmentObject(environmentObject)
|
||||||
@@ -60,6 +63,7 @@ enum Route: Hashable {
|
|||||||
RelayConfigView(state: damusState)
|
RelayConfigView(state: damusState)
|
||||||
case .Bookmarks:
|
case .Bookmarks:
|
||||||
BookmarksView(state: damusState)
|
BookmarksView(state: damusState)
|
||||||
|
.environmentObject(navigationCordinator)
|
||||||
case .Config:
|
case .Config:
|
||||||
ConfigView(state: damusState)
|
ConfigView(state: damusState)
|
||||||
case .EditMetadata:
|
case .EditMetadata:
|
||||||
@@ -78,6 +82,8 @@ enum Route: Hashable {
|
|||||||
ZapSettingsView(settings: settings)
|
ZapSettingsView(settings: settings)
|
||||||
case .TranslationSettings(let settings):
|
case .TranslationSettings(let settings):
|
||||||
NotificationSettingsView(settings: settings)
|
NotificationSettingsView(settings: settings)
|
||||||
|
case .SearchSettings(let settings):
|
||||||
|
SearchSettingsView(settings: settings)
|
||||||
case .Thread(let thread):
|
case .Thread(let thread):
|
||||||
ThreadView(state: damusState, thread: thread)
|
ThreadView(state: damusState, thread: thread)
|
||||||
case .Reposts(let reposts):
|
case .Reposts(let reposts):
|
||||||
@@ -88,6 +94,7 @@ enum Route: Hashable {
|
|||||||
ZapsView(state: damusState, target: target)
|
ZapsView(state: damusState, target: target)
|
||||||
case .Search(let search):
|
case .Search(let search):
|
||||||
SearchView(appstate: damusState, search: search)
|
SearchView(appstate: damusState, search: search)
|
||||||
|
.environmentObject(navigationCordinator)
|
||||||
case .EULA:
|
case .EULA:
|
||||||
EULAView()
|
EULAView()
|
||||||
.environmentObject(navigationCordinator)
|
.environmentObject(navigationCordinator)
|
||||||
@@ -146,6 +153,8 @@ enum Route: Hashable {
|
|||||||
return true
|
return true
|
||||||
case (.TranslationSettings(_), .TranslationSettings(_)):
|
case (.TranslationSettings(_), .TranslationSettings(_)):
|
||||||
return true
|
return true
|
||||||
|
case (.SearchSettings(_), .SearchSettings(_)):
|
||||||
|
return true
|
||||||
case (.Thread(let lhs_threadModel), .Thread(thread: let rhs_threadModel)):
|
case (.Thread(let lhs_threadModel), .Thread(thread: let rhs_threadModel)):
|
||||||
return lhs_threadModel.event.id == rhs_threadModel.event.id
|
return lhs_threadModel.event.id == rhs_threadModel.event.id
|
||||||
case (.Reposts(let lhs_reposts), .Reposts(let rhs_reposts)):
|
case (.Reposts(let lhs_reposts), .Reposts(let rhs_reposts)):
|
||||||
@@ -219,6 +228,8 @@ enum Route: Hashable {
|
|||||||
hasher.combine("zapSettings")
|
hasher.combine("zapSettings")
|
||||||
case .TranslationSettings(_):
|
case .TranslationSettings(_):
|
||||||
hasher.combine("translationSettings")
|
hasher.combine("translationSettings")
|
||||||
|
case .SearchSettings(_):
|
||||||
|
hasher.combine("searchSettings")
|
||||||
case .Thread(let threadModel):
|
case .Thread(let threadModel):
|
||||||
hasher.combine("thread")
|
hasher.combine("thread")
|
||||||
hasher.combine(threadModel.event.id)
|
hasher.combine(threadModel.event.id)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ struct BookmarksView: View {
|
|||||||
@State private var clearAllAlert: Bool = false
|
@State private var clearAllAlert: Bool = false
|
||||||
|
|
||||||
@Environment(\.dismiss) var dismiss
|
@Environment(\.dismiss) var dismiss
|
||||||
|
@EnvironmentObject var navigationCoordinator: NavigationCoordinator
|
||||||
@ObservedObject var manager: BookmarksManager
|
@ObservedObject var manager: BookmarksManager
|
||||||
|
|
||||||
init(state: DamusState) {
|
init(state: DamusState) {
|
||||||
@@ -38,6 +39,7 @@ struct BookmarksView: View {
|
|||||||
} else {
|
} else {
|
||||||
ScrollView {
|
ScrollView {
|
||||||
InnerTimelineView(events: EventHolder(events: bookmarks, incoming: []), damus: state, filter: noneFilter)
|
InnerTimelineView(events: EventHolder(events: bookmarks, incoming: []), damus: state, filter: noneFilter)
|
||||||
|
.environmentObject(navigationCoordinator)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ struct ConfigView: View {
|
|||||||
IconLabel(NSLocalizedString("Appearance", comment: "Section header for text and appearance settings"), img_name: "eye", color: .red)
|
IconLabel(NSLocalizedString("Appearance", comment: "Section header for text and appearance settings"), img_name: "eye", color: .red)
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationLink(destination: SearchSettingsView(settings: settings)) {
|
NavigationLink(value: Route.SearchSettings(settings: settings)) {
|
||||||
IconLabel(NSLocalizedString("Search/Universe", comment: "Section header for search/universe settings"), img_name: "magnifyingglass", color: .red)
|
IconLabel(NSLocalizedString("Search/Universe", comment: "Section header for search/universe settings"), img_name: "magnifyingglass", color: .red)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,13 +18,11 @@ struct DirectMessagesView: View {
|
|||||||
@State var dm_type: DMType = .friend
|
@State var dm_type: DMType = .friend
|
||||||
@ObservedObject var model: DirectMessagesModel
|
@ObservedObject var model: DirectMessagesModel
|
||||||
@ObservedObject var settings: UserSettingsStore
|
@ObservedObject var settings: UserSettingsStore
|
||||||
|
|
||||||
|
@EnvironmentObject var navigationCoordinator: NavigationCoordinator
|
||||||
|
|
||||||
func MainContent(requests: Bool) -> some View {
|
func MainContent(requests: Bool) -> some View {
|
||||||
ScrollView {
|
ScrollView {
|
||||||
let chat = DMChatView(damus_state: damus_state, dms: model.active_model)
|
|
||||||
NavigationLink(destination: chat, isActive: $model.open_dm) {
|
|
||||||
EmptyView()
|
|
||||||
}
|
|
||||||
LazyVStack(spacing: 0) {
|
LazyVStack(spacing: 0) {
|
||||||
if model.dms.isEmpty, !model.loading {
|
if model.dms.isEmpty, !model.loading {
|
||||||
EmptyTimelineView()
|
EmptyTimelineView()
|
||||||
@@ -54,7 +52,8 @@ struct DirectMessagesView: View {
|
|||||||
if ok, let ev = model.events.last {
|
if ok, let ev = model.events.last {
|
||||||
EventView(damus: damus_state, event: ev, pubkey: model.pubkey, options: options)
|
EventView(damus: damus_state, event: ev, pubkey: model.pubkey, options: options)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
self.model.open_dm_by_model(model)
|
self.model.set_active_dm_model(model)
|
||||||
|
navigationCoordinator.push(route: Route.DMChat(dms: self.model.active_model))
|
||||||
}
|
}
|
||||||
|
|
||||||
Divider()
|
Divider()
|
||||||
|
|||||||
@@ -12,14 +12,8 @@ struct FollowUserView: View {
|
|||||||
let damus_state: DamusState
|
let damus_state: DamusState
|
||||||
|
|
||||||
static let markdown = Markdown()
|
static let markdown = Markdown()
|
||||||
@State var navigating: Bool = false
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
let dest = ProfileView(damus_state: damus_state, pubkey: target.pubkey)
|
|
||||||
NavigationLink(destination: dest, isActive: $navigating) {
|
|
||||||
EmptyView()
|
|
||||||
}
|
|
||||||
|
|
||||||
HStack {
|
HStack {
|
||||||
UserViewRow(damus_state: damus_state, pubkey: target.pubkey)
|
UserViewRow(damus_state: damus_state, pubkey: target.pubkey)
|
||||||
|
|
||||||
|
|||||||
@@ -192,6 +192,8 @@ struct EventGroupView: View {
|
|||||||
let state: DamusState
|
let state: DamusState
|
||||||
let event: NostrEvent?
|
let event: NostrEvent?
|
||||||
let group: EventGroupType
|
let group: EventGroupType
|
||||||
|
|
||||||
|
@EnvironmentObject var navigationCoordinator: NavigationCoordinator
|
||||||
|
|
||||||
func GroupDescription(_ pubkeys: [String]) -> some View {
|
func GroupDescription(_ pubkeys: [String]) -> some View {
|
||||||
Text(verbatim: "\(reacting_to_text(profiles: state.profiles, our_pubkey: state.pubkey, group: group, ev: event, pubkeys: pubkeys))")
|
Text(verbatim: "\(reacting_to_text(profiles: state.profiles, our_pubkey: state.pubkey, group: group, ev: event, pubkeys: pubkeys))")
|
||||||
@@ -237,6 +239,7 @@ struct EventGroupView: View {
|
|||||||
let unique_pubkeys = event_group_unique_pubkeys(profiles: state.profiles, group: group)
|
let unique_pubkeys = event_group_unique_pubkeys(profiles: state.profiles, group: group)
|
||||||
|
|
||||||
ProfilePicturesView(state: state, pubkeys: unique_pubkeys)
|
ProfilePicturesView(state: state, pubkeys: unique_pubkeys)
|
||||||
|
.environmentObject(navigationCoordinator)
|
||||||
|
|
||||||
if let event {
|
if let event {
|
||||||
let thread = ThreadModel(event: event, damus_state: state)
|
let thread = ThreadModel(event: event, damus_state: state)
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ func notification_item_event(events: EventCache, notif: NotificationItem) -> Sho
|
|||||||
struct NotificationItemView: View {
|
struct NotificationItemView: View {
|
||||||
let state: DamusState
|
let state: DamusState
|
||||||
let item: NotificationItem
|
let item: NotificationItem
|
||||||
|
|
||||||
|
@EnvironmentObject var navigationCoordinator: NavigationCoordinator
|
||||||
|
|
||||||
var show_item: ShowItem {
|
var show_item: ShowItem {
|
||||||
notification_item_event(events: state.events, notif: item)
|
notification_item_event(events: state.events, notif: item)
|
||||||
@@ -48,15 +50,19 @@ struct NotificationItemView: View {
|
|||||||
switch item {
|
switch item {
|
||||||
case .repost(_, let evgrp):
|
case .repost(_, let evgrp):
|
||||||
EventGroupView(state: state, event: ev, group: .repost(evgrp))
|
EventGroupView(state: state, event: ev, group: .repost(evgrp))
|
||||||
|
.environmentObject(navigationCoordinator)
|
||||||
|
|
||||||
case .event_zap(_, let zapgrp):
|
case .event_zap(_, let zapgrp):
|
||||||
EventGroupView(state: state, event: ev, group: .zap(zapgrp))
|
EventGroupView(state: state, event: ev, group: .zap(zapgrp))
|
||||||
|
.environmentObject(navigationCoordinator)
|
||||||
|
|
||||||
case .profile_zap(let grp):
|
case .profile_zap(let grp):
|
||||||
EventGroupView(state: state, event: nil, group: .profile_zap(grp))
|
EventGroupView(state: state, event: nil, group: .profile_zap(grp))
|
||||||
|
.environmentObject(navigationCoordinator)
|
||||||
|
|
||||||
case .reaction(_, let evgrp):
|
case .reaction(_, let evgrp):
|
||||||
EventGroupView(state: state, event: ev, group: .reaction(evgrp))
|
EventGroupView(state: state, event: ev, group: .reaction(evgrp))
|
||||||
|
.environmentObject(navigationCoordinator)
|
||||||
|
|
||||||
case .reply(let ev):
|
case .reply(let ev):
|
||||||
NavigationLink(value: Route.Thread(thread: ThreadModel(event: ev, damus_state: state))) {
|
NavigationLink(value: Route.Thread(thread: ThreadModel(event: ev, damus_state: state))) {
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ struct NotificationsView: View {
|
|||||||
@SceneStorage("NotificationsView.filter_state") var filter_state: NotificationFilterState = .all
|
@SceneStorage("NotificationsView.filter_state") var filter_state: NotificationFilterState = .all
|
||||||
|
|
||||||
@Environment(\.colorScheme) var colorScheme
|
@Environment(\.colorScheme) var colorScheme
|
||||||
|
@EnvironmentObject var navigationCoordinator: NavigationCoordinator
|
||||||
|
|
||||||
var mystery: some View {
|
var mystery: some View {
|
||||||
VStack(spacing: 20) {
|
VStack(spacing: 20) {
|
||||||
@@ -173,6 +174,7 @@ struct NotificationsView: View {
|
|||||||
.frame(height: 5)
|
.frame(height: 5)
|
||||||
ForEach(filter.filter(contacts: state.contacts, items: notifications.notifications), id: \.id) { item in
|
ForEach(filter.filter(contacts: state.contacts, items: notifications.notifications), id: \.id) { item in
|
||||||
NotificationItemView(state: state, item: item)
|
NotificationItemView(state: state, item: item)
|
||||||
|
.environmentObject(navigationCoordinator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.background(GeometryReader { proxy -> Color in
|
.background(GeometryReader { proxy -> Color in
|
||||||
|
|||||||
@@ -11,19 +11,14 @@ struct ProfilePicturesView: View {
|
|||||||
let state: DamusState
|
let state: DamusState
|
||||||
let pubkeys: [String]
|
let pubkeys: [String]
|
||||||
|
|
||||||
@State var nav_target: String? = nil
|
@EnvironmentObject var navigationCoordinator: NavigationCoordinator
|
||||||
@State var navigating: Bool = false
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationLink(destination: ProfileView(damus_state: state, pubkey: nav_target ?? ""), isActive: $navigating) {
|
|
||||||
EmptyView()
|
|
||||||
}
|
|
||||||
HStack {
|
HStack {
|
||||||
ForEach(pubkeys.prefix(8), id: \.self) { pubkey in
|
ForEach(pubkeys.prefix(8), id: \.self) { pubkey in
|
||||||
ProfilePicView(pubkey: pubkey, size: 32.0, highlight: .none, profiles: state.profiles, disable_animation: state.settings.disable_animation)
|
ProfilePicView(pubkey: pubkey, size: 32.0, highlight: .none, profiles: state.profiles, disable_animation: state.settings.disable_animation)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
nav_target = pubkey
|
navigationCoordinator.push(route: Route.ProfileByKey(pubkey: pubkey))
|
||||||
navigating = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,6 +132,8 @@ struct ProfileView: View {
|
|||||||
@StateObject var followers: FollowersModel
|
@StateObject var followers: FollowersModel
|
||||||
@StateObject var zap_button_model: ZapButtonModel = ZapButtonModel()
|
@StateObject var zap_button_model: ZapButtonModel = ZapButtonModel()
|
||||||
|
|
||||||
|
@EnvironmentObject var navigationCoordinator: NavigationCoordinator
|
||||||
|
|
||||||
init(damus_state: DamusState, profile: ProfileModel, followers: FollowersModel) {
|
init(damus_state: DamusState, profile: ProfileModel, followers: FollowersModel) {
|
||||||
self.damus_state = damus_state
|
self.damus_state = damus_state
|
||||||
self._profile = StateObject(wrappedValue: profile)
|
self._profile = StateObject(wrappedValue: profile)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ struct SearchHomeView: View {
|
|||||||
@StateObject var model: SearchHomeModel
|
@StateObject var model: SearchHomeModel
|
||||||
@State var search: String = ""
|
@State var search: String = ""
|
||||||
@FocusState private var isFocused: Bool
|
@FocusState private var isFocused: Bool
|
||||||
|
@EnvironmentObject var navigationCoordinator: NavigationCoordinator
|
||||||
|
|
||||||
let preferredLanguages = Set(Locale.preferredLanguages.map { localeToLanguage($0) })
|
let preferredLanguages = Set(Locale.preferredLanguages.map { localeToLanguage($0) })
|
||||||
|
|
||||||
@@ -67,6 +68,7 @@ struct SearchHomeView: View {
|
|||||||
return preferredLanguages.contains(note_lang)
|
return preferredLanguages.contains(note_lang)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
.environmentObject(navigationCoordinator)
|
||||||
.refreshable {
|
.refreshable {
|
||||||
// Fetch new information by unsubscribing and resubscribing to the relay
|
// Fetch new information by unsubscribing and resubscribing to the relay
|
||||||
model.unsubscribe()
|
model.unsubscribe()
|
||||||
|
|||||||
@@ -11,9 +11,11 @@ struct SearchView: View {
|
|||||||
let appstate: DamusState
|
let appstate: DamusState
|
||||||
@StateObject var search: SearchModel
|
@StateObject var search: SearchModel
|
||||||
@Environment(\.dismiss) var dismiss
|
@Environment(\.dismiss) var dismiss
|
||||||
|
@EnvironmentObject var navigationCoordinator: NavigationCoordinator
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
TimelineView(events: search.events, loading: $search.loading, damus: appstate, show_friend_icon: true, filter: { _ in true })
|
TimelineView(events: search.events, loading: $search.loading, damus: appstate, show_friend_icon: true, filter: { _ in true })
|
||||||
|
.environmentObject(navigationCoordinator)
|
||||||
.navigationBarTitle(describe_search(search.search))
|
.navigationBarTitle(describe_search(search.search))
|
||||||
.onReceive(handle_notify(.switched_timeline)) { obj in
|
.onReceive(handle_notify(.switched_timeline)) { obj in
|
||||||
dismiss()
|
dismiss()
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ struct InnerTimelineView: View {
|
|||||||
@ObservedObject var events: EventHolder
|
@ObservedObject var events: EventHolder
|
||||||
let state: DamusState
|
let state: DamusState
|
||||||
let filter: (NostrEvent) -> Bool
|
let filter: (NostrEvent) -> Bool
|
||||||
@State var nav_target: NostrEvent
|
|
||||||
@State var navigating: Bool = false
|
@EnvironmentObject var navigationCoordinator: NavigationCoordinator
|
||||||
|
|
||||||
static var count: Int = 0
|
static var count: Int = 0
|
||||||
|
|
||||||
@@ -23,8 +23,6 @@ struct InnerTimelineView: View {
|
|||||||
self.filter = filter
|
self.filter = filter
|
||||||
print("rendering InnerTimelineView \(InnerTimelineView.count)")
|
print("rendering InnerTimelineView \(InnerTimelineView.count)")
|
||||||
InnerTimelineView.count += 1
|
InnerTimelineView.count += 1
|
||||||
// dummy event to avoid MaybeThreadView
|
|
||||||
self._nav_target = State(initialValue: test_event)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var event_options: EventViewOptions {
|
var event_options: EventViewOptions {
|
||||||
@@ -36,11 +34,6 @@ struct InnerTimelineView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
let thread = ThreadModel(event: nav_target, damus_state: state)
|
|
||||||
let dest = ThreadView(state: state, thread: thread)
|
|
||||||
NavigationLink(destination: dest, isActive: $navigating) {
|
|
||||||
EmptyView()
|
|
||||||
}
|
|
||||||
LazyVStack(spacing: 0) {
|
LazyVStack(spacing: 0) {
|
||||||
let events = self.events.events
|
let events = self.events.events
|
||||||
if events.isEmpty {
|
if events.isEmpty {
|
||||||
@@ -53,8 +46,9 @@ struct InnerTimelineView: View {
|
|||||||
let ind = tup.1
|
let ind = tup.1
|
||||||
EventView(damus: state, event: ev, options: event_options)
|
EventView(damus: state, event: ev, options: event_options)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
nav_target = ev.get_inner_event(cache: state.events) ?? ev
|
let event = ev.get_inner_event(cache: state.events) ?? ev
|
||||||
navigating = true
|
let thread = ThreadModel(event: event, damus_state: state)
|
||||||
|
navigationCoordinator.push(route: Route.Thread(thread: thread))
|
||||||
}
|
}
|
||||||
.padding(.top, 7)
|
.padding(.top, 7)
|
||||||
.onAppear {
|
.onAppear {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct TimelineView: View {
|
struct TimelineView: View {
|
||||||
|
@EnvironmentObject var navigationCoordinator: NavigationCoordinator
|
||||||
@ObservedObject var events: EventHolder
|
@ObservedObject var events: EventHolder
|
||||||
@Binding var loading: Bool
|
@Binding var loading: Bool
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ struct TimelineView: View {
|
|||||||
.frame(height: 1)
|
.frame(height: 1)
|
||||||
|
|
||||||
InnerTimelineView(events: events, damus: damus, filter: loading ? { _ in true } : filter)
|
InnerTimelineView(events: events, damus: damus, filter: loading ? { _ in true } : filter)
|
||||||
|
.environmentObject(navigationCoordinator)
|
||||||
.redacted(reason: loading ? .placeholder : [])
|
.redacted(reason: loading ? .placeholder : [])
|
||||||
.shimmer(loading)
|
.shimmer(loading)
|
||||||
.disabled(loading)
|
.disabled(loading)
|
||||||
|
|||||||
Reference in New Issue
Block a user