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

iOS TextField, interface SkikoUITextInputTraits (#749)

Rename interface to SkikoUITextInputTraits
Also added missing functions from https://developer.apple.com/documentation/uikit/uitextinputtraits?language=objc
parent f44fd6c4
......@@ -3,7 +3,7 @@ package org.jetbrains.skiko
import kotlinx.cinterop.*
import org.jetbrains.skia.Point
import org.jetbrains.skia.Rect
import org.jetbrains.skiko.ios.UIKitKeyboardOptions
import org.jetbrains.skiko.ios.SkikoUITextInputTraits
import platform.CoreGraphics.*
import platform.Foundation.*
import platform.UIKit.*
......@@ -31,7 +31,7 @@ class SkikoUIView : UIView, UIKeyInputProtocol, UITextInputProtocol,
private var skiaLayer: SkiaLayer? = null
private var _pointInside: (Point, UIEvent?) -> Boolean = { _, _ -> true }
private var _keyboardOptions: UIKitKeyboardOptions = object : UIKitKeyboardOptions {}
private var _skikoUITextInputTrains: SkikoUITextInputTraits = object : SkikoUITextInputTraits {}
private var _inputDelegate: UITextInputDelegateProtocol? = null
private var _currentTextMenuActions: TextActions? = null
......@@ -39,11 +39,11 @@ class SkikoUIView : UIView, UIKeyInputProtocol, UITextInputProtocol,
skiaLayer: SkiaLayer,
frame: CValue<CGRect> = CGRectNull.readValue(),
pointInside: (Point, UIEvent?) -> Boolean = {_,_-> true },
keyboardOptions: UIKitKeyboardOptions = object : UIKitKeyboardOptions {},
skikoUITextInputTrains: SkikoUITextInputTraits = object : SkikoUITextInputTraits {},
) : super(frame) {
this.skiaLayer = skiaLayer
_pointInside = pointInside
_keyboardOptions = keyboardOptions
_skikoUITextInputTrains = skikoUITextInputTrains
}
/**
......@@ -488,14 +488,14 @@ class SkikoUIView : UIView, UIKeyInputProtocol, UITextInputProtocol,
else -> false
}
override fun keyboardType(): UIKeyboardType = _keyboardOptions.keyboardType()
override fun keyboardAppearance(): UIKeyboardAppearance = _keyboardOptions.keyboardAppearance()
override fun returnKeyType(): UIReturnKeyType = _keyboardOptions.returnKeyType()
override fun textContentType(): UITextContentType? = _keyboardOptions.textContentType()
override fun isSecureTextEntry(): Boolean = _keyboardOptions.isSecureTextEntry()
override fun enablesReturnKeyAutomatically(): Boolean = _keyboardOptions.enablesReturnKeyAutomatically()
override fun autocapitalizationType(): UITextAutocapitalizationType = _keyboardOptions.autocapitalizationType()
override fun autocorrectionType(): UITextAutocorrectionType = _keyboardOptions.autocorrectionType()
override fun keyboardType(): UIKeyboardType = _skikoUITextInputTrains.keyboardType()
override fun keyboardAppearance(): UIKeyboardAppearance = _skikoUITextInputTrains.keyboardAppearance()
override fun returnKeyType(): UIReturnKeyType = _skikoUITextInputTrains.returnKeyType()
override fun textContentType(): UITextContentType? = _skikoUITextInputTrains.textContentType()
override fun isSecureTextEntry(): Boolean = _skikoUITextInputTrains.isSecureTextEntry()
override fun enablesReturnKeyAutomatically(): Boolean = _skikoUITextInputTrains.enablesReturnKeyAutomatically()
override fun autocapitalizationType(): UITextAutocapitalizationType = _skikoUITextInputTrains.autocapitalizationType()
override fun autocorrectionType(): UITextAutocorrectionType = _skikoUITextInputTrains.autocorrectionType()
override fun dictationRecognitionFailed() {
//todo may be useful
......
......@@ -3,10 +3,10 @@ package org.jetbrains.skiko.ios
import platform.UIKit.*
/**
* Represents a part of UITextInputTraits protocol. Needs to control onscreen keyboard features.
* @see https://developer.apple.com/documentation/uikit/uitextinputtraits?language=objc
*/
interface UIKitKeyboardOptions {
* Represents a part of UITextInputTraits protocol. Needs to control onscreen keyboard features.
* https://developer.apple.com/documentation/uikit/uitextinputtraits?language=objc
*/
interface SkikoUITextInputTraits {
fun keyboardType(): UIKeyboardType =
UIKeyboardTypeDefault
......@@ -32,4 +32,16 @@ interface UIKitKeyboardOptions {
fun autocorrectionType(): UITextAutocorrectionType =
UITextAutocorrectionType.UITextAutocorrectionTypeYes
fun spellCheckingType(): UITextSpellCheckingType =
UITextSpellCheckingType.UITextSpellCheckingTypeDefault
fun smartQuotesType(): UITextSmartQuotesType =
UITextSmartQuotesType.UITextSmartQuotesTypeDefault
fun smartDashesType(): UITextSmartDashesType =
UITextSmartDashesType.UITextSmartDashesTypeDefault
fun smartInsertDeleteType(): UITextSmartInsertDeleteType =
UITextSmartInsertDeleteType.UITextSmartInsertDeleteTypeDefault
}
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