Add / Remove tag from tag groups from timeline view

This commit is contained in:
Thomas Ricouard 2023-10-05 09:47:51 +02:00
parent 1bf4d9e398
commit 1275b09f20
20 changed files with 92 additions and 40 deletions

View file

@ -613,4 +613,5 @@
"add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)"; "add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)";
"add-tag-groups.edit.tags" = "Add tags to the group"; "add-tag-groups.edit.tags" = "Add tags to the group";
"add-tag-groups.edit.tags.add" = "Tag"; "add-tag-groups.edit.tags.add" = "Tag";
"tag-groups.edit.section.title" = "Add or remove tag from tag groups";

View file

@ -607,9 +607,4 @@
"add-tag-groups.edit.icon.field" = "Icona del Grup d'Etiquetes (SFSymbol)"; "add-tag-groups.edit.icon.field" = "Icona del Grup d'Etiquetes (SFSymbol)";
"add-tag-groups.edit.tags" = "Afegeix etiquetes al grup"; "add-tag-groups.edit.tags" = "Afegeix etiquetes al grup";
"add-tag-groups.edit.tags.add" = "Etiqueta"; "add-tag-groups.edit.tags.add" = "Etiqueta";
"tag-groups.edit.section.title" = "Add or remove tag from tag groups";
// MARK: Tag Groups
"add-tag-groups.edit.title.field" = "Tag Group Title";
"add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)";
"add-tag-groups.edit.tags" = "Add tags to the group";
"add-tag-groups.edit.tags.add" = "Tag";

View file

@ -594,3 +594,4 @@
"add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)"; "add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)";
"add-tag-groups.edit.tags" = "Add tags to the group"; "add-tag-groups.edit.tags" = "Add tags to the group";
"add-tag-groups.edit.tags.add" = "Tag"; "add-tag-groups.edit.tags.add" = "Tag";
"tag-groups.edit.section.title" = "Add or remove tag from tag groups";

View file

@ -608,3 +608,4 @@
"add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)"; "add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)";
"add-tag-groups.edit.tags" = "Add tags to the group"; "add-tag-groups.edit.tags" = "Add tags to the group";
"add-tag-groups.edit.tags.add" = "Tag"; "add-tag-groups.edit.tags.add" = "Tag";
"tag-groups.edit.section.title" = "Add or remove tag from tag groups";

View file

@ -610,3 +610,4 @@
"add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)"; "add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)";
"add-tag-groups.edit.tags" = "Add tags to the group"; "add-tag-groups.edit.tags" = "Add tags to the group";
"add-tag-groups.edit.tags.add" = "Tag"; "add-tag-groups.edit.tags.add" = "Tag";
"tag-groups.edit.section.title" = "Add or remove tag from tag groups";

View file

@ -609,3 +609,4 @@
"add-tag-groups.edit.icon.field" = "Icono del Grupo de Etiquetas (SFSymbol)"; "add-tag-groups.edit.icon.field" = "Icono del Grupo de Etiquetas (SFSymbol)";
"add-tag-groups.edit.tags" = "Añade etiquetas al grupo"; "add-tag-groups.edit.tags" = "Añade etiquetas al grupo";
"add-tag-groups.edit.tags.add" = "Etiqueta"; "add-tag-groups.edit.tags.add" = "Etiqueta";
"tag-groups.edit.section.title" = "Add or remove tag from tag groups";

View file

@ -595,3 +595,4 @@
"add-tag-groups.edit.icon.field" = "Traola-sortaren ikonoa (SFSymbol izena)"; "add-tag-groups.edit.icon.field" = "Traola-sortaren ikonoa (SFSymbol izena)";
"add-tag-groups.edit.tags" = "Gehitu traolak sortara"; "add-tag-groups.edit.tags" = "Gehitu traolak sortara";
"add-tag-groups.edit.tags.add" = "Traola"; "add-tag-groups.edit.tags.add" = "Traola";
"tag-groups.edit.section.title" = "Add or remove tag from tag groups";

View file

@ -604,3 +604,4 @@
"add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)"; "add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)";
"add-tag-groups.edit.tags" = "Add tags to the group"; "add-tag-groups.edit.tags" = "Add tags to the group";
"add-tag-groups.edit.tags.add" = "Tag"; "add-tag-groups.edit.tags.add" = "Tag";
"tag-groups.edit.section.title" = "Add or remove tag from tag groups";

View file

