diff --git a/app/src/androidTest/java/org/fnives/test/showcase/ui/AuthComposeInstrumentedTest.kt b/app/src/androidTest/java/org/fnives/test/showcase/ui/AuthComposeInstrumentedTest.kt index f768093..4ee0571 100644 --- a/app/src/androidTest/java/org/fnives/test/showcase/ui/AuthComposeInstrumentedTest.kt +++ b/app/src/androidTest/java/org/fnives/test/showcase/ui/AuthComposeInstrumentedTest.kt @@ -36,7 +36,6 @@ class AuthComposeInstrumentedTest : KoinTest { val ruleOrder: RuleChain = RuleChain.outerRule(mockServerScenarioSetupTestRule) .around(dispatcherTestRule) - @Before fun setup() { stateRestorationTester.setContent { @@ -171,4 +170,4 @@ class AuthComposeInstrumentedTest : KoinTest { robot.assertUsername("alma") .assertPassword("banan") } -} \ No newline at end of file +} diff --git a/app/src/androidTest/java/org/fnives/test/showcase/ui/ComposeLoginRobot.kt b/app/src/androidTest/java/org/fnives/test/showcase/ui/ComposeLoginRobot.kt index 53c237d..162b39a 100644 --- a/app/src/androidTest/java/org/fnives/test/showcase/ui/ComposeLoginRobot.kt +++ b/app/src/androidTest/java/org/fnives/test/showcase/ui/ComposeLoginRobot.kt @@ -1,8 +1,14 @@ package org.fnives.test.showcase.ui import android.content.Context -import androidx.compose.ui.test.* +import androidx.compose.ui.test.assertCountEquals +import androidx.compose.ui.test.assertIsDisplayed +import androidx.compose.ui.test.assertTextContains import androidx.compose.ui.test.junit4.ComposeTestRule +import androidx.compose.ui.test.onAllNodesWithTag +import androidx.compose.ui.test.onNodeWithTag +import androidx.compose.ui.test.performClick +import androidx.compose.ui.test.performTextInput import androidx.test.core.app.ApplicationProvider import org.fnives.test.showcase.compose.screen.auth.AuthScreenTag @@ -44,5 +50,4 @@ class ComposeLoginRobot( composeTestRule.onNodeWithTag(AuthScreenTag.LoginError) .assertTextContains(ApplicationProvider.getApplicationContext().resources.getString(stringId)) } - -} \ No newline at end of file +} diff --git a/app/src/androidTest/java/org/fnives/test/showcase/ui/ComposeNavigationRobot.kt b/app/src/androidTest/java/org/fnives/test/showcase/ui/ComposeNavigationRobot.kt index 881875f..644f20f 100644 --- a/app/src/androidTest/java/org/fnives/test/showcase/ui/ComposeNavigationRobot.kt +++ b/app/src/androidTest/java/org/fnives/test/showcase/ui/ComposeNavigationRobot.kt @@ -15,4 +15,4 @@ class ComposeNavigationRobot( fun assertAuthScreen(): ComposeNavigationRobot = apply { composeTestRule.onNodeWithTag(AppNavigationTag.AuthScreen).assertExists() } -} \ No newline at end of file +} diff --git a/app/src/main/java/org/fnives/test/showcase/compose/ComposeActivity.kt b/app/src/main/java/org/fnives/test/showcase/compose/ComposeActivity.kt index 5a0b0cd..262718e 100644 --- a/app/src/main/java/org/fnives/test/showcase/compose/ComposeActivity.kt +++ b/app/src/main/java/org/fnives/test/showcase/compose/ComposeActivity.kt @@ -25,4 +25,4 @@ fun TestShowCaseApp() { AppNavigation() } } -} \ No newline at end of file +} diff --git a/app/src/main/java/org/fnives/test/showcase/compose/screen/AppNavigation.kt b/app/src/main/java/org/fnives/test/showcase/compose/screen/AppNavigation.kt index 2c1f7cb..b5ae528 100644 --- a/app/src/main/java/org/fnives/test/showcase/compose/screen/AppNavigation.kt +++ b/app/src/main/java/org/fnives/test/showcase/compose/screen/AppNavigation.kt @@ -34,16 +34,19 @@ fun AppNavigation(isUserLogeInUseCase: IsUserLoggedInUseCase = get()) { ) { composable("Splash") { SplashScreen() } composable("Auth") { - AuthScreen(modifier = Modifier.testTag(AppNavigationTag.AuthScreen), + AuthScreen( + modifier = Modifier.testTag(AppNavigationTag.AuthScreen), authScreenState = rememberAuthScreenState( onLoginSuccess = { navController.navigate("Home") } - )) + ) + ) } composable("Home") { HomeScreen( - Modifier.testTag(AppNavigationTag.HomeScreen), + modifier = Modifier.testTag(AppNavigationTag.HomeScreen), homeScreenState = rememberHomeScreenState( - onLogout = { navController.navigate("Auth") }) + onLogout = { navController.navigate("Auth") } + ) ) } } @@ -52,4 +55,4 @@ fun AppNavigation(isUserLogeInUseCase: IsUserLoggedInUseCase = get()) { object AppNavigationTag { const val AuthScreen = "AppNavigationTag.AuthScreen" const val HomeScreen = "AppNavigationTag.HomeScreen" -} \ No newline at end of file +} diff --git a/app/src/main/java/org/fnives/test/showcase/compose/screen/auth/AuthScreen.kt b/app/src/main/java/org/fnives/test/showcase/compose/screen/auth/AuthScreen.kt index 708d115..dc2e512 100644 --- a/app/src/main/java/org/fnives/test/showcase/compose/screen/auth/AuthScreen.kt +++ b/app/src/main/java/org/fnives/test/showcase/compose/screen/auth/AuthScreen.kt @@ -4,11 +4,29 @@ import androidx.compose.animation.graphics.res.animatedVectorResource import androidx.compose.animation.graphics.res.rememberAnimatedVectorPainter import androidx.compose.animation.graphics.vector.AnimatedImageVector import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material.* -import androidx.compose.runtime.* +import androidx.compose.material.Button +import androidx.compose.material.CircularProgressIndicator +import androidx.compose.material.Icon +import androidx.compose.material.MaterialTheme +import androidx.compose.material.OutlinedTextField +import androidx.compose.material.Snackbar +import androidx.compose.material.SnackbarHost +import androidx.compose.material.SnackbarHostState +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +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.ExperimentalComposeUiApi import androidx.compose.ui.Modifier @@ -32,16 +50,23 @@ fun AuthScreen( ConstraintLayout(modifier.fillMaxSize()) { val (title, credentials, snackbar, loading, login) = createRefs() Title( - Modifier + modifier = Modifier .statusBarsPadding() - .constrainAs(title) { top.linkTo(parent.top) }) - CredentialsFields(authScreenState, Modifier.constrainAs(credentials) { - top.linkTo(title.bottom) - bottom.linkTo(login.top) - }) - Snackbar(authScreenState, Modifier.constrainAs(snackbar) { - bottom.linkTo(login.top) - }) + .constrainAs(title) { top.linkTo(parent.top) } + ) + CredentialsFields( + authScreenState = authScreenState, + modifier = Modifier.constrainAs(credentials) { + top.linkTo(title.bottom) + bottom.linkTo(login.top) + } + ) + Snackbar( + authScreenState = authScreenState, + modifier = Modifier.constrainAs(snackbar) { + bottom.linkTo(login.top) + } + ) if (authScreenState.loading) { CircularProgressIndicator( Modifier @@ -49,7 +74,8 @@ fun AuthScreen( .constrainAs(loading) { bottom.linkTo(login.top) centerHorizontallyTo(parent) - }) + } + ) } LoginButton( modifier = Modifier @@ -84,7 +110,7 @@ private fun PasswordField(authScreenState: AuthScreenState) { label = { Text(text = stringResource(id = R.string.password)) }, placeholder = { Text(text = stringResource(id = R.string.password)) }, trailingIcon = { - val image = AnimatedImageVector.animatedVectorResource(R.drawable.avd_show_password) + val image = AnimatedImageVector.animatedVectorResource(R.drawable.show_password) Icon( painter = rememberAnimatedVectorPainter(image, passwordVisible), contentDescription = null, @@ -94,7 +120,11 @@ private fun PasswordField(authScreenState: AuthScreenState) { ) }, onValueChange = { authScreenState.onPasswordChanged(it) }, - keyboardOptions = KeyboardOptions(autoCorrect = false, imeAction = ImeAction.Done, keyboardType = KeyboardType.Password), + keyboardOptions = KeyboardOptions( + autoCorrect = false, + imeAction = ImeAction.Done, + keyboardType = KeyboardType.Password + ), keyboardActions = KeyboardActions(onDone = { keyboardController?.hide() authScreenState.onLogin() diff --git a/app/src/main/java/org/fnives/test/showcase/compose/screen/auth/AuthScreenState.kt b/app/src/main/java/org/fnives/test/showcase/compose/screen/auth/AuthScreenState.kt index c0e4840..35c3f97 100644 --- a/app/src/main/java/org/fnives/test/showcase/compose/screen/auth/AuthScreenState.kt +++ b/app/src/main/java/org/fnives/test/showcase/compose/screen/auth/AuthScreenState.kt @@ -1,9 +1,13 @@ package org.fnives.test.showcase.compose.screen.auth -import androidx.compose.runtime.* +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.saveable.Saver import androidx.compose.runtime.saveable.mapSaver import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -103,4 +107,4 @@ class AuthScreenState( } ) } -} \ No newline at end of file +} diff --git a/app/src/main/java/org/fnives/test/showcase/compose/screen/home/HomeScreen.kt b/app/src/main/java/org/fnives/test/showcase/compose/screen/home/HomeScreen.kt index d09f4a6..34716c1 100644 --- a/app/src/main/java/org/fnives/test/showcase/compose/screen/home/HomeScreen.kt +++ b/app/src/main/java/org/fnives/test/showcase/compose/screen/home/HomeScreen.kt @@ -2,7 +2,14 @@ package org.fnives.test.showcase.compose.screen.home import androidx.compose.foundation.Image import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape @@ -49,7 +56,8 @@ fun HomeScreen( state = rememberSwipeRefreshState(isRefreshing = homeScreenState.loading), onRefresh = { homeScreenState.onRefresh() - }) { + } + ) { LazyColumn(modifier = Modifier.fillMaxSize()) { items(homeScreenState.content) { item -> Item( @@ -88,15 +96,15 @@ private fun Item( Text(text = favouriteContent.content.title) Text(text = favouriteContent.content.description) } + val favouriteIcon = if (favouriteContent.isFavourite) R.drawable.favorite_24 else R.drawable.favorite_border_24 Image( - painter = painterResource(id = if (favouriteContent.isFavourite) R.drawable.favorite_24 else R.drawable.favorite_border_24), + painter = painterResource(id = favouriteIcon), contentDescription = null, Modifier.clickable { onFavouriteToggle() } ) } } - @Composable private fun Title(modifier: Modifier = Modifier) { Text( @@ -114,4 +122,4 @@ private fun ErrorText(modifier: Modifier = Modifier) { style = MaterialTheme.typography.h4, textAlign = TextAlign.Center ) -} \ No newline at end of file +} diff --git a/app/src/main/java/org/fnives/test/showcase/compose/screen/home/HomeScreenState.kt b/app/src/main/java/org/fnives/test/showcase/compose/screen/home/HomeScreenState.kt index 38a283b..33c21c4 100644 --- a/app/src/main/java/org/fnives/test/showcase/compose/screen/home/HomeScreenState.kt +++ b/app/src/main/java/org/fnives/test/showcase/compose/screen/home/HomeScreenState.kt @@ -19,6 +19,7 @@ import org.fnives.test.showcase.model.content.FavouriteContent import org.fnives.test.showcase.model.shared.Resource import org.koin.androidx.compose.get +@Suppress("LongParameterList") @Composable fun rememberHomeScreenState( stateScope: CoroutineScope = rememberCoroutineScope(), @@ -42,6 +43,7 @@ fun rememberHomeScreenState( } } +@Suppress("LongParameterList") class HomeScreenState( private val stateScope: CoroutineScope, private val getAllContentUseCase: GetAllContentUseCase, @@ -113,4 +115,4 @@ class HomeScreenState( } } } -} \ No newline at end of file +} diff --git a/app/src/main/java/org/fnives/test/showcase/compose/screen/splash/SplashScreen.kt b/app/src/main/java/org/fnives/test/showcase/compose/screen/splash/SplashScreen.kt index aeff842..6a04d6f 100644 --- a/app/src/main/java/org/fnives/test/showcase/compose/screen/splash/SplashScreen.kt +++ b/app/src/main/java/org/fnives/test/showcase/compose/screen/splash/SplashScreen.kt @@ -13,7 +13,6 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import org.fnives.test.showcase.R - @Composable fun SplashScreen() { Box(Modifier.fillMaxSize().background(colorResource(R.color.purple_700)), contentAlignment = Alignment.Center) { @@ -23,4 +22,4 @@ fun SplashScreen() { modifier = Modifier.size(120.dp) ) } -} \ No newline at end of file +} diff --git a/app/src/main/res/drawable/avd_hide_password.xml b/app/src/main/res/drawable/avd_hide_password.xml deleted file mode 100644 index 89f4cdd..0000000 --- a/app/src/main/res/drawable/avd_hide_password.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/drawable/avd_show_password.xml b/app/src/main/res/drawable/show_password.xml similarity index 85% rename from app/src/main/res/drawable/avd_show_password.xml rename to app/src/main/res/drawable/show_password.xml index aed3983..6d35533 100644 --- a/app/src/main/res/drawable/avd_show_password.xml +++ b/app/src/main/res/drawable/show_password.xml @@ -34,18 +34,21 @@ android:pathData="@string/path_password_strike_through" android:strokeColor="@android:color/white" android:strokeLineCap="square" - android:strokeWidth="1.8"/> + android:strokeWidth="1.8" + tools:ignore="PrivateResource" /> + android:pathData="@string/path_password_eye_mask_strike_through" + tools:ignore="PrivateResource" /> + android:pathData="@string/path_password_eye" + tools:ignore="PrivateResource" /> @@ -63,7 +66,8 @@ android:propertyName="pathData" android:valueFrom="@string/path_password_eye_mask_strike_through" android:valueTo="@string/path_password_eye_mask_visible" - android:valueType="pathType"/> + android:valueType="pathType" + tools:ignore="PrivateResource" /> @@ -78,7 +82,8 @@ android:interpolator="@android:interpolator/fast_out_linear_in" android:propertyName="trimPathEnd" android:valueFrom="1" - android:valueTo="0"/> + android:valueTo="0" + tools:ignore="PrivateResource" />