Split settings view + add recently used tags list
This commit is contained in:
parent
73882b0806
commit
e4f7a6954b
|
@ -0,0 +1,37 @@
|
|||
import SwiftUI
|
||||
import SwiftData
|
||||
import Models
|
||||
import Env
|
||||
import DesignSystem
|
||||
|
||||
struct RecenTagsSettingView: View {
|
||||
@Environment(\.modelContext) private var context
|
||||
|
||||
@Environment(RouterPath.self) private var routerPath
|
||||
@Environment(Theme.self) private var theme
|
||||
|
||||
@Query(sort: \RecentTag.lastUse, order: .reverse) var tags: [RecentTag]
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
ForEach(tags) { tag in
|
||||
Text("#\(tag.title)")
|
||||
}.onDelete { indexes in
|
||||
if let index = indexes.first {
|
||||
context.delete(tags[index])
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
.navigationTitle("settings.general.recent-tags")
|
||||
.scrollContentBackground(.hidden)
|
||||
#if !os(visionOS)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
.toolbar {
|
||||
EditButton()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import SwiftUI
|
||||
import SwiftData
|
||||
import Models
|
||||
import Env
|
||||
import DesignSystem
|
||||
|
||||
struct RemoteTimelinesSettingView: View {
|
||||
@Environment(\.modelContext) private var context
|
||||
|
||||
@Environment(RouterPath.self) private var routerPath
|
||||
@Environment(Theme.self) private var theme
|
||||
|
||||
@Query(sort: \LocalTimeline.creationDate, order: .reverse) var localTimelines: [LocalTimeline]
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
ForEach(localTimelines) { timeline in
|
||||
Text(timeline.instance)
|
||||
}.onDelete { indexes in
|
||||
if let index = indexes.first {
|
||||
context.delete(localTimelines[index])
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
Button {
|
||||
routerPath.presentedSheet = .addRemoteLocalTimeline
|
||||
} label: {
|
||||
Label("settings.timeline.add", systemImage: "badge.plus.radiowaves.right")
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
.navigationTitle("settings.general.remote-timelines")
|
||||
.scrollContentBackground(.hidden)
|
||||
#if !os(visionOS)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
.toolbar {
|
||||
EditButton()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,7 +13,6 @@ import Timeline
|
|||
@MainActor
|
||||
struct SettingsTabs: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@Environment(\.modelContext) private var context
|
||||
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||
|
||||
@Environment(PushNotificationsService.self) private var pushNotifications
|
||||
|
@ -33,9 +32,6 @@ struct SettingsTabs: View {
|
|||
|
||||
let isModal: Bool
|
||||
|
||||
@Query(sort: \LocalTimeline.creationDate, order: .reverse) var localTimelines: [LocalTimeline]
|
||||
@Query(sort: \TagGroup.creationDate, order: .reverse) var tagGroups: [TagGroup]
|
||||
|
||||
var body: some View {
|
||||
NavigationStack(path: $routerPath.path) {
|
||||
Form {
|
||||
|
@ -149,12 +145,15 @@ struct SettingsTabs: View {
|
|||
Label("settings.general.haptic", systemImage: "waveform.path")
|
||||
}
|
||||
}
|
||||
NavigationLink(destination: remoteLocalTimelinesView) {
|
||||
NavigationLink(destination: RemoteTimelinesSettingView()) {
|
||||
Label("settings.general.remote-timelines", systemImage: "dot.radiowaves.right")
|
||||
}
|
||||
NavigationLink(destination: tagGroupsView) {
|
||||
NavigationLink(destination: TagsGroupSettingView()) {
|
||||
Label("timeline.filter.tag-groups", systemImage: "number")
|
||||
}
|
||||
NavigationLink(destination: RecenTagsSettingView()) {
|
||||
Label("settings.general.recent-tags", systemImage: "clock")
|
||||
}
|
||||
NavigationLink(destination: ContentSettingsView()) {
|
||||
Label("settings.general.content", systemImage: "rectangle.stack")
|
||||
}
|
||||
|
@ -300,73 +299,6 @@ struct SettingsTabs: View {
|
|||
}
|
||||
}
|
||||
|
||||
private var tagGroupsView: some View {
|
||||
Form {
|
||||
ForEach(tagGroups) { group in
|
||||
Label(group.title, systemImage: group.symbolName)
|
||||
.onTapGesture {
|
||||
routerPath.presentedSheet = .editTagGroup(tagGroup: group, onSaved: nil)
|
||||
}
|
||||
}
|
||||
.onDelete { indexes in
|
||||
if let index = indexes.first {
|
||||
context.delete(tagGroups[index])
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
|
||||
Button {
|
||||
routerPath.presentedSheet = .addTagGroup
|
||||
} label: {
|
||||
Label("timeline.filter.add-tag-groups", systemImage: "plus")
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
.navigationTitle("timeline.filter.tag-groups")
|
||||
.scrollContentBackground(.hidden)
|
||||
#if !os(visionOS)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
.toolbar {
|
||||
EditButton()
|
||||
}
|
||||
}
|
||||
|
||||
private var remoteLocalTimelinesView: some View {
|
||||
Form {
|
||||
ForEach(localTimelines) { timeline in
|
||||
Text(timeline.instance)
|
||||
}.onDelete { indexes in
|
||||
if let index = indexes.first {
|
||||
context.delete(localTimelines[index])
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
Button {
|
||||
routerPath.presentedSheet = .addRemoteLocalTimeline
|
||||
} label: {
|
||||
Label("settings.timeline.add", systemImage: "badge.plus.radiowaves.right")
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
.navigationTitle("settings.general.remote-timelines")
|
||||
.scrollContentBackground(.hidden)
|
||||
#if !os(visionOS)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
.toolbar {
|
||||
EditButton()
|
||||
}
|
||||
}
|
||||
|
||||
private var cacheSection: some View {
|
||||
Section("settings.section.cache") {
|
||||
if cachedRemoved {
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
import SwiftUI
|
||||
import SwiftData
|
||||
import Models
|
||||
import Env
|
||||
import DesignSystem
|
||||
|
||||
struct TagsGroupSettingView: View {
|
||||
@Environment(\.modelContext) private var context
|
||||
|
||||
@Environment(RouterPath.self) private var routerPath
|
||||
@Environment(Theme.self) private var theme
|
||||
|
||||
@Query(sort: \TagGroup.creationDate, order: .reverse) var tagGroups: [TagGroup]
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
ForEach(tagGroups) { group in
|
||||
Label(group.title, systemImage: group.symbolName)
|
||||
.onTapGesture {
|
||||
routerPath.presentedSheet = .editTagGroup(tagGroup: group, onSaved: nil)
|
||||
}
|
||||
}
|
||||
.onDelete { indexes in
|
||||
if let index = indexes.first {
|
||||
context.delete(tagGroups[index])
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
|
||||
Button {
|
||||
routerPath.presentedSheet = .addTagGroup
|
||||
} label: {
|
||||
Label("timeline.filter.add-tag-groups", systemImage: "plus")
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
.navigationTitle("timeline.filter.tag-groups")
|
||||
.scrollContentBackground(.hidden)
|
||||
#if !os(visionOS)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
.toolbar {
|
||||
EditButton()
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue