Skip to content

Commit

Permalink
Add archived goal item card
Browse files Browse the repository at this point in the history
Signed-off-by: starry-shivam <[email protected]>
  • Loading branch information
starry-shivam committed May 7, 2024
1 parent 990c621 commit a919d89
Show file tree
Hide file tree
Showing 12 changed files with 192 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ sealed class DrawerScreens(val route: String, val nameResId: Int, val iconResId:
DrawerScreens("archive", R.string.drawer_archive, R.drawable.ic_nav_archive)

data object Backups :
DrawerScreens("backups", R.string.drawer_backups, R.drawable.ic_nav_backups)
DrawerScreens("backups", R.string.drawer_backup, R.drawable.ic_nav_backups)

data object Settings :
DrawerScreens("settings", R.string.drawer_settings, R.drawable.ic_nav_settings)
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 @@ -34,6 +34,7 @@ import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import com.starry.greenstash.ui.screens.archive.composables.ArchiveScreen
import com.starry.greenstash.ui.screens.backups.composables.BackupScreen
import com.starry.greenstash.ui.screens.dwscreen.composables.DWScreen
import com.starry.greenstash.ui.screens.home.composables.HomeScreen
Expand Down Expand Up @@ -144,6 +145,17 @@ fun NavGraph(
CongratsScreen(navController = navController)
}

/** Archive Screen */
composable(
route = DrawerScreens.Archive.route,
enterTransition = { enterTransition() },
exitTransition = { exitTransition() },
popEnterTransition = { popEnterTransition() },
popExitTransition = { popExitTransition() },
) {
ArchiveScreen(navController = navController)
}

/** Backup Screen */
composable(
route = DrawerScreens.Backups.route,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,156 @@

package com.starry.greenstash.ui.screens.archive.composables

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
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.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Face2
import androidx.compose.material.icons.filled.Image
import androidx.compose.material.icons.filled.Refresh
import androidx.compose.material.icons.outlined.Delete
import androidx.compose.material3.Card
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavController
import com.starry.greenstash.ui.screens.archive.ArchiveViewModel
import com.starry.greenstash.ui.theme.greenstashFont
import com.starry.greenstash.ui.theme.greenstashNumberFont

@Composable
fun ArchiveScreen(navController: NavController) {
val viewModel: ArchiveViewModel = hiltViewModel()
ArchivedGoalItem(
title = "Home Decorations",
icon = Icons.Filled.Face2,
savedAmount = "₹10,000",
onRestoreClicked = {},
onDeleteClicked = {}
)
}

@Composable
fun ArchivedGoalItem(
title: String,
icon: ImageVector?,
savedAmount: String,
onRestoreClicked: () -> Unit,
onDeleteClicked: () -> Unit
) {
Card(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 12.dp, vertical = 8.dp)
) {
Column(
Modifier
.fillMaxWidth()
.padding(12.dp)
) {
Row(
modifier = Modifier
.fillMaxWidth()
) {
Icon(
imageVector = icon ?: Icons.Filled.Image,
contentDescription = title,
modifier = Modifier.size(40.dp)
)

Spacer(modifier = Modifier.weight(1f))

Box(
modifier = Modifier
.size(40.dp)
.background(
color = MaterialTheme.colorScheme.primaryContainer,
shape = CircleShape
)
.clip(CircleShape)
.clickable { onRestoreClicked() }
) {
Icon(
imageVector = Icons.Filled.Refresh,
contentDescription = title,
modifier = Modifier
.fillMaxSize()
.padding(10.dp),
)
}
Spacer(modifier = Modifier.width(16.dp))

Box(
modifier = Modifier
.size(40.dp)
.background(
color = MaterialTheme.colorScheme.primaryContainer,
shape = CircleShape
)
.clip(CircleShape)
.clickable { onDeleteClicked() }
) {
Icon(
imageVector = Icons.Outlined.Delete,
contentDescription = title,
modifier = Modifier
.fillMaxSize()
.padding(10.dp),
)
}
}

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

Text(
text = title,
fontWeight = FontWeight.Medium,
fontFamily = greenstashFont,
fontSize = 18.sp,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)

Text(
text = savedAmount,
fontSize = 22.sp,
fontFamily = greenstashNumberFont,
fontWeight = FontWeight.Bold,
maxLines = 2,
)
}
}
}

@Preview
@Composable
fun ArchiveItemPV() {
ArchivedGoalItem(
title = "Home Decorations",
icon = Icons.Filled.Face2,
savedAmount = "₹10,000",
onRestoreClicked = {},
onDeleteClicked = {}
)
}

// TODO: Implement the Archive Screen
}
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ fun GoalItemsPV() {
savedAmount = "$1,000.00",
daysLeftText = "Goal Achieved! 🎉",
goalProgress = 0.8f,
goalIcon = ImageVector.vectorResource(id = R.drawable.ic_nav_backups),
goalIcon = ImageVector.vectorResource(id = R.drawable.ic_nav_rating),
onDepositClicked = {},
onWithdrawClicked = {},
onInfoClicked = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ fun GoalLazyColumnItem(
openDeleteDialog = openDeleteDialog,
onDeleteConfirmed = {
viewModel.deleteGoal(item.goal)
coroutineScope.launch {
/*coroutineScope.launch {
snackBarHostState.showSnackbar(context.getString(R.string.goal_delete_success))
}
}*/
}
)
}
6 changes: 3 additions & 3 deletions app/src/main/res/drawable/ic_nav_archive.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

<path
android:fillColor="#1C274C"
android:pathData="M20.5348 3.46447C19.0704 2 16.7133 2 11.9993 2C7.28525 2 4.92823 2 3.46377 3.46447C2.70628 4.22195 2.3406 5.21824 2.16406 6.65598C2.69473 6.06532 3.33236 5.57328 4.04836 5.20846C4.82984 4.81027 5.66664 4.6488 6.59316 4.5731C7.48829 4.49997 8.58971 4.49998 9.93646 4.5H14.0621C15.4089 4.49998 16.5103 4.49997 17.4054 4.5731C18.332 4.6488 19.1688 4.81027 19.9502 5.20846C20.6662 5.57328 21.3039 6.06532 21.8345 6.65598C21.658 5.21824 21.2923 4.22195 20.5348 3.46447Z" />
android:fillType="evenOdd"
android:pathData="M2.54497 8.73005C2 9.79961 2 11.1997 2 14C2 16.8003 2 18.2004 2.54497 19.27C3.02433 20.2108 3.78924 20.9757 4.73005 21.455C5.79961 22 7.19974 22 10 22H14C16.8003 22 18.2004 22 19.27 21.455C20.2108 20.9757 20.9757 20.2108 21.455 19.27C22 18.2004 22 16.8003 22 14C22 11.1997 22 9.79961 21.455 8.73005C20.9757 7.78924 20.2108 7.02433 19.27 6.54497C18.2004 6 16.8003 6 14 6H10C7.19974 6 5.79961 6 4.73005 6.54497C3.78924 7.02433 3.02433 7.78924 2.54497 8.73005ZM15.0595 12.4995C15.3353 12.1905 15.3085 11.7164 14.9995 11.4406C14.6905 11.1647 14.2164 11.1915 13.9406 11.5005L10.9286 14.8739L10.0595 13.9005C9.78359 13.5915 9.30947 13.5647 9.0005 13.8406C8.69152 14.1164 8.66468 14.5905 8.94055 14.8995L10.3691 16.4995C10.5114 16.6589 10.7149 16.75 10.9286 16.75C11.1422 16.75 11.3457 16.6589 11.488 16.4995L15.0595 12.4995Z" />
<path
android:fillColor="#1C274C"
android:fillType="evenOdd"
android:pathData="M2 14C2 11.1997 2 9.79961 2.54497 8.73005C3.02433 7.78924 3.78924 7.02433 4.73005 6.54497C5.79961 6 7.19974 6 10 6H14C16.8003 6 18.2004 6 19.27 6.54497C20.2108 7.02433 20.9757 7.78924 21.455 8.73005C22 9.79961 22 11.1997 22 14C22 16.8003 22 18.2004 21.455 19.27C20.9757 20.2108 20.2108 20.9757 19.27 21.455C18.2004 22 16.8003 22 14 22H10C7.19974 22 5.79961 22 4.73005 21.455C3.78924 20.9757 3.02433 20.2108 2.54497 19.27C2 18.2004 2 16.8003 2 14ZM12.5303 10.4697C12.3897 10.329 12.1989 10.25 12 10.25C11.8011 10.25 11.6103 10.329 11.4697 10.4697L8.96967 12.9697C8.67678 13.2626 8.67678 13.7374 8.96967 14.0303C9.26256 14.3232 9.73744 14.3232 10.0303 14.0303L11.25 12.8107V17C11.25 17.4142 11.5858 17.75 12 17.75C12.4142 17.75 12.75 17.4142 12.75 17V12.8107L13.9697 14.0303C14.2626 14.3232 14.7374 14.3232 15.0303 14.0303C15.3232 13.7374 15.3232 13.2626 15.0303 12.9697L12.5303 10.4697Z" />
android:pathData="M20.5348 3.46447C19.0704 2 16.7133 2 11.9993 2C7.28525 2 4.92823 2 3.46377 3.46447C2.70628 4.22195 2.3406 5.21824 2.16406 6.65598C2.69473 6.06532 3.33236 5.57328 4.04836 5.20846C4.82984 4.81027 5.66664 4.6488 6.59316 4.5731C7.48829 4.49997 8.58971 4.49998 9.93646 4.5H14.0621C15.4089 4.49998 16.5103 4.49997 17.4054 4.5731C18.332 4.6488 19.1688 4.81027 19.9502 5.20846C20.6662 5.57328 21.3039 6.06532 21.8345 6.65598C21.658 5.21824 21.2923 4.22195 20.5348 3.46447Z" />
</vector>
6 changes: 5 additions & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

<!-- Navigation Drawer -->
<string name="drawer_home">Inicio</string>
<string name="drawer_backups">Respaldo</string>
<string name="drawer_archive">Archivo</string>
<string name="drawer_backup">Respaldo</string>
<string name="drawer_settings">Ajustes</string>
<string name="drawer_rating">Calificarnos</string>
<string name="drawer_share">Compartir</string>
Expand Down Expand Up @@ -70,6 +71,9 @@
<string name="goal_already_achieved">Ya has completado esta meta.</string>
<string name="withdraw_button">Retirar</string>
<string name="withdraw_button_error">No has depositado nada aún.</string>
<string name="archive_button">Archivar</string>
<string name="goal_archive_confirmation">¿Quieres archivar esta meta?</string>
<string name="goal_archive_success">Archivado correctamente.</string>
<string name="goal_delete_confirmation">¿Estás seguro/a?</string>
<string name="goal_delete_success">Eliminación exitosa.</string>
<string name="info_button_description">Ver información de la meta.</string>
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

<!-- Navigation Drawer -->
<string name="drawer_home">Главная</string>
<string name="drawer_backups">Резервные копии</string>
<string name="drawer_archive">Архив</string>
<string name="drawer_backup">Резервные копии</string>
<string name="drawer_settings">Настройки</string>
<string name="drawer_rating">Оценить нас</string>
<string name="drawer_share">Поделиться</string>
Expand Down Expand Up @@ -71,6 +72,9 @@
<string name="goal_already_achieved">Вы уже достигли этой цели.</string>
<string name="withdraw_button">Вывести</string>
<string name="withdraw_button_error">Вы еще не вносили никакой суммы.</string>
<string name="archive_button">Архивировать</string>
<string name="goal_archive_confirmation">Хотите ли вы архивировать эту цель?</string>
<string name="goal_archive_success">Успешно архивировано.</string>
<string name="goal_delete_confirmation">Вы уверены?</string>
<string name="goal_delete_success">Удалено успешно.</string>
<string name="info_button_description">Просмотр информации о цели.</string>
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

<!-- Navigation Drawer -->
<string name="drawer_home">Ana Sayfa</string>
<string name="drawer_backups">Yedekler</string>
<string name="drawer_archive">Arşiv</string>
<string name="drawer_backup">Yedekler</string>
<string name="drawer_settings">Ayarlar</string>
<string name="drawer_rating">Bizi Değerlendir</string>
<string name="drawer_share">Paylaş</string>
Expand Down Expand Up @@ -70,6 +71,9 @@
<string name="goal_already_achieved">Birikim hedefine zaten ulaştın.</string>
<string name="withdraw_button">çek</string>
<string name="withdraw_button_error">Henüz herhangi bir tutar yatırmadın.</string>
<string name="archive_button">Arşivle</string>
<string name="goal_archive_confirmation">Bu hedefi arşivlemek istiyor musunuz?</string>
<string name="goal_archive_success">Başarıyla arşivlendi.</string>
<string name="goal_delete_confirmation">Emin misin?</string>
<string name="goal_delete_success">Başarıyla Silindi.</string>
<string name="info_button_description">Hedef bilgilerini görüntüle.</string>
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

<!-- Navigation Drawer -->
<string name="drawer_home">主页</string>
<string name="drawer_backups">备份</string>
<string name="drawer_archive">存档</string>
<string name="drawer_backup">备份</string>
<string name="drawer_settings">设置</string>
<string name="drawer_rating">给我们评分</string>
<string name="drawer_share">分享</string>
Expand Down Expand Up @@ -69,6 +70,9 @@
<string name="goal_already_achieved">您已经实现了此目标。</string>
<string name="withdraw_button">取钱</string>
<string name="withdraw_button_error">您尚未存入任何金额。</string>
<string name="archive_button">存档</string>
<string name="goal_archive_confirmation">您要存档此目标吗?</string>
<string name="goal_archive_success">已成功存档。</string>
<string name="goal_delete_confirmation">确定吗?</string>
<string name="goal_delete_success">删除成功。</string>
<string name="info_button_description">查看目标信息。</string>
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

<!-- Navigation Drawer -->
<string name="drawer_home">首頁</string>
<string name="drawer_backups">備份</string>
<string name="drawer_archive">存檔</string>
<string name="drawer_backup">備份</string>
<string name="drawer_settings">設定</string>
<string name="drawer_rating">給我們評分</string>
<string name="drawer_share">分享</string>
Expand Down Expand Up @@ -68,6 +69,9 @@
<string name="goal_already_achieved">您已達成此目標。</string>
<string name="withdraw_button">提款</string>
<string name="withdraw_button_error">您尚未存入任何金額。</string>
<string name="archive_button">存檔</string>
<string name="goal_archive_confirmation">您要將此目標存檔嗎?</string>
<string name="goal_archive_success">已成功存檔。</string>
<string name="goal_delete_confirmation">您確定嗎?</string>
<string name="goal_delete_success">成功刪除。</string>
<string name="info_button_description">檢視目標資訊。</string>
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!-- Navigation Drawer -->
<string name="drawer_home">Home</string>
<string name="drawer_archive">Archive</string>
<string name="drawer_backups">Backups</string>
<string name="drawer_backup">Backup</string>
<string name="drawer_settings">Settings</string>
<string name="drawer_rating">Rate Us</string>
<string name="drawer_share">Share</string>
Expand Down Expand Up @@ -70,6 +70,9 @@
<string name="goal_already_achieved">You\'ve already achieved this goal.</string>
<string name="withdraw_button">Withdraw</string>
<string name="withdraw_button_error">You haven\'t deposited any amount yet.</string>
<string name="archive_button">Archive</string>
<string name="goal_archive_confirmation">Do you want to archive this goal?</string>
<string name="goal_archive_success">Archived Successfully.</string>
<string name="goal_delete_confirmation">Are you sure?</string>
<string name="goal_delete_success">Deleted Successfully.</string>
<string name="info_button_description">View goal information.</string>
Expand Down

0 comments on commit a919d89

Please sign in to comment.