@ -610,3 +610,4 @@
"add-tag-groups.edit.icon.field" = "Icona del gruppo (nome simbolo SF)"; "add-tag-groups.edit.icon.field" = "Icona del gruppo (nome simbolo SF)";
"add-tag-groups.edit.tags" = "Tag aggiunti al gruppo"; "add-tag-groups.edit.tags" = "Tag aggiunti al gruppo";
"add-tag-groups.edit.tags.add" = "Tag"; "add-tag-groups.edit.tags.add" = "Tag";
"tag-groups.edit.section.title" = "Add or remove tag from tag groups";

View file

@ -607,3 +607,4 @@
"add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)"; "add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)";
"add-tag-groups.edit.tags" = "Add tags to the group"; "add-tag-groups.edit.tags" = "Add tags to the group";
"add-tag-groups.edit.tags.add" = "Tag"; "add-tag-groups.edit.tags.add" = "Tag";
"tag-groups.edit.section.title" = "Add or remove tag from tag groups";

View file

@ -611,3 +611,4 @@
"add-tag-groups.edit.icon.field" = "태그 모음 아이콘 (SF Symbol 이름)"; "add-tag-groups.edit.icon.field" = "태그 모음 아이콘 (SF Symbol 이름)";
"add-tag-groups.edit.tags" = "모음에 포함할 태그"; "add-tag-groups.edit.tags" = "모음에 포함할 태그";
"add-tag-groups.edit.tags.add" = "태그"; "add-tag-groups.edit.tags.add" = "태그";
"tag-groups.edit.section.title" = "Add or remove tag from tag groups";

View file

@ -608,3 +608,4 @@
"add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)"; "add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)";
"add-tag-groups.edit.tags" = "Add tags to the group"; "add-tag-groups.edit.tags" = "Add tags to the group";
"add-tag-groups.edit.tags.add" = "Tag"; "add-tag-groups.edit.tags.add" = "Tag";
"tag-groups.edit.section.title" = "Add or remove tag from tag groups";

View file

@ -605,3 +605,4 @@
"add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)"; "add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)";
"add-tag-groups.edit.tags" = "Add tags to the group"; "add-tag-groups.edit.tags" = "Add tags to the group";
"add-tag-groups.edit.tags.add" = "Tag"; "add-tag-groups.edit.tags.add" = "Tag";
"tag-groups.edit.section.title" = "Add or remove tag from tag groups";

View file

@ -597,4 +597,5 @@
"add-tag-groups.edit.icon.field" = "Ikona grupy (nazwa symbolu SF)"; "add-tag-groups.edit.icon.field" = "Ikona grupy (nazwa symbolu SF)";
"add-tag-groups.edit.tags" = "Dodaj hasztagi do grupy"; "add-tag-groups.edit.tags" = "Dodaj hasztagi do grupy";
"add-tag-groups.edit.tags.add" = "Hasztag"; "add-tag-groups.edit.tags.add" = "Hasztag";
"tag-groups.edit.section.title" = "Add or remove tag from tag groups";

View file

@ -608,3 +608,4 @@
"add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)"; "add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)";
"add-tag-groups.edit.tags" = "Add tags to the group"; "add-tag-groups.edit.tags" = "Add tags to the group";
"add-tag-groups.edit.tags.add" = "Tag"; "add-tag-groups.edit.tags.add" = "Tag";
"tag-groups.edit.section.title" = "Add or remove tag from tag groups";

View file

@ -608,3 +608,4 @@
"add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)"; "add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)";
"add-tag-groups.edit.tags" = "Add tags to the group"; "add-tag-groups.edit.tags" = "Add tags to the group";
"add-tag-groups.edit.tags.add" = "Tag"; "add-tag-groups.edit.tags.add" = "Tag";
"tag-groups.edit.section.title" = "Add or remove tag from tag groups";

View file

@ -609,4 +609,5 @@
"add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)"; "add-tag-groups.edit.icon.field" = "Tag Group Icon (SFSymbol name)";
"add-tag-groups.edit.tags" = "Add tags to the group"; "add-tag-groups.edit.tags" = "Add tags to the group";
"add-tag-groups.edit.tags.add" = "Tag"; "add-tag-groups.edit.tags.add" = "Tag";
"tag-groups.edit.section.title" = "Add or remove tag from tag groups";

View file

@ -610,3 +610,4 @@
"add-tag-groups.edit.icon.field" = "标签组图标SFSymbol"; "add-tag-groups.edit.icon.field" = "标签组图标SFSymbol";
"add-tag-groups.edit.tags" = "将标签添加到组"; "add-tag-groups.edit.tags" = "将标签添加到组";
"add-tag-groups.edit.tags.add" = "标签"; "add-tag-groups.edit.tags.add" = "标签";
"tag-groups.edit.section.title" = "Add or remove tag from tag groups";

