Skip to content

Commit

Permalink
Merge pull request #358 from ensan-hcl/develop_iOS16
Browse files Browse the repository at this point in the history
[Refactoring] Minumum targetをiOS 16に更新
  • Loading branch information
ensan-hcl authored Nov 3, 2023
2 parents 57c7a05 + dd9a265 commit f310ed2
Show file tree
Hide file tree
Showing 51 changed files with 341 additions and 533 deletions.
2 changes: 1 addition & 1 deletion AzooKeyCore/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
31 changes: 3 additions & 28 deletions AzooKeyCore/Sources/AzooKeyUtils/AzooKeyMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ 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"

// 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
Expand All @@ -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
}
}
Expand All @@ -50,31 +50,6 @@ public enum AzooKeyMessageProvider: ApplicationSpecificKeyboardViewMessageProvid

public static var messages: [MessageData<MessageIdentifier>] {
[
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<MessageID>.checkDone(.iOS16_4_new_emoji, userDefaults: userDefaults) {
return true
}
return false
},
containerAppShouldMakeItDone: { false }
),
MessageData(
id: .iOS16_4_new_emoji,
title: "お知らせ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fileprivate extension CustardInterface {
}
}

@MainActor func flickKeyModels<Extension: ApplicationSpecificKeyboardViewExtension>(extension _: Extension.Type) -> [KeyPosition: (model: any FlickKeyModelProtocol, width: Int, height: Int)] {
@MainActor func flickKeyModels<Extension: ApplicationSpecificKeyboardViewExtension>(extension _: Extension.Type) -> [KeyPosition: (model: any FlickKeyModelProtocol<Extension>, width: Int, height: Int)] {
self.keys.reduce(into: [:]) {dictionary, value in
switch value.key {
case let .gridFit(data):
Expand All @@ -71,7 +71,7 @@ fileprivate extension CustardInterface {
}
}

@MainActor func qwertyKeyModels<Extension: ApplicationSpecificKeyboardViewExtension>(extension _: Extension.Type) -> [KeyPosition: (model: any QwertyKeyModelProtocol, sizeType: QwertyKeySizeType)] {
@MainActor func qwertyKeyModels<Extension: ApplicationSpecificKeyboardViewExtension>(extension _: Extension.Type) -> [KeyPosition: (model: any QwertyKeyModelProtocol<Extension>, sizeType: QwertyKeySizeType)] {
self.keys.reduce(into: [:]) {dictionary, value in
switch value.key {
case let .gridFit(data):
Expand Down Expand Up @@ -126,28 +126,28 @@ fileprivate extension CustardKeyDesign.ColorType {
}

extension CustardInterfaceKey {
@MainActor public func flickKeyModel<Extension: ApplicationSpecificKeyboardViewExtension>(extension _: Extension.Type) -> any FlickKeyModelProtocol {
@MainActor public func flickKeyModel<Extension: ApplicationSpecificKeyboardViewExtension>(extension _: Extension.Type) -> any FlickKeyModelProtocol<Extension> {
switch self {
case let .system(value):
switch value {
case .changeKeyboard:
return FlickChangeKeyboardModel<Extension>.shared
return FlickChangeKeyboardModel.shared
case .enter:
return FlickEnterKeyModel<Extension>()
return FlickEnterKeyModel()
case .upperLower:
return FlickAaKeyModel<Extension>()
return FlickAaKeyModel()
case .nextCandidate:
return FlickNextCandidateKeyModel<Extension>.shared
return FlickNextCandidateKeyModel.shared
case .flickKogaki:
return FlickKogakiKeyModel<Extension>.shared
return FlickKogakiKeyModel.shared
case .flickKutoten:
return FlickKanaSymbolsKeyModel<Extension>.shared
return FlickKanaSymbolsKeyModel.shared
case .flickHiraTab:
return FlickTabKeyModel<Extension>.hiraTabKeyModel()
return FlickTabKeyModel.hiraTabKeyModel()
case .flickAbcTab:
return FlickTabKeyModel<Extension>.abcTabKeyModel()
return FlickTabKeyModel.abcTabKeyModel()
case .flickStar123Tab:
return FlickTabKeyModel<Extension>.numberTabKeyModel()
return FlickTabKeyModel.numberTabKeyModel()
}
case let .custom(value):
let flickKeyModels: [FlickDirection: FlickedKeyModel] = value.variations.reduce(into: [:]) {dictionary, variation in
Expand All @@ -162,24 +162,23 @@ extension CustardInterfaceKey {
break
}
}
let model = FlickKeyModel<Extension>(
return FlickKeyModel(
labelType: value.design.label.keyLabelType,
pressActions: value.press_actions.map {$0.actionType},
longPressActions: value.longpress_actions.longpressActionType,
flickKeys: flickKeyModels,
needSuggestView: value.longpress_actions == .none && !value.variations.isEmpty,
keycolorType: value.design.color.flickKeyColorType
)
return model
}
}

private func convertToQwertyKeyModel<Extension: ApplicationSpecificKeyboardViewExtension>(customKey: KeyFlickSetting.SettingData, extension _: Extension.Type) -> any QwertyKeyModelProtocol {
private func convertToQwertyKeyModel<Extension: ApplicationSpecificKeyboardViewExtension>(customKey: KeyFlickSetting.SettingData, extension _: Extension.Type) -> any QwertyKeyModelProtocol<Extension> {
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<Extension>(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<Extension: ApplicationSpecificKeyboardViewExtension>(layout: CustardInterfaceLayout, extension: Extension.Type) -> any QwertyKeyModelProtocol {
@MainActor func qwertyKeyModel<Extension: ApplicationSpecificKeyboardViewExtension>(layout: CustardInterfaceLayout, extension: Extension.Type) -> any QwertyKeyModelProtocol<Extension> {
switch self {
case let .system(value):
switch value {
Expand All @@ -192,11 +191,11 @@ extension CustardInterfaceKey {
}
return changeKeyboardKey
case .enter:
return QwertyEnterKeyModel<Extension>(keySizeType: .enter)
return QwertyEnterKeyModel(keySizeType: .enter)
case .upperLower:
return QwertyAaKeyModel<Extension>()
return QwertyAaKeyModel()
case .nextCandidate:
return QwertyNextCandidateKeyModel<Extension>()
return QwertyNextCandidateKeyModel()
case .flickKogaki:
return convertToQwertyKeyModel(customKey: Extension.SettingProvider.koganaFlickCustomKey.compiled(), extension: Extension.self)
case .flickKutoten:
Expand All @@ -218,7 +217,7 @@ extension CustardInterfaceKey {
}
}

let model = QwertyKeyModel<Extension>(
return QwertyKeyModel(
labelType: value.design.label.keyLabelType,
pressActions: value.press_actions.map {$0.actionType},
longPressActions: value.longpress_actions.longpressActionType,
Expand All @@ -227,35 +226,34 @@ extension CustardInterfaceKey {
needSuggestView: value.longpress_actions == .none,
for: (1, 1)
)
return model
}
}

func simpleKeyModel<Extension: ApplicationSpecificKeyboardViewExtension>(extension _: Extension.Type) -> any SimpleKeyModelProtocol {
func simpleKeyModel<Extension: ApplicationSpecificKeyboardViewExtension>(extension _: Extension.Type) -> any SimpleKeyModelProtocol<Extension> {
switch self {
case let .system(value):
switch value {
case .changeKeyboard:
return SimpleChangeKeyboardKeyModel<Extension>()
return SimpleChangeKeyboardKeyModel()
case .enter:
return SimpleEnterKeyModel<Extension>()
return SimpleEnterKeyModel()
case .upperLower:
return SimpleKeyModel<Extension>(keyLabelType: .text("a/A"), unpressedKeyColorType: .special, pressActions: [.changeCharacterType])
return SimpleKeyModel(keyLabelType: .text("a/A"), unpressedKeyColorType: .special, pressActions: [.changeCharacterType])
case .nextCandidate:
return SimpleNextCandidateKeyModel<Extension>()
return SimpleNextCandidateKeyModel()
case .flickKogaki:
return SimpleKeyModel<Extension>(keyLabelType: .text("小゙゚"), unpressedKeyColorType: .special, pressActions: [.changeCharacterType])
return SimpleKeyModel(keyLabelType: .text("小゙゚"), unpressedKeyColorType: .special, pressActions: [.changeCharacterType])
case .flickKutoten:
return SimpleKeyModel<Extension>(keyLabelType: .text(""), unpressedKeyColorType: .normal, pressActions: [.input("")])
return SimpleKeyModel(keyLabelType: .text(""), unpressedKeyColorType: .normal, pressActions: [.input("")])
case .flickHiraTab:
return SimpleKeyModel<Extension>(keyLabelType: .text("あいう"), unpressedKeyColorType: .special, pressActions: [.moveTab(.system(.user_japanese))])
return SimpleKeyModel(keyLabelType: .text("あいう"), unpressedKeyColorType: .special, pressActions: [.moveTab(.system(.user_japanese))])
case .flickAbcTab:
return SimpleKeyModel<Extension>(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<Extension>(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<Extension>(
return SimpleKeyModel(
keyLabelType: value.design.label.keyLabelType,
unpressedKeyColorType: value.design.color.simpleKeyColorType,
pressActions: value.press_actions.map {$0.actionType},
Expand Down Expand Up @@ -337,7 +335,7 @@ struct CustomKeyboardView<Extension: ApplicationSpecificKeyboardViewExtension>:
public struct CustardFlickKeysView<Extension: ApplicationSpecificKeyboardViewExtension, Content: View>: View {
@State private var suggestState = FlickSuggestState()

public init(models: [KeyPosition: (model: any FlickKeyModelProtocol, width: Int, height: Int)], tabDesign: TabDependentDesign, layout: CustardInterfaceLayoutGridValue, blur: Bool = false, @ViewBuilder generator: @escaping (FlickKeyView<Extension>, Int, Int) -> (Content)) {
public init(models: [KeyPosition: (model: any FlickKeyModelProtocol<Extension>, width: Int, height: Int)], tabDesign: TabDependentDesign, layout: CustardInterfaceLayoutGridValue, blur: Bool = false, @ViewBuilder generator: @escaping (FlickKeyView<Extension>, Int, Int) -> (Content)) {
self.models = models
self.tabDesign = tabDesign
self.layout = layout
Expand All @@ -346,7 +344,7 @@ public struct CustardFlickKeysView<Extension: ApplicationSpecificKeyboardViewExt
}

private let contentGenerator: (FlickKeyView<Extension>, Int, Int) -> (Content)
private let models: [KeyPosition: (model: any FlickKeyModelProtocol, width: Int, height: Int)]
private let models: [KeyPosition: (model: any FlickKeyModelProtocol<Extension>, width: Int, height: Int)]
private let tabDesign: TabDependentDesign
private let layout: CustardInterfaceLayoutGridValue
private let blur: Bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ enum SimpleUnpressedKeyColorType: UInt8 {
}
}

protocol SimpleKeyModelProtocol {
protocol SimpleKeyModelProtocol<Extension> {
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<Extension: ApplicationSpecificKeyboardViewExtension>(width: CGFloat, states: VariableStates, theme: Extension.Theme) -> KeyLabel<Extension>
@MainActor func label(width: CGFloat, states: VariableStates) -> KeyLabel<Extension>
@MainActor func backGroundColorWhenPressed(theme: Extension.Theme) -> Color
/// `pressActions`とは別に、押された際に発火する操作
/// - note: タブ固有の事情で実行しなければならないような処理に利用すること
Expand Down Expand Up @@ -82,7 +82,7 @@ struct SimpleKeyModel<Extension: ApplicationSpecificKeyboardViewExtension>: Simp
private let pressActions: [ActionType]
let longPressActions: LongpressActionType

func label<E: ApplicationSpecificKeyboardViewExtension>(width: CGFloat, states: VariableStates, theme: ThemeData<some ApplicationSpecificTheme>) -> KeyLabel<E> {
func label(width: CGFloat, states: VariableStates) -> KeyLabel<Extension> {
KeyLabel(self.keyLabelType, width: width)
}

Expand Down Expand Up @@ -115,7 +115,7 @@ struct SimpleEnterKeyModel<Extension: ApplicationSpecificKeyboardViewExtension>:
}

let unpressedKeyColorType: SimpleUnpressedKeyColorType = .enter
func label<E: ApplicationSpecificKeyboardViewExtension>(width: CGFloat, states: VariableStates, theme: ThemeData<some ApplicationSpecificTheme>) -> KeyLabel<E> {
func label(width: CGFloat, states: VariableStates) -> KeyLabel<Extension> {
let text = Design.language.getEnterKeyText(states.enterKeyState)
return KeyLabel(.text(text), width: width)
}
Expand Down Expand Up @@ -148,7 +148,7 @@ struct SimpleNextCandidateKeyModel<Extension: ApplicationSpecificKeyboardViewExt
}
}

func label<E: ApplicationSpecificKeyboardViewExtension>(width: CGFloat, states: VariableStates, theme: ThemeData<some ApplicationSpecificTheme>) -> KeyLabel<E> {
func label(width: CGFloat, states: VariableStates) -> KeyLabel<Extension> {
if states.resultModel.results.isEmpty {
KeyLabel(.text("空白"), width: width)
} else {
Expand Down Expand Up @@ -181,7 +181,7 @@ struct SimpleChangeKeyboardKeyModel<Extension: ApplicationSpecificKeyboardViewEx
.none
}

func label<E: ApplicationSpecificKeyboardViewExtension>(width: CGFloat, states: VariableStates, theme: ThemeData<some ApplicationSpecificTheme>) -> KeyLabel<E> {
func label(width: CGFloat, states: VariableStates) -> KeyLabel<Extension> {
if SemiStaticStates.shared.needsInputModeSwitchKey {
return KeyLabel(.changeKeyboard, width: width)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ import SwiftUIUtils

@MainActor
struct SimpleKeyView<Extension: ApplicationSpecificKeyboardViewExtension>: View {
private let model: any SimpleKeyModelProtocol
private let model: any SimpleKeyModelProtocol<Extension>
@EnvironmentObject private var variableStates: VariableStates
@Environment(Extension.Theme.self) private var theme
@Environment(\.userActionManager) private var action

private let keyViewWidth: CGFloat
private let keyViewHeight: CGFloat

init(model: any SimpleKeyModelProtocol, tabDesign: TabDependentDesign) {
init(model: any SimpleKeyModelProtocol<Extension>, 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<Extension>, width: CGFloat, height: CGFloat) {
self.model = model
self.keyViewWidth = width
self.keyViewHeight = height
Expand All @@ -36,7 +36,7 @@ struct SimpleKeyView<Extension: ApplicationSpecificKeyboardViewExtension>: View
@State private var pressStartDate = Date()

private func label(width: CGFloat) -> some View {
model.label(width: keyViewWidth, states: variableStates, theme: theme) as KeyLabel<Extension>
model.label(width: keyViewWidth, states: variableStates)
}

var body: some View {
Expand Down
Loading

0 comments on commit f310ed2

Please sign in to comment.