From 54a5746473987d2daa32f31e3409ab20cc3593de Mon Sep 17 00:00:00 2001 From: ensan-hcl Date: Sun, 8 Oct 2023 17:56:26 +0900 Subject: [PATCH 01/10] Update iOS version requirement --- azooKey.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azooKey.xcodeproj/project.pbxproj b/azooKey.xcodeproj/project.pbxproj index 1444fb74..84b83b3a 100644 --- a/azooKey.xcodeproj/project.pbxproj +++ b/azooKey.xcodeproj/project.pbxproj @@ -1642,7 +1642,7 @@ ENABLE_PREVIEWS = YES; INFOPLIST_FILE = MainApp/Info.plist; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1678,7 +1678,7 @@ "GCC_OPTIMIZATION_LEVEL[arch=*]" = s; INFOPLIST_FILE = MainApp/Info.plist; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", From 2b443e0c7bd54fc269225dbf653132b3f19fafc3 Mon Sep 17 00:00:00 2001 From: ensan-hcl Date: Sun, 8 Oct 2023 18:06:49 +0900 Subject: [PATCH 02/10] Delete unused codes for iOS 15 --- .../Sources/AzooKeyUtils/AzooKeyMessage.swift | 31 ++---------------- .../SpecialTabs/ClipboardHistoryTab.swift | 2 +- .../View/SpecialTabs/EmojiTab.swift | 4 +-- .../Sources/SwiftUIUtils/Availability.swift | 21 ------------ Keyboard/Display/InputManager.swift | 11 +++---- Keyboard/Display/KeyboardActionManager.swift | 15 ++------- Keyboard/Display/KeyboardViewController.swift | 16 ++-------- MainApp/ContentView.swift | 4 +-- MainApp/Customize/ManageCustardView.swift | 6 ++-- .../AdditionalDictManageView.swift | 4 +-- .../AzooKeyUserDictionary.swift | 10 ++---- .../KeyboardLayoutSettingItemView.swift | 32 +++++-------------- MainApp/Theme/ThemeShareView.swift | 12 +++---- 13 files changed, 33 insertions(+), 135 deletions(-) delete mode 100644 AzooKeyCore/Sources/SwiftUIUtils/Availability.swift diff --git a/AzooKeyCore/Sources/AzooKeyUtils/AzooKeyMessage.swift b/AzooKeyCore/Sources/AzooKeyUtils/AzooKeyMessage.swift index 579fbeeb..b0ff1876 100644 --- a/AzooKeyCore/Sources/AzooKeyUtils/AzooKeyMessage.swift +++ b/AzooKeyCore/Sources/AzooKeyUtils/AzooKeyMessage.swift @@ -11,7 +11,6 @@ import KeyboardViews public enum MessageIdentifier: String, CaseIterable, MessageIdentifierProtocol { case mock = "mock_alert_2022_09_16_03" - case iOS15_4_new_emoji = "iOS_15_4_new_emoji" // MARK: frozen case iOS16_4_new_emoji = "iOS_16_4_new_emoji_commit" // MARK: frozen case ver1_9_user_dictionary_update = "ver1_9_user_dictionary_update_release" // MARK: frozen case ver2_1_emoji_tab = "ver2_1_emoji_tab" @@ -19,8 +18,9 @@ public enum MessageIdentifier: String, CaseIterable, MessageIdentifierProtocol { // MARK: 過去にプロダクションで用いていたメッセージID // ver1_9_user_dictionary_updateが実行されれば不要になるので、この宣言は削除 // case ver1_5_update_loudstxt = "ver1_5_update_loudstxt" // MARK: frozen - // iOS15_4_new_emojiが実行されれば不要になるので、この宣言は削除 + // iOS16_4_new_emojiが実行されれば不要になるので、これらの宣言は削除 // case iOS14_5_new_emoji = "iOS_14_5_new_emoji_fixed_ver_1_6_1" // MARK: frozen + // case iOS15_4_new_emoji = "iOS_15_4_new_emoji" // MARK: frozen // 新機能の紹介も削除 // case liveconversion_introduction = "liveconversion_introduction" // MARK: frozen // case ver1_8_autocomplete_introduction = "ver1_8_autocomplete_introduction" // MARK: frozen @@ -33,7 +33,7 @@ public enum MessageIdentifier: String, CaseIterable, MessageIdentifierProtocol { switch self { case .ver1_9_user_dictionary_update, .ver2_1_emoji_tab: return true - case .iOS15_4_new_emoji, .iOS16_4_new_emoji, .mock: + case .iOS16_4_new_emoji, .mock: return false } } @@ -50,31 +50,6 @@ public enum AzooKeyMessageProvider: ApplicationSpecificKeyboardViewMessageProvid public static var messages: [MessageData] { [ - MessageData( - id: .iOS15_4_new_emoji, - title: "お知らせ", - description: "iOS15.4で新しい絵文字が追加されました。本体アプリを開き、データを更新しますか?", - button: .two(primary: .openContainer(text: "更新"), secondary: .later), - precondition: { - if #available(iOS 15.4, *) { - return true - } else { - return false - } - }, - silentDoneCondition: { - // ダウンロードがv1.8以降の場合はDone - if (SharedStore.initialAppVersion ?? .azooKey_v1_7_1) >= .azooKey_v1_8 { - return true - } - // .iOS16_4の方が終わっていたらDone - if MessageManager.checkDone(.iOS16_4_new_emoji, userDefaults: userDefaults) { - return true - } - return false - }, - containerAppShouldMakeItDone: { false } - ), MessageData( id: .iOS16_4_new_emoji, title: "お知らせ", diff --git a/AzooKeyCore/Sources/KeyboardViews/View/SpecialTabs/ClipboardHistoryTab.swift b/AzooKeyCore/Sources/KeyboardViews/View/SpecialTabs/ClipboardHistoryTab.swift index be77d381..58cf96d3 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/SpecialTabs/ClipboardHistoryTab.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/SpecialTabs/ClipboardHistoryTab.swift @@ -191,7 +191,7 @@ struct ClipboardHistoryTab: } } } - .iOS16_scrollContentBackground(.hidden) + .scrollContentBackground(.hidden) } private func enterKey(_ design: TabDependentDesign) -> some View { diff --git a/AzooKeyCore/Sources/KeyboardViews/View/SpecialTabs/EmojiTab.swift b/AzooKeyCore/Sources/KeyboardViews/View/SpecialTabs/EmojiTab.swift index 0ddc8dd8..13c47c22 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/SpecialTabs/EmojiTab.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/SpecialTabs/EmojiTab.swift @@ -210,10 +210,8 @@ struct EmojiTab: View { // 読み込むファイルはバージョンごとに変更する必要がある if #available(iOS 16.4, *) { fileURL = Bundle.main.bundleURL.appendingPathComponent("emoji_genre_E15.0.txt.gen", isDirectory: false) - } else if #available(iOS 15.4, *) { - fileURL = Bundle.main.bundleURL.appendingPathComponent("emoji_genre_E14.0.txt.gen", isDirectory: false) } else { - fileURL = Bundle.main.bundleURL.appendingPathComponent("emoji_genre_E13.1.txt.gen", isDirectory: false) + fileURL = Bundle.main.bundleURL.appendingPathComponent("emoji_genre_E14.0.txt.gen", isDirectory: false) } let genres: [String: Genre] = [ "Symbols": .symbols, diff --git a/AzooKeyCore/Sources/SwiftUIUtils/Availability.swift b/AzooKeyCore/Sources/SwiftUIUtils/Availability.swift deleted file mode 100644 index f1db98e7..00000000 --- a/AzooKeyCore/Sources/SwiftUIUtils/Availability.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// Availability.swift -// Availability -// -// Created by ensan on 2021/07/21. -// Copyright © 2021 ensan. All rights reserved. -// - -import Foundation -import SwiftUI - -public extension View { - @ViewBuilder - func iOS16_scrollContentBackground(_ visibility: Visibility) -> some View { - if #available(iOS 16, macOS 13, *) { - self.scrollContentBackground(visibility) - } else { - self - } - } -} diff --git a/Keyboard/Display/InputManager.swift b/Keyboard/Display/InputManager.swift index c42e68f5..d8636be8 100644 --- a/Keyboard/Display/InputManager.swift +++ b/Keyboard/Display/InputManager.swift @@ -655,14 +655,11 @@ import UIKit /// iOS16以上の仕様変更に対応するため追加されたAPI func adjustLeftString(_ left: String) -> String { - if #available(iOS 16, *) { - var newLeft = left.components(separatedBy: "\n").last ?? "" - if left.contains("\n") && newLeft.isEmpty { - newLeft = "\n" - } - return newLeft + var newLeft = left.components(separatedBy: "\n").last ?? "" + if left.contains("\n") && newLeft.isEmpty { + newLeft = "\n" } - return left + return newLeft } /// クリップボードの文字列をペーストする diff --git a/Keyboard/Display/KeyboardActionManager.swift b/Keyboard/Display/KeyboardActionManager.swift index cfca34c9..fe285a3b 100644 --- a/Keyboard/Display/KeyboardActionManager.swift +++ b/Keyboard/Display/KeyboardActionManager.swift @@ -510,17 +510,6 @@ import SwiftUtils --------------------- */ - private func adjustLeftString(_ left: String) -> String { - if #available(iOS 16, *) { - var newLeft = left.components(separatedBy: "\n").last ?? "" - if left.contains("\n") && newLeft.isEmpty { - newLeft = "\n" - } - return newLeft - } - return left - } - /// 何かが変化した後に状態を比較し、どのような変化が起こったのか判断する関数。 override func notifySomethingDidChange(a_left: String, a_center: String, a_right: String, variableStates: VariableStates) { defer { @@ -544,8 +533,8 @@ import SwiftUtils } // iOS16以降左側の文字列の設計が変わったので、adjustする - let a_left = adjustLeftString(a_left) - let b_left = adjustLeftString(tempLeft) + let a_left = self.inputManager.adjustLeftString(a_left) + let b_left = self.inputManager.adjustLeftString(tempLeft) // システムによる操作でこの関数が呼ばれた場合はスルーする if let operation = self.inputManager.getPreviousSystemOperation() { diff --git a/Keyboard/Display/KeyboardViewController.swift b/Keyboard/Display/KeyboardViewController.swift index 65d14552..84a9a10e 100644 --- a/Keyboard/Display/KeyboardViewController.swift +++ b/Keyboard/Display/KeyboardViewController.swift @@ -257,24 +257,14 @@ final class KeyboardViewController: UIInputViewController { // この関数は「これから」向きが変わる場合に呼ばれるので、デバイスの向きによってwidthとheightが逆転するUIScreen.main.bounds.sizeを用いて向きを確かめることができる。 // ただしこの時点でのUIScreen.mainの値はOSバージョンで変わる debug("KeyboardViewController.viewWillTransition", size, UIScreen.main.bounds.size) - if #available(iOS 16, *) { - SemiStaticStates.shared.setScreenWidth(size.width) - KeyboardViewController.variableStates.setInterfaceSize(orientation: UIScreen.main.bounds.width < UIScreen.main.bounds.height ? .horizontal : .vertical, screenWidth: size.width) - } else { - SemiStaticStates.shared.setScreenWidth(size.width) - KeyboardViewController.variableStates.setInterfaceSize(orientation: UIScreen.main.bounds.width < UIScreen.main.bounds.height ? .vertical : .horizontal, screenWidth: size.width) - } + SemiStaticStates.shared.setScreenWidth(size.width) + KeyboardViewController.variableStates.setInterfaceSize(orientation: UIScreen.main.bounds.width < UIScreen.main.bounds.height ? .horizontal : .vertical, screenWidth: size.width) } override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() debug("KeyboardViewController.viewDidLayoutSubviews", SemiStaticStates.shared.screenWidth) - if #available(iOS 16, *) { - self.view.frame.size.height = Design.keyboardScreenHeight(upsideComponent: KeyboardViewController.variableStates.upsideComponent, orientation: KeyboardViewController.variableStates.keyboardOrientation) - } else { - self.view.frame.size.height = Design.keyboardScreenHeight(upsideComponent: KeyboardViewController.variableStates.upsideComponent, orientation: KeyboardViewController.variableStates.keyboardOrientation) - self.updateViewConstraints() - } + self.view.frame.size.height = Design.keyboardScreenHeight(upsideComponent: KeyboardViewController.variableStates.upsideComponent, orientation: KeyboardViewController.variableStates.keyboardOrientation) } func reloadAllView() { diff --git a/MainApp/ContentView.swift b/MainApp/ContentView.swift index 8a898518..68a20fb0 100644 --- a/MainApp/ContentView.swift +++ b/MainApp/ContentView.swift @@ -80,7 +80,7 @@ struct ContentView: View { if messageManager.requireShow(data.id) { switch data.id { case .mock: - EmptyView() + EmptyView()g case .ver1_9_user_dictionary_update: // ユーザ辞書を更新する DataUpdateView(id: data.id, manager: $messageManager) { @@ -100,7 +100,7 @@ struct ContentView: View { tabBarData.lastUpdateDate = .now try? manager.saveTabBarData(tabBarData: tabBarData) } - case .iOS15_4_new_emoji, .iOS16_4_new_emoji: + case .iOS16_4_new_emoji: // 絵文字を更新する DataUpdateView(id: data.id, manager: $messageManager) { AdditionalDictManager().userDictUpdate() diff --git a/MainApp/Customize/ManageCustardView.swift b/MainApp/Customize/ManageCustardView.swift index e23fb87d..9d7a00c4 100644 --- a/MainApp/Customize/ManageCustardView.swift +++ b/MainApp/Customize/ManageCustardView.swift @@ -175,10 +175,8 @@ struct ManageCustardView: View { } } } else if let custardFileURL = self.getCustardFile(identifier: identifier) { - if #available(iOS 16, *) { - ShareLink(item: custardFileURL) { - Label("読み込みに失敗したカスタムタブ「\(identifier)」を書き出す", systemImage: "square.and.arrow.up") - } + ShareLink(item: custardFileURL) { + Label("読み込みに失敗したカスタムタブ「\(identifier)」を書き出す", systemImage: "square.and.arrow.up") } } } diff --git a/MainApp/Setting/AdditionalDict/AdditionalDictManageView.swift b/MainApp/Setting/AdditionalDict/AdditionalDictManageView.swift index 385079af..c50cbdb1 100644 --- a/MainApp/Setting/AdditionalDict/AdditionalDictManageView.swift +++ b/MainApp/Setting/AdditionalDict/AdditionalDictManageView.swift @@ -43,10 +43,8 @@ struct AdditionalSystemDictManager: OnOffSettingSet { case .emoji: if #available(iOS 16.4, *) { return ["emoji_dict_E15.0.txt.gen"] - } else if #available(iOS 15.4, *) { - return ["emoji_dict_E14.0.txt.gen"] } else { - return ["emoji_dict_E13.1.txt.gen"] + return ["emoji_dict_E14.0.txt.gen"] } case .kaomoji: return ["kaomoji_dict.tsv"] diff --git a/MainApp/Setting/AdditionalDict/AzooKeyUserDictionary.swift b/MainApp/Setting/AdditionalDict/AzooKeyUserDictionary.swift index f42180d5..eb73e37b 100644 --- a/MainApp/Setting/AdditionalDict/AzooKeyUserDictionary.swift +++ b/MainApp/Setting/AdditionalDict/AzooKeyUserDictionary.swift @@ -159,7 +159,6 @@ private struct UserDictionaryDataEditor: CancelableEditor { self.base = (item.copy(), variables.templates) } - @available(iOS 16.0, *) private func hasTemplate(word: String) -> Bool { word.contains(templateRegex) } @@ -182,12 +181,10 @@ private struct UserDictionaryDataEditor: CancelableEditor { @State private var sending = false @FocusState private var focusOnWordField: Bool? - @available(iOS 16.0, *) private var templateRegex: some RegexComponent { /{{.+?}}/ } - @available(iOS 16.0, *) private func parsedWord(word: String) -> [String] { var result: [String] = [] var startIndex = word.startIndex @@ -201,7 +198,6 @@ private struct UserDictionaryDataEditor: CancelableEditor { return result } - @available(iOS 16.0, *) private func replaceTemplate(selectedTemplate: (name: String, index: Int), newName: String) { var parsedWords = parsedWord(word: item.data.word) if parsedWords.indices.contains(selectedTemplate.index) && parsedWords[selectedTemplate.index] == "{{\(selectedTemplate.name)}}" { @@ -211,7 +207,6 @@ private struct UserDictionaryDataEditor: CancelableEditor { } @ViewBuilder - @available(iOS 16.0, *) private func templateWordView(word: String) -> some View { let parsedWords = parsedWord(word: word) ScrollView(.horizontal, showsIndicators: false) { @@ -249,7 +244,6 @@ private struct UserDictionaryDataEditor: CancelableEditor { } } - @available(iOS 16.0, *) @ViewBuilder private func templateEditor(index: Int, selectedTemplate: (name: String, index: Int)) -> some View { if variables.templates[index].name == selectedTemplate.name { @@ -276,7 +270,7 @@ private struct UserDictionaryDataEditor: CancelableEditor { if wordEditMode { wordField } else { - if #available(iOS 16.0, *), hasTemplate(word: item.data.word) { + if hasTemplate(word: item.data.word) { templateWordView(word: item.data.word) Spacer() Divider() @@ -338,7 +332,7 @@ private struct UserDictionaryDataEditor: CancelableEditor { Text("この単語をazooKeyの本体辞書に追加することを申請します。\n個人情報を含む単語は申請しないでください。") } } - if #available(iOS 16.0, *), let selectedTemplate { + if let selectedTemplate { if let index = templateIndex(name: selectedTemplate.name) { Section(header: Text("テンプレートを編集する")) { Text("{{\(selectedTemplate.name)}}を編集できます") diff --git a/MainApp/Setting/KeyboardLayout/KeyboardLayoutSettingItemView.swift b/MainApp/Setting/KeyboardLayout/KeyboardLayoutSettingItemView.swift index d57cfd28..574ac3ea 100644 --- a/MainApp/Setting/KeyboardLayout/KeyboardLayoutSettingItemView.swift +++ b/MainApp/Setting/KeyboardLayout/KeyboardLayoutSettingItemView.swift @@ -97,31 +97,15 @@ struct LanguageLayoutSettingView: Vie Group { // ラベルの数でUIを出し分ける if types.count > 3 { - if #available(iOS 16, *) { - Picker(selection: $selection, label: Text(labelText)) { - ForEach(0 ..< types.count, id: \.self) { i in - Text(types[i].label).tag(types[i]) - } - } - CenterAlignedView { - KeyboardPreview(scale: 0.8, defaultTab: tab) - .allowsHitTesting(false) - .disabled(true) + Picker(selection: $selection, label: Text(labelText)) { + ForEach(0 ..< types.count, id: \.self) { i in + Text(types[i].label).tag(types[i]) } - } else { - Text(labelText) - CenterAlignedView { - KeyboardPreview(scale: 0.8, defaultTab: tab) - .allowsHitTesting(false) - .disabled(true) - } - Picker(selection: $selection, label: Text(labelText)) { - ForEach(0 ..< types.count, id: \.self) { i in - Text(types[i].label).tag(types[i]) - } - } - .labelsHidden() - .pickerStyle(.segmented) + } + CenterAlignedView { + KeyboardPreview(scale: 0.8, defaultTab: tab) + .allowsHitTesting(false) + .disabled(true) } } else { VStack { diff --git a/MainApp/Theme/ThemeShareView.swift b/MainApp/Theme/ThemeShareView.swift index 89997950..7288b26c 100644 --- a/MainApp/Theme/ThemeShareView.swift +++ b/MainApp/Theme/ThemeShareView.swift @@ -45,14 +45,10 @@ struct ThemeShareView: View { .fixedSize(horizontal: false, vertical: true) Button { - if #available(iOS 16, *) { - let renderer = ImageRenderer(content: keyboardPreview) - renderer.scale = 3.0 - if let image = renderer.uiImage { - shareImage.setImage(image) - } - } else { - shareImage.setImage(keyboardPreview.snapshot()) + let renderer = ImageRenderer(content: keyboardPreview) + renderer.scale = 3.0 + if let image = renderer.uiImage { + shareImage.setImage(image) } showActivityView = true } label: { From 4dcee0d623cb6270cef74e642c72b4bcd68af529 Mon Sep 17 00:00:00 2001 From: ensan-hcl Date: Sun, 8 Oct 2023 18:08:04 +0900 Subject: [PATCH 03/10] Update OS version (fix mistakes) --- AzooKeyCore/Package.swift | 2 +- azooKey.xcodeproj/project.pbxproj | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/AzooKeyCore/Package.swift b/AzooKeyCore/Package.swift index 82e1ea65..6494edb2 100644 --- a/AzooKeyCore/Package.swift +++ b/AzooKeyCore/Package.swift @@ -16,7 +16,7 @@ let swiftSettings: [SwiftSetting] = [ ] let package = Package( name: "AzooKeyCore", - platforms: [.iOS(.v15), .macOS(.v12)], + platforms: [.iOS(.v16), .macOS(.v13)], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( diff --git a/azooKey.xcodeproj/project.pbxproj b/azooKey.xcodeproj/project.pbxproj index 84b83b3a..35766cea 100644 --- a/azooKey.xcodeproj/project.pbxproj +++ b/azooKey.xcodeproj/project.pbxproj @@ -1707,7 +1707,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 9S3UXHYP65; INFOPLIST_FILE = azooKeyTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1731,7 +1731,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 9S3UXHYP65; INFOPLIST_FILE = azooKeyTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1757,7 +1757,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 9S3UXHYP65; INFOPLIST_FILE = MainAppUITests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1782,7 +1782,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 9S3UXHYP65; INFOPLIST_FILE = MainAppUITests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1811,7 +1811,7 @@ GCC_OPTIMIZATION_LEVEL = fast; GCC_WARN_UNUSED_PARAMETER = YES; INFOPLIST_FILE = Keyboard/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1846,7 +1846,7 @@ GCC_OPTIMIZATION_LEVEL = fast; GCC_WARN_UNUSED_PARAMETER = YES; INFOPLIST_FILE = Keyboard/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", From 7034cc06fbbf2a9ab97bae8de25f289ae7a8277c Mon Sep 17 00:00:00 2001 From: ensan-hcl Date: Sun, 8 Oct 2023 18:11:46 +0900 Subject: [PATCH 04/10] Fix error --- MainApp/ContentView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MainApp/ContentView.swift b/MainApp/ContentView.swift index 68a20fb0..3d6822be 100644 --- a/MainApp/ContentView.swift +++ b/MainApp/ContentView.swift @@ -80,7 +80,7 @@ struct ContentView: View { if messageManager.requireShow(data.id) { switch data.id { case .mock: - EmptyView()g + EmptyView() case .ver1_9_user_dictionary_update: // ユーザ辞書を更新する DataUpdateView(id: data.id, manager: $messageManager) { From a0ee64de5d2246ebdddb43626f2540f6b125bdc6 Mon Sep 17 00:00:00 2001 From: ensan-hcl Date: Sun, 8 Oct 2023 18:39:18 +0900 Subject: [PATCH 05/10] Replace manual impl of PhotosPicker with standard one --- MainApp/General/Pickers/PhotoPicker.swift | 84 ----------------------- MainApp/Theme/ThemeEditView.swift | 28 ++++---- azooKey.xcodeproj/project.pbxproj | 4 -- 3 files changed, 16 insertions(+), 100 deletions(-) delete mode 100644 MainApp/General/Pickers/PhotoPicker.swift diff --git a/MainApp/General/Pickers/PhotoPicker.swift b/MainApp/General/Pickers/PhotoPicker.swift deleted file mode 100644 index 6844957b..00000000 --- a/MainApp/General/Pickers/PhotoPicker.swift +++ /dev/null @@ -1,84 +0,0 @@ -// -// PhotoPicker.swift -// MainApp -// -// Created by ensan on 2021/02/08. -// Copyright © 2021 ensan. All rights reserved. -// - -import Foundation -import PhotosUI -import SwiftUI -import SwiftUtils - -struct PhotoPicker: UIViewControllerRepresentable { - internal init(configuration: PHPickerConfiguration, pickerResult: Binding, isPresented: Binding) { - self.configuration = configuration - self._pickerResult = pickerResult - self._isPresented = isPresented - } - - private let configuration: PHPickerConfiguration - @Binding private var pickerResult: UIImage? - @Binding private var isPresented: Bool - - func makeUIViewController(context: Context) -> PHPickerViewController { - let controller = PHPickerViewController(configuration: configuration) - controller.delegate = context.coordinator - return controller - } - - func updateUIViewController(_ uiViewController: PHPickerViewController, context: Context) { - - } - - func makeCoordinator() -> Coordinator { - Coordinator(self) - } - - /// PHPickerViewControllerDelegate => Coordinator - final class Coordinator: PHPickerViewControllerDelegate { - private let parent: PhotoPicker - - init(_ parent: PhotoPicker) { - self.parent = parent - } - // PHPickerViewControllerDelegateの設定 - func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) { - for image in results { - if image.itemProvider.canLoadObject(ofClass: PHLivePhoto.self) { - image.itemProvider.loadObject(ofClass: PHLivePhoto.self) { (livePhotoObject, error) in - // PHLivePhotoとして取得 - if let livePhoto = livePhotoObject as? PHLivePhoto, - let imageUrl = livePhoto.value(forKey: "imageURL") as? URL { - do { - // Dataで取得 - let imageData: Data = try Data(contentsOf: imageUrl) - if let uiImage = UIImage(data: imageData), let cgImage = uiImage.cgImage { - self.parent.pickerResult = UIImage(cgImage: cgImage, scale: 1, orientation: uiImage.imageOrientation) - } - } catch { - debug(error) - } - } - } - } else if image.itemProvider.canLoadObject(ofClass: UIImage.self) { - image.itemProvider.loadObject(ofClass: UIImage.self) { (selectedImage, error) in - if let error { - debug("error: \(error.localizedDescription)") - return - } - guard let wrapImage = selectedImage as? UIImage else { - debug("wrap error") - return - } - // 選択したImageをpickerResultに格納 - self.parent.pickerResult = wrapImage - } - } - } - // 閉じる - parent.isPresented = false - } - } -} diff --git a/MainApp/Theme/ThemeEditView.swift b/MainApp/Theme/ThemeEditView.swift index ae341c09..7fab6e39 100644 --- a/MainApp/Theme/ThemeEditView.swift +++ b/MainApp/Theme/ThemeEditView.swift @@ -87,10 +87,10 @@ struct ThemeEditView: CancelableEditor { @Binding private var manager: ThemeIndexManager + @State private var photosPickerItem: PhotosPickerItem? @State private var trimmedImage: UIImage? @State private var isTrimmingViewPresented = false @State private var pickedImage: UIImage? - @State private var isSheetPresented = false @State private var viewType = ViewType.editor private let colorConverter = ThemeColorTranslator.self @@ -139,18 +139,15 @@ struct ThemeEditView: CancelableEditor { Form { Section(header: Text("背景")) { if trimmedImage != nil { - Button("\(systemImage: "photo")画像を選び直す") { - self.isSheetPresented = true - } + PhotosPicker("\(systemImage: "photo")画像を選び直す", selection: $photosPickerItem) Button("画像を削除") { + photosPickerItem = nil pickedImage = nil trimmedImage = nil } .foregroundStyle(.red) } else { - Button("\(systemImage: "photo")画像を選ぶ") { - self.isSheetPresented = true - } + PhotosPicker("\(systemImage: "photo")画像を選ぶ", selection: $photosPickerItem) ColorPicker("背景の色", selection: $theme.backgroundColor.converted(colorConverter)) } } @@ -234,11 +231,18 @@ struct ThemeEditView: CancelableEditor { self.theme.pushedKeyFillColor = .color(pushedKeyColor) } } - .sheet(isPresented: $isSheetPresented, content: { - PhotoPicker(configuration: self.config, - pickerResult: $pickedImage, - isPresented: $isSheetPresented) - }) + .onChange(of: self.photosPickerItem) { item in + guard let item else { + return + } + Task { + if let data = try await item.loadTransferable(type: Data.self) { + if let uiImage = UIImage(data: data) { + self.pickedImage = uiImage + } + } + } + } .navigationBarTitle(Text(self.title), displayMode: .inline) .navigationBarBackButtonHidden(true) .navigationBarItems( diff --git a/azooKey.xcodeproj/project.pbxproj b/azooKey.xcodeproj/project.pbxproj index 35766cea..6632c45b 100644 --- a/azooKey.xcodeproj/project.pbxproj +++ b/azooKey.xcodeproj/project.pbxproj @@ -142,7 +142,6 @@ 1AD8FDF12988076F00DA4296 /* ConverterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AD8FDF02988076F00DA4296 /* ConverterTests.swift */; }; 1AD96FB82A22F9C800FD4EA4 /* SwiftUIUtils in Frameworks */ = {isa = PBXBuildFile; productRef = 1AD96FB72A22F9C800FD4EA4 /* SwiftUIUtils */; }; 1AD96FBA2A22F9CD00FD4EA4 /* SwiftUIUtils in Frameworks */ = {isa = PBXBuildFile; productRef = 1AD96FB92A22F9CD00FD4EA4 /* SwiftUIUtils */; }; - 1AE1023625D0C99200CA7277 /* PhotoPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AE1023525D0C99200CA7277 /* PhotoPicker.swift */; }; 1AE1025625D1788300CA7277 /* Capture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AE1025525D1788300CA7277 /* Capture.swift */; }; 1AE102CF25D3713C00CA7277 /* TrimmingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AE102CE25D3713C00CA7277 /* TrimmingView.swift */; }; 1AE1913625D4A3370044EE4B /* ThemeShareView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AE1913525D4A3370044EE4B /* ThemeShareView.swift */; }; @@ -338,7 +337,6 @@ 1AD4454526AAB8E4003CF854 /* DisclosuringList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisclosuringList.swift; sourceTree = ""; }; 1AD5E17726AB230F001B4FF7 /* CustomKeysSettingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomKeysSettingView.swift; sourceTree = ""; }; 1AD8FDF02988076F00DA4296 /* ConverterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConverterTests.swift; sourceTree = ""; }; - 1AE1023525D0C99200CA7277 /* PhotoPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoPicker.swift; sourceTree = ""; }; 1AE1025525D1788300CA7277 /* Capture.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Capture.swift; sourceTree = ""; }; 1AE102CE25D3713C00CA7277 /* TrimmingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrimmingView.swift; sourceTree = ""; }; 1AE1913525D4A3370044EE4B /* ThemeShareView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeShareView.swift; sourceTree = ""; }; @@ -453,7 +451,6 @@ 1A10D81325E506460095CB67 /* Pickers */ = { isa = PBXGroup; children = ( - 1AE1023525D0C99200CA7277 /* PhotoPicker.swift */, 1A18424225DD6857003985AB /* FontPicker.swift */, ); path = Pickers; @@ -1337,7 +1334,6 @@ 1AFA57662584815B00477DC2 /* QwertyCustomKeysItemView.swift in Sources */, 1AFB68422518C48100C649C4 /* OpenSourceSoftwaresLicenseView.swift in Sources */, 1A5C7EAC25F36A6E00A7CBA8 /* PreferredLanguageSettingView.swift in Sources */, - 1AE1023625D0C99200CA7277 /* PhotoPicker.swift in Sources */, 1A2C293926273E9900DFE465 /* DraggableView.swift in Sources */, 1AF28D00253DA5250012CF94 /* DynamicTypeSettingFailureTips.swift in Sources */, 1AE1025625D1788300CA7277 /* Capture.swift in Sources */, From dcdd1ebc826cc56bbaced4106aeba007ebce370c Mon Sep 17 00:00:00 2001 From: ensan-hcl Date: Sun, 8 Oct 2023 18:46:37 +0900 Subject: [PATCH 06/10] Use requestReviewAction instead of old impl --- MainApp/Customize/CustomizeTabView.swift | 5 ++--- MainApp/Setting/SettingTab.swift | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/MainApp/Customize/CustomizeTabView.swift b/MainApp/Customize/CustomizeTabView.swift index 2d0de750..c676a30c 100644 --- a/MainApp/Customize/CustomizeTabView.swift +++ b/MainApp/Customize/CustomizeTabView.swift @@ -13,6 +13,7 @@ import SwiftUIUtils struct CustomizeTabView: View { @EnvironmentObject private var appStates: MainAppStates + @Environment(\.requestReview) var requestReview var body: some View { ZStack { @@ -51,9 +52,7 @@ struct CustomizeTabView: View { .navigationBarTitle(Text("拡張"), displayMode: .large) .onAppear { if appStates.requestReviewManager.shouldTryRequestReview, appStates.requestReviewManager.shouldRequestReview() { - if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene { - SKStoreReviewController.requestReview(in: scene) - } + requestReview() } } } diff --git a/MainApp/Setting/SettingTab.swift b/MainApp/Setting/SettingTab.swift index 00bf26bd..3b0efa00 100644 --- a/MainApp/Setting/SettingTab.swift +++ b/MainApp/Setting/SettingTab.swift @@ -12,6 +12,7 @@ import StoreKit import SwiftUI struct SettingTabView: View { + @Environment(\.requestReview) var requestReview @EnvironmentObject private var appStates: MainAppStates private func canFlickLayout(_ layout: LanguageLayout) -> Bool { if layout == .flick { @@ -136,9 +137,7 @@ struct SettingTabView: View { .navigationBarTitle(Text("設定"), displayMode: .large) .onAppear { if appStates.requestReviewManager.shouldTryRequestReview, appStates.requestReviewManager.shouldRequestReview() { - if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene { - SKStoreReviewController.requestReview(in: scene) - } + requestReview() } } } From cb90047358cceaa595e3acf5cb034d441d469035 Mon Sep 17 00:00:00 2001 From: ensan-hcl Date: Sun, 8 Oct 2023 18:57:59 +0900 Subject: [PATCH 07/10] replace any FlickKeyModelProtocol with any FlickKeyModelProtocol so that they are now more type-safe --- .../View/CustomKeybaord/CustomKeyboard.swift | 8 +- .../FlickKeyboard/FlickDataProvider.swift | 126 +++++++++--------- .../FlickKeyboard/FlickKeyboardView.swift | 6 +- .../KeyView/FlickAaKeyModel.swift | 2 +- .../KeyView/FlickChangeKeyboardKeyModel.swift | 2 +- .../KeyView/FlickEnterKeyModel.swift | 2 +- .../KeyView/FlickKanaSymbolsKeyModel.swift | 2 +- .../FlickKeyboard/KeyView/FlickKeyModel.swift | 2 +- .../KeyView/FlickKeyModelProtocol.swift | 4 +- .../FlickKeyboard/KeyView/FlickKeyView.swift | 4 +- .../KeyView/FlickKogakiKeyModel.swift | 2 +- .../KeyView/FlickNextCandidateKeyModel.swift | 2 +- .../KeyView/FlickSpaceKeyModel.swift | 2 +- .../KeyView/FlickTabKeyModel.swift | 2 +- .../Customize/EditingTenkeyCustardView.swift | 2 +- 15 files changed, 83 insertions(+), 85 deletions(-) diff --git a/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/CustomKeyboard.swift b/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/CustomKeyboard.swift index 3be6497f..e4aeadbb 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/CustomKeyboard.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/CustomKeyboard.swift @@ -60,7 +60,7 @@ fileprivate extension CustardInterface { } } - @MainActor func flickKeyModels(extension _: Extension.Type) -> [KeyPosition: (model: any FlickKeyModelProtocol, width: Int, height: Int)] { + @MainActor func flickKeyModels(extension _: Extension.Type) -> [KeyPosition: (model: any FlickKeyModelProtocol, width: Int, height: Int)] { self.keys.reduce(into: [:]) {dictionary, value in switch value.key { case let .gridFit(data): @@ -126,7 +126,7 @@ fileprivate extension CustardKeyDesign.ColorType { } extension CustardInterfaceKey { - @MainActor public func flickKeyModel(extension _: Extension.Type) -> any FlickKeyModelProtocol { + @MainActor public func flickKeyModel(extension _: Extension.Type) -> any FlickKeyModelProtocol { switch self { case let .system(value): switch value { @@ -337,7 +337,7 @@ struct CustomKeyboardView: public struct CustardFlickKeysView: View { @State private var suggestState = FlickSuggestState() - public init(models: [KeyPosition: (model: any FlickKeyModelProtocol, width: Int, height: Int)], tabDesign: TabDependentDesign, layout: CustardInterfaceLayoutGridValue, @ViewBuilder generator: @escaping (FlickKeyView, Int, Int) -> (Content)) { + public init(models: [KeyPosition: (model: any FlickKeyModelProtocol, width: Int, height: Int)], tabDesign: TabDependentDesign, layout: CustardInterfaceLayoutGridValue, @ViewBuilder generator: @escaping (FlickKeyView, Int, Int) -> (Content)) { self.models = models self.tabDesign = tabDesign self.layout = layout @@ -345,7 +345,7 @@ public struct CustardFlickKeysView, Int, Int) -> (Content) - private let models: [KeyPosition: (model: any FlickKeyModelProtocol, width: Int, height: Int)] + private let models: [KeyPosition: (model: any FlickKeyModelProtocol, width: Int, height: Int)] private let tabDesign: TabDependentDesign private let layout: CustardInterfaceLayoutGridValue diff --git a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/FlickDataProvider.swift b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/FlickDataProvider.swift index 49bc8df7..0c51f963 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/FlickDataProvider.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/FlickDataProvider.swift @@ -15,59 +15,59 @@ struct FlickDataProvider { Extension.SettingProvider.preferredLanguage } - @MainActor static func TabKeys() -> [any FlickKeyModelProtocol] { - let first: any FlickKeyModelProtocol = { + @MainActor static func TabKeys() -> [any FlickKeyModelProtocol] { + let first: any FlickKeyModelProtocol = { switch preferredLanguage.first { - case .el_GR: return FlickChangeKeyboardModel.shared - case .en_US: return FlickTabKeyModel.abcTabKeyModel() - case .ja_JP: return FlickTabKeyModel.hiraTabKeyModel() - case .none: return FlickChangeKeyboardModel.shared + case .el_GR: return FlickChangeKeyboardModel.shared + case .en_US: return FlickTabKeyModel.abcTabKeyModel() + case .ja_JP: return FlickTabKeyModel.hiraTabKeyModel() + case .none: return FlickChangeKeyboardModel.shared } }() - let second: (any FlickKeyModelProtocol)? = { + let second: (any FlickKeyModelProtocol)? = { guard let second = preferredLanguage.second else { return nil } switch second { case .none: return nil - case .el_GR: return FlickChangeKeyboardModel.shared - case .en_US: return FlickTabKeyModel.abcTabKeyModel() - case .ja_JP: return FlickTabKeyModel.hiraTabKeyModel() + case .el_GR: return FlickChangeKeyboardModel.shared + case .en_US: return FlickTabKeyModel.abcTabKeyModel() + case .ja_JP: return FlickTabKeyModel.hiraTabKeyModel() } }() if let second { return [ - FlickTabKeyModel.numberTabKeyModel(), + FlickTabKeyModel.numberTabKeyModel(), second, first, - FlickChangeKeyboardModel.shared + FlickChangeKeyboardModel.shared ] } else { return [ - FlickKeyModel( + FlickKeyModel( labelType: .image("list.bullet"), pressActions: [.setTabBar(.toggle)], longPressActions: .init(start: [.setTabBar(.toggle)]), flickKeys: [:], needSuggestView: false, keycolorType: .tabkey ), - FlickTabKeyModel.numberTabKeyModel(), + FlickTabKeyModel.numberTabKeyModel(), first, - FlickChangeKeyboardModel.shared + FlickChangeKeyboardModel.shared ] } } // 縦に並べる @MainActor - static var hiraKeyboard: [[any FlickKeyModelProtocol]] { + static var hiraKeyboard: [[any FlickKeyModelProtocol]] { [ // 第1列 Self.TabKeys(), // 第2列 [ - FlickKeyModel(labelType: .text("あ"), pressActions: [.input("あ")], flickKeys: [ + FlickKeyModel(labelType: .text("あ"), pressActions: [.input("あ")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("い"), pressActions: [.input("い")] @@ -86,7 +86,7 @@ struct FlickDataProvider { ) ]), - FlickKeyModel(labelType: .text("た"), pressActions: [.input("た")], flickKeys: [ + FlickKeyModel(labelType: .text("た"), pressActions: [.input("た")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("ち"), pressActions: [.input("ち")] @@ -104,7 +104,7 @@ struct FlickDataProvider { pressActions: [.input("と")] ) ]), - FlickKeyModel(labelType: .text("ま"), pressActions: [.input("ま")], flickKeys: [ + FlickKeyModel(labelType: .text("ま"), pressActions: [.input("ま")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("み"), pressActions: [.input("み")] @@ -123,11 +123,11 @@ struct FlickDataProvider { ) ]), - FlickKogakiKeyModel.shared + FlickKogakiKeyModel.shared ], // 第3列 [ - FlickKeyModel(labelType: .text("か"), pressActions: [.input("か")], flickKeys: [ + FlickKeyModel(labelType: .text("か"), pressActions: [.input("か")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("き"), pressActions: [.input("き")] @@ -146,7 +146,7 @@ struct FlickDataProvider { ) ]), - FlickKeyModel(labelType: .text("な"), pressActions: [.input("な")], flickKeys: [ + FlickKeyModel(labelType: .text("な"), pressActions: [.input("な")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("に"), pressActions: [.input("に")] @@ -165,7 +165,7 @@ struct FlickDataProvider { ) ]), - FlickKeyModel(labelType: .text("や"), pressActions: [.input("や")], flickKeys: [ + FlickKeyModel(labelType: .text("や"), pressActions: [.input("や")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("「"), pressActions: [.input("「")] @@ -184,7 +184,7 @@ struct FlickDataProvider { ) ]), - FlickKeyModel(labelType: .text("わ"), pressActions: [.input("わ")], flickKeys: [ + FlickKeyModel(labelType: .text("わ"), pressActions: [.input("わ")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("を"), pressActions: [.input("を")] @@ -202,7 +202,7 @@ struct FlickDataProvider { ], // 第4列 [ - FlickKeyModel(labelType: .text("さ"), pressActions: [.input("さ")], flickKeys: [ + FlickKeyModel(labelType: .text("さ"), pressActions: [.input("さ")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("し"), pressActions: [.input("し")] @@ -221,7 +221,7 @@ struct FlickDataProvider { ) ]), - FlickKeyModel(labelType: .text("は"), pressActions: [.input("は")], flickKeys: [ + FlickKeyModel(labelType: .text("は"), pressActions: [.input("は")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("ひ"), pressActions: [.input("ひ")] @@ -240,7 +240,7 @@ struct FlickDataProvider { ) ]), - FlickKeyModel(labelType: .text("ら"), pressActions: [.input("ら")], flickKeys: [ + FlickKeyModel(labelType: .text("ら"), pressActions: [.input("ら")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("り"), pressActions: [.input("り")] @@ -259,13 +259,13 @@ struct FlickDataProvider { ) ]), - FlickKanaSymbolsKeyModel.shared + FlickKanaSymbolsKeyModel.shared ], // 第5列 [ - FlickKeyModel.delete, - FlickSpaceKeyModel.shared, - FlickEnterKeyModel.shared + FlickKeyModel.delete, + FlickSpaceKeyModel.shared, + FlickEnterKeyModel.shared ] ] @@ -273,13 +273,13 @@ struct FlickDataProvider { // 縦に並べる @MainActor - static var abcKeyboard: [[any FlickKeyModelProtocol]] { + static var abcKeyboard: [[any FlickKeyModelProtocol]] { [ // 第1列 Self.TabKeys(), // 第2列 [ - FlickKeyModel(labelType: .text("@#/&_"), pressActions: [.input("@")], flickKeys: [ + FlickKeyModel(labelType: .text("@#/&_"), pressActions: [.input("@")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("#"), pressActions: [.input("#")] @@ -297,7 +297,7 @@ struct FlickDataProvider { pressActions: [.input("_")] ) ]), - FlickKeyModel(labelType: .text("GHI"), pressActions: [.input("g")], flickKeys: [ + FlickKeyModel(labelType: .text("GHI"), pressActions: [.input("g")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("H"), pressActions: [.input("h")] @@ -307,7 +307,7 @@ struct FlickDataProvider { pressActions: [.input("i")] ) ]), - FlickKeyModel(labelType: .text("PQRS"), pressActions: [.input("p")], flickKeys: [ + FlickKeyModel(labelType: .text("PQRS"), pressActions: [.input("p")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("Q"), pressActions: [.input("q")] @@ -321,12 +321,12 @@ struct FlickDataProvider { pressActions: [.input("s")] ) ]), - FlickAaKeyModel.shared + FlickAaKeyModel.shared ], // 第3列 [ - FlickKeyModel(labelType: .text("ABC"), pressActions: [.input("a")], flickKeys: [ + FlickKeyModel(labelType: .text("ABC"), pressActions: [.input("a")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("B"), pressActions: [.input("b")] @@ -336,7 +336,7 @@ struct FlickDataProvider { pressActions: [.input("c")] ) ]), - FlickKeyModel(labelType: .text("JKL"), pressActions: [.input("j")], flickKeys: [ + FlickKeyModel(labelType: .text("JKL"), pressActions: [.input("j")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("K"), pressActions: [.input("k")] @@ -346,7 +346,7 @@ struct FlickDataProvider { pressActions: [.input("l")] ) ]), - FlickKeyModel(labelType: .text("TUV"), pressActions: [.input("t")], flickKeys: [ + FlickKeyModel(labelType: .text("TUV"), pressActions: [.input("t")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("U"), pressActions: [.input("u")] @@ -356,7 +356,7 @@ struct FlickDataProvider { pressActions: [.input("v")] ) ]), - FlickKeyModel(labelType: .text("\'\"()"), pressActions: [.input("\'")], flickKeys: [ + FlickKeyModel(labelType: .text("\'\"()"), pressActions: [.input("\'")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("\""), pressActions: [.input("\"")] @@ -374,7 +374,7 @@ struct FlickDataProvider { ], // 第4列 [ - FlickKeyModel(labelType: .text("DEF"), pressActions: [.input("d")], flickKeys: [ + FlickKeyModel(labelType: .text("DEF"), pressActions: [.input("d")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("E"), pressActions: [.input("e")] @@ -385,7 +385,7 @@ struct FlickDataProvider { ) ]), - FlickKeyModel(labelType: .text("MNO"), pressActions: [.input("m")], flickKeys: [ + FlickKeyModel(labelType: .text("MNO"), pressActions: [.input("m")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("N"), pressActions: [.input("n")] @@ -396,7 +396,7 @@ struct FlickDataProvider { ) ]), - FlickKeyModel(labelType: .text("WXYZ"), pressActions: [.input("w")], flickKeys: [ + FlickKeyModel(labelType: .text("WXYZ"), pressActions: [.input("w")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("X"), pressActions: [.input("x")] @@ -410,7 +410,7 @@ struct FlickDataProvider { pressActions: [.input("z")] ) ]), - FlickKeyModel(labelType: .text(".,?!"), pressActions: [.input(".")], flickKeys: [ + FlickKeyModel(labelType: .text(".,?!"), pressActions: [.input(".")], flickKeys: [ .left: FlickedKeyModel( labelType: .text(","), pressActions: [.input(",")] @@ -427,21 +427,21 @@ struct FlickDataProvider { ], // 第5列 [ - FlickKeyModel.delete, - FlickSpaceKeyModel.shared, - FlickEnterKeyModel.shared + FlickKeyModel.delete, + FlickSpaceKeyModel.shared, + FlickEnterKeyModel.shared ] ] } // 縦に並べる @MainActor - static var numberKeyboard: [[any FlickKeyModelProtocol]] { + static var numberKeyboard: [[any FlickKeyModelProtocol]] { [ // 第1列 Self.TabKeys(), // 第2列 [ - FlickKeyModel(labelType: .symbols(["1", "☆", "♪", "→"]), pressActions: [.input("1")], flickKeys: [ + FlickKeyModel(labelType: .symbols(["1", "☆", "♪", "→"]), pressActions: [.input("1")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("☆"), pressActions: [.input("☆")] @@ -455,7 +455,7 @@ struct FlickDataProvider { pressActions: [.input("→")] ) ]), - FlickKeyModel(labelType: .symbols(["4", "○", "*", "・"]), pressActions: [.input("4")], flickKeys: [ + FlickKeyModel(labelType: .symbols(["4", "○", "*", "・"]), pressActions: [.input("4")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("○"), pressActions: [.input("○")] @@ -469,7 +469,7 @@ struct FlickDataProvider { pressActions: [.input("・")] ) ]), - FlickKeyModel(labelType: .symbols(["7", "「", "」", ":"]), pressActions: [.input("7")], flickKeys: [ + FlickKeyModel(labelType: .symbols(["7", "「", "」", ":"]), pressActions: [.input("7")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("「"), pressActions: [.input("「")] @@ -483,7 +483,7 @@ struct FlickDataProvider { pressActions: [.input(":")] ) ]), - FlickKeyModel(labelType: .text("()[]"), pressActions: [.input("(")], flickKeys: [ + FlickKeyModel(labelType: .text("()[]"), pressActions: [.input("(")], flickKeys: [ .left: FlickedKeyModel( labelType: .text(")"), pressActions: [.input(")")] @@ -501,7 +501,7 @@ struct FlickDataProvider { ], // 第3列 [ - FlickKeyModel(labelType: .symbols(["2", "¥", "$", "€"]), pressActions: [.input("2")], flickKeys: [ + FlickKeyModel(labelType: .symbols(["2", "¥", "$", "€"]), pressActions: [.input("2")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("¥"), pressActions: [.input("¥")] @@ -515,7 +515,7 @@ struct FlickDataProvider { pressActions: [.input("€")] ) ]), - FlickKeyModel(labelType: .symbols(["5", "+", "×", "÷"]), pressActions: [.input("5")], flickKeys: [ + FlickKeyModel(labelType: .symbols(["5", "+", "×", "÷"]), pressActions: [.input("5")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("+"), pressActions: [.input("+")] @@ -529,7 +529,7 @@ struct FlickDataProvider { pressActions: [.input("÷")] ) ]), - FlickKeyModel(labelType: .symbols(["8", "〒", "々", "〆"]), pressActions: [.input("8")], flickKeys: [ + FlickKeyModel(labelType: .symbols(["8", "〒", "々", "〆"]), pressActions: [.input("8")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("〒"), pressActions: [.input("〒")] @@ -543,7 +543,7 @@ struct FlickDataProvider { pressActions: [.input("〆")] ) ]), - FlickKeyModel(labelType: .symbols(["0", "〜", "…"]), pressActions: [.input("0")], flickKeys: [ + FlickKeyModel(labelType: .symbols(["0", "〜", "…"]), pressActions: [.input("0")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("〜"), pressActions: [.input("〜")] @@ -557,7 +557,7 @@ struct FlickDataProvider { ], // 第4列 [ - FlickKeyModel(labelType: .symbols(["3", "%", "°", "#"]), pressActions: [.input("3")], flickKeys: [ + FlickKeyModel(labelType: .symbols(["3", "%", "°", "#"]), pressActions: [.input("3")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("%"), pressActions: [.input("%")] @@ -572,7 +572,7 @@ struct FlickDataProvider { ) ]), - FlickKeyModel(labelType: .symbols(["6", "<", "=", ">"]), pressActions: [.input("6")], flickKeys: [ + FlickKeyModel(labelType: .symbols(["6", "<", "=", ">"]), pressActions: [.input("6")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("<"), pressActions: [.input("<")] @@ -587,7 +587,7 @@ struct FlickDataProvider { ) ]), - FlickKeyModel(labelType: .symbols(["9", "^", "|", "\\"]), pressActions: [.input("9")], flickKeys: [ + FlickKeyModel(labelType: .symbols(["9", "^", "|", "\\"]), pressActions: [.input("9")], flickKeys: [ .left: FlickedKeyModel( labelType: .text("^"), pressActions: [.input("^")] @@ -601,7 +601,7 @@ struct FlickDataProvider { pressActions: [.input("\\")] ) ]), - FlickKeyModel(labelType: .text(".,-/"), pressActions: [.input(".")], flickKeys: [ + FlickKeyModel(labelType: .text(".,-/"), pressActions: [.input(".")], flickKeys: [ .left: FlickedKeyModel( labelType: .text(","), pressActions: [.input(",")] @@ -618,9 +618,9 @@ struct FlickDataProvider { ], // 第5列 [ - FlickKeyModel.delete, - FlickSpaceKeyModel.shared, - FlickEnterKeyModel.shared + FlickKeyModel.delete, + FlickSpaceKeyModel.shared, + FlickEnterKeyModel.shared ] ] } diff --git a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/FlickKeyboardView.swift b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/FlickKeyboardView.swift index 44e88ad0..82976799 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/FlickKeyboardView.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/FlickKeyboardView.swift @@ -14,11 +14,11 @@ struct FlickKeyboardView: V @State private var suggestState = FlickSuggestState() private let tabDesign: TabDependentDesign - private let models: [KeyPosition: (model: any FlickKeyModelProtocol, width: Int, height: Int)] - init(keyModels: [[any FlickKeyModelProtocol]], interfaceSize: CGSize, keyboardOrientation: KeyboardOrientation) { + private let models: [KeyPosition: (model: any FlickKeyModelProtocol, width: Int, height: Int)] + init(keyModels: [[any FlickKeyModelProtocol]], interfaceSize: CGSize, keyboardOrientation: KeyboardOrientation) { self.tabDesign = TabDependentDesign(width: 5, height: 4, interfaceSize: interfaceSize, layout: .flick, orientation: keyboardOrientation) - var models: [KeyPosition: (model: any FlickKeyModelProtocol, width: Int, height: Int)] = [:] + var models: [KeyPosition: (model: any FlickKeyModelProtocol, width: Int, height: Int)] = [:] for h in keyModels.indices { for v in keyModels[h].indices { let model = keyModels[h][v] diff --git a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickAaKeyModel.swift b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickAaKeyModel.swift index 95de8648..1f442965 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickAaKeyModel.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickAaKeyModel.swift @@ -40,7 +40,7 @@ struct FlickAaKeyModel: Fli } } - func label(width: CGFloat, states: VariableStates) -> KeyLabel { + func label(width: CGFloat, states: VariableStates) -> KeyLabel { if states.boolStates.isCapsLocked { return KeyLabel(.image("capslock.fill"), width: width) } else { diff --git a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickChangeKeyboardKeyModel.swift b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickChangeKeyboardKeyModel.swift index e17f1be8..5c91affd 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickChangeKeyboardKeyModel.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickChangeKeyboardKeyModel.swift @@ -45,7 +45,7 @@ struct FlickChangeKeyboardModel(width: CGFloat, states: VariableStates) -> KeyLabel { + func label(width: CGFloat, states: VariableStates) -> KeyLabel { switch SemiStaticStates.shared.needsInputModeSwitchKey { case true: return KeyLabel(.changeKeyboard, width: width) diff --git a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickEnterKeyModel.swift b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickEnterKeyModel.swift index 55011445..d1d8682c 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickEnterKeyModel.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickEnterKeyModel.swift @@ -30,7 +30,7 @@ struct FlickEnterKeyModel: [:] } - func label(width: CGFloat, states: VariableStates) -> KeyLabel { + func label(width: CGFloat, states: VariableStates) -> KeyLabel { let text = Design.language.getEnterKeyText(states.enterKeyState) return KeyLabel(.text(text), width: width) } diff --git a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickKanaSymbolsKeyModel.swift b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickKanaSymbolsKeyModel.swift index 6e84de08..e00e847d 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickKanaSymbolsKeyModel.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickKanaSymbolsKeyModel.swift @@ -33,7 +33,7 @@ struct FlickKanaSymbolsKeyModel(width: CGFloat, states: VariableStates) -> KeyLabel { + func label(width: CGFloat, states: VariableStates) -> KeyLabel { KeyLabel(self.labelType, width: width) } diff --git a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickKeyModel.swift b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickKeyModel.swift index 22d6b30c..f54d6667 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickKeyModel.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickKeyModel.swift @@ -53,7 +53,7 @@ struct FlickKeyModel: Flick self.flickKeys } - func label(width: CGFloat, states: VariableStates) -> KeyLabel { + func label(width: CGFloat, states: VariableStates) -> KeyLabel { KeyLabel(self.labelType, width: width) } diff --git a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickKeyModelProtocol.swift b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickKeyModelProtocol.swift index fdee67ce..ce856d39 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickKeyModelProtocol.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickKeyModelProtocol.swift @@ -44,9 +44,7 @@ public protocol FlickKeyModelProtocol { @MainActor func flickKeys(variableStates: VariableStates) -> [FlickDirection: FlickedKeyModel] @MainActor func isFlickAble(to direction: FlickDirection, variableStates: VariableStates) -> Bool - // FIXME: any FlickKeyModelProtocolではassociatedtypeが扱いづらい問題に対処するため、任意のExtensionに対して扱えるようにする - // FIXME: iOS 16以降はany FlickKeyModelProtocolを使って解消できる - @MainActor func label(width: CGFloat, states: VariableStates) -> KeyLabel + @MainActor func label(width: CGFloat, states: VariableStates) -> KeyLabel @MainActor func flickSensitivity(to direction: FlickDirection) -> CGFloat @MainActor func feedback(variableStates: VariableStates) diff --git a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickKeyView.swift b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickKeyView.swift index 2920f698..fa0851cd 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickKeyView.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickKeyView.swift @@ -28,7 +28,7 @@ enum KeyPressState { @MainActor public struct FlickKeyView: View { - private let model: any FlickKeyModelProtocol + private let model: any FlickKeyModelProtocol @State private var pressState: KeyPressState = .inactive @Binding private var suggestState: FlickSuggestState @@ -42,7 +42,7 @@ public struct FlickKeyView: private let size: CGSize private let position: (x: Int, y: Int) - init(model: any FlickKeyModelProtocol, size: CGSize, position: (x: Int, y: Int), suggestState: Binding) { + init(model: any FlickKeyModelProtocol, size: CGSize, position: (x: Int, y: Int), suggestState: Binding) { self.model = model self.size = size self.position = position diff --git a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickKogakiKeyModel.swift b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickKogakiKeyModel.swift index ab2324c3..7e18751e 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickKogakiKeyModel.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickKogakiKeyModel.swift @@ -35,7 +35,7 @@ struct FlickKogakiKeyModel: .none } - func label(width: CGFloat, states: VariableStates) -> KeyLabel { + func label(width: CGFloat, states: VariableStates) -> KeyLabel { KeyLabel(self.labelType, width: width) } diff --git a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickNextCandidateKeyModel.swift b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickNextCandidateKeyModel.swift index 44e21300..b86e164c 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickNextCandidateKeyModel.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickNextCandidateKeyModel.swift @@ -49,7 +49,7 @@ struct FlickNextCandidateKeyModel(width: CGFloat, states: VariableStates) -> KeyLabel { + func label(width: CGFloat, states: VariableStates) -> KeyLabel { if states.resultModel.results.isEmpty { KeyLabel(.text("空白"), width: width) } else { diff --git a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickSpaceKeyModel.swift b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickSpaceKeyModel.swift index 4b8bd688..aed6b087 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickSpaceKeyModel.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickSpaceKeyModel.swift @@ -43,7 +43,7 @@ struct FlickSpaceKeyModel: .init(start: [.setCursorBar(.toggle)]) } - func label(width: CGFloat, states: VariableStates) -> KeyLabel { + func label(width: CGFloat, states: VariableStates) -> KeyLabel { KeyLabel(.text("空白"), width: width) } diff --git a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickTabKeyModel.swift b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickTabKeyModel.swift index c356e77a..ff20387e 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickTabKeyModel.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/FlickKeyboard/KeyView/FlickTabKeyModel.swift @@ -37,7 +37,7 @@ struct FlickTabKeyModel: Fl self.tab = tab } - func label(width: CGFloat, states: VariableStates) -> KeyLabel { + func label(width: CGFloat, states: VariableStates) -> KeyLabel { KeyLabel(self.data.labelType, width: width) } diff --git a/MainApp/Customize/EditingTenkeyCustardView.swift b/MainApp/Customize/EditingTenkeyCustardView.swift index 9cc65e9c..dca50ca1 100644 --- a/MainApp/Customize/EditingTenkeyCustardView.swift +++ b/MainApp/Customize/EditingTenkeyCustardView.swift @@ -47,7 +47,7 @@ struct EditingTenkeyCustardView: CancelableEditor { @Binding private var manager: CustardManager @State private var showPreview = false @State private var copiedKey: UserMadeTenKeyCustard.KeyData? - private var models: [KeyPosition: (model: any FlickKeyModelProtocol, width: Int, height: Int)] { + private var models: [KeyPosition: (model: any FlickKeyModelProtocol, width: Int, height: Int)] { (0.. Date: Sun, 8 Oct 2023 19:06:11 +0900 Subject: [PATCH 08/10] replace any QwertyKeyModelProtocol with any QwertyKeyModelProtocol --- .../View/CustomKeybaord/CustomKeyboard.swift | 14 +- .../KeyView/QwertyAaKeyModel.swift | 2 +- .../QwertyChangeKeyboardKeyModel.swift | 2 +- .../KeyView/QwertyEnterKeyModel.swift | 2 +- .../KeyView/QwertyFunctionalKeyModel.swift | 2 +- .../KeyView/QwertyKeyModel.swift | 2 +- .../KeyView/QwertyKeyModelProtocol.swift | 2 +- .../KeyView/QwertyKeyView.swift | 6 +- .../QwertyLanguageSwitchKeyModel.swift | 4 +- .../KeyView/QwertyNextCandidateKeyModel.swift | 2 +- .../KeyView/QwertyShiftKeyModel.swift | 2 +- .../KeyView/QwertySpaceKeyModel.swift | 2 +- .../KeyView/QwertyTabKeyModel.swift | 2 +- .../QwertyKeyboard/QwertyDataProvider.swift | 260 +++++++++--------- .../QwertyKeyboard/QwertyKeyboardView.swift | 6 +- 15 files changed, 155 insertions(+), 155 deletions(-) diff --git a/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/CustomKeyboard.swift b/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/CustomKeyboard.swift index e4aeadbb..e9e72734 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/CustomKeyboard.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/CustomKeyboard.swift @@ -71,7 +71,7 @@ fileprivate extension CustardInterface { } } - @MainActor func qwertyKeyModels(extension _: Extension.Type) -> [KeyPosition: (model: any QwertyKeyModelProtocol, sizeType: QwertyKeySizeType)] { + @MainActor func qwertyKeyModels(extension _: Extension.Type) -> [KeyPosition: (model: any QwertyKeyModelProtocol, sizeType: QwertyKeySizeType)] { self.keys.reduce(into: [:]) {dictionary, value in switch value.key { case let .gridFit(data): @@ -174,12 +174,12 @@ extension CustardInterfaceKey { } } - private func convertToQwertyKeyModel(customKey: KeyFlickSetting.SettingData, extension _: Extension.Type) -> any QwertyKeyModelProtocol { + private func convertToQwertyKeyModel(customKey: KeyFlickSetting.SettingData, extension _: Extension.Type) -> any QwertyKeyModelProtocol { let variations = VariationsModel([customKey.flick[.left], customKey.flick[.top], customKey.flick[.right], customKey.flick[.bottom]].compactMap {$0}.map {(label: $0.labelType, actions: $0.pressActions)}) - return QwertyKeyModel(labelType: customKey.labelType, pressActions: customKey.actions, longPressActions: customKey.longpressActions, variationsModel: variations, keyColorType: .normal, needSuggestView: false, for: (1, 1)) + return QwertyKeyModel(labelType: customKey.labelType, pressActions: customKey.actions, longPressActions: customKey.longpressActions, variationsModel: variations, keyColorType: .normal, needSuggestView: false, for: (1, 1)) } - @MainActor func qwertyKeyModel(layout: CustardInterfaceLayout, extension: Extension.Type) -> any QwertyKeyModelProtocol { + @MainActor func qwertyKeyModel(layout: CustardInterfaceLayout, extension: Extension.Type) -> any QwertyKeyModelProtocol { switch self { case let .system(value): switch value { @@ -192,11 +192,11 @@ extension CustardInterfaceKey { } return changeKeyboardKey case .enter: - return QwertyEnterKeyModel(keySizeType: .enter) + return QwertyEnterKeyModel(keySizeType: .enter) case .upperLower: - return QwertyAaKeyModel() + return QwertyAaKeyModel() case .nextCandidate: - return QwertyNextCandidateKeyModel() + return QwertyNextCandidateKeyModel() case .flickKogaki: return convertToQwertyKeyModel(customKey: Extension.SettingProvider.koganaFlickCustomKey.compiled(), extension: Extension.self) case .flickKutoten: diff --git a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyAaKeyModel.swift b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyAaKeyModel.swift index 03ff1ab8..9f6372ee 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyAaKeyModel.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyAaKeyModel.swift @@ -28,7 +28,7 @@ struct QwertyAaKeyModel: Qw .init(start: [.setBoolState(VariableStates.BoolStates.isCapsLockedKey, .toggle)]) } - func label(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel { + func label(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel { if states.boolStates.isCapsLocked { return KeyLabel(.image("capslock.fill"), width: width, textColor: color) } else { diff --git a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyChangeKeyboardKeyModel.swift b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyChangeKeyboardKeyModel.swift index dddafd1d..8af5a2d0 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyChangeKeyboardKeyModel.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyChangeKeyboardKeyModel.swift @@ -68,7 +68,7 @@ struct QwertyChangeKeyboardKeyModel(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel { + func label(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel { if SemiStaticStates.shared.needsInputModeSwitchKey { return KeyLabel(.changeKeyboard, width: width, textColor: color) } diff --git a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyEnterKeyModel.swift b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyEnterKeyModel.swift index e2fafb48..d783af6a 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyEnterKeyModel.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyEnterKeyModel.swift @@ -34,7 +34,7 @@ struct QwertyEnterKeyModel: .none } - func label(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel { + func label(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel { let text = Design.language.getEnterKeyText(states.enterKeyState) return KeyLabel(.text(text), width: width, textSize: .small, textColor: color) } diff --git a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyFunctionalKeyModel.swift b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyFunctionalKeyModel.swift index cf8420fe..101366c2 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyFunctionalKeyModel.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyFunctionalKeyModel.swift @@ -38,7 +38,7 @@ struct QwertyFunctionalKeyModel(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel { + func label(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel { KeyLabel(self.labelType, width: width, textColor: color) } diff --git a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyKeyModel.swift b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyKeyModel.swift index 96acb6cb..f50926c9 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyKeyModel.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyKeyModel.swift @@ -31,7 +31,7 @@ struct QwertyKeyModel: Qwer self.unpressedKeyColorType = keyColorType } - func label(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel { + func label(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel { if (states.boolStates.isCapsLocked || states.boolStates.isShifted), states.keyboardLanguage == .en_US, case let .text(text) = self.labelType { return KeyLabel(.text(text.uppercased()), width: width, textColor: color) } diff --git a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyKeyModelProtocol.swift b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyKeyModelProtocol.swift index e2fa274d..3b8a290f 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyKeyModelProtocol.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyKeyModelProtocol.swift @@ -92,7 +92,7 @@ protocol QwertyKeyModelProtocol { @MainActor func longPressActions(variableStates: VariableStates) -> LongpressActionType /// 二回連続で押した際に発火するActionを指定する @MainActor func doublePressActions(variableStates: VariableStates) -> [ActionType] - @MainActor func label(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel + @MainActor func label(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel func backGroundColorWhenPressed(theme: Extension.Theme) -> Color var unpressedKeyColorType: QwertyUnpressedKeyColorType {get} diff --git a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyKeyView.swift b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyKeyView.swift index c9179d7c..7039e2bf 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyKeyView.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyKeyView.swift @@ -98,7 +98,7 @@ struct QwertyKeyDoublePressState { @MainActor struct QwertyKeyView: View { - private let model: any QwertyKeyModelProtocol + private let model: any QwertyKeyModelProtocol @EnvironmentObject private var variableStates: VariableStates @State private var pressState: QwertyKeyPressState = .unpressed @@ -112,7 +112,7 @@ struct QwertyKeyView: View private let tabDesign: TabDependentDesign private let size: CGSize - init(model: any QwertyKeyModelProtocol, tabDesign: TabDependentDesign, size: CGSize) { + init(model: any QwertyKeyModelProtocol, tabDesign: TabDependentDesign, size: CGSize) { self.model = model self.tabDesign = tabDesign self.size = size @@ -227,7 +227,7 @@ struct QwertyKeyView: View } private func label(width: CGFloat, color: Color?) -> some View { - self.model.label(width: width, states: variableStates, color: color) as KeyLabel + self.model.label(width: width, states: variableStates, color: color) } var body: some View { diff --git a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyLanguageSwitchKeyModel.swift b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyLanguageSwitchKeyModel.swift index 1d9e45c4..913c89da 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyLanguageSwitchKeyModel.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyLanguageSwitchKeyModel.swift @@ -55,7 +55,7 @@ struct QwertySwitchLanguageKeyModel(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel { + func label(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel { let current = currentTabLanguage(variableStates: states) if languages.0 == current { return KeyLabel(.selectable(languages.0.symbol, languages.1.symbol), width: width, textColor: color) @@ -64,7 +64,7 @@ struct QwertySwitchLanguageKeyModel(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel { + func label(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel { if states.resultModel.results.isEmpty { switch states.keyboardLanguage { case .el_GR: diff --git a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyShiftKeyModel.swift b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyShiftKeyModel.swift index d8751a7e..25661474 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyShiftKeyModel.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyShiftKeyModel.swift @@ -37,7 +37,7 @@ struct QwertyShiftKeyModel: } } - func label(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel { + func label(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel { if states.boolStates.isCapsLocked { return KeyLabel(.image("capslock.fill"), width: width, textColor: color) } else if states.boolStates.isShifted { diff --git a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertySpaceKeyModel.swift b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertySpaceKeyModel.swift index 16c20490..0ae02b98 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertySpaceKeyModel.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertySpaceKeyModel.swift @@ -18,7 +18,7 @@ struct QwertySpaceKeyModel: init() {} - func label(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel { + func label(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel { switch states.keyboardLanguage { case .el_GR: return KeyLabel(.text("διάστημα"), width: width, textSize: .small, textColor: color) diff --git a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyTabKeyModel.swift b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyTabKeyModel.swift index 4cffc7f7..d366ae9e 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyTabKeyModel.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/KeyView/QwertyTabKeyModel.swift @@ -41,7 +41,7 @@ struct QwertyTabKeyModel: Q self.keySizeType = .functional(normal: rowInfo.normal, functional: rowInfo.functional, enter: rowInfo.enter, space: rowInfo.space) } - func label(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel { + func label(width: CGFloat, states: VariableStates, color: Color?) -> KeyLabel { switch SemiStaticStates.shared.needsInputModeSwitchKey { case true: switch states.keyboardLanguage { diff --git a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/QwertyDataProvider.swift b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/QwertyDataProvider.swift index 6106d9d7..743c7fa0 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/QwertyDataProvider.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/QwertyDataProvider.swift @@ -10,9 +10,9 @@ import Foundation import enum CustardKit.TabData struct QwertyDataProvider { - @MainActor static func tabKeys(rowInfo: (normal: Int, functional: Int, space: Int, enter: Int)) -> (languageKey: any QwertyKeyModelProtocol, numbersKey: any QwertyKeyModelProtocol, symbolsKey: any QwertyKeyModelProtocol, changeKeyboardKey: any QwertyKeyModelProtocol) { + @MainActor static func tabKeys(rowInfo: (normal: Int, functional: Int, space: Int, enter: Int)) -> (languageKey: any QwertyKeyModelProtocol, numbersKey: any QwertyKeyModelProtocol, symbolsKey: any QwertyKeyModelProtocol, changeKeyboardKey: any QwertyKeyModelProtocol) { let preferredLanguage = Extension.SettingProvider.preferredLanguage - let languageKey: any QwertyKeyModelProtocol + let languageKey: any QwertyKeyModelProtocol let first = preferredLanguage.first if let second = preferredLanguage.second { languageKey = QwertySwitchLanguageKeyModel(rowInfo: rowInfo, languages: (first, second)) @@ -30,10 +30,10 @@ struct QwertyDataProvider { languageKey = QwertyFunctionalKeyModel(labelType: .text(first.symbol), rowInfo: rowInfo, pressActions: [.moveTab(targetTab)], longPressActions: .none, needSuggestView: false) } - let numbersKey: any QwertyKeyModelProtocol = QwertyFunctionalKeyModel(labelType: .image("textformat.123"), rowInfo: rowInfo, pressActions: [.moveTab(.system(.qwerty_numbers))], longPressActions: .init(start: [.setTabBar(.toggle)])) - let symbolsKey: any QwertyKeyModelProtocol = QwertyFunctionalKeyModel(labelType: .text("#+="), rowInfo: rowInfo, pressActions: [.moveTab(.system(.qwerty_symbols))], longPressActions: .init(start: [.setTabBar(.toggle)])) + let numbersKey: any QwertyKeyModelProtocol = QwertyFunctionalKeyModel(labelType: .image("textformat.123"), rowInfo: rowInfo, pressActions: [.moveTab(.system(.qwerty_numbers))], longPressActions: .init(start: [.setTabBar(.toggle)])) + let symbolsKey: any QwertyKeyModelProtocol = QwertyFunctionalKeyModel(labelType: .text("#+="), rowInfo: rowInfo, pressActions: [.moveTab(.system(.qwerty_symbols))], longPressActions: .init(start: [.setTabBar(.toggle)])) - let changeKeyboardKey: any QwertyKeyModelProtocol + let changeKeyboardKey: any QwertyKeyModelProtocol if let second = preferredLanguage.second { changeKeyboardKey = QwertyChangeKeyboardKeyModel(keySizeType: .functional(normal: rowInfo.normal, functional: rowInfo.functional, enter: rowInfo.enter, space: rowInfo.space), fallBackType: .secondTab(secondLanguage: second)) } else { @@ -48,9 +48,9 @@ struct QwertyDataProvider { } // 横に並べる - @MainActor static var numberKeyboard: [[any QwertyKeyModelProtocol]] {[ + @MainActor static var numberKeyboard: [[any QwertyKeyModelProtocol]] {[ [ - QwertyKeyModel( + QwertyKeyModel( labelType: .text("1"), pressActions: [.input("1")], variationsModel: VariationsModel([ @@ -61,7 +61,7 @@ struct QwertyDataProvider { ], direction: .right) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("2"), pressActions: [.input("2")], variationsModel: VariationsModel([ @@ -72,7 +72,7 @@ struct QwertyDataProvider { ], direction: .right) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("3"), pressActions: [.input("3")], variationsModel: VariationsModel([ @@ -83,7 +83,7 @@ struct QwertyDataProvider { ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("4"), pressActions: [.input("4")], variationsModel: VariationsModel([ @@ -93,7 +93,7 @@ struct QwertyDataProvider { (label: .text("④"), actions: [.input("④")] ) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("5"), pressActions: [.input("5")], variationsModel: VariationsModel([ @@ -103,7 +103,7 @@ struct QwertyDataProvider { (label: .text("⑤"), actions: [.input("⑤")] ) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("6"), pressActions: [.input("6")], variationsModel: VariationsModel([ @@ -113,7 +113,7 @@ struct QwertyDataProvider { (label: .text("⑥"), actions: [.input("⑥")] ) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("7"), pressActions: [.input("7")], variationsModel: VariationsModel([ @@ -123,7 +123,7 @@ struct QwertyDataProvider { (label: .text("⑦"), actions: [.input("⑦")] ) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("8"), pressActions: [.input("8")], variationsModel: VariationsModel([ @@ -133,7 +133,7 @@ struct QwertyDataProvider { (label: .text("⑧"), actions: [.input("⑧")] ) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("9"), pressActions: [.input("9")], variationsModel: VariationsModel([ @@ -143,7 +143,7 @@ struct QwertyDataProvider { (label: .text("⑨"), actions: [.input("⑨")] ) ], direction: .left) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("0"), pressActions: [.input("0")], variationsModel: VariationsModel([ @@ -155,8 +155,8 @@ struct QwertyDataProvider { ) ], [ - QwertyKeyModel(labelType: .text("-"), pressActions: [.input("-")]), - QwertyKeyModel( + QwertyKeyModel(labelType: .text("-"), pressActions: [.input("-")]), + QwertyKeyModel( labelType: .text("/"), pressActions: [.input("/")], variationsModel: VariationsModel([ @@ -164,7 +164,7 @@ struct QwertyDataProvider { (label: .text("\\"), actions: [.input("\\")] ) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text(":"), pressActions: [.input(":")], variationsModel: VariationsModel([ @@ -174,7 +174,7 @@ struct QwertyDataProvider { (label: .text(";"), actions: [.input(";")] ) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("@"), pressActions: [.input("@")], variationsModel: VariationsModel([ @@ -182,9 +182,9 @@ struct QwertyDataProvider { (label: .text("@"), actions: [.input("@")] ) ]) ), - QwertyKeyModel(labelType: .text("("), pressActions: [.input("(")]), - QwertyKeyModel(labelType: .text(")"), pressActions: [.input(")")]), - QwertyKeyModel( + QwertyKeyModel(labelType: .text("("), pressActions: [.input("(")]), + QwertyKeyModel(labelType: .text(")"), pressActions: [.input(")")]), + QwertyKeyModel( labelType: .text("「"), pressActions: [.input("「")], variationsModel: VariationsModel([ @@ -195,7 +195,7 @@ struct QwertyDataProvider { (label: .text("《"), actions: [.input("《")] ) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("」"), pressActions: [.input("」")], variationsModel: VariationsModel([ @@ -206,7 +206,7 @@ struct QwertyDataProvider { (label: .text("》"), actions: [.input("》")] ) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("¥"), pressActions: [.input("¥")], variationsModel: VariationsModel([ @@ -220,7 +220,7 @@ struct QwertyDataProvider { (label: .text("¤"), actions: [.input("¤")] ) ], direction: .left) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("&"), pressActions: [.input("&")], variationsModel: VariationsModel([ @@ -234,21 +234,21 @@ struct QwertyDataProvider { Self.tabKeys(rowInfo: (7, 2, 0, 0)).symbolsKey ] + Extension.SettingProvider.numberTabCustomKeysSetting.compiled(extension: Extension.self) + [ - QwertyFunctionalKeyModel.delete + QwertyFunctionalKeyModel.delete ], [ Self.tabKeys(rowInfo: (0, 2, 1, 1)).languageKey, Self.tabKeys(rowInfo: (0, 2, 1, 1)).changeKeyboardKey, - QwertyNextCandidateKeyModel(), - QwertyEnterKeyModel.shared + QwertyNextCandidateKeyModel(), + QwertyEnterKeyModel.shared ] ] } // 横に並べる - @MainActor static func symbolsKeyboard() -> [[any QwertyKeyModelProtocol]] {[ + @MainActor static func symbolsKeyboard() -> [[any QwertyKeyModelProtocol]] {[ [ - QwertyKeyModel( + QwertyKeyModel( labelType: .text("["), pressActions: [.input("[")], variationsModel: VariationsModel([ @@ -256,7 +256,7 @@ struct QwertyDataProvider { (label: .text("["), actions: [.input("[")]) ], direction: .right) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("]"), pressActions: [.input("]")], variationsModel: VariationsModel([ @@ -264,7 +264,7 @@ struct QwertyDataProvider { (label: .text("]"), actions: [.input("]")]) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("{"), pressActions: [.input("{")], variationsModel: VariationsModel([ @@ -272,7 +272,7 @@ struct QwertyDataProvider { (label: .text("{"), actions: [.input("{")]) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("}"), pressActions: [.input("}")], variationsModel: VariationsModel([ @@ -280,7 +280,7 @@ struct QwertyDataProvider { (label: .text("}"), actions: [.input("}")]) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("#"), pressActions: [.input("#")], variationsModel: VariationsModel([ @@ -288,7 +288,7 @@ struct QwertyDataProvider { (label: .text("#"), actions: [.input("#")]) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("%"), pressActions: [.input("%")], variationsModel: VariationsModel([ @@ -296,7 +296,7 @@ struct QwertyDataProvider { (label: .text("%"), actions: [.input("%")]) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("^"), pressActions: [.input("^")], variationsModel: VariationsModel([ @@ -304,7 +304,7 @@ struct QwertyDataProvider { (label: .text("^"), actions: [.input("^")]) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("*"), pressActions: [.input("*")], variationsModel: VariationsModel([ @@ -312,7 +312,7 @@ struct QwertyDataProvider { (label: .text("*"), actions: [.input("*")]) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("+"), pressActions: [.input("+")], variationsModel: VariationsModel([ @@ -321,7 +321,7 @@ struct QwertyDataProvider { (label: .text("±"), actions: [.input("±")]) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("="), pressActions: [.input("=")], variationsModel: VariationsModel([ @@ -334,8 +334,8 @@ struct QwertyDataProvider { ) ], [ - QwertyKeyModel(labelType: .text("_"), pressActions: [.input("_")]), - QwertyKeyModel( + QwertyKeyModel(labelType: .text("_"), pressActions: [.input("_")]), + QwertyKeyModel( labelType: .text("\\"), pressActions: [.input("\\")], variationsModel: VariationsModel([ @@ -343,7 +343,7 @@ struct QwertyDataProvider { (label: .text("\\"), actions: [.input("\\")] ) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text(";"), pressActions: [.input(";")], variationsModel: VariationsModel([ @@ -353,7 +353,7 @@ struct QwertyDataProvider { (label: .text(";"), actions: [.input(";")] ) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("|"), pressActions: [.input("|")], variationsModel: VariationsModel([ @@ -361,7 +361,7 @@ struct QwertyDataProvider { (label: .text("|"), actions: [.input("|")] ) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("<"), pressActions: [.input("<")], variationsModel: VariationsModel([ @@ -369,7 +369,7 @@ struct QwertyDataProvider { (label: .text("<"), actions: [.input("<")]) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text(">"), pressActions: [.input(">")], variationsModel: VariationsModel([ @@ -377,7 +377,7 @@ struct QwertyDataProvider { (label: .text(">"), actions: [.input(">")]) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("\""), pressActions: [.input("\"")], variationsModel: VariationsModel([ @@ -387,7 +387,7 @@ struct QwertyDataProvider { (label: .text("”"), actions: [.input("”")]) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("'"), pressActions: [.input("'")], variationsModel: VariationsModel([ @@ -396,7 +396,7 @@ struct QwertyDataProvider { ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("$"), pressActions: [.input("$")], variationsModel: VariationsModel([ @@ -404,7 +404,7 @@ struct QwertyDataProvider { (label: .text("$"), actions: [.input("$")]) ]) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("€"), pressActions: [.input("€")], variationsModel: VariationsModel([ @@ -422,7 +422,7 @@ struct QwertyDataProvider { [ Self.tabKeys(rowInfo: (7, 2, 0, 0)).numbersKey, - QwertyKeyModel( + QwertyKeyModel( labelType: .text("."), pressActions: [.input(".")], variationsModel: VariationsModel([ @@ -431,7 +431,7 @@ struct QwertyDataProvider { ]), for: (7, 5) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text(","), pressActions: [.input(",")], variationsModel: VariationsModel([ @@ -439,7 +439,7 @@ struct QwertyDataProvider { (label: .text(","), actions: [.input(",")] ) ]), for: (7, 5)), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("?"), pressActions: [.input("?")], variationsModel: VariationsModel([ @@ -448,7 +448,7 @@ struct QwertyDataProvider { ]), for: (7, 5) ), - QwertyKeyModel( + QwertyKeyModel( labelType: .text("!"), pressActions: [.input("!")], variationsModel: VariationsModel([ @@ -456,116 +456,116 @@ struct QwertyDataProvider { (label: .text("!"), actions: [.input("!")] ) ]), for: (7, 5)), - QwertyKeyModel(labelType: .text("・"), pressActions: [.input("…")], for: (7, 5)), - QwertyFunctionalKeyModel.delete + QwertyKeyModel(labelType: .text("・"), pressActions: [.input("…")], for: (7, 5)), + QwertyFunctionalKeyModel.delete ], [ Self.tabKeys(rowInfo: (0, 2, 1, 1)).languageKey, Self.tabKeys(rowInfo: (0, 2, 1, 1)).changeKeyboardKey, - QwertyNextCandidateKeyModel(), - QwertyEnterKeyModel.shared + QwertyNextCandidateKeyModel(), + QwertyEnterKeyModel.shared ] ]} // 横に並べる - @MainActor static func hiraKeyboard() -> [[any QwertyKeyModelProtocol]] {[ + @MainActor static func hiraKeyboard() -> [[any QwertyKeyModelProtocol]] {[ [ - QwertyKeyModel(labelType: .text("q"), pressActions: [.input("q")]), - QwertyKeyModel(labelType: .text("w"), pressActions: [.input("w")]), - QwertyKeyModel(labelType: .text("e"), pressActions: [.input("e")]), - QwertyKeyModel(labelType: .text("r"), pressActions: [.input("r")]), - QwertyKeyModel(labelType: .text("t"), pressActions: [.input("t")]), - QwertyKeyModel(labelType: .text("y"), pressActions: [.input("y")]), - QwertyKeyModel(labelType: .text("u"), pressActions: [.input("u")]), - QwertyKeyModel(labelType: .text("i"), pressActions: [.input("i")]), - QwertyKeyModel(labelType: .text("o"), pressActions: [.input("o")]), - QwertyKeyModel(labelType: .text("p"), pressActions: [.input("p")]) + QwertyKeyModel(labelType: .text("q"), pressActions: [.input("q")]), + QwertyKeyModel(labelType: .text("w"), pressActions: [.input("w")]), + QwertyKeyModel(labelType: .text("e"), pressActions: [.input("e")]), + QwertyKeyModel(labelType: .text("r"), pressActions: [.input("r")]), + QwertyKeyModel(labelType: .text("t"), pressActions: [.input("t")]), + QwertyKeyModel(labelType: .text("y"), pressActions: [.input("y")]), + QwertyKeyModel(labelType: .text("u"), pressActions: [.input("u")]), + QwertyKeyModel(labelType: .text("i"), pressActions: [.input("i")]), + QwertyKeyModel(labelType: .text("o"), pressActions: [.input("o")]), + QwertyKeyModel(labelType: .text("p"), pressActions: [.input("p")]) ], [ - QwertyKeyModel(labelType: .text("a"), pressActions: [.input("a")]), - QwertyKeyModel(labelType: .text("s"), pressActions: [.input("s")]), - QwertyKeyModel(labelType: .text("d"), pressActions: [.input("d")]), - QwertyKeyModel(labelType: .text("f"), pressActions: [.input("f")]), - QwertyKeyModel(labelType: .text("g"), pressActions: [.input("g")]), - QwertyKeyModel(labelType: .text("h"), pressActions: [.input("h")]), - QwertyKeyModel(labelType: .text("j"), pressActions: [.input("j")]), - QwertyKeyModel(labelType: .text("k"), pressActions: [.input("k")]), - QwertyKeyModel(labelType: .text("l"), pressActions: [.input("l")]), - QwertyKeyModel(labelType: .text("ー"), pressActions: [.input("ー")]) + QwertyKeyModel(labelType: .text("a"), pressActions: [.input("a")]), + QwertyKeyModel(labelType: .text("s"), pressActions: [.input("s")]), + QwertyKeyModel(labelType: .text("d"), pressActions: [.input("d")]), + QwertyKeyModel(labelType: .text("f"), pressActions: [.input("f")]), + QwertyKeyModel(labelType: .text("g"), pressActions: [.input("g")]), + QwertyKeyModel(labelType: .text("h"), pressActions: [.input("h")]), + QwertyKeyModel(labelType: .text("j"), pressActions: [.input("j")]), + QwertyKeyModel(labelType: .text("k"), pressActions: [.input("k")]), + QwertyKeyModel(labelType: .text("l"), pressActions: [.input("l")]), + QwertyKeyModel(labelType: .text("ー"), pressActions: [.input("ー")]) ], [ Self.tabKeys(rowInfo: (7, 2, 0, 0)).languageKey, - QwertyKeyModel(labelType: .text("z"), pressActions: [.input("z")]), - QwertyKeyModel(labelType: .text("x"), pressActions: [.input("x")]), - QwertyKeyModel(labelType: .text("c"), pressActions: [.input("c")]), - QwertyKeyModel(labelType: .text("v"), pressActions: [.input("v")]), - QwertyKeyModel(labelType: .text("b"), pressActions: [.input("b")]), - QwertyKeyModel(labelType: .text("n"), pressActions: [.input("n")]), - QwertyKeyModel(labelType: .text("m"), pressActions: [.input("m")]), - QwertyFunctionalKeyModel.delete + QwertyKeyModel(labelType: .text("z"), pressActions: [.input("z")]), + QwertyKeyModel(labelType: .text("x"), pressActions: [.input("x")]), + QwertyKeyModel(labelType: .text("c"), pressActions: [.input("c")]), + QwertyKeyModel(labelType: .text("v"), pressActions: [.input("v")]), + QwertyKeyModel(labelType: .text("b"), pressActions: [.input("b")]), + QwertyKeyModel(labelType: .text("n"), pressActions: [.input("n")]), + QwertyKeyModel(labelType: .text("m"), pressActions: [.input("m")]), + QwertyFunctionalKeyModel.delete ], [ Self.tabKeys(rowInfo: (0, 2, 1, 1)).numbersKey, Self.tabKeys(rowInfo: (0, 2, 1, 1)).changeKeyboardKey, - QwertyNextCandidateKeyModel(), - QwertyEnterKeyModel.shared + QwertyNextCandidateKeyModel(), + QwertyEnterKeyModel.shared ] ]} // 横に並べる - @MainActor static func abcKeyboard() -> [[any QwertyKeyModelProtocol]] {[ + @MainActor static func abcKeyboard() -> [[any QwertyKeyModelProtocol]] {[ [ - QwertyKeyModel(labelType: .text("q"), pressActions: [.input("q")]), - QwertyKeyModel(labelType: .text("w"), pressActions: [.input("w")]), - QwertyKeyModel(labelType: .text("e"), pressActions: [.input("e")]), - QwertyKeyModel(labelType: .text("r"), pressActions: [.input("r")]), - QwertyKeyModel(labelType: .text("t"), pressActions: [.input("t")]), - QwertyKeyModel(labelType: .text("y"), pressActions: [.input("y")]), - QwertyKeyModel(labelType: .text("u"), pressActions: [.input("u")]), - QwertyKeyModel(labelType: .text("i"), pressActions: [.input("i")]), - QwertyKeyModel(labelType: .text("o"), pressActions: [.input("o")]), - QwertyKeyModel(labelType: .text("p"), pressActions: [.input("p")]) + QwertyKeyModel(labelType: .text("q"), pressActions: [.input("q")]), + QwertyKeyModel(labelType: .text("w"), pressActions: [.input("w")]), + QwertyKeyModel(labelType: .text("e"), pressActions: [.input("e")]), + QwertyKeyModel(labelType: .text("r"), pressActions: [.input("r")]), + QwertyKeyModel(labelType: .text("t"), pressActions: [.input("t")]), + QwertyKeyModel(labelType: .text("y"), pressActions: [.input("y")]), + QwertyKeyModel(labelType: .text("u"), pressActions: [.input("u")]), + QwertyKeyModel(labelType: .text("i"), pressActions: [.input("i")]), + QwertyKeyModel(labelType: .text("o"), pressActions: [.input("o")]), + QwertyKeyModel(labelType: .text("p"), pressActions: [.input("p")]) ], Extension.SettingProvider.useShiftKey ? [ - QwertyShiftKeyModel.shared, - QwertyKeyModel(labelType: .text("a"), pressActions: [.input("a")]), - QwertyKeyModel(labelType: .text("s"), pressActions: [.input("s")]), - QwertyKeyModel(labelType: .text("d"), pressActions: [.input("d")]), - QwertyKeyModel(labelType: .text("f"), pressActions: [.input("f")]), - QwertyKeyModel(labelType: .text("g"), pressActions: [.input("g")]), - QwertyKeyModel(labelType: .text("h"), pressActions: [.input("h")]), - QwertyKeyModel(labelType: .text("j"), pressActions: [.input("j")]), - QwertyKeyModel(labelType: .text("k"), pressActions: [.input("k")]), - QwertyKeyModel(labelType: .text("l"), pressActions: [.input("l")]) + QwertyShiftKeyModel.shared, + QwertyKeyModel(labelType: .text("a"), pressActions: [.input("a")]), + QwertyKeyModel(labelType: .text("s"), pressActions: [.input("s")]), + QwertyKeyModel(labelType: .text("d"), pressActions: [.input("d")]), + QwertyKeyModel(labelType: .text("f"), pressActions: [.input("f")]), + QwertyKeyModel(labelType: .text("g"), pressActions: [.input("g")]), + QwertyKeyModel(labelType: .text("h"), pressActions: [.input("h")]), + QwertyKeyModel(labelType: .text("j"), pressActions: [.input("j")]), + QwertyKeyModel(labelType: .text("k"), pressActions: [.input("k")]), + QwertyKeyModel(labelType: .text("l"), pressActions: [.input("l")]) ] : [ - QwertyKeyModel(labelType: .text("a"), pressActions: [.input("a")]), - QwertyKeyModel(labelType: .text("s"), pressActions: [.input("s")]), - QwertyKeyModel(labelType: .text("d"), pressActions: [.input("d")]), - QwertyKeyModel(labelType: .text("f"), pressActions: [.input("f")]), - QwertyKeyModel(labelType: .text("g"), pressActions: [.input("g")]), - QwertyKeyModel(labelType: .text("h"), pressActions: [.input("h")]), - QwertyKeyModel(labelType: .text("j"), pressActions: [.input("j")]), - QwertyKeyModel(labelType: .text("k"), pressActions: [.input("k")]), - QwertyKeyModel(labelType: .text("l"), pressActions: [.input("l")]), - QwertyAaKeyModel.shared + QwertyKeyModel(labelType: .text("a"), pressActions: [.input("a")]), + QwertyKeyModel(labelType: .text("s"), pressActions: [.input("s")]), + QwertyKeyModel(labelType: .text("d"), pressActions: [.input("d")]), + QwertyKeyModel(labelType: .text("f"), pressActions: [.input("f")]), + QwertyKeyModel(labelType: .text("g"), pressActions: [.input("g")]), + QwertyKeyModel(labelType: .text("h"), pressActions: [.input("h")]), + QwertyKeyModel(labelType: .text("j"), pressActions: [.input("j")]), + QwertyKeyModel(labelType: .text("k"), pressActions: [.input("k")]), + QwertyKeyModel(labelType: .text("l"), pressActions: [.input("l")]), + QwertyAaKeyModel.shared ], [ Self.tabKeys(rowInfo: (7, 2, 0, 0)).languageKey, - QwertyKeyModel(labelType: .text("z"), pressActions: [.input("z")]), - QwertyKeyModel(labelType: .text("x"), pressActions: [.input("x")]), - QwertyKeyModel(labelType: .text("c"), pressActions: [.input("c")]), - QwertyKeyModel(labelType: .text("v"), pressActions: [.input("v")]), - QwertyKeyModel(labelType: .text("b"), pressActions: [.input("b")]), - QwertyKeyModel(labelType: .text("n"), pressActions: [.input("n")]), - QwertyKeyModel(labelType: .text("m"), pressActions: [.input("m")]), - QwertyFunctionalKeyModel.delete + QwertyKeyModel(labelType: .text("z"), pressActions: [.input("z")]), + QwertyKeyModel(labelType: .text("x"), pressActions: [.input("x")]), + QwertyKeyModel(labelType: .text("c"), pressActions: [.input("c")]), + QwertyKeyModel(labelType: .text("v"), pressActions: [.input("v")]), + QwertyKeyModel(labelType: .text("b"), pressActions: [.input("b")]), + QwertyKeyModel(labelType: .text("n"), pressActions: [.input("n")]), + QwertyKeyModel(labelType: .text("m"), pressActions: [.input("m")]), + QwertyFunctionalKeyModel.delete ], [ Self.tabKeys(rowInfo: (0, 2, 1, 1)).numbersKey, Self.tabKeys(rowInfo: (0, 2, 1, 1)).changeKeyboardKey, - QwertyNextCandidateKeyModel(), - QwertyEnterKeyModel.shared + QwertyNextCandidateKeyModel(), + QwertyEnterKeyModel.shared ] ]} } diff --git a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/QwertyKeyboardView.swift b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/QwertyKeyboardView.swift index 6797e2a2..f880de21 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/QwertyKeyboardView.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/QwertyKeyboardView.swift @@ -11,9 +11,9 @@ import SwiftUI struct QwertyKeyboardView: View { private let tabDesign: TabDependentDesign - private let keyModels: [[any QwertyKeyModelProtocol]] + private let keyModels: [[any QwertyKeyModelProtocol]] - init(keyModels: [[any QwertyKeyModelProtocol]], interfaceSize: CGSize, keyboardOrientation: KeyboardOrientation) { + init(keyModels: [[any QwertyKeyModelProtocol]], interfaceSize: CGSize, keyboardOrientation: KeyboardOrientation) { self.keyModels = keyModels self.tabDesign = TabDependentDesign(width: 10, height: 4, interfaceSize: interfaceSize, layout: .qwerty, orientation: keyboardOrientation) } @@ -32,7 +32,7 @@ struct QwertyKeyboardView: HStack(spacing: tabDesign.horizontalSpacing) { ForEach(self.horizontalIndices(v: v), id: \.self) {(h: Int) in let model = self.keyModels[v][h] - QwertyKeyView( + QwertyKeyView( model: model, tabDesign: tabDesign, size: CGSize( From b35b0a0ad0bb18b753b3e2b7d9f4fb1f234b941d Mon Sep 17 00:00:00 2001 From: ensan-hcl Date: Sun, 8 Oct 2023 19:15:41 +0900 Subject: [PATCH 09/10] replace any SimpleKeyModelProtocol with any SimpleKeyModelProtocol --- .../View/CustomKeybaord/CustomKeyboard.swift | 22 +++++++++---------- .../SimpleKeyView/SimpleKeyModel.swift | 12 +++++----- .../SimpleKeyView/SimpleKeyView.swift | 8 +++---- .../View/SpecialTabs/EmojiTab.swift | 6 ++--- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/CustomKeyboard.swift b/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/CustomKeyboard.swift index e9e72734..96fc241a 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/CustomKeyboard.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/CustomKeyboard.swift @@ -231,31 +231,31 @@ extension CustardInterfaceKey { } } - func simpleKeyModel(extension _: Extension.Type) -> any SimpleKeyModelProtocol { + func simpleKeyModel(extension _: Extension.Type) -> any SimpleKeyModelProtocol { switch self { case let .system(value): switch value { case .changeKeyboard: - return SimpleChangeKeyboardKeyModel() + return SimpleChangeKeyboardKeyModel() case .enter: - return SimpleEnterKeyModel() + return SimpleEnterKeyModel() case .upperLower: - return SimpleKeyModel(keyLabelType: .text("a/A"), unpressedKeyColorType: .special, pressActions: [.changeCharacterType]) + return SimpleKeyModel(keyLabelType: .text("a/A"), unpressedKeyColorType: .special, pressActions: [.changeCharacterType]) case .nextCandidate: - return SimpleNextCandidateKeyModel() + return SimpleNextCandidateKeyModel() case .flickKogaki: - return SimpleKeyModel(keyLabelType: .text("小゙゚"), unpressedKeyColorType: .special, pressActions: [.changeCharacterType]) + return SimpleKeyModel(keyLabelType: .text("小゙゚"), unpressedKeyColorType: .special, pressActions: [.changeCharacterType]) case .flickKutoten: - return SimpleKeyModel(keyLabelType: .text("、"), unpressedKeyColorType: .normal, pressActions: [.input("、")]) + return SimpleKeyModel(keyLabelType: .text("、"), unpressedKeyColorType: .normal, pressActions: [.input("、")]) case .flickHiraTab: - return SimpleKeyModel(keyLabelType: .text("あいう"), unpressedKeyColorType: .special, pressActions: [.moveTab(.system(.user_japanese))]) + return SimpleKeyModel(keyLabelType: .text("あいう"), unpressedKeyColorType: .special, pressActions: [.moveTab(.system(.user_japanese))]) case .flickAbcTab: - return SimpleKeyModel(keyLabelType: .text("abc"), unpressedKeyColorType: .special, pressActions: [.moveTab(.system(.user_english))]) + return SimpleKeyModel(keyLabelType: .text("abc"), unpressedKeyColorType: .special, pressActions: [.moveTab(.system(.user_english))]) case .flickStar123Tab: - return SimpleKeyModel(keyLabelType: .text("☆123"), unpressedKeyColorType: .special, pressActions: [.moveTab(.system(.flick_numbersymbols))]) + return SimpleKeyModel(keyLabelType: .text("☆123"), unpressedKeyColorType: .special, pressActions: [.moveTab(.system(.flick_numbersymbols))]) } case let .custom(value): - return SimpleKeyModel( + return SimpleKeyModel( keyLabelType: value.design.label.keyLabelType, unpressedKeyColorType: value.design.color.simpleKeyColorType, pressActions: value.press_actions.map {$0.actionType}, diff --git a/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/SimpleKeyView/SimpleKeyModel.swift b/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/SimpleKeyView/SimpleKeyModel.swift index 1314062a..14230eab 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/SimpleKeyView/SimpleKeyModel.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/SimpleKeyView/SimpleKeyModel.swift @@ -47,14 +47,14 @@ enum SimpleUnpressedKeyColorType: UInt8 { } } -protocol SimpleKeyModelProtocol { +protocol SimpleKeyModelProtocol { associatedtype Extension: ApplicationSpecificKeyboardViewExtension var unpressedKeyColorType: SimpleUnpressedKeyColorType {get} @MainActor func pressActions(variableStates: VariableStates) -> [ActionType] @MainActor func longPressActions(variableStates: VariableStates) -> LongpressActionType @MainActor func feedback(variableStates: VariableStates) - @MainActor func label(width: CGFloat, states: VariableStates, theme: Extension.Theme) -> KeyLabel + @MainActor func label(width: CGFloat, states: VariableStates) -> KeyLabel @MainActor func backGroundColorWhenPressed(theme: Extension.Theme) -> Color /// `pressActions`とは別に、押された際に発火する操作 /// - note: タブ固有の事情で実行しなければならないような処理に利用すること @@ -82,7 +82,7 @@ struct SimpleKeyModel: Simp private let pressActions: [ActionType] let longPressActions: LongpressActionType - func label(width: CGFloat, states: VariableStates, theme: ThemeData) -> KeyLabel { + func label(width: CGFloat, states: VariableStates) -> KeyLabel { KeyLabel(self.keyLabelType, width: width) } @@ -115,7 +115,7 @@ struct SimpleEnterKeyModel: } let unpressedKeyColorType: SimpleUnpressedKeyColorType = .enter - func label(width: CGFloat, states: VariableStates, theme: ThemeData) -> KeyLabel { + func label(width: CGFloat, states: VariableStates) -> KeyLabel { let text = Design.language.getEnterKeyText(states.enterKeyState) return KeyLabel(.text(text), width: width) } @@ -148,7 +148,7 @@ struct SimpleNextCandidateKeyModel(width: CGFloat, states: VariableStates, theme: ThemeData) -> KeyLabel { + func label(width: CGFloat, states: VariableStates) -> KeyLabel { if states.resultModel.results.isEmpty { KeyLabel(.text("空白"), width: width) } else { @@ -182,7 +182,7 @@ struct SimpleChangeKeyboardKeyModel(width: CGFloat, states: VariableStates, theme: ThemeData) -> KeyLabel { + func label(width: CGFloat, states: VariableStates) -> KeyLabel { if SemiStaticStates.shared.needsInputModeSwitchKey { return KeyLabel(.changeKeyboard, width: width) } else { diff --git a/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/SimpleKeyView/SimpleKeyView.swift b/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/SimpleKeyView/SimpleKeyView.swift index e8257b63..e134506e 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/SimpleKeyView/SimpleKeyView.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/SimpleKeyView/SimpleKeyView.swift @@ -12,7 +12,7 @@ import SwiftUIUtils @MainActor struct SimpleKeyView: View { - private let model: any SimpleKeyModelProtocol + private let model: any SimpleKeyModelProtocol @EnvironmentObject private var variableStates: VariableStates @Environment(Extension.Theme.self) private var theme @Environment(\.userActionManager) private var action @@ -20,13 +20,13 @@ struct SimpleKeyView: View private let keyViewWidth: CGFloat private let keyViewHeight: CGFloat - init(model: any SimpleKeyModelProtocol, tabDesign: TabDependentDesign) { + init(model: any SimpleKeyModelProtocol, tabDesign: TabDependentDesign) { self.model = model self.keyViewWidth = tabDesign.keyViewWidth self.keyViewHeight = tabDesign.keyViewHeight } - init(model: any SimpleKeyModelProtocol, width: CGFloat, height: CGFloat) { + init(model: any SimpleKeyModelProtocol, width: CGFloat, height: CGFloat) { self.model = model self.keyViewWidth = width self.keyViewHeight = height @@ -36,7 +36,7 @@ struct SimpleKeyView: View @State private var pressStartDate = Date() private func label(width: CGFloat) -> some View { - model.label(width: keyViewWidth, states: variableStates, theme: theme) as KeyLabel + model.label(width: keyViewWidth, states: variableStates) } var body: some View { diff --git a/AzooKeyCore/Sources/KeyboardViews/View/SpecialTabs/EmojiTab.swift b/AzooKeyCore/Sources/KeyboardViews/View/SpecialTabs/EmojiTab.swift index 13c47c22..70509188 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/SpecialTabs/EmojiTab.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/SpecialTabs/EmojiTab.swift @@ -366,7 +366,7 @@ struct EmojiTab: View { private struct ExpandKeyModel: SimpleKeyModelProtocol { private var currentLevel: EmojiTabExpandModePreference.Level private var action: () -> Void - func label(width: CGFloat, states: VariableStates, theme: ThemeData) -> KeyLabel { + func label(width: CGFloat, states: VariableStates) -> KeyLabel { KeyLabel(.image(self.currentLevel.icon), width: width, textSize: .max) } @@ -393,7 +393,7 @@ private struct ExpandKeyModel: SimpleKeyModelProtocol { private var action: () -> Void private var systemImage: String - func label(width: CGFloat, states: VariableStates, theme: ThemeData) -> KeyLabel { + func label(width: CGFloat, states: VariableStates) -> KeyLabel { KeyLabel(.image(systemImage), width: width, textSize: .max) } @@ -432,7 +432,7 @@ private struct EmojiKeyModel(width: CGFloat, states _: VariableStates, theme _: ThemeData) -> KeyLabel { + func label(width: CGFloat, states _: VariableStates) -> KeyLabel { KeyLabel(.text(emoji), width: width, textSize: .max) } From cad557c55e314481c6a3d0fd946784067c0ea3ea Mon Sep 17 00:00:00 2001 From: ensan-hcl Date: Sun, 8 Oct 2023 19:18:12 +0900 Subject: [PATCH 10/10] clean up redundant code --- .../View/CustomKeybaord/CustomKeyboard.swift | 24 +++++++++---------- .../QwertyKeyboard/QwertyDataProvider.swift | 12 +++++----- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/CustomKeyboard.swift b/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/CustomKeyboard.swift index 96fc241a..08d32704 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/CustomKeyboard.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/CustomKeybaord/CustomKeyboard.swift @@ -131,23 +131,23 @@ extension CustardInterfaceKey { case let .system(value): switch value { case .changeKeyboard: - return FlickChangeKeyboardModel.shared + return FlickChangeKeyboardModel.shared case .enter: - return FlickEnterKeyModel() + return FlickEnterKeyModel() case .upperLower: - return FlickAaKeyModel() + return FlickAaKeyModel() case .nextCandidate: - return FlickNextCandidateKeyModel.shared + return FlickNextCandidateKeyModel.shared case .flickKogaki: - return FlickKogakiKeyModel.shared + return FlickKogakiKeyModel.shared case .flickKutoten: - return FlickKanaSymbolsKeyModel.shared + return FlickKanaSymbolsKeyModel.shared case .flickHiraTab: - return FlickTabKeyModel.hiraTabKeyModel() + return FlickTabKeyModel.hiraTabKeyModel() case .flickAbcTab: - return FlickTabKeyModel.abcTabKeyModel() + return FlickTabKeyModel.abcTabKeyModel() case .flickStar123Tab: - return FlickTabKeyModel.numberTabKeyModel() + return FlickTabKeyModel.numberTabKeyModel() } case let .custom(value): let flickKeyModels: [FlickDirection: FlickedKeyModel] = value.variations.reduce(into: [:]) {dictionary, variation in @@ -162,7 +162,7 @@ extension CustardInterfaceKey { break } } - let model = FlickKeyModel( + return FlickKeyModel( labelType: value.design.label.keyLabelType, pressActions: value.press_actions.map {$0.actionType}, longPressActions: value.longpress_actions.longpressActionType, @@ -170,7 +170,6 @@ extension CustardInterfaceKey { needSuggestView: value.longpress_actions == .none && !value.variations.isEmpty, keycolorType: value.design.color.flickKeyColorType ) - return model } } @@ -218,7 +217,7 @@ extension CustardInterfaceKey { } } - let model = QwertyKeyModel( + return QwertyKeyModel( labelType: value.design.label.keyLabelType, pressActions: value.press_actions.map {$0.actionType}, longPressActions: value.longpress_actions.longpressActionType, @@ -227,7 +226,6 @@ extension CustardInterfaceKey { needSuggestView: value.longpress_actions == .none, for: (1, 1) ) - return model } } diff --git a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/QwertyDataProvider.swift b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/QwertyDataProvider.swift index 743c7fa0..65d16308 100644 --- a/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/QwertyDataProvider.swift +++ b/AzooKeyCore/Sources/KeyboardViews/View/QwertyKeyboard/QwertyDataProvider.swift @@ -15,7 +15,7 @@ struct QwertyDataProvider { let languageKey: any QwertyKeyModelProtocol let first = preferredLanguage.first if let second = preferredLanguage.second { - languageKey = QwertySwitchLanguageKeyModel(rowInfo: rowInfo, languages: (first, second)) + languageKey = QwertySwitchLanguageKeyModel(rowInfo: rowInfo, languages: (first, second)) } else { let targetTab: TabData = { switch first { @@ -27,17 +27,17 @@ struct QwertyDataProvider { return .system(.user_japanese) } }() - languageKey = QwertyFunctionalKeyModel(labelType: .text(first.symbol), rowInfo: rowInfo, pressActions: [.moveTab(targetTab)], longPressActions: .none, needSuggestView: false) + languageKey = QwertyFunctionalKeyModel(labelType: .text(first.symbol), rowInfo: rowInfo, pressActions: [.moveTab(targetTab)], longPressActions: .none, needSuggestView: false) } - let numbersKey: any QwertyKeyModelProtocol = QwertyFunctionalKeyModel(labelType: .image("textformat.123"), rowInfo: rowInfo, pressActions: [.moveTab(.system(.qwerty_numbers))], longPressActions: .init(start: [.setTabBar(.toggle)])) - let symbolsKey: any QwertyKeyModelProtocol = QwertyFunctionalKeyModel(labelType: .text("#+="), rowInfo: rowInfo, pressActions: [.moveTab(.system(.qwerty_symbols))], longPressActions: .init(start: [.setTabBar(.toggle)])) + let numbersKey: any QwertyKeyModelProtocol = QwertyFunctionalKeyModel(labelType: .image("textformat.123"), rowInfo: rowInfo, pressActions: [.moveTab(.system(.qwerty_numbers))], longPressActions: .init(start: [.setTabBar(.toggle)])) + let symbolsKey: any QwertyKeyModelProtocol = QwertyFunctionalKeyModel(labelType: .text("#+="), rowInfo: rowInfo, pressActions: [.moveTab(.system(.qwerty_symbols))], longPressActions: .init(start: [.setTabBar(.toggle)])) let changeKeyboardKey: any QwertyKeyModelProtocol if let second = preferredLanguage.second { - changeKeyboardKey = QwertyChangeKeyboardKeyModel(keySizeType: .functional(normal: rowInfo.normal, functional: rowInfo.functional, enter: rowInfo.enter, space: rowInfo.space), fallBackType: .secondTab(secondLanguage: second)) + changeKeyboardKey = QwertyChangeKeyboardKeyModel(keySizeType: .functional(normal: rowInfo.normal, functional: rowInfo.functional, enter: rowInfo.enter, space: rowInfo.space), fallBackType: .secondTab(secondLanguage: second)) } else { - changeKeyboardKey = QwertyChangeKeyboardKeyModel(keySizeType: .functional(normal: rowInfo.normal, functional: rowInfo.functional, enter: rowInfo.enter, space: rowInfo.space), fallBackType: .tabBar) + changeKeyboardKey = QwertyChangeKeyboardKeyModel(keySizeType: .functional(normal: rowInfo.normal, functional: rowInfo.functional, enter: rowInfo.enter, space: rowInfo.space), fallBackType: .tabBar) } return ( languageKey: languageKey,