Skip to content

Commit

Permalink
Finish Deposit & Withdraw screen and remove authentication toast nessage
Browse files Browse the repository at this point in the history
Signed-off-by: starry-shivam <[email protected]>
  • Loading branch information
starry-shivam committed Feb 23, 2024
1 parent 88da1f6 commit 79ffd30
Show file tree
Hide file tree
Showing 14 changed files with 379 additions and 152,132 deletions.
2 changes: 0 additions & 2 deletions app/src/main/java/com/starry/greenstash/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import com.starry.greenstash.ui.screens.settings.viewmodels.SettingsViewModel
import com.starry.greenstash.ui.screens.settings.viewmodels.ThemeMode
import com.starry.greenstash.ui.theme.GreenStashTheme
import com.starry.greenstash.utils.Utils
import com.starry.greenstash.utils.toToast
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.ExperimentalCoroutinesApi
import java.util.concurrent.Executor
Expand Down Expand Up @@ -104,7 +103,6 @@ class MainActivity : AppCompatActivity() {
result: BiometricPrompt.AuthenticationResult
) {
super.onAuthenticationSucceeded(result)
getString(R.string.auth_successful).toToast(this@MainActivity)
// make app contents visible after successful authentication.
setAppContents()
mainViewModel.appUnlocked = true
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/com/starry/greenstash/ui/navigation/NavGraph.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import com.starry.greenstash.ui.screens.backups.BackupScreen
import com.starry.greenstash.ui.screens.home.composables.HomeScreen
import com.starry.greenstash.ui.screens.info.composables.GoalInfoScreen
import com.starry.greenstash.ui.screens.input.composables.DWScreen
import com.starry.greenstash.ui.screens.input.composables.CongratsScreen
import com.starry.greenstash.ui.screens.input.composables.InputScreen
import com.starry.greenstash.ui.screens.settings.composables.AboutScreen
import com.starry.greenstash.ui.screens.settings.composables.OSLScreen
Expand Down Expand Up @@ -175,6 +176,17 @@ fun NavGraph(
InputScreen(editGoalId = editGoalId, navController = navController)
}

/** Goal Achieved Screen */
composable(
route = Screens.CongratsScreen.route,
enterTransition = { enterTransition() },
exitTransition = { exitTransition() },
popEnterTransition = { popEnterTransition() },
popExitTransition = { popExitTransition() },
) {
CongratsScreen(navController = navController)
}

/** Backup Screen */
composable(
route = DrawerScreens.Backups.route,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ sealed class Screens(val route: String) {
}
}

data object CongratsScreen: Screens("goal_achieved_screen")
data object AboutScreen : Screens("about_screen")
data object OSLScreen : Screens("osl_screen")
data object WelcomeScreen : Screens("welcome_screen")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package com.starry.greenstash.ui.screens.input.composables

import androidx.activity.compose.BackHandler
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.airbnb.lottie.compose.LottieAnimation
import com.airbnb.lottie.compose.LottieCompositionResult
import com.airbnb.lottie.compose.LottieCompositionSpec
import com.airbnb.lottie.compose.LottieConstants
import com.airbnb.lottie.compose.animateLottieCompositionAsState
import com.airbnb.lottie.compose.rememberLottieComposition
import com.starry.greenstash.R
import com.starry.greenstash.ui.navigation.DrawerScreens

@Composable
fun CongratsScreen(navController: NavController) {
Scaffold(modifier = Modifier.fillMaxSize()) { paddingValues ->

BackHandler {
navController.popBackStack(DrawerScreens.Home.route, true)
navController.navigate(DrawerScreens.Home.route)
}

Column(
modifier = Modifier
.fillMaxSize()
.padding(paddingValues)
.verticalScroll(rememberScrollState()),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
val compositionResult: LottieCompositionResult = rememberLottieComposition(
spec = LottieCompositionSpec.RawRes(R.raw.congrats_lottie)
)
val progressAnimation by animateLottieCompositionAsState(
compositionResult.value,
isPlaying = true,
iterations = LottieConstants.IterateForever,
speed = 1f
)

LottieAnimation(
composition = compositionResult.value,
progress = progressAnimation,
modifier = Modifier.size(320.dp),
enableMergePaths = true
)

Text(
text = stringResource(id = R.string.goal_achieved_heading),
fontWeight = FontWeight.Bold,
fontSize = 24.sp
)

Spacer(modifier = Modifier.height(10.dp))

Text(
text = stringResource(id = R.string.goal_achieved_subtext),
fontWeight = FontWeight.SemiBold,
fontSize = 20.sp,
)

Spacer(modifier = Modifier.height(10.dp))

OutlinedButton(
onClick = {
navController.popBackStack(DrawerScreens.Home.route, true)
navController.navigate(DrawerScreens.Home.route)
},
shape = RoundedCornerShape(12.dp),
modifier = Modifier.width(100.dp)
) {
Text(text = stringResource(id = R.string.goal_achieved_button))
}

Spacer(modifier = Modifier.height(100.dp))
}
}
}

@Preview
@Composable
private fun PV() {
CongratsScreen(rememberNavController())
}
Loading

0 comments on commit 79ffd30

Please sign in to comment.