mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-24 01:01:00 +00:00
Move all localization to views
This commit is contained in:
parent
96fdc6c837
commit
bd1f7af036
4 changed files with 39 additions and 37 deletions
|
@ -58,22 +58,3 @@ extension EditFilterViewModel {
|
|||
.store(in: &cancellables)
|
||||
}
|
||||
}
|
||||
|
||||
extension Filter.Context {
|
||||
var localized: String {
|
||||
switch self {
|
||||
case .home:
|
||||
return NSLocalizedString("filter.context.home", comment: "")
|
||||
case .notifications:
|
||||
return NSLocalizedString("filter.context.notifications", comment: "")
|
||||
case .public:
|
||||
return NSLocalizedString("filter.context.public", comment: "")
|
||||
case .thread:
|
||||
return NSLocalizedString("filter.context.thread", comment: "")
|
||||
case .account:
|
||||
return NSLocalizedString("filter.context.account", comment: "")
|
||||
case .unknown:
|
||||
return NSLocalizedString("filter.context.unknown", comment: "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,21 +43,6 @@ extension TabNavigationViewModel {
|
|||
}
|
||||
}
|
||||
|
||||
func title(timeline: Timeline) -> String {
|
||||
switch timeline {
|
||||
case .home:
|
||||
return NSLocalizedString("timelines.home", comment: "")
|
||||
case .local:
|
||||
return NSLocalizedString("timelines.local", comment: "")
|
||||
case .federated:
|
||||
return NSLocalizedString("timelines.federated", comment: "")
|
||||
case let .list(list):
|
||||
return list.title
|
||||
case let .tag(tag):
|
||||
return "#" + tag
|
||||
}
|
||||
}
|
||||
|
||||
func systemImageName(timeline: Timeline) -> String {
|
||||
switch timeline {
|
||||
case .home: return "house"
|
||||
|
|
|
@ -76,6 +76,25 @@ struct EditFilterView: View {
|
|||
}
|
||||
}
|
||||
|
||||
extension Filter.Context {
|
||||
var localized: String {
|
||||
switch self {
|
||||
case .home:
|
||||
return NSLocalizedString("filter.context.home", comment: "")
|
||||
case .notifications:
|
||||
return NSLocalizedString("filter.context.notifications", comment: "")
|
||||
case .public:
|
||||
return NSLocalizedString("filter.context.public", comment: "")
|
||||
case .thread:
|
||||
return NSLocalizedString("filter.context.thread", comment: "")
|
||||
case .account:
|
||||
return NSLocalizedString("filter.context.account", comment: "")
|
||||
case .unknown:
|
||||
return NSLocalizedString("filter.context.unknown", comment: "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
struct EditFilterView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
|
|
|
@ -43,11 +43,11 @@ private extension TabNavigationView {
|
|||
StatusListView(viewModel: viewModel.viewModel(timeline: viewModel.timeline))
|
||||
.id(viewModel.timeline.id)
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
.navigationBarTitle(viewModel.title(timeline: viewModel.timeline), displayMode: .inline)
|
||||
.navigationBarTitle(timelineTitle, displayMode: .inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .principal) {
|
||||
VStack {
|
||||
Text(viewModel.title(timeline: viewModel.timeline))
|
||||
Text(timelineTitle)
|
||||
.font(.headline)
|
||||
Text(viewModel.timelineSubtitle)
|
||||
.font(.footnote)
|
||||
|
@ -62,7 +62,7 @@ private extension TabNavigationView {
|
|||
Button {
|
||||
viewModel.timeline = timeline
|
||||
} label: {
|
||||
Label(viewModel.title(timeline: timeline),
|
||||
Label(timelineTitle,
|
||||
systemImage: viewModel.systemImageName(timeline: timeline))
|
||||
}
|
||||
}
|
||||
|
@ -101,6 +101,23 @@ private extension TabNavigationView {
|
|||
}
|
||||
}
|
||||
|
||||
private extension TabNavigationView {
|
||||
var timelineTitle: String {
|
||||
switch viewModel.timeline {
|
||||
case .home:
|
||||
return NSLocalizedString("timelines.home", comment: "")
|
||||
case .local:
|
||||
return NSLocalizedString("timelines.local", comment: "")
|
||||
case .federated:
|
||||
return NSLocalizedString("timelines.federated", comment: "")
|
||||
case let .list(list):
|
||||
return list.title
|
||||
case let .tag(tag):
|
||||
return "#" + tag
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
struct TabNavigation_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
|
|
Loading…
Reference in a new issue