Skip to content

Commit

Permalink
fix: update code for review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
phlpsong committed Jan 19, 2024
1 parent 502a346 commit ff36390
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
17 changes: 17 additions & 0 deletions Easydict/App/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -2415,6 +2415,23 @@
}
}
},
"setting.disabled.import_app_error.message" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Unable to add Application"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "无法添加应用"
}
}
}
},
"setting.general.advance.default_tts_service" : {
"localizations" : {
"en" : {
Expand Down
21 changes: 14 additions & 7 deletions Easydict/NewApp/View/SettingView/Tabs/DisabledAppTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ class DisabledAppViewModel: ObservableObject {

@Published var isImporting = false

@Published var isShowImportErrorAlert = false

init() {
fetchDisabledApps()
}

func fetchDisabledApps() {
appModelList = EZLocalStorage.shared().selectTextTypeAppModelList
}
Expand Down Expand Up @@ -57,7 +63,7 @@ class DisabledAppViewModel: ObservableObject {

@available(macOS 13.0, *)
struct DisabledAppTab: View {
@ObservedObject var disabledAppViewModel = DisabledAppViewModel()
@StateObject var disabledAppViewModel = DisabledAppViewModel()

var listToolbar: some View {
ListToolbar()
Expand All @@ -71,8 +77,12 @@ struct DisabledAppTab: View {
disabledAppViewModel.newAppURLsSelected(from: urls)
case let .failure(error):
print("fileImporter error: \(error)")
disabledAppViewModel.isShowImportErrorAlert.toggle()
}
}
.alert(isPresented: $disabledAppViewModel.isShowImportErrorAlert) {
Alert(title: Text(""), message: Text("setting.disabled.import_app_error.message"), dismissButton: .default(Text("ok")))
}
}

var appListView: some View {
Expand Down Expand Up @@ -110,14 +120,11 @@ struct DisabledAppTab: View {
}
.frame(maxWidth: 500)
.environmentObject(disabledAppViewModel)
.onAppear {
disabledAppViewModel.fetchDisabledApps()
}
}
}

@available(macOS 13.0, *)
struct ListToolbar: View {
private struct ListToolbar: View {
@EnvironmentObject private var disabledAppViewModel: DisabledAppViewModel

var body: some View {
Expand All @@ -142,7 +149,7 @@ struct ListToolbar: View {
}

@available(macOS 13.0, *)
struct ListButton: View {
private struct ListButton: View {
var imageName: String
var action: () -> Void

Expand All @@ -162,7 +169,7 @@ struct ListButton: View {
}

@available(macOS 13.0, *)
struct BlockAppItemView: View {
private struct BlockAppItemView: View {
@StateObject private var appFetcher: AppFetcher

@EnvironmentObject var disabledAppViewModel: DisabledAppViewModel
Expand Down

0 comments on commit ff36390

Please sign in to comment.