mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-29 03:31:02 +00:00
Feature: Use tagGroup icon in timeline quick access feature (#1834)
* Use tagGroup icon in timeline quick access feature * Make tagGroup symbol optional
This commit is contained in:
parent
6f42ed8de0
commit
334b09ebe3
3 changed files with 14 additions and 11 deletions
|
@ -94,7 +94,7 @@ struct TimelineTab: View {
|
||||||
lastTimelineFilter = newValue
|
lastTimelineFilter = newValue
|
||||||
}
|
}
|
||||||
switch newValue {
|
switch newValue {
|
||||||
case let .tagGroup(title, _):
|
case let .tagGroup(title, _, _):
|
||||||
if let group = tagGroups.first(where: { $0.title == title}) {
|
if let group = tagGroups.first(where: { $0.title == title}) {
|
||||||
selectedTagGroup = group
|
selectedTagGroup = group
|
||||||
}
|
}
|
||||||
|
@ -297,7 +297,7 @@ struct TimelineTab: View {
|
||||||
Menu("timeline.filter.tag-groups") {
|
Menu("timeline.filter.tag-groups") {
|
||||||
ForEach(tagGroups) { group in
|
ForEach(tagGroups) { group in
|
||||||
Button {
|
Button {
|
||||||
timeline = .tagGroup(title: group.title, tags: group.tags)
|
timeline = .tagGroup(title: group.title, tags: group.tags, symbolName: group.symbolName)
|
||||||
} label: {
|
} label: {
|
||||||
VStack {
|
VStack {
|
||||||
let icon = group.symbolName.isEmpty ? "number" : group.symbolName
|
let icon = group.symbolName.isEmpty ? "number" : group.symbolName
|
||||||
|
|
|
@ -33,7 +33,7 @@ public enum TimelineFilter: Hashable, Equatable, Identifiable {
|
||||||
|
|
||||||
case home, local, federated, trending
|
case home, local, federated, trending
|
||||||
case hashtag(tag: String, accountId: String?)
|
case hashtag(tag: String, accountId: String?)
|
||||||
case tagGroup(title: String, tags: [String])
|
case tagGroup(title: String, tags: [String], symbolName: String?)
|
||||||
case list(list: Models.List)
|
case list(list: Models.List)
|
||||||
case remoteLocal(server: String, filter: RemoteTimelineFilter)
|
case remoteLocal(server: String, filter: RemoteTimelineFilter)
|
||||||
case latest
|
case latest
|
||||||
|
@ -81,7 +81,7 @@ public enum TimelineFilter: Hashable, Equatable, Identifiable {
|
||||||
"Home"
|
"Home"
|
||||||
case let .hashtag(tag, _):
|
case let .hashtag(tag, _):
|
||||||
"#\(tag)"
|
"#\(tag)"
|
||||||
case let .tagGroup(title, _):
|
case let .tagGroup(title, _, _):
|
||||||
title
|
title
|
||||||
case let .list(list):
|
case let .list(list):
|
||||||
list.title
|
list.title
|
||||||
|
@ -106,7 +106,7 @@ public enum TimelineFilter: Hashable, Equatable, Identifiable {
|
||||||
"timeline.home"
|
"timeline.home"
|
||||||
case let .hashtag(tag, _):
|
case let .hashtag(tag, _):
|
||||||
"#\(tag)"
|
"#\(tag)"
|
||||||
case let .tagGroup(title, _):
|
case let .tagGroup(title, _, _):
|
||||||
LocalizedStringKey(title) // ?? not sure since this can't be localized.
|
LocalizedStringKey(title) // ?? not sure since this can't be localized.
|
||||||
case let .list(list):
|
case let .list(list):
|
||||||
LocalizedStringKey(list.title)
|
LocalizedStringKey(list.title)
|
||||||
|
@ -133,8 +133,8 @@ public enum TimelineFilter: Hashable, Equatable, Identifiable {
|
||||||
"list.bullet"
|
"list.bullet"
|
||||||
case .remoteLocal:
|
case .remoteLocal:
|
||||||
"dot.radiowaves.right"
|
"dot.radiowaves.right"
|
||||||
case .tagGroup:
|
case let .tagGroup(_, _, symbolName):
|
||||||
"tag"
|
symbolName ?? "tag"
|
||||||
case .hashtag:
|
case .hashtag:
|
||||||
"number"
|
"number"
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ public enum TimelineFilter: Hashable, Equatable, Identifiable {
|
||||||
} else {
|
} else {
|
||||||
return Timelines.hashtag(tag: tag, additional: nil, maxId: maxId, minId: minId)
|
return Timelines.hashtag(tag: tag, additional: nil, maxId: maxId, minId: minId)
|
||||||
}
|
}
|
||||||
case let .tagGroup(_, tags):
|
case let .tagGroup(_, tags, _):
|
||||||
var tags = tags
|
var tags = tags
|
||||||
if !tags.isEmpty {
|
if !tags.isEmpty {
|
||||||
let tag = tags.removeFirst()
|
let tag = tags.removeFirst()
|
||||||
|
@ -214,9 +214,11 @@ extension TimelineFilter: Codable {
|
||||||
var nestedContainer = try container.nestedUnkeyedContainer(forKey: .tagGroup)
|
var nestedContainer = try container.nestedUnkeyedContainer(forKey: .tagGroup)
|
||||||
let title = try nestedContainer.decode(String.self)
|
let title = try nestedContainer.decode(String.self)
|
||||||
let tags = try nestedContainer.decode([String].self)
|
let tags = try nestedContainer.decode([String].self)
|
||||||
|
let symbolName = try? nestedContainer.decode(String.self)
|
||||||
self = .tagGroup(
|
self = .tagGroup(
|
||||||
title: title,
|
title: title,
|
||||||
tags: tags
|
tags: tags,
|
||||||
|
symbolName: symbolName
|
||||||
)
|
)
|
||||||
case .list:
|
case .list:
|
||||||
let list = try container.decode(
|
let list = try container.decode(
|
||||||
|
@ -259,10 +261,11 @@ extension TimelineFilter: Codable {
|
||||||
var nestedContainer = container.nestedUnkeyedContainer(forKey: .hashtag)
|
var nestedContainer = container.nestedUnkeyedContainer(forKey: .hashtag)
|
||||||
try nestedContainer.encode(tag)
|
try nestedContainer.encode(tag)
|
||||||
try nestedContainer.encode(accountId)
|
try nestedContainer.encode(accountId)
|
||||||
case let .tagGroup(title, tags):
|
case let .tagGroup(title, tags, symbolName):
|
||||||
var nestedContainer = container.nestedUnkeyedContainer(forKey: .tagGroup)
|
var nestedContainer = container.nestedUnkeyedContainer(forKey: .tagGroup)
|
||||||
try nestedContainer.encode(title)
|
try nestedContainer.encode(title)
|
||||||
try nestedContainer.encode(tags)
|
try nestedContainer.encode(tags)
|
||||||
|
try? nestedContainer.encode(symbolName)
|
||||||
case let .list(list):
|
case let .list(list):
|
||||||
try container.encode(list, forKey: .list)
|
try container.encode(list, forKey: .list)
|
||||||
case let .remoteLocal(server, filter):
|
case let .remoteLocal(server, filter):
|
||||||
|
|
|
@ -28,7 +28,7 @@ struct TimelineTagGroupheaderView: View {
|
||||||
.scrollIndicators(.hidden)
|
.scrollIndicators(.hidden)
|
||||||
Button("status.action.edit") {
|
Button("status.action.edit") {
|
||||||
routerPath.presentedSheet = .editTagGroup(tagGroup: group, onSaved: { group in
|
routerPath.presentedSheet = .editTagGroup(tagGroup: group, onSaved: { group in
|
||||||
timeline = .tagGroup(title: group.title, tags: group.tags)
|
timeline = .tagGroup(title: group.title, tags: group.tags, symbolName: group.symbolName)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
.buttonStyle(.bordered)
|
.buttonStyle(.bordered)
|
||||||
|
|
Loading…
Reference in a new issue