Skip to content

Commit

Permalink
Merge branch 'main' into ANDROID-14884_list_row_a11y
Browse files Browse the repository at this point in the history
* main:
  Update design tokens (#370)
  ANDROID-15026 make TextInput label param as nullable (#374)
  ANDROID-15025 add number input (#373)
  • Loading branch information
haynlo committed Aug 27, 2024
2 parents cfcd25d + a88ace8 commit 39b41cd
Show file tree
Hide file tree
Showing 32 changed files with 386 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.telefonica.mistica.compose.input.CheckBoxInput
import com.telefonica.mistica.compose.input.DropDownInput
import com.telefonica.mistica.compose.input.EmailInput
import com.telefonica.mistica.compose.input.LimitCharacters
import com.telefonica.mistica.compose.input.NumberInput
import com.telefonica.mistica.compose.input.PasswordInput
import com.telefonica.mistica.compose.input.PhoneInput
import com.telefonica.mistica.compose.input.TextAreaInput
Expand Down Expand Up @@ -62,6 +63,8 @@ fun Inputs() {
PasswordInputSample()
Title("Phone input")
PhoneInputSample()
Title("Number input")
NumericInputSample()
Title("Email input")
EmailInputSample()
Title("Email input with validation")
Expand Down Expand Up @@ -211,6 +214,25 @@ private fun PhoneInputSample() {
)
}

@Composable
private fun NumericInputSample() {
var text by remember {
mutableStateOf("")
}

NumberInput(
modifier = Modifier
.fillMaxWidth()
.padding(top = 8.dp, start = 16.dp, end = 16.dp)
,
value = text,
onValueChange = {
text = it
},
label = "Type Something"
)
}

@Composable
private fun TextInputWithTransformation() {
var text by remember {
Expand Down
14 changes: 14 additions & 0 deletions catalog/src/main/res/layout/screen_inputs_catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,20 @@
app:inputHint="Phone number"
app:inputType="phone" />

<com.telefonica.mistica.title.TitleView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
app:title="Number Input" />

<com.telefonica.mistica.input.TextInput
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:inputHint="Number"
app:inputType="number" />

<com.telefonica.mistica.title.TitleView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fun EmailInput(
modifier: Modifier,
value: String,
onValueChange: (String) -> Unit,
label: String,
label: String?,
helperText: String? = null,
isError: Boolean = false,
errorText: String? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.telefonica.mistica.compose.input

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.VisualTransformation
import androidx.core.text.isDigitsOnly

@Composable
fun NumberInput(
modifier: Modifier,
value: String,
onValueChange: (String) -> Unit,
label: String?,
helperText: String? = null,
isError: Boolean = false,
errorText: String? = null,
trailingIcon: @Composable (() -> Unit)? = null,
isInverse: Boolean = false,
enabled: Boolean = true,
readOnly: Boolean = false,
onClick: (() -> Unit)? = null,
visualTransformation: VisualTransformation = VisualTransformation.None,
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
) {

TextInputImpl(
modifier = modifier,
value = value,
onValueChange = onValueChange,
label = label,
helperText = helperText,
isError = isError,
errorText = errorText,
trailingIcon = trailingIcon,
isInverse = isInverse,
enabled = enabled,
readOnly = readOnly,
onClick = onClick,
visualTransformation = visualTransformation,
keyboardOptions = keyboardOptions.toFoundationKeyboardOptions(
keyboardType = KeyboardType.Decimal
)
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import com.telefonica.mistica.R
fun PasswordInput(
value: String,
onValueChange: (String) -> Unit,
label: String,
label: String?,
modifier: Modifier = Modifier,
helperText: String? = null,
isError: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fun PhoneInput(
modifier: Modifier,
value: String,
onValueChange: (String) -> Unit,
label: String,
label: String?,
helperText: String? = null,
isError: Boolean = false,
errorText: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import androidx.compose.ui.tooling.preview.Preview
fun TextAreaInput(
value: String,
onValueChange: (String) -> Unit,
label: String,
label: String?,
modifier: Modifier = Modifier,
helperText: String? = null,
isError: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fun TextInput(
modifier: Modifier,
value: String,
onValueChange: (String) -> Unit,
label: String,
label: String?,
helperText: String? = null,
isError: Boolean = false,
errorText: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal fun TextInputImpl(
modifier: Modifier = Modifier,
value: String,
onValueChange: (String) -> Unit,
label: String,
label: String?,
helperText: String?,
isError: Boolean,
errorText: String?,
Expand Down Expand Up @@ -82,7 +82,7 @@ private fun TextBox(
value: String,
modifier: Modifier = Modifier,
onValueChange: (String) -> Unit,
label: String,
label: String?,
isError: Boolean,
trailingIcon: @Composable (() -> Unit)?,
enabled: Boolean,
Expand Down Expand Up @@ -113,16 +113,18 @@ private fun TextBox(
readOnly = readOnly,
value = value,
onValueChange = onValueChange,
label = {
val transformedText = remember(value) {
visualTransformation.filter(AnnotatedString(value))
label = label?.let {
{
val transformedText = remember(value) {
visualTransformation.filter(AnnotatedString(value))
}
TextInputLabel(
text = it,
inputIsNotEmpty = transformedText.text.isNotEmpty(),
isFocused = interactionSource.collectIsFocusedAsState().value,
isError = isError,
)
}
TextInputLabel(
text = label,
inputIsNotEmpty = transformedText.text.isNotEmpty(),
isFocused = interactionSource.collectIsFocusedAsState().value,
isError = isError,
)
},
interactionSource = interactionSource,
keyboardOptions = keyboardOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,24 @@ public object BlauBrandFontSizes {
public val tabsLabelFontSize: TextUnit = 16.sp

public val title2FontSize: TextUnit = 20.sp

public val text1FontSize: TextUnit = 12.sp

public val text2FontSize: TextUnit = 14.sp

public val text3FontSize: TextUnit = 16.sp

public val text4FontSize: TextUnit = 18.sp

public val text5FontSize: TextUnit = 20.sp

public val text6FontSize: TextUnit = 24.sp

public val text7FontSize: TextUnit = 28.sp

public val text8FontSize: TextUnit = 32.sp

public val text9FontSize: TextUnit = 40.sp

public val text10FontSize: TextUnit = 48.sp
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,24 @@ public object MovistarBrandFontSizes {
public val tabsLabelFontSize: TextUnit = 16.sp

public val title2FontSize: TextUnit = 20.sp

public val text1FontSize: TextUnit = 12.sp

public val text2FontSize: TextUnit = 14.sp

public val text3FontSize: TextUnit = 16.sp

public val text4FontSize: TextUnit = 18.sp

public val text5FontSize: TextUnit = 20.sp

public val text6FontSize: TextUnit = 24.sp

public val text7FontSize: TextUnit = 28.sp

public val text8FontSize: TextUnit = 32.sp

public val text9FontSize: TextUnit = 40.sp

public val text10FontSize: TextUnit = 48.sp
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,24 @@ public object O2BrandFontSizes {
public val tabsLabelFontSize: TextUnit = 16.sp

public val title2FontSize: TextUnit = 20.sp

public val text1FontSize: TextUnit = 12.sp

public val text2FontSize: TextUnit = 14.sp

public val text3FontSize: TextUnit = 16.sp

public val text4FontSize: TextUnit = 18.sp

public val text5FontSize: TextUnit = 20.sp

public val text6FontSize: TextUnit = 24.sp

public val text7FontSize: TextUnit = 28.sp

public val text8FontSize: TextUnit = 32.sp

public val text9FontSize: TextUnit = 40.sp

public val text10FontSize: TextUnit = 48.sp
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public object O2NewBrandColors {
iosControlKnob = O2NewPaletteColor.o2New_color_white
divider = O2NewPaletteColor.o2New_color_grey30
dividerInverse = O2NewPaletteColor.o2New_color_white_20_alpha
navigationBarDivider = O2NewPaletteColor.o2New_color_beyondBlue
navigationBarDivider = O2NewPaletteColor.o2New_color_darkBlue
badge = O2NewPaletteColor.o2New_color_o2Red65
feedbackErrorBackground = O2NewPaletteColor.o2New_color_o2Red60
feedbackInfoBackground = O2NewPaletteColor.o2New_color_black
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,24 @@ public object O2NewBrandFontSizes {
public val tabsLabelFontSize: TextUnit = 16.sp

public val title2FontSize: TextUnit = 20.sp

public val text1FontSize: TextUnit = 12.sp

public val text2FontSize: TextUnit = 14.sp

public val text3FontSize: TextUnit = 16.sp

public val text4FontSize: TextUnit = 18.sp

public val text5FontSize: TextUnit = 20.sp

public val text6FontSize: TextUnit = 24.sp

public val text7FontSize: TextUnit = 28.sp

public val text8FontSize: TextUnit = 32.sp

public val text9FontSize: TextUnit = 40.sp

public val text10FontSize: TextUnit = 48.sp
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,24 @@ public object TelefonicaBrandFontSizes {
public val tabsLabelFontSize: TextUnit = 16.sp

public val title2FontSize: TextUnit = 20.sp

public val text1FontSize: TextUnit = 12.sp

public val text2FontSize: TextUnit = 14.sp

public val text3FontSize: TextUnit = 16.sp

public val text4FontSize: TextUnit = 18.sp

public val text5FontSize: TextUnit = 20.sp

public val text6FontSize: TextUnit = 24.sp

public val text7FontSize: TextUnit = 28.sp

public val text8FontSize: TextUnit = 32.sp

public val text9FontSize: TextUnit = 40.sp

public val text10FontSize: TextUnit = 48.sp
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,24 @@ public object TuBrandFontSizes {
public val tabsLabelFontSize: TextUnit = 16.sp

public val title2FontSize: TextUnit = 20.sp

public val text1FontSize: TextUnit = 12.sp

public val text2FontSize: TextUnit = 14.sp

public val text3FontSize: TextUnit = 16.sp

public val text4FontSize: TextUnit = 18.sp

public val text5FontSize: TextUnit = 20.sp

public val text6FontSize: TextUnit = 24.sp

public val text7FontSize: TextUnit = 28.sp

public val text8FontSize: TextUnit = 32.sp

public val text9FontSize: TextUnit = 40.sp

public val text10FontSize: TextUnit = 48.sp
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,24 @@ public object VivoBrandFontSizes {
public val tabsLabelFontSize: TextUnit = 16.sp

public val title2FontSize: TextUnit = 20.sp

public val text1FontSize: TextUnit = 12.sp

public val text2FontSize: TextUnit = 14.sp

public val text3FontSize: TextUnit = 16.sp

public val text4FontSize: TextUnit = 18.sp

public val text5FontSize: TextUnit = 20.sp

public val text6FontSize: TextUnit = 24.sp

public val text7FontSize: TextUnit = 28.sp

public val text8FontSize: TextUnit = 32.sp

public val text9FontSize: TextUnit = 40.sp

public val text10FontSize: TextUnit = 48.sp
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public object VivoNewBrandColors {
textNavigationBarSecondary = VivoNewPaletteColor.vivoNew_color_vivoPurpleLight50
textNavigationSearchBarHint = VivoNewPaletteColor.vivoNew_color_vivoPurpleLight50
textNavigationSearchBarText = VivoNewPaletteColor.vivoNew_color_white
textAppBar = VivoNewPaletteColor.vivoNew_color_grey4
textAppBar = VivoNewPaletteColor.vivoNew_color_grey5
textAppBarSelected = VivoNewPaletteColor.vivoNew_color_vivoPurple
customTabsBackground = VivoNewPaletteColor.vivoNew_color_white
tagTextPromo = VivoNewPaletteColor.vivoNew_color_vivoPurple
Expand Down
Loading

0 comments on commit 39b41cd

Please sign in to comment.