mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-25 09:41:02 +00:00
Add more sheets to shared + link to filters in timeline top filters
This commit is contained in:
parent
e612fbdf7c
commit
b56da94a7c
5 changed files with 48 additions and 24 deletions
|
@ -140,6 +140,12 @@ extension View {
|
|||
.presentationDetents([.medium])
|
||||
.presentationBackground(.thinMaterial)
|
||||
.withEnvironments()
|
||||
case .accountEditInfo:
|
||||
EditAccountView()
|
||||
.withEnvironments()
|
||||
case .accountFiltersList:
|
||||
FiltersListView()
|
||||
.withEnvironments()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,8 @@ struct AccountSettingsView: View {
|
|||
@Environment(Theme.self) private var theme
|
||||
@Environment(AppAccountsManager.self) private var appAccountsManager
|
||||
@Environment(Client.self) private var client
|
||||
@Environment(RouterPath.self) private var routerPath
|
||||
|
||||
@State private var isEditingAccount: Bool = false
|
||||
@State private var isEditingFilters: Bool = false
|
||||
@State private var cachedPostsCount: Int = 0
|
||||
@State private var timelineCache = TimelineCache()
|
||||
|
||||
|
@ -30,7 +29,7 @@ struct AccountSettingsView: View {
|
|||
Form {
|
||||
Section {
|
||||
Button {
|
||||
isEditingAccount = true
|
||||
routerPath.presentedSheet = .accountFiltersList
|
||||
} label: {
|
||||
Label("account.action.edit-info", systemImage: "pencil")
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
@ -40,7 +39,7 @@ struct AccountSettingsView: View {
|
|||
|
||||
if currentInstance.isFiltersSupported {
|
||||
Button {
|
||||
isEditingFilters = true
|
||||
routerPath.presentedSheet = .accountFiltersList
|
||||
} label: {
|
||||
Label("account.action.edit-filters", systemImage: "line.3.horizontal.decrease.circle")
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
@ -96,12 +95,6 @@ struct AccountSettingsView: View {
|
|||
}
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
}
|
||||
.sheet(isPresented: $isEditingAccount, content: {
|
||||
EditAccountView()
|
||||
})
|
||||
.sheet(isPresented: $isEditingFilters, content: {
|
||||
FiltersListView()
|
||||
})
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .principal) {
|
||||
HStack {
|
||||
|
|
|
@ -23,9 +23,6 @@ public struct AccountDetailView: View {
|
|||
@State private var viewModel: AccountDetailViewModel
|
||||
@State private var isCurrentUser: Bool = false
|
||||
@State private var showBlockConfirmation: Bool = false
|
||||
|
||||
@State private var isEditingAccount: Bool = false
|
||||
@State private var isEditingFilters: Bool = false
|
||||
@State private var isEditingRelationshipNote: Bool = false
|
||||
|
||||
@State private var displayTitle: Bool = false
|
||||
|
@ -136,20 +133,14 @@ public struct AccountDetailView: View {
|
|||
viewModel.handleEvent(event: latestEvent, currentAccount: currentAccount)
|
||||
}
|
||||
}
|
||||
.onChange(of: isEditingAccount) { _, newValue in
|
||||
if !newValue {
|
||||
.onChange(of: routerPath.presentedSheet) { oldValue, newValue in
|
||||
if oldValue == .accountEditInfo || newValue == .accountEditInfo {
|
||||
Task {
|
||||
await viewModel.fetchAccount()
|
||||
await preferences.refreshServerPreferences()
|
||||
}
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $isEditingAccount, content: {
|
||||
EditAccountView()
|
||||
})
|
||||
.sheet(isPresented: $isEditingFilters, content: {
|
||||
FiltersListView()
|
||||
})
|
||||
.sheet(isPresented: $isEditingRelationshipNote, content: {
|
||||
EditRelationshipNoteView(accountDetailViewModel: viewModel)
|
||||
})
|
||||
|
@ -306,7 +297,7 @@ public struct AccountDetailView: View {
|
|||
|
||||
if isCurrentUser {
|
||||
Button {
|
||||
isEditingAccount = true
|
||||
routerPath.presentedSheet = .accountEditInfo
|
||||
} label: {
|
||||
Label("account.action.edit-info", systemImage: "pencil")
|
||||
}
|
||||
|
@ -321,7 +312,7 @@ public struct AccountDetailView: View {
|
|||
|
||||
if currentInstance.isFiltersSupported {
|
||||
Button {
|
||||
isEditingFilters = true
|
||||
routerPath.presentedSheet = .accountFiltersList
|
||||
} label: {
|
||||
Label("account.action.edit-filters", systemImage: "line.3.horizontal.decrease.circle")
|
||||
}
|
||||
|
|
|
@ -38,7 +38,15 @@ public enum WindowDestinationMedia: Hashable, Codable {
|
|||
case mediaViewer(attachments: [MediaAttachment], selectedAttachment: MediaAttachment)
|
||||
}
|
||||
|
||||
public enum SheetDestination: Identifiable {
|
||||
public enum SheetDestination: Identifiable, Hashable {
|
||||
public static func == (lhs: SheetDestination, rhs: SheetDestination) -> Bool {
|
||||
lhs.id == rhs.id
|
||||
}
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(id)
|
||||
}
|
||||
|
||||
case newStatusEditor(visibility: Models.Visibility)
|
||||
case editStatusEditor(status: Status)
|
||||
case replyToStatusEditor(status: Status)
|
||||
|
@ -60,6 +68,8 @@ public enum SheetDestination: Identifiable {
|
|||
case shareImage(image: UIImage, status: Status)
|
||||
case editTagGroup(tagGroup: TagGroup, onSaved: ((TagGroup) -> Void)?)
|
||||
case timelineContentFilter
|
||||
case accountEditInfo
|
||||
case accountFiltersList
|
||||
|
||||
public var id: String {
|
||||
switch self {
|
||||
|
@ -90,6 +100,10 @@ public enum SheetDestination: Identifiable {
|
|||
"settings"
|
||||
case .timelineContentFilter:
|
||||
"timelineContentFilter"
|
||||
case .accountEditInfo:
|
||||
"accountEditInfo"
|
||||
case .accountFiltersList:
|
||||
"accountFiltersList"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
import DesignSystem
|
||||
import SwiftUI
|
||||
import Env
|
||||
|
||||
public struct TimelineContentFilterView: View {
|
||||
@Environment(Theme.self) private var theme
|
||||
@Environment(CurrentInstance.self) private var currentInstance
|
||||
@Environment(RouterPath.self) private var routerPath
|
||||
|
||||
@State private var contentFilter = TimelineContentFilter.shared
|
||||
@State private var isEditingFilters = false
|
||||
|
||||
public init() {}
|
||||
|
||||
|
@ -27,6 +31,22 @@ public struct TimelineContentFilterView: View {
|
|||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
|
||||
Section {
|
||||
if currentInstance.isFiltersSupported {
|
||||
Button {
|
||||
routerPath.presentedSheet = .accountFiltersList
|
||||
} label: {
|
||||
Label("account.action.edit-filters", systemImage: "line.3.horizontal.decrease.circle")
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
.navigationTitle("timeline.content-filter.title")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
|
|
Loading…
Reference in a new issue