secant-android-wallet/ui-design-lib/src/main/java/co/electriccoin/zcash/ui/design/component/TextField.kt

63 lines
2.2 KiB
Kotlin
Raw Normal View History

package co.electriccoin.zcash.ui.design.component
import androidx.compose.foundation.border
[#808] Use Dimens Across App * [#808] Use Dimens across the app - Shorter Onboarding screen design enhanced * Shorter New Wallet Backup screen UI enhanced * Home screen UI enhance * Seed screen UI enhance * Link SendArgumentsWrapper issue * Move custom buttons paddings to PaddingValues - Optional Modifier parameter should have a default value of Modifier - Thanks to this we introduced the outerPaddingValues parameter to all our buttons with default paddings - Also notice the difference between e.g. ShortOnboardingView and ShortNewWalletBackupView. In the backup, we have the bottom button to be part of Scaffold’s bottomBar, which is maybe a better pattern than stretching the buttons with spacers in case of part of the screen content view, but it has also its tradeoffs. * Settings screen enhance * Support screen UI enhance * About screen UI enhance * Scan screen UI enhance - Move modifiers to the caller’s side - Match texts to predefined styles - Add color to Small text component + reorder parameters * Send screen UI enahnce - Lifted out some modifiers arguments to the caller’s side - Fixed button’s horizontal paddings * Scan move BackHandler to Android class * Update screen UI enhance * Receive screen UI enhance * Address screen UI enhance * Ignore AndroidUpdate back action test - Will be refactored soon * Remove TODO as already implemented * Restore screens UI enhance * Create UpdateViewAndroidTest * [#807][Design system] Remove deprecated Paddings * [#705] Instrumentation coverage generation fails locally * [#808] Use Dimens across the app - Shorter Onboarding screen design enhanced * Shorter New Wallet Backup screen UI enhanced * Home screen UI enhance * Seed screen UI enhance * Link SendArgumentsWrapper issue * Move custom buttons paddings to PaddingValues - Optional Modifier parameter should have a default value of Modifier - Thanks to this we introduced the outerPaddingValues parameter to all our buttons with default paddings - Also notice the difference between e.g. ShortOnboardingView and ShortNewWalletBackupView. In the backup, we have the bottom button to be part of Scaffold’s bottomBar, which is maybe a better pattern than stretching the buttons with spacers in case of part of the screen content view, but it has also its tradeoffs. * Settings screen enhance * Support screen UI enhance * About screen UI enhance * Scan screen UI enhance - Move modifiers to the caller’s side - Match texts to predefined styles - Add color to Small text component + reorder parameters * Send screen UI enahnce - Lifted out some modifiers arguments to the caller’s side - Fixed button’s horizontal paddings * Scan move BackHandler to Android class * Update screen UI enhance * Receive screen UI enhance * Address screen UI enhance * Ignore AndroidUpdate back action test - Will be refactored soon * Remove TODO as already implemented * Restore screens UI enhance * Create UpdateViewAndroidTest * [#807][Design system] Remove deprecated Paddings * Address review comments
2023-04-04 05:21:18 -07:00
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.TextField
import androidx.compose.material3.TextFieldColors
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
[#808] Use Dimens Across App * [#808] Use Dimens across the app - Shorter Onboarding screen design enhanced * Shorter New Wallet Backup screen UI enhanced * Home screen UI enhance * Seed screen UI enhance * Link SendArgumentsWrapper issue * Move custom buttons paddings to PaddingValues - Optional Modifier parameter should have a default value of Modifier - Thanks to this we introduced the outerPaddingValues parameter to all our buttons with default paddings - Also notice the difference between e.g. ShortOnboardingView and ShortNewWalletBackupView. In the backup, we have the bottom button to be part of Scaffold’s bottomBar, which is maybe a better pattern than stretching the buttons with spacers in case of part of the screen content view, but it has also its tradeoffs. * Settings screen enhance * Support screen UI enhance * About screen UI enhance * Scan screen UI enhance - Move modifiers to the caller’s side - Match texts to predefined styles - Add color to Small text component + reorder parameters * Send screen UI enahnce - Lifted out some modifiers arguments to the caller’s side - Fixed button’s horizontal paddings * Scan move BackHandler to Android class * Update screen UI enhance * Receive screen UI enhance * Address screen UI enhance * Ignore AndroidUpdate back action test - Will be refactored soon * Remove TODO as already implemented * Restore screens UI enhance * Create UpdateViewAndroidTest * [#807][Design system] Remove deprecated Paddings * [#705] Instrumentation coverage generation fails locally * [#808] Use Dimens across the app - Shorter Onboarding screen design enhanced * Shorter New Wallet Backup screen UI enhanced * Home screen UI enhance * Seed screen UI enhance * Link SendArgumentsWrapper issue * Move custom buttons paddings to PaddingValues - Optional Modifier parameter should have a default value of Modifier - Thanks to this we introduced the outerPaddingValues parameter to all our buttons with default paddings - Also notice the difference between e.g. ShortOnboardingView and ShortNewWalletBackupView. In the backup, we have the bottom button to be part of Scaffold’s bottomBar, which is maybe a better pattern than stretching the buttons with spacers in case of part of the screen content view, but it has also its tradeoffs. * Settings screen enhance * Support screen UI enhance * About screen UI enhance * Scan screen UI enhance - Move modifiers to the caller’s side - Match texts to predefined styles - Add color to Small text component + reorder parameters * Send screen UI enahnce - Lifted out some modifiers arguments to the caller’s side - Fixed button’s horizontal paddings * Scan move BackHandler to Android class * Update screen UI enhance * Receive screen UI enhance * Address screen UI enhance * Ignore AndroidUpdate back action test - Will be refactored soon * Remove TODO as already implemented * Restore screens UI enhance * Create UpdateViewAndroidTest * [#807][Design system] Remove deprecated Paddings * Address review comments
2023-04-04 05:21:18 -07:00
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.unit.dp
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
@Suppress("LongParameterList")
@Composable
fun FormTextField(
value: String,
onValueChange: (String) -> Unit,
modifier: Modifier = Modifier,
textStyle: TextStyle = ZcashTheme.extendedTypography.textFieldValue,
label: @Composable (() -> Unit)? = null,
leadingIcon: @Composable (() -> Unit)? = null,
trailingIcon: @Composable (() -> Unit)? = null,
keyboardOptions: KeyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
colors: TextFieldColors =
TextFieldDefaults.colors(
focusedContainerColor = Color.Transparent,
unfocusedContainerColor = Color.Transparent,
disabledContainerColor = Color.Transparent,
errorContainerColor = Color.Transparent,
),
[#808] Use Dimens Across App * [#808] Use Dimens across the app - Shorter Onboarding screen design enhanced * Shorter New Wallet Backup screen UI enhanced * Home screen UI enhance * Seed screen UI enhance * Link SendArgumentsWrapper issue * Move custom buttons paddings to PaddingValues - Optional Modifier parameter should have a default value of Modifier - Thanks to this we introduced the outerPaddingValues parameter to all our buttons with default paddings - Also notice the difference between e.g. ShortOnboardingView and ShortNewWalletBackupView. In the backup, we have the bottom button to be part of Scaffold’s bottomBar, which is maybe a better pattern than stretching the buttons with spacers in case of part of the screen content view, but it has also its tradeoffs. * Settings screen enhance * Support screen UI enhance * About screen UI enhance * Scan screen UI enhance - Move modifiers to the caller’s side - Match texts to predefined styles - Add color to Small text component + reorder parameters * Send screen UI enahnce - Lifted out some modifiers arguments to the caller’s side - Fixed button’s horizontal paddings * Scan move BackHandler to Android class * Update screen UI enhance * Receive screen UI enhance * Address screen UI enhance * Ignore AndroidUpdate back action test - Will be refactored soon * Remove TODO as already implemented * Restore screens UI enhance * Create UpdateViewAndroidTest * [#807][Design system] Remove deprecated Paddings * [#705] Instrumentation coverage generation fails locally * [#808] Use Dimens across the app - Shorter Onboarding screen design enhanced * Shorter New Wallet Backup screen UI enhanced * Home screen UI enhance * Seed screen UI enhance * Link SendArgumentsWrapper issue * Move custom buttons paddings to PaddingValues - Optional Modifier parameter should have a default value of Modifier - Thanks to this we introduced the outerPaddingValues parameter to all our buttons with default paddings - Also notice the difference between e.g. ShortOnboardingView and ShortNewWalletBackupView. In the backup, we have the bottom button to be part of Scaffold’s bottomBar, which is maybe a better pattern than stretching the buttons with spacers in case of part of the screen content view, but it has also its tradeoffs. * Settings screen enhance * Support screen UI enhance * About screen UI enhance * Scan screen UI enhance - Move modifiers to the caller’s side - Match texts to predefined styles - Add color to Small text component + reorder parameters * Send screen UI enahnce - Lifted out some modifiers arguments to the caller’s side - Fixed button’s horizontal paddings * Scan move BackHandler to Android class * Update screen UI enhance * Receive screen UI enhance * Address screen UI enhance * Ignore AndroidUpdate back action test - Will be refactored soon * Remove TODO as already implemented * Restore screens UI enhance * Create UpdateViewAndroidTest * [#807][Design system] Remove deprecated Paddings * Address review comments
2023-04-04 05:21:18 -07:00
keyboardActions: KeyboardActions = KeyboardActions.Default,
shape: Shape = TextFieldDefaults.shape,
// To enable border around the TextField
withBorder: Boolean = true,
) {
TextField(
value = value,
onValueChange = onValueChange,
label = label,
textStyle = textStyle,
keyboardOptions = keyboardOptions,
colors = colors,
modifier =
modifier.then(
if (withBorder) {
modifier.border(width = 1.dp, color = MaterialTheme.colorScheme.primary)
} else {
Modifier
}
),
leadingIcon = leadingIcon,
[#808] Use Dimens Across App * [#808] Use Dimens across the app - Shorter Onboarding screen design enhanced * Shorter New Wallet Backup screen UI enhanced * Home screen UI enhance * Seed screen UI enhance * Link SendArgumentsWrapper issue * Move custom buttons paddings to PaddingValues - Optional Modifier parameter should have a default value of Modifier - Thanks to this we introduced the outerPaddingValues parameter to all our buttons with default paddings - Also notice the difference between e.g. ShortOnboardingView and ShortNewWalletBackupView. In the backup, we have the bottom button to be part of Scaffold’s bottomBar, which is maybe a better pattern than stretching the buttons with spacers in case of part of the screen content view, but it has also its tradeoffs. * Settings screen enhance * Support screen UI enhance * About screen UI enhance * Scan screen UI enhance - Move modifiers to the caller’s side - Match texts to predefined styles - Add color to Small text component + reorder parameters * Send screen UI enahnce - Lifted out some modifiers arguments to the caller’s side - Fixed button’s horizontal paddings * Scan move BackHandler to Android class * Update screen UI enhance * Receive screen UI enhance * Address screen UI enhance * Ignore AndroidUpdate back action test - Will be refactored soon * Remove TODO as already implemented * Restore screens UI enhance * Create UpdateViewAndroidTest * [#807][Design system] Remove deprecated Paddings * [#705] Instrumentation coverage generation fails locally * [#808] Use Dimens across the app - Shorter Onboarding screen design enhanced * Shorter New Wallet Backup screen UI enhanced * Home screen UI enhance * Seed screen UI enhance * Link SendArgumentsWrapper issue * Move custom buttons paddings to PaddingValues - Optional Modifier parameter should have a default value of Modifier - Thanks to this we introduced the outerPaddingValues parameter to all our buttons with default paddings - Also notice the difference between e.g. ShortOnboardingView and ShortNewWalletBackupView. In the backup, we have the bottom button to be part of Scaffold’s bottomBar, which is maybe a better pattern than stretching the buttons with spacers in case of part of the screen content view, but it has also its tradeoffs. * Settings screen enhance * Support screen UI enhance * About screen UI enhance * Scan screen UI enhance - Move modifiers to the caller’s side - Match texts to predefined styles - Add color to Small text component + reorder parameters * Send screen UI enahnce - Lifted out some modifiers arguments to the caller’s side - Fixed button’s horizontal paddings * Scan move BackHandler to Android class * Update screen UI enhance * Receive screen UI enhance * Address screen UI enhance * Ignore AndroidUpdate back action test - Will be refactored soon * Remove TODO as already implemented * Restore screens UI enhance * Create UpdateViewAndroidTest * [#807][Design system] Remove deprecated Paddings * Address review comments
2023-04-04 05:21:18 -07:00
trailingIcon = trailingIcon,
keyboardActions = keyboardActions,
shape = shape
)
}