diff --git a/Easydict/App/Localizable.xcstrings b/Easydict/App/Localizable.xcstrings index 2114e3a63..55c00671f 100644 --- a/Easydict/App/Localizable.xcstrings +++ b/Easydict/App/Localizable.xcstrings @@ -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" : { diff --git a/Easydict/NewApp/View/SettingView/Tabs/DisabledAppTab.swift b/Easydict/NewApp/View/SettingView/Tabs/DisabledAppTab.swift index 5893730ef..d12c0f4cd 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/DisabledAppTab.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/DisabledAppTab.swift @@ -16,6 +16,12 @@ class DisabledAppViewModel: ObservableObject { @Published var isImporting = false + @Published var isShowImportErrorAlert = false + + init() { + fetchDisabledApps() + } + func fetchDisabledApps() { appModelList = EZLocalStorage.shared().selectTextTypeAppModelList } @@ -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() @@ -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 { @@ -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 { @@ -142,7 +149,7 @@ struct ListToolbar: View { } @available(macOS 13.0, *) -struct ListButton: View { +private struct ListButton: View { var imageName: String var action: () -> Void @@ -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