Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.thelightphone.sdk.ui.LightThemeTokens
data class EditorRequest(
val title: String,
val initialValue: String,
val initialCaps: Boolean = false,
)

class UiDemoTextInputEditorScreen(
Expand All @@ -37,6 +38,7 @@ class UiDemoTextInputEditorScreen(
onSubmit = { result -> goBack(result.toString()) },
onBack = { goBack(null) },
modifier = Modifier.background(LightThemeTokens.colors.background),
initialCaps = editorRequest.initialCaps,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ class UiDemoTextInputScreen(sealedActivity: SealedLightActivity) :
value = nameValue,
placeholder = "Your name",
onClick = {
val editorRequest = EditorRequest(title = "Name", initialValue = nameValue)
val editorRequest = EditorRequest(
title = "Name",
initialValue = nameValue,
initialCaps = nameValue.isBlank(),
)
navigateTo(
screenFactory = { UiDemoTextInputEditorScreen(it, editorRequest) },
resultCallback = { viewModel.setName(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ fun LightTextInputEditor(
submitIcon: LightIconConfiguration? = null,
showBackButton: Boolean = true,
singleLine: Boolean = false,
initialCaps: Boolean = false,
editorKey: Any = remember { Any() },
) {
val currentOnSubmit by rememberUpdatedState(onSubmit)
Expand All @@ -74,7 +75,7 @@ fun LightTextInputEditor(

val keyboardViewModel: Lp3KeyboardViewModel<*> = viewModel<EnQwertyLp3KeyboardViewModel<*>>(
key = "LightTextInputEditor-$editorKey",
factory = factory(keyboardCallback, keyboardOptionsFlow),
factory = factory(keyboardCallback, keyboardOptionsFlow, initialCaps),
)

LightTextInputEditor(
Expand Down Expand Up @@ -215,7 +216,8 @@ fun LightTextInputEditor(

private fun factory(
callback: Lp3RepeatableKeyboardCallback,
keyboardOptionsFlow: StateFlow<KeyboardOptions>
keyboardOptionsFlow: StateFlow<KeyboardOptions>,
initialCaps: Boolean,
): ViewModelProvider.Factory =
object : ViewModelProvider.Factory {
@Suppress("UNCHECKED_CAST")
Expand All @@ -227,7 +229,9 @@ private fun factory(
val showCloseButton = !it.isRootLayout
LayoutOptions(showCloseButton)
},
) as T
).apply {
if (initialCaps) setCapsMode(true)
} as T
}

}
Expand Down
Loading