-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from PetJournal/feature/add-castration-field-o…
…n-date-of-birth-screen Add pet castration selectors to the birth date screen
- Loading branch information
Showing
20 changed files
with
314 additions
and
19 deletions.
There are no files selected for viewing
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
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
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
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
150 changes: 150 additions & 0 deletions
150
...etjournal/ui/screens_app/screens_pets/petBirthDateScreen/components/CastrationSelector.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,150 @@ | ||
package com.soujunior.petjournal.ui.screens_app.screens_pets.petBirthDateScreen.components | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.platform.testTag | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import com.soujunior.petjournal.R | ||
import com.soujunior.petjournal.ui.components.AlertText | ||
import com.soujunior.petjournal.ui.components.RoundedSquare | ||
|
||
|
||
@Composable | ||
fun CastrationSelector( | ||
selectedCastration: (Boolean?) -> Unit, | ||
clearSelection: () -> Boolean, | ||
textError: List<String>? = null, | ||
textNamePet: String = "Bolinha" | ||
) { | ||
Column(modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(16.dp), | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
content = { | ||
Row { | ||
Text( | ||
modifier = Modifier.fillMaxWidth(), | ||
text = stringResource(id = R.string.pet_castration, textNamePet), | ||
fontSize = 17.sp, | ||
style = MaterialTheme.typography.bodyMedium, | ||
color = MaterialTheme.colorScheme.primary, | ||
textAlign = TextAlign.Center | ||
) | ||
Spacer( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(25.dp) | ||
) | ||
} | ||
|
||
CastrationButtons(selectedCastration, clearSelection, textError) | ||
}) | ||
} | ||
|
||
@Composable | ||
private fun CastrationButtons( | ||
selectedCastration: (Boolean?) -> Unit, | ||
clearSelection: () -> Boolean, | ||
textError: List<String>? = null, | ||
) { | ||
|
||
var selectedItem by remember { mutableStateOf("") } | ||
if (clearSelection()) { | ||
selectedItem = "" | ||
selectedCastration(null) | ||
} | ||
|
||
Row( | ||
modifier = Modifier | ||
.padding(horizontal = 2.dp) | ||
.testTag("genderButtons_test"), | ||
horizontalArrangement = Arrangement.spacedBy(16.dp) | ||
) { | ||
RoundedSquare( | ||
text = stringResource(id = R.string.text_yes), | ||
colorText = if (selectedItem == "S") MaterialTheme.colorScheme.tertiary else MaterialTheme.colorScheme.onSurfaceVariant, | ||
isSelected = selectedItem == "S", | ||
size = 120.dp, | ||
topLeftRadius = 32.dp, | ||
topRightRadius = 32.dp, | ||
bottomLeftRadius = 32.dp, | ||
bottomRightRadius = 32.dp, | ||
image = if (selectedItem == "S") painterResource(id = R.drawable.icon_solid_check_enable) else painterResource( | ||
id = R.drawable.icon_check | ||
), | ||
selectedColor = if (selectedItem == "S") MaterialTheme.colorScheme.primary else Color.Transparent, | ||
|
||
|
||
colorBackground = Color.Transparent, | ||
onClick = { | ||
selectedItem = "S" | ||
selectedCastration(true) | ||
} | ||
) | ||
|
||
RoundedSquare( | ||
text = stringResource(id = R.string.text_no), | ||
colorText = if (selectedItem == "N") MaterialTheme.colorScheme.error else MaterialTheme.colorScheme.onSurfaceVariant, | ||
isSelected = selectedItem == "N", | ||
size = 120.dp, | ||
topLeftRadius = 32.dp, | ||
topRightRadius = 32.dp, | ||
bottomLeftRadius = 32.dp, | ||
bottomRightRadius = 32.dp, | ||
image = if (selectedItem == "N") painterResource(id = R.drawable.icon_solid_close_enable) else painterResource( | ||
id = R.drawable.icon_close | ||
), | ||
selectedColor = if (selectedItem == "N") MaterialTheme.colorScheme.primary else Color.Transparent, | ||
colorBackground = Color.Transparent, | ||
onClick = { | ||
selectedItem = "N" | ||
selectedCastration(false) | ||
} | ||
) | ||
} | ||
Row(modifier = Modifier.fillMaxWidth()) { | ||
if (textError != null) { | ||
textError.forEach { | ||
AlertText(textMessage = it, modifier = Modifier.padding(10.dp)) | ||
} | ||
} else { | ||
Text( | ||
text = stringResource(id = R.string.required_field), | ||
modifier = Modifier.padding(start = 2.dp, top = 10.dp), | ||
fontSize = 15.sp, | ||
textAlign = TextAlign.Start | ||
) | ||
} | ||
} | ||
} | ||
|
||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun CastrationSelectorPreview() { | ||
CastrationSelector( | ||
selectedCastration = {}, | ||
clearSelection = { true }, | ||
textError = null | ||
) | ||
} |
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
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
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,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="960" | ||
android:viewportHeight="960" | ||
android:tint="?attr/colorControlNormal"> | ||
<path | ||
android:fillColor="#B2B2B2" | ||
android:pathData="M422.46,563.69L329.62,470.85Q320,461.23 306.85,460.85Q293.69,460.46 283.31,470.85Q272.92,481.23 272.92,494Q272.92,506.77 283.31,517.15L390.85,624.69Q404.36,638.38 422.37,638.38Q440.38,638.38 454.08,624.69L677.15,401.62Q686.77,392 687.15,378.85Q687.54,365.69 677.15,355.31Q666.77,344.92 654,344.92Q641.23,344.92 630.85,355.31L422.46,563.69ZM480.13,872Q398.82,872 327.24,841.14Q255.67,810.28 202.72,757.38Q149.77,704.48 118.89,632.96Q88,561.45 88,480.13Q88,398.57 118.92,326.76Q149.84,254.96 202.84,201.85Q255.84,148.73 327.26,118.37Q398.67,88 479.87,88Q561.42,88 633.22,118.34Q705.01,148.68 758.14,201.76Q811.27,254.84 841.63,326.6Q872,398.36 872,479.95Q872,561.54 841.66,632.78Q811.32,704.01 758.25,757.06Q705.18,810.11 633.44,841.06Q561.7,872 480.13,872Z"/> | ||
</vector> |
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,13 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="69dp" | ||
android:height="68dp" | ||
android:viewportWidth="69" | ||
android:viewportHeight="68"> | ||
<group> | ||
<clip-path | ||
android:pathData="M3.947,4h60v60h-60z"/> | ||
<path | ||
android:pathData="M33.947,4C36.701,4 39.357,4.352 41.916,5.055C44.475,5.758 46.857,6.773 49.064,8.102C51.271,9.43 53.293,10.992 55.129,12.789C56.965,14.586 58.537,16.607 59.846,18.854C61.154,21.1 62.16,23.492 62.863,26.031C63.566,28.57 63.928,31.227 63.947,34C63.947,36.754 63.596,39.41 62.893,41.969C62.189,44.527 61.174,46.91 59.846,49.117C58.518,51.324 56.955,53.346 55.158,55.182C53.361,57.018 51.34,58.59 49.094,59.898C46.848,61.207 44.455,62.213 41.916,62.916C39.377,63.619 36.721,63.98 33.947,64C31.193,64 28.537,63.648 25.979,62.945C23.42,62.242 21.037,61.227 18.83,59.898C16.623,58.57 14.602,57.008 12.766,55.211C10.93,53.414 9.357,51.393 8.049,49.146C6.74,46.9 5.734,44.508 5.031,41.969C4.328,39.43 3.967,36.773 3.947,34C3.947,31.246 4.299,28.59 5.002,26.031C5.705,23.473 6.721,21.09 8.049,18.883C9.377,16.676 10.939,14.654 12.736,12.818C14.533,10.982 16.555,9.41 18.801,8.102C21.047,6.793 23.44,5.787 25.979,5.084C28.518,4.381 31.174,4.02 33.947,4ZM37.258,34L47.277,23.98L43.967,20.67L33.947,30.69L23.928,20.67L20.617,23.98L30.637,34L20.617,44.02L23.928,47.33L33.947,37.311L43.967,47.33L47.277,44.02L37.258,34Z" | ||
android:fillColor="#B2B2B2"/> | ||
</group> | ||
</vector> |
10 changes: 10 additions & 0 deletions
10
petJournal/app/src/main/res/drawable/icon_solid_check_enable.xml
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,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="960" | ||
android:viewportHeight="960" | ||
android:tint="#A7EC97"> | ||
<path | ||
android:fillColor="#B2B2B2" | ||
android:pathData="M422.46,563.69L329.62,470.85Q320,461.23 306.85,460.85Q293.69,460.46 283.31,470.85Q272.92,481.23 272.92,494Q272.92,506.77 283.31,517.15L390.85,624.69Q404.36,638.38 422.37,638.38Q440.38,638.38 454.08,624.69L677.15,401.62Q686.77,392 687.15,378.85Q687.54,365.69 677.15,355.31Q666.77,344.92 654,344.92Q641.23,344.92 630.85,355.31L422.46,563.69ZM480.13,872Q398.82,872 327.24,841.14Q255.67,810.28 202.72,757.38Q149.77,704.48 118.89,632.96Q88,561.45 88,480.13Q88,398.57 118.92,326.76Q149.84,254.96 202.84,201.85Q255.84,148.73 327.26,118.37Q398.67,88 479.87,88Q561.42,88 633.22,118.34Q705.01,148.68 758.14,201.76Q811.27,254.84 841.63,326.6Q872,398.36 872,479.95Q872,561.54 841.66,632.78Q811.32,704.01 758.25,757.06Q705.18,810.11 633.44,841.06Q561.7,872 480.13,872Z"/> | ||
</vector> |
9 changes: 9 additions & 0 deletions
9
petJournal/app/src/main/res/drawable/icon_solid_close_enable.xml
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,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="69dp" | ||
android:height="68dp" | ||
android:viewportWidth="69" | ||
android:viewportHeight="68"> | ||
<path | ||
android:pathData="M33.947,4C36.701,4 39.357,4.352 41.916,5.055C44.475,5.758 46.857,6.773 49.064,8.102C51.271,9.43 53.293,10.992 55.129,12.789C56.965,14.586 58.537,16.607 59.846,18.854C61.154,21.1 62.16,23.492 62.863,26.031C63.566,28.57 63.928,31.227 63.947,34C63.947,36.754 63.596,39.41 62.893,41.969C62.189,44.527 61.174,46.91 59.846,49.117C58.518,51.324 56.955,53.346 55.158,55.182C53.361,57.018 51.34,58.59 49.094,59.898C46.848,61.207 44.455,62.213 41.916,62.916C39.377,63.619 36.721,63.98 33.947,64C31.193,64 28.537,63.648 25.979,62.945C23.42,62.242 21.037,61.227 18.83,59.898C16.623,58.57 14.602,57.008 12.766,55.211C10.93,53.414 9.357,51.393 8.049,49.146C6.74,46.9 5.734,44.508 5.031,41.969C4.328,39.43 3.967,36.773 3.947,34C3.947,31.246 4.299,28.59 5.002,26.031C5.705,23.473 6.721,21.09 8.049,18.883C9.377,16.676 10.939,14.654 12.736,12.818C14.533,10.982 16.555,9.41 18.801,8.102C21.047,6.793 23.44,5.787 25.979,5.084C28.518,4.381 31.174,4.02 33.947,4ZM37.258,34L47.277,23.98L43.967,20.67L33.947,30.69L23.928,20.67L20.617,23.98L30.637,34L20.617,44.02L23.928,47.33L33.947,37.311L43.967,47.33L47.277,44.02L37.258,34Z" | ||
android:fillColor="#FF917A"/> | ||
</vector> |
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
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
Oops, something went wrong.