Unverified Commit ff9ecbc2 authored by dima.avdeev's avatar dima.avdeev Committed by GitHub

iOS TextField add keyboard options (#743)

* iOS TextField add keyboard options
* Simplify lateinit vars
parent 52c586f9
...@@ -20,33 +20,33 @@ build configuration. ...@@ -20,33 +20,33 @@ build configuration.
## Publishing ## Publishing
##### Publish JVM target to Maven local ##### Publish JVM target to Maven local
``` ```bash
./gradlew publishToMavenLocal ./gradlew publishToMavenLocal
``` ```
##### Publish all targets to Maven Local ##### Publish all targets to Maven Local
``` ```bash
./gradlew publishToMavenLocal -Pskiko.native.enabled=true -Pskiko.wasm.enabled=true -Pskiko.android.enabled=true ./gradlew publishToMavenLocal -Pskiko.native.enabled=true -Pskiko.wasm.enabled=true -Pskiko.android.enabled=true
``` ```
##### Publish to `build/repo` directory ##### Publish to `build/repo` directory
``` ```bash
./gradlew publishToBuildRepo ./gradlew publishToBuildRepo
``` ```
##### Publish to Compose repo ##### Publish to Compose repo
Set up environment variables `COMPOSE_REPO_USERNAME` and `COMPOSE_REPO_KEY`. Set up environment variables `COMPOSE_REPO_USERNAME` and `COMPOSE_REPO_KEY`.
``` ```bash
./gradlew publishToComposeRepo ./gradlew publishToComposeRepo
``` ```
##### Publish to all repositories ##### Publish to all repositories
``` ```bash
./gradlew publish ./gradlew publish
``` ```
##### Publish local version ##### Publish local version
``` ```bash
./gradlew <PUBLISH_TASK> -Pdeploy.version=0.2.0 -Pdeploy.release=true ./gradlew <PUBLISH_TASK> -Pdeploy.version=0.2.0 -Pdeploy.release=true
``` ```
...@@ -54,7 +54,7 @@ Set up environment variables `COMPOSE_REPO_USERNAME` and `COMPOSE_REPO_KEY`. ...@@ -54,7 +54,7 @@ Set up environment variables `COMPOSE_REPO_USERNAME` and `COMPOSE_REPO_KEY`.
macOS for Apple Silicon builds aimed for distribution require mandatory code signing, macOS for Apple Silicon builds aimed for distribution require mandatory code signing,
so use command like so use command like
``` ```bash
./gradlew -Psigner="Apple Distribution: Nikolay Igotti (N462MKSJ7M)" <PUBLISH_TASK> ./gradlew -Psigner="Apple Distribution: Nikolay Igotti (N462MKSJ7M)" <PUBLISH_TASK>
``` ```
to codesign the JNI library. to codesign the JNI library.
......
...@@ -3,6 +3,7 @@ package org.jetbrains.skiko ...@@ -3,6 +3,7 @@ package org.jetbrains.skiko
import kotlinx.cinterop.* import kotlinx.cinterop.*
import org.jetbrains.skia.Point import org.jetbrains.skia.Point
import org.jetbrains.skia.Rect import org.jetbrains.skia.Rect
import org.jetbrains.skiko.ios.UIKitKeyboardOptions
import platform.CoreGraphics.* import platform.CoreGraphics.*
import platform.Foundation.* import platform.Foundation.*
import platform.UIKit.* import platform.UIKit.*
...@@ -29,25 +30,20 @@ class SkikoUIView : UIView, UIKeyInputProtocol, UITextInputProtocol, ...@@ -29,25 +30,20 @@ class SkikoUIView : UIView, UIKeyInputProtocol, UITextInputProtocol,
} }
private var skiaLayer: SkiaLayer? = null private var skiaLayer: SkiaLayer? = null
private lateinit var _pointInside: (Point, UIEvent?) -> Boolean private var _pointInside: (Point, UIEvent?) -> Boolean = { _, _ -> true }
private var _keyboardOptions: UIKitKeyboardOptions = object : UIKitKeyboardOptions {}
private var _inputDelegate: UITextInputDelegateProtocol? = null private var _inputDelegate: UITextInputDelegateProtocol? = null
private var _currentTextMenuActions: TextActions? = null private var _currentTextMenuActions: TextActions? = null
var currentKeyboardType: UIKeyboardType = UIKeyboardTypeDefault
var currentKeyboardAppearance: UIKeyboardAppearance = UIKeyboardAppearanceDefault
var currentReturnKeyType: UIReturnKeyType = UIReturnKeyType.UIReturnKeyDefault
var currentTextContentType: UITextContentType? = null
var currentIsSecureTextEntry: Boolean = false
var currentEnablesReturnKeyAutomatically: Boolean = false
var currentAutocapitalizationType: UITextAutocapitalizationType = UITextAutocapitalizationType.UITextAutocapitalizationTypeSentences
var currentAutocorrectionType: UITextAutocorrectionType = UITextAutocorrectionType.UITextAutocorrectionTypeYes
constructor( constructor(
skiaLayer: SkiaLayer, skiaLayer: SkiaLayer,
frame: CValue<CGRect> = CGRectNull.readValue(), frame: CValue<CGRect> = CGRectNull.readValue(),
pointInside: (Point, UIEvent?) -> Boolean = {_,_-> true } pointInside: (Point, UIEvent?) -> Boolean = {_,_-> true },
keyboardOptions: UIKitKeyboardOptions = object : UIKitKeyboardOptions {},
) : super(frame) { ) : super(frame) {
this.skiaLayer = skiaLayer this.skiaLayer = skiaLayer
_pointInside = pointInside _pointInside = pointInside
_keyboardOptions = keyboardOptions
} }
/** /**
...@@ -492,37 +488,14 @@ class SkikoUIView : UIView, UIKeyInputProtocol, UITextInputProtocol, ...@@ -492,37 +488,14 @@ class SkikoUIView : UIView, UIKeyInputProtocol, UITextInputProtocol,
else -> false else -> false
} }
override fun keyboardType(): UIKeyboardType { override fun keyboardType(): UIKeyboardType = _keyboardOptions.keyboardType()
return currentKeyboardType override fun keyboardAppearance(): UIKeyboardAppearance = _keyboardOptions.keyboardAppearance()
} override fun returnKeyType(): UIReturnKeyType = _keyboardOptions.returnKeyType()
override fun textContentType(): UITextContentType? = _keyboardOptions.textContentType()
override fun keyboardAppearance(): UIKeyboardAppearance { override fun isSecureTextEntry(): Boolean = _keyboardOptions.isSecureTextEntry()
return currentKeyboardAppearance override fun enablesReturnKeyAutomatically(): Boolean = _keyboardOptions.enablesReturnKeyAutomatically()
} override fun autocapitalizationType(): UITextAutocapitalizationType = _keyboardOptions.autocapitalizationType()
override fun autocorrectionType(): UITextAutocorrectionType = _keyboardOptions.autocorrectionType()
override fun returnKeyType(): UIReturnKeyType {
return currentReturnKeyType
}
override fun textContentType(): UITextContentType? {
return currentTextContentType
}
override fun isSecureTextEntry(): Boolean {
return currentIsSecureTextEntry //todo secure text to prevent copy
}
override fun enablesReturnKeyAutomatically(): Boolean {
return currentEnablesReturnKeyAutomatically
}
override fun autocapitalizationType(): UITextAutocapitalizationType {
return currentAutocapitalizationType
}
override fun autocorrectionType(): UITextAutocorrectionType {
return currentAutocorrectionType
}
override fun dictationRecognitionFailed() { override fun dictationRecognitionFailed() {
//todo may be useful //todo may be useful
......
package org.jetbrains.skiko.ios
import platform.UIKit.*
interface UIKitKeyboardOptions {
fun keyboardType(): UIKeyboardType =
UIKeyboardTypeDefault
fun keyboardAppearance(): UIKeyboardAppearance =
UIKeyboardAppearanceDefault
fun returnKeyType(): UIReturnKeyType =
UIReturnKeyType.UIReturnKeyDefault
fun textContentType(): UITextContentType? =
null
fun isSecureTextEntry(): Boolean =
false
fun enablesReturnKeyAutomatically(): Boolean =
false
fun autocapitalizationType(): UITextAutocapitalizationType =
UITextAutocapitalizationType.UITextAutocapitalizationTypeSentences
fun autocorrectionType(): UITextAutocorrectionType =
UITextAutocorrectionType.UITextAutocorrectionTypeYes
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment