Skip to content

Commit

Permalink
feat: add a back button when selected service is not nil
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng committed Oct 27, 2024
1 parent 413ea6b commit 27c8663
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 9 deletions.
34 changes: 34 additions & 0 deletions Easydict/App/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,40 @@
}
}
},
"setting.service.back" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Back"
}
},
"en-CA" : {
"stringUnit" : {
"state" : "translated",
"value" : "Back"
}
},
"sk" : {
"stringUnit" : {
"state" : "translated",
"value" : "Späť"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "返回"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "返回"
}
}
}
},
"Baidu" : {
"extractionState" : "manual",
"localizations" : {
Expand Down
26 changes: 17 additions & 9 deletions Easydict/Swift/View/SettingView/Tabs/TabView/ServiceTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct ServiceTab: View {
// MARK: Internal

var body: some View {
HStack {
HStack(alignment: .top, spacing: 0) {
VStack {
WindowTypePicker(windowType: $viewModel.windowType)
.padding()
Expand All @@ -35,16 +35,24 @@ struct ServiceTab: View {

Group {
if let service = viewModel.selectedService {
if let view = service.configurationListItems() as? (any View) {
Form {
AnyView(view)
VStack(alignment: .leading) {
Button("setting.service.back") {
viewModel.selectedService = nil
}
.formStyle(.grouped)

} else {
HStack {
.padding()

if let view = service.configurationListItems() as? (any View) {
Form {
AnyView(view)
}
.formStyle(.grouped)
} else {
Spacer()
Text("setting.service.detail.no_configuration \(service.name())")
HStack {
Spacer()
Text("setting.service.detail.no_configuration \(service.name())")
Spacer()
}
Spacer()
}
}
Expand Down

0 comments on commit 27c8663

Please sign in to comment.