forked from androidx/androidx
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iOS SingleLayerComposeScene with feature flag
- Loading branch information
1 parent
9c83148
commit 76cfbe7
Showing
21 changed files
with
2,502 additions
and
1,533 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...e/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/platform/IOSPlatformContextImpl.uikit.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2023 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package androidx.compose.ui.platform | ||
|
||
import androidx.compose.ui.input.InputMode | ||
import androidx.compose.ui.text.input.PlatformTextInputService | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.window.DensityProvider | ||
|
||
internal class IOSPlatformContextImpl( | ||
inputServices: PlatformTextInputService, | ||
override val textToolbar: TextToolbar, | ||
override val windowInfo: WindowInfo, | ||
densityProvider: DensityProvider, | ||
) : PlatformContext by PlatformContext.Empty { | ||
override val textInputService: PlatformTextInputService = inputServices | ||
override val viewConfiguration = object : ViewConfiguration by EmptyViewConfiguration { | ||
override val touchSlop: Float | ||
get() = with(densityProvider()) { | ||
// this value is originating from iOS 16 drag behavior reverse engineering | ||
10.dp.toPx() | ||
} | ||
} | ||
override val inputModeManager = DefaultInputModeManager(InputMode.Touch) | ||
} |
File renamed without changes.
69 changes: 0 additions & 69 deletions
69
compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/platform/SkikoUITextInputTraits.kt
This file was deleted.
Oops, something went wrong.
156 changes: 156 additions & 0 deletions
156
...e/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/platform/SkikoUITextInputTraits.uikit.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
/* | ||
* Copyright 2023 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package androidx.compose.ui.platform | ||
|
||
import androidx.compose.ui.text.input.ImeAction | ||
import androidx.compose.ui.text.input.ImeOptions | ||
import androidx.compose.ui.text.input.KeyboardCapitalization | ||
import androidx.compose.ui.text.input.KeyboardType | ||
import platform.UIKit.UIKeyboardAppearance | ||
import platform.UIKit.UIKeyboardAppearanceDefault | ||
import platform.UIKit.UIKeyboardType | ||
import platform.UIKit.UIKeyboardTypeASCIICapable | ||
import platform.UIKit.UIKeyboardTypeDecimalPad | ||
import platform.UIKit.UIKeyboardTypeDefault | ||
import platform.UIKit.UIKeyboardTypeEmailAddress | ||
import platform.UIKit.UIKeyboardTypeNumberPad | ||
import platform.UIKit.UIKeyboardTypePhonePad | ||
import platform.UIKit.UIKeyboardTypeURL | ||
import platform.UIKit.UIReturnKeyType | ||
import platform.UIKit.UITextAutocapitalizationType | ||
import platform.UIKit.UITextAutocorrectionType | ||
import platform.UIKit.UITextContentType | ||
import platform.UIKit.UITextContentTypeEmailAddress | ||
import platform.UIKit.UITextContentTypePassword | ||
import platform.UIKit.UITextContentTypeTelephoneNumber | ||
import platform.UIKit.UITextSmartDashesType | ||
import platform.UIKit.UITextSmartInsertDeleteType | ||
import platform.UIKit.UITextSmartQuotesType | ||
import platform.UIKit.UITextSpellCheckingType | ||
|
||
internal interface SkikoUITextInputTraits { | ||
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 | ||
|
||
fun spellCheckingType(): UITextSpellCheckingType = | ||
UITextSpellCheckingType.UITextSpellCheckingTypeDefault | ||
|
||
fun smartQuotesType(): UITextSmartQuotesType = | ||
UITextSmartQuotesType.UITextSmartQuotesTypeDefault | ||
|
||
fun smartDashesType(): UITextSmartDashesType = | ||
UITextSmartDashesType.UITextSmartDashesTypeDefault | ||
|
||
fun smartInsertDeleteType(): UITextSmartInsertDeleteType = | ||
UITextSmartInsertDeleteType.UITextSmartInsertDeleteTypeDefault | ||
|
||
} | ||
|
||
internal fun getUITextInputTraits(currentImeOptions: ImeOptions?) = | ||
object : SkikoUITextInputTraits { | ||
override fun keyboardType(): UIKeyboardType = | ||
when (currentImeOptions?.keyboardType) { | ||
KeyboardType.Text -> UIKeyboardTypeDefault | ||
KeyboardType.Ascii -> UIKeyboardTypeASCIICapable | ||
KeyboardType.Number -> UIKeyboardTypeNumberPad | ||
KeyboardType.Phone -> UIKeyboardTypePhonePad | ||
KeyboardType.Uri -> UIKeyboardTypeURL | ||
KeyboardType.Email -> UIKeyboardTypeEmailAddress | ||
KeyboardType.Password -> UIKeyboardTypeASCIICapable // TODO Correct? | ||
KeyboardType.NumberPassword -> UIKeyboardTypeNumberPad // TODO Correct? | ||
KeyboardType.Decimal -> UIKeyboardTypeDecimalPad | ||
else -> UIKeyboardTypeDefault | ||
} | ||
|
||
override fun keyboardAppearance(): UIKeyboardAppearance = UIKeyboardAppearanceDefault | ||
override fun returnKeyType(): UIReturnKeyType = | ||
when (currentImeOptions?.imeAction) { | ||
ImeAction.Default -> UIReturnKeyType.UIReturnKeyDefault | ||
ImeAction.None -> UIReturnKeyType.UIReturnKeyDefault | ||
ImeAction.Go -> UIReturnKeyType.UIReturnKeyGo | ||
ImeAction.Search -> UIReturnKeyType.UIReturnKeySearch | ||
ImeAction.Send -> UIReturnKeyType.UIReturnKeySend | ||
ImeAction.Previous -> UIReturnKeyType.UIReturnKeyDefault | ||
ImeAction.Next -> UIReturnKeyType.UIReturnKeyNext | ||
ImeAction.Done -> UIReturnKeyType.UIReturnKeyDone | ||
else -> UIReturnKeyType.UIReturnKeyDefault | ||
} | ||
|
||
override fun textContentType(): UITextContentType? = | ||
when (currentImeOptions?.keyboardType) { | ||
KeyboardType.Password, KeyboardType.NumberPassword -> UITextContentTypePassword | ||
KeyboardType.Email -> UITextContentTypeEmailAddress | ||
KeyboardType.Phone -> UITextContentTypeTelephoneNumber | ||
else -> null | ||
} | ||
|
||
override fun isSecureTextEntry(): Boolean = | ||
when (currentImeOptions?.keyboardType) { | ||
KeyboardType.Password, KeyboardType.NumberPassword -> true | ||
else -> false | ||
} | ||
|
||
override fun enablesReturnKeyAutomatically(): Boolean = false | ||
|
||
override fun autocapitalizationType(): UITextAutocapitalizationType = | ||
when (currentImeOptions?.capitalization) { | ||
KeyboardCapitalization.None -> | ||
UITextAutocapitalizationType.UITextAutocapitalizationTypeNone | ||
|
||
KeyboardCapitalization.Characters -> | ||
UITextAutocapitalizationType.UITextAutocapitalizationTypeAllCharacters | ||
|
||
KeyboardCapitalization.Words -> | ||
UITextAutocapitalizationType.UITextAutocapitalizationTypeWords | ||
|
||
KeyboardCapitalization.Sentences -> | ||
UITextAutocapitalizationType.UITextAutocapitalizationTypeSentences | ||
|
||
else -> | ||
UITextAutocapitalizationType.UITextAutocapitalizationTypeNone | ||
} | ||
|
||
override fun autocorrectionType(): UITextAutocorrectionType = | ||
when (currentImeOptions?.autoCorrect) { | ||
true -> UITextAutocorrectionType.UITextAutocorrectionTypeYes | ||
false -> UITextAutocorrectionType.UITextAutocorrectionTypeNo | ||
else -> UITextAutocorrectionType.UITextAutocorrectionTypeDefault | ||
} | ||
|
||
} | ||
|
File renamed without changes.
Oops, something went wrong.