Skip to content

Commit

Permalink
Merge pull request #436 from ensan-hcl/fix/swift_5.10
Browse files Browse the repository at this point in the history
[Fix] Swift 5.10のビルドエラーを解消
  • Loading branch information
ensan-hcl committed Mar 6, 2024
2 parents d6cffae + 7a578a0 commit 8913c75
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ protocol Savable {
}

@propertyWrapper
@MainActor
public struct KeyboardSetting<T: KeyboardSettingKey> {
public init(_ key: T) {}
public var wrappedValue: T.Value {
@MainActor public var wrappedValue: T.Value {
get {
T.value
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SwiftUtils
import UIKit

/// UI側の入力中のテキストの更新を受け持つクラス
@MainActor final public class DisplayedTextManager {
final public class DisplayedTextManager {
public init(isLiveConversionEnabled: Bool, isMarkedTextEnabled: Bool) {
self.isLiveConversionEnabled = isLiveConversionEnabled
self.isMarkedTextEnabled = isMarkedTextEnabled
Expand Down Expand Up @@ -61,15 +61,15 @@ import UIKit
}
}

public var documentContextAfterInput: String? {
@MainActor public var documentContextAfterInput: String? {
self.proxy?.documentContextAfterInput
}

public var selectedText: String? {
@MainActor public var selectedText: String? {
self.proxy?.selectedText
}

public var documentContextBeforeInput: String? {
@MainActor public var documentContextBeforeInput: String? {
self.proxy?.documentContextBeforeInput
}

Expand Down Expand Up @@ -101,7 +101,7 @@ import UIKit
}

/// カーソルを何カウント分動かせばいいか計算する
private func getActualOffset(count: Int) -> Int {
@MainActor private func getActualOffset(count: Int) -> Int {
if count == 0 {
return 0
} else if count > 0 {
Expand All @@ -127,13 +127,13 @@ import UIKit

/// MarkedTextを更新する関数
/// この関数自体はisMarkedTextEnabledのチェックを行わない。
private func updateMarkedText() {
@MainActor private func updateMarkedText() {
let text = self.displayedLiveConversionText ?? self.composingText.convertTarget
let cursorPosition = self.displayedLiveConversionText.map(NSString.init(string:))?.length ?? NSString(string: String(self.composingText.convertTarget.prefix(self.composingText.convertTargetCursorPosition))).length
self.proxy?.setMarkedText(text, selectedRange: NSRange(location: cursorPosition, length: 0))
}

public func insertText(_ text: String) {
@MainActor public func insertText(_ text: String) {
guard !text.isEmpty else {
return
}
Expand All @@ -142,15 +142,15 @@ import UIKit
}

/// In-Keyboard TextFiledが用いられていても、そちらではない方に強制的に入力を行う関数
public func insertMainDisplayText(_ text: String) {
@MainActor public func insertMainDisplayText(_ text: String) {
guard !text.isEmpty else {
return
}
self.displayedTextProxy?.insertText(text)
self.textChangedCount += 1
}

public func moveCursor(count: Int) {
@MainActor public func moveCursor(count: Int) {
guard count != 0 else {
return
}
Expand All @@ -160,7 +160,7 @@ import UIKit
}

// ただ与えられた回数の削除を実行する関数
private func rawDeleteBackward(count: Int = 1) {
@MainActor private func rawDeleteBackward(count: Int = 1) {
guard count != 0 else {
return
}
Expand All @@ -172,7 +172,7 @@ import UIKit

// isComposingの場合、countはadjust済みであることを期待する
// されていなかった場合は例外を投げる
public func deleteBackward(count: Int) {
@MainActor public func deleteBackward(count: Int) {
if count == 0 {
return
}
Expand All @@ -186,7 +186,7 @@ import UIKit
// ただ与えられた回数の削除を入力方向に実行する関数
// カーソルが動かせない場合を検知するために工夫を入れている
// TODO: iOS16以降のテキストフィールドの仕様変更で動かなくなっている。直す必要があるが、どうしようもない気がしている。
private func rawDeleteForward(count: Int) {
@MainActor private func rawDeleteForward(count: Int) {
guard count != 0 else {
return
}
Expand All @@ -205,7 +205,7 @@ import UIKit

// isComposingの場合、countはadjust済みであることを期待する
// されていなかった場合は例外を投げる
public func deleteForward(count: Int = 1) {
@MainActor public func deleteForward(count: Int = 1) {
if count == 0 {
return
}
Expand All @@ -217,7 +217,7 @@ import UIKit
}

/// `composingText`を更新する
public func updateComposingText(composingText: ComposingText, newLiveConversionText: String?) {
@MainActor public func updateComposingText(composingText: ComposingText, newLiveConversionText: String?) {
if isMarkedTextEnabled {
self.composingText = composingText
self.displayedLiveConversionText = newLiveConversionText
Expand All @@ -244,7 +244,7 @@ import UIKit
}
}

public func updateComposingText(composingText: ComposingText, userMovedCount: Int, adjustedMovedCount: Int) -> Bool {
@MainActor public func updateComposingText(composingText: ComposingText, userMovedCount: Int, adjustedMovedCount: Int) -> Bool {
let delta = adjustedMovedCount - userMovedCount
self.composingText = composingText
if delta != 0 {
Expand All @@ -255,7 +255,7 @@ import UIKit
return false
}

public func updateComposingText(composingText: ComposingText, completedPrefix: String, isSelected: Bool) {
@MainActor public func updateComposingText(composingText: ComposingText, completedPrefix: String, isSelected: Bool) {
if isMarkedTextEnabled {
self.insertText(completedPrefix)
self.composingText = composingText
Expand Down
4 changes: 2 additions & 2 deletions AzooKeyCore/Sources/KeyboardViews/SemiStaticStates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import class CoreHaptics.CHHapticEngine

/// 実行しないと値が確定しないが、実行されれば全く変更されない値。収容アプリでも共有できる形にすること。
public final class SemiStaticStates {
public static let shared = SemiStaticStates()
private init() {}
@MainActor public static let shared = SemiStaticStates()
@MainActor private init() {}

// MARK: 端末依存の値
@MainActor private(set) public lazy var needsInputModeSwitchKey = {
Expand Down
1 change: 0 additions & 1 deletion AzooKeyCore/Sources/KeyboardViews/UserActionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import SwiftUI
import KeyboardExtensionUtils

/// キーボードの操作を管理するためのクラス
/// - finalにはできない
open class UserActionManager {
public init() {}
@MainActor open func registerAction(_ action: ActionType, variableStates: VariableStates) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public extension View {
struct MessageEnvironmentKey: EnvironmentKey {
typealias Value = Bool

static var defaultValue = true
static let defaultValue = true
}

public extension EnvironmentValues {
Expand All @@ -64,7 +64,7 @@ public extension EnvironmentValues {
struct UserActionManagerEnvironmentKey: EnvironmentKey {
typealias Value = UserActionManager

static var defaultValue = UserActionManager()
static let defaultValue = UserActionManager()
}

public extension EnvironmentValues {
Expand Down
Loading

0 comments on commit 8913c75

Please sign in to comment.