View file

@ -610,3 +610,4 @@
"add-tag-groups.edit.icon.field" = "標籤組圖示SFSymbol 名稱)"; "add-tag-groups.edit.icon.field" = "標籤組圖示SFSymbol 名稱)";
"add-tag-groups.edit.tags" = "把標籤加入標籤組"; "add-tag-groups.edit.tags" = "把標籤加入標籤組";
"add-tag-groups.edit.tags.add" = "標籤"; "add-tag-groups.edit.tags.add" = "標籤";
"tag-groups.edit.section.title" = "Add or remove tag from tag groups";

View file

@ -6,6 +6,7 @@ import Shimmer
import Status import Status
import SwiftUI import SwiftUI
import SwiftUIIntrospect import SwiftUIIntrospect
import SwiftData
@MainActor @MainActor
public struct TimelineView: View { public struct TimelineView: View {
@ -25,6 +26,9 @@ public struct TimelineView: View {
@Binding var timeline: TimelineFilter @Binding var timeline: TimelineFilter
@Binding var selectedTagGroup: TagGroup? @Binding var selectedTagGroup: TagGroup?
@Binding var scrollToTopSignal: Int @Binding var scrollToTopSignal: Int
@Query(sort: \TagGroup.creationDate, order: .reverse) var tagGroups: [TagGroup]
private let canFilterTimeline: Bool private let canFilterTimeline: Bool
public init(timeline: Binding<TimelineFilter>, public init(timeline: Binding<TimelineFilter>,
@ -88,40 +92,8 @@ public struct TimelineView: View {
} }
} }
.toolbar { .toolbar {
ToolbarItem(placement: .principal) { toolbarTitleView
VStack(alignment: .center) { toolbarTagGroupButton
switch timeline {
case let .remoteLocal(_, filter):
Text(filter.localizedTitle())
.font(.headline)
Text(timeline.localizedTitle())
.font(.caption)
.foregroundColor(.gray)
default:
Text(timeline.localizedTitle())
.font(.headline)
}
}
.accessibilityRepresentation {
switch timeline {
case let .remoteLocal(_, filter):
if canFilterTimeline {
Menu(filter.localizedTitle()) {}
} else {
Text(filter.localizedTitle())
}
default:
if canFilterTimeline {
Menu(timeline.localizedTitle()) {}
} else {
Text(timeline.localizedTitle())
}
}
}
.accessibilityAddTraits(.isHeader)
.accessibilityRemoveTraits(.isButton)
.accessibilityRespondsToUserInteraction(canFilterTimeline)
}
} }
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.onAppear { .onAppear {
@ -253,6 +225,73 @@ public struct TimelineView: View {
trailing: .layoutPadding)) trailing: .layoutPadding))
} }
@ToolbarContentBuilder
private var toolbarTitleView: some ToolbarContent {
ToolbarItem(placement: .principal) {
VStack(alignment: .center) {
switch timeline {
case let .remoteLocal(_, filter):
Text(filter.localizedTitle())
.font(.headline)
Text(timeline.localizedTitle())
.font(.caption)
.foregroundColor(.gray)
default:
Text(timeline.localizedTitle())
.font(.headline)
}
}
.accessibilityRepresentation {
switch timeline {
case let .remoteLocal(_, filter):
if canFilterTimeline {
Menu(filter.localizedTitle()) {}
} else {
Text(filter.localizedTitle())
}
default:
if canFilterTimeline {
Menu(timeline.localizedTitle()) {}
} else {
Text(timeline.localizedTitle())
}
}
}
.accessibilityAddTraits(.isHeader)
.accessibilityRemoveTraits(.isButton)
.accessibilityRespondsToUserInteraction(canFilterTimeline)
}
}
@ToolbarContentBuilder
private var toolbarTagGroupButton: some ToolbarContent {
ToolbarItem(placement: .topBarTrailing) {
switch timeline {
case let .hashtag(tag, _):
Menu {
Section("tag-groups.edit.section.title") {
ForEach(tagGroups) { group in
Button {
if group.tags.contains(tag) {
group.tags.removeAll(where: { $0 == tag })
} else {
group.tags.append(tag)
}
} label: {
Label(group.title,
systemImage: group.tags.contains(tag) ? "checkmark.rectangle.fill" : "checkmark.rectangle")
}
}
}
} label: {
Image(systemName: "ellipsis")
}
default:
EmptyView()
}
}
}
private var scrollToTopView: some View { private var scrollToTopView: some View {
ScrollToView() ScrollToView()
.frame(height: .layoutPadding) .frame(height: .layoutPadding)