diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 309334c..2daccaa 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -12,8 +12,8 @@ android { applicationId = "pl.firmatpp.kierowca" minSdk = 26 targetSdk = 35 - versionCode = 12 - versionName = "1.0.11" + versionCode = 13 + versionName = "1.0.12" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" buildConfigField("String", "API_BASE_URL", "\"https://api-intranet.firmatpp.pl/api/\"") diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ed437c6..1229ae2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -7,7 +7,9 @@ Unit) { - var phone by remember { mutableStateOf(state.phone) } - AuthShell(title = "TPP Kierowca", subtitle = "Zaloguj sie numerem telefonu kierowcy.") { - OutlinedTextField( - value = phone, - onValueChange = { phone = it }, - label = { Text("Numer telefonu") }, - leadingIcon = { Icon(Icons.Outlined.Phone, contentDescription = null) }, - keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Phone), - modifier = Modifier.fillMaxWidth(), + var phoneDigits by remember(state.phone) { mutableStateOf(polishPhoneDigits(state.phone)) } + Box( + Modifier + .fillMaxSize() + .background(TppColors.Surface) + .statusBarsPadding() + .navigationBarsPadding() + .padding(24.dp), + ) { + Card( + modifier = Modifier.fillMaxSize(), + colors = CardDefaults.cardColors(containerColor = Color(0xFFFEFFFC)), + border = BorderStroke(1.dp, TppColors.Outline), + shape = RoundedCornerShape(4.dp), + ) { + Column( + Modifier + .fillMaxSize() + .verticalScroll(rememberScrollState()) + .padding(horizontal = 28.dp, vertical = 36.dp), + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Image( + painter = painterResource(R.drawable.tpp5), + contentDescription = "Firma TPP", + contentScale = ContentScale.Fit, + modifier = Modifier + .fillMaxWidth() + .height(132.dp), + ) + Spacer(Modifier.height(42.dp)) + Text( + "Zaloguj się", + style = MaterialTheme.typography.headlineLarge, + color = TppColors.Muted, + fontWeight = FontWeight.Bold, + ) + Spacer(Modifier.height(76.dp)) + Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(18.dp)) { + Text( + "Numer Telefonu", + color = Color.Black, + fontFamily = FontFamily.Monospace, + fontWeight = FontWeight.Bold, + fontSize = 23.sp, + ) + PhoneNumberField( + digits = phoneDigits, + onDigitsChange = { phoneDigits = polishPhoneDigits(it) }, + ) + Text( + "Otrzymasz kod SMS do weryfikacji.", + color = TppColors.Muted, + fontFamily = FontFamily.Monospace, + fontWeight = FontWeight.SemiBold, + fontSize = 18.sp, + ) + ErrorText(state.error) + Spacer(Modifier.height(if (state.error.isNullOrBlank()) 22.dp else 8.dp)) + Button( + onClick = { onSubmit("+48$phoneDigits") }, + modifier = Modifier + .fillMaxWidth() + .height(72.dp), + colors = ButtonDefaults.buttonColors(containerColor = TppColors.ContainerGreen), + shape = RoundedCornerShape(4.dp), + contentPadding = PaddingValues(horizontal = 20.dp), + ) { + Text( + "Wyślij kod OTP", + fontFamily = FontFamily.Monospace, + fontWeight = FontWeight.Bold, + fontSize = 22.sp, + ) + } + } + } + } + } +} + +@Composable +private fun PhoneNumberField(digits: String, onDigitsChange: (String) -> Unit) { + Row( + modifier = Modifier + .fillMaxWidth() + .height(82.dp) + .background(Color(0xFFFEFFFC), RoundedCornerShape(2.dp)) + .border(BorderStroke(1.dp, TppColors.Outline), RoundedCornerShape(2.dp)), + verticalAlignment = Alignment.CenterVertically, + ) { + Box( + Modifier + .width(94.dp) + .fillMaxHeight() + .background(TppColors.Panel), + contentAlignment = Alignment.Center, + ) { + Text("+48", color = TppColors.Ink, fontSize = 26.sp) + } + Box(Modifier.width(1.dp).fillMaxHeight().background(TppColors.Outline)) + BasicTextField( + value = formatPolishPhoneDigits(digits), + onValueChange = { onDigitsChange(it) }, singleLine = true, + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Phone), + textStyle = TextStyle( + color = TppColors.Muted, + fontSize = 28.sp, + fontWeight = FontWeight.Medium, + ), + modifier = Modifier + .weight(1f) + .padding(horizontal = 24.dp), + decorationBox = { innerTextField -> + Box(contentAlignment = Alignment.CenterStart) { + if (digits.isBlank()) { + Text( + "000 000 000", + color = TppColors.Muted.copy(alpha = 0.92f), + fontSize = 28.sp, + fontWeight = FontWeight.Medium, + ) + } + innerTextField() + } + }, ) - ErrorText(state.error) - Spacer(Modifier.height(if (state.error.isNullOrBlank()) 18.dp else 8.dp)) - PrimaryButton("Wyslij kod") { onSubmit(phone) } } } @@ -998,6 +1118,16 @@ private fun ErrorText(error: String?) { if (!error.isNullOrBlank()) Text(error, color = TppColors.Error, modifier = Modifier.padding(vertical = 8.dp)) } +private fun polishPhoneDigits(value: String): String { + val digits = value.filter(Char::isDigit) + val withoutCountryCode = if (digits.length > 9 && digits.startsWith("48")) digits.drop(2) else digits + + return withoutCountryCode.take(9) +} + +private fun formatPolishPhoneDigits(value: String): String = + value.chunked(3).joinToString(" ") + private fun createCameraUri(context: Context): Uri { val dir = File(context.cacheDir, "camera").apply { mkdirs() } val file = File.createTempFile("ladunek-", ".jpg", dir) diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..239660b --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,4 @@ + + + + diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..3ba4e35 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..3ba4e35 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..60e1ce8 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..eac35ca Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..e3da5c3 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..8e4486e Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..bbd66b5 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..cb44938 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..b757d27 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..a434aa8 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..a7ccfe9 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..c168843 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..79a93f9 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..ea6f407 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..414e071 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..7decad8 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..630a15e Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index af35d75..34194e3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,4 +1,4 @@ - TPP Kierowca + Firma TPP - Kierowca