From 82a08188a6447bbcc227775c0247f1808587beae Mon Sep 17 00:00:00 2001 From: Achintha Isuru Date: Mon, 6 May 2024 09:24:39 +0530 Subject: [PATCH] [improvement] improve home and profile screen --- .../screens/profile/ProfileScreen.kt | 10 ++++++---- .../presentation/util/pets_list/PetsList.kt | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/petcare-sample/b2c/mobile-app/petcare-with-sdk/app/src/main/java/com/wso2_sample/api_auth_sample/features/home/presentation/screens/profile/ProfileScreen.kt b/petcare-sample/b2c/mobile-app/petcare-with-sdk/app/src/main/java/com/wso2_sample/api_auth_sample/features/home/presentation/screens/profile/ProfileScreen.kt index fbcf009c9..dd7f027c7 100644 --- a/petcare-sample/b2c/mobile-app/petcare-with-sdk/app/src/main/java/com/wso2_sample/api_auth_sample/features/home/presentation/screens/profile/ProfileScreen.kt +++ b/petcare-sample/b2c/mobile-app/petcare-with-sdk/app/src/main/java/com/wso2_sample/api_auth_sample/features/home/presentation/screens/profile/ProfileScreen.kt @@ -94,10 +94,12 @@ fun ProfileScreenContent( verticalArrangement = Arrangement.spacedBy(8.dp) ) { ProfileImage(imageUrl = state.user?.imageUrl ?: "") - NameSection( - firstName = state.user?.firstName, - lastName = state.user?.lastName - ) + if (state.user?.firstName != null || state.user?.lastName != null) { + NameSection( + firstName = state.user.firstName, + lastName = state.user.lastName + ) + } } Spacer(modifier = Modifier.height(32.dp)) Column( diff --git a/petcare-sample/b2c/mobile-app/petcare-with-sdk/app/src/main/java/com/wso2_sample/api_auth_sample/features/home/presentation/util/pets_list/PetsList.kt b/petcare-sample/b2c/mobile-app/petcare-with-sdk/app/src/main/java/com/wso2_sample/api_auth_sample/features/home/presentation/util/pets_list/PetsList.kt index 59fae8ce2..6aa6f0a84 100644 --- a/petcare-sample/b2c/mobile-app/petcare-with-sdk/app/src/main/java/com/wso2_sample/api_auth_sample/features/home/presentation/util/pets_list/PetsList.kt +++ b/petcare-sample/b2c/mobile-app/petcare-with-sdk/app/src/main/java/com/wso2_sample/api_auth_sample/features/home/presentation/util/pets_list/PetsList.kt @@ -25,7 +25,9 @@ import androidx.compose.foundation.layout.padding import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import com.wso2_sample.api_auth_sample.features.home.domain.models.pet.Pet @@ -42,9 +44,20 @@ fun PetsList(pets: List) { Column( modifier = Modifier .padding(top = 16.dp) - .fillMaxWidth(), - verticalArrangement = Arrangement.spacedBy(16.dp) + .fillMaxWidth() + .align(Alignment.CenterHorizontally), + verticalArrangement = Arrangement.spacedBy(16.dp), ) { + + if (pets.isEmpty()) { + Text( + text = "You don't have any pets yet", + style = MaterialTheme.typography.bodyMedium, + color = MaterialTheme.colorScheme.tertiaryContainer, + textAlign = TextAlign.Center + ) + } + pets.forEach { pet -> PetCard(pet = pet) }