mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-02-16 17:55:13 +00:00
Split settings view + add recently used tags list
This commit is contained in:
parent
73882b0806
commit
e4f7a6954b
4 changed files with 137 additions and 73 deletions
37
IceCubesApp/App/Tabs/Settings/RecenTagsSettingView.swift
Normal file
37
IceCubesApp/App/Tabs/Settings/RecenTagsSettingView.swift
Normal file
|
@ -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
|
@MainActor
|
||||||
struct SettingsTabs: View {
|
struct SettingsTabs: View {
|
||||||
@Environment(\.dismiss) private var dismiss
|
@Environment(\.dismiss) private var dismiss
|
||||||
@Environment(\.modelContext) private var context
|
|
||||||
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||||
|
|
||||||
@Environment(PushNotificationsService.self) private var pushNotifications
|
@Environment(PushNotificationsService.self) private var pushNotifications
|
||||||
|
@ -33,9 +32,6 @@ struct SettingsTabs: View {
|
||||||
|
|
||||||
let isModal: Bool
|
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 {
|
var body: some View {
|
||||||
NavigationStack(path: $routerPath.path) {
|
NavigationStack(path: $routerPath.path) {
|
||||||
Form {
|
Form {
|
||||||
|
@ -149,12 +145,15 @@ struct SettingsTabs: View {
|
||||||
Label("settings.general.haptic", systemImage: "waveform.path")
|
Label("settings.general.haptic", systemImage: "waveform.path")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NavigationLink(destination: remoteLocalTimelinesView) {
|
NavigationLink(destination: RemoteTimelinesSettingView()) {
|
||||||
Label("settings.general.remote-timelines", systemImage: "dot.radiowaves.right")
|
Label("settings.general.remote-timelines", systemImage: "dot.radiowaves.right")
|
||||||
}
|
}
|
||||||
NavigationLink(destination: tagGroupsView) {
|
NavigationLink(destination: TagsGroupSettingView()) {
|
||||||
Label("timeline.filter.tag-groups", systemImage: "number")
|
Label("timeline.filter.tag-groups", systemImage: "number")
|
||||||
}
|
}
|
||||||
|
NavigationLink(destination: RecenTagsSettingView()) {
|
||||||
|
Label("settings.general.recent-tags", systemImage: "clock")
|
||||||
|
}
|
||||||
NavigationLink(destination: ContentSettingsView()) {
|
NavigationLink(destination: ContentSettingsView()) {
|
||||||
Label("settings.general.content", systemImage: "rectangle.stack")
|
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 {
|
private var cacheSection: some View {
|
||||||
Section("settings.section.cache") {
|
Section("settings.section.cache") {
|
||||||
if cachedRemoved {
|
if cachedRemoved {
|
||||||
|
|
50
IceCubesApp/App/Tabs/Settings/TagsGroupSettingView.swift
Normal file
50
IceCubesApp/App/Tabs/Settings/TagsGroupSettingView.swift
Normal file
|
@ -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 a new issue