From 208cf763be510fe6d8994ebaee7c6d3052fda51a Mon Sep 17 00:00:00 2001 From: pravinkurhade Date: Tue, 2 Jan 2024 22:41:06 +0530 Subject: [PATCH] - Save Button was not properly visible fixed UI issue - Updated Text Field to OutlinedText Field - added card to list - updated one gradle deprecation Look and fill improvements --- app/build.gradle.kts | 2 +- .../feature/mymodel/ui/MyModelScreen.kt | 45 ++++++++++++++----- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 0baac87..088c99c 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -72,7 +72,7 @@ android { kotlinCompilerExtensionVersion = libs.versions.androidxComposeCompiler.get() } - packagingOptions { + packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" } diff --git a/feature-mymodel/src/main/java/android/template/feature/mymodel/ui/MyModelScreen.kt b/feature-mymodel/src/main/java/android/template/feature/mymodel/ui/MyModelScreen.kt index b305d16..49da32f 100644 --- a/feature-mymodel/src/main/java/android/template/feature/mymodel/ui/MyModelScreen.kt +++ b/feature-mymodel/src/main/java/android/template/feature/mymodel/ui/MyModelScreen.kt @@ -19,20 +19,24 @@ package android.template.feature.mymodel.ui import android.template.core.ui.MyApplicationTheme import android.template.feature.mymodel.ui.MyModelUiState.Success import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.width import androidx.compose.material3.Button +import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Text -import androidx.compose.material3.TextField 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.Modifier +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel @@ -59,20 +63,39 @@ internal fun MyModelScreen( Column(modifier) { var nameMyModel by remember { mutableStateOf("Compose") } Row( - modifier = Modifier.fillMaxWidth().padding(bottom = 24.dp), + modifier = Modifier + .fillMaxWidth() + .padding(bottom = 16.dp), horizontalArrangement = Arrangement.spacedBy(16.dp) ) { - TextField( - value = nameMyModel, - onValueChange = { nameMyModel = it } - ) - - Button(modifier = Modifier.width(96.dp), onClick = { onSave(nameMyModel) }) { - Text("Save") + Box(Modifier.weight(7f)) { + OutlinedTextField( + value = nameMyModel, + onValueChange = { nameMyModel = it } + ) + } + Box(Modifier.weight(3f)) { + Button(modifier = Modifier.fillMaxWidth(), onClick = { onSave(nameMyModel) }) { + Text("Save") + } } } items.forEach { - Text("Saved item: $it") + Card( + Modifier + .fillMaxWidth() + .padding(top = 10.dp, bottom = 10.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + ), + ) { + Text( + "Saved item: $it", + modifier = Modifier + .padding(16.dp), + textAlign = TextAlign.Center, + ) + } } } }