Skip to content

Commit

Permalink
Minor UI improvements
Browse files Browse the repository at this point in the history
Signed-off-by: starry-shivam <[email protected]>
  • Loading branch information
starry-shivam committed Dec 25, 2023
1 parent 1399e4d commit e3ca60a
Show file tree
Hide file tree
Showing 25 changed files with 118 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ package com.starry.greenstash.ui.navigation
import com.starry.greenstash.R

sealed class DrawerScreens(val route: String, val nameResId: Int, val iconResId: Int) {
object Home : DrawerScreens("home", R.string.drawer_home, R.drawable.ic_nav_home)
object Backups : DrawerScreens("backups", R.string.drawer_backups, R.drawable.ic_nav_backups)
object Settings :
data object Home : DrawerScreens("home", R.string.drawer_home, R.drawable.ic_nav_home)
data object Backups : DrawerScreens("backups", R.string.drawer_backups, R.drawable.ic_nav_backups)
data object Settings :
DrawerScreens("settings", R.string.drawer_settings, R.drawable.ic_nav_settings)
}

Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/starry/greenstash/ui/navigation/Screens.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ const val EDIT_GOAL_ARG_KEY = "editGoal"
const val GOAL_INFO_ARG_KEY = "goalId"

sealed class Screens(val route: String) {
object InputScreen : Screens("input_screen?$EDIT_GOAL_ARG_KEY={$EDIT_GOAL_ARG_KEY}") {
data object InputScreen : Screens("input_screen?$EDIT_GOAL_ARG_KEY={$EDIT_GOAL_ARG_KEY}") {
fun withGoalToEdit(goalId: String): String {
return route.replace("{$EDIT_GOAL_ARG_KEY}", goalId)
}
}

object GoalInfoScreen : Screens("goal_info_screen/{$GOAL_INFO_ARG_KEY}") {
data object GoalInfoScreen : Screens("goal_info_screen/{$GOAL_INFO_ARG_KEY}") {
fun withGoalId(goalId: String): String {
return route.replace("{$GOAL_INFO_ARG_KEY}", goalId)
}
}

object AboutScreen : Screens("about_screen")
object OSLScreen : Screens("osl_screen")
object WelcomeScreen : Screens("welcome_screen")
data object AboutScreen : Screens("about_screen")
data object OSLScreen : Screens("osl_screen")
data object WelcomeScreen : Screens("welcome_screen")
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import androidx.compose.ui.unit.sp
import coil.compose.AsyncImage
import coil.request.ImageRequest
import com.starry.greenstash.R
import com.starry.greenstash.ui.theme.greenstashFont

@Composable
fun GoalItem(
Expand Down Expand Up @@ -148,7 +149,8 @@ fun GoalItem(
Text(
text = stringResource(id = R.string.deposit_button).uppercase(),
fontWeight = FontWeight.SemiBold,
color = MaterialTheme.colorScheme.onSurface
color = MaterialTheme.colorScheme.onSurface,
fontFamily = greenstashFont
)
}
TextButton(
Expand All @@ -157,7 +159,8 @@ fun GoalItem(
Text(
text = stringResource(id = R.string.withdraw_button).uppercase(),
fontWeight = FontWeight.SemiBold,
color = MaterialTheme.colorScheme.onSurface
color = MaterialTheme.colorScheme.onSurface,
fontFamily = greenstashFont
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.starry.greenstash.R
import com.starry.greenstash.ui.screens.home.viewmodels.SearchWidgetState
import com.starry.greenstash.ui.theme.greenstashFont

@ExperimentalMaterial3Api
@Composable
Expand Down Expand Up @@ -108,6 +109,7 @@ fun DefaultAppBar(
stringResource(id = R.string.home_screen_header),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
fontFamily = greenstashFont
)
}, navigationIcon = {
IconButton(onClick = { onMenuClicked() }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ import com.starry.greenstash.ui.screens.home.viewmodels.FilterField
import com.starry.greenstash.ui.screens.home.viewmodels.FilterSortType
import com.starry.greenstash.ui.screens.home.viewmodels.HomeViewModel
import com.starry.greenstash.ui.screens.home.viewmodels.SearchWidgetState
import com.starry.greenstash.utils.Utils
import com.starry.greenstash.utils.isScrollingUp
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.delay
Expand Down Expand Up @@ -197,18 +198,19 @@ fun HomeScreenContent(
Spacer(Modifier.height(14.dp))

Text(
text = stringResource(id = R.string.app_name),
text = Utils.getGreeting(),
modifier = Modifier.padding(start = 16.dp, top = 12.dp),
fontSize = 18.sp,
fontWeight = FontWeight.Medium,
fontSize = 24.sp,
fontWeight = FontWeight.SemiBold,
color = MaterialTheme.colorScheme.onSurface
)

Divider(
thickness = 1.dp,
thickness = 0.5.dp,
modifier = Modifier
.fillMaxWidth()
.padding(top = 16.dp, bottom = 16.dp),
color = MaterialTheme.colorScheme.onSurface
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.2f)
)

items.forEach { item ->
Expand Down Expand Up @@ -528,15 +530,15 @@ fun FilterMenuSheet(viewModel: HomeViewModel) {
)
Row(modifier = Modifier.fillMaxWidth()) {
Column(modifier = Modifier.weight(1f), verticalArrangement = Arrangement.Center) {
FilterField.values().forEach {
FilterField.entries.forEach {
FilterButton(
text = it.name,
isSelected = it == viewModel.filterFlowData.value.filterField,
onClick = { viewModel.updateFilterField(it) })
}
}
Column(modifier = Modifier.weight(1f), verticalArrangement = Arrangement.Center) {
FilterSortType.values().forEach {
FilterSortType.entries.forEach {
FilterButton(
text = it.name,
isSelected = viewModel.filterFlowData.value.sortType.name == it.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ import com.starry.greenstash.ui.common.ExpandableCard
import com.starry.greenstash.ui.common.ExpandableTextCard
import com.starry.greenstash.ui.screens.info.viewmodels.InfoViewModel
import com.starry.greenstash.ui.screens.settings.viewmodels.ThemeMode
import com.starry.greenstash.ui.theme.greenstashFont
import com.starry.greenstash.utils.Utils
import com.starry.greenstash.utils.getActivity
import kotlinx.coroutines.ExperimentalCoroutinesApi
Expand All @@ -121,6 +122,7 @@ fun GoalInfoScreen(goalId: String, navController: NavController) {
text = stringResource(id = R.string.info_screen_header),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
fontFamily = greenstashFont
)
}, navigationIcon = {
IconButton(onClick = { navController.navigateUp() }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ import com.starry.greenstash.database.goal.GoalPriority
import com.starry.greenstash.ui.common.SelectableChipGroup
import com.starry.greenstash.ui.navigation.DrawerScreens
import com.starry.greenstash.ui.screens.input.viewmodels.InputViewModel
import com.starry.greenstash.ui.theme.greenstashFont
import com.starry.greenstash.utils.Utils
import com.starry.greenstash.utils.getActivity
import com.starry.greenstash.utils.hasNotificationPermission
Expand Down Expand Up @@ -237,6 +238,7 @@ fun InputScreen(editGoalId: String?, navController: NavController) {
text = topBarText,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
fontFamily = greenstashFont
)
}, navigationIcon = {
IconButton(onClick = { navController.navigateUp() }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import com.starry.greenstash.R
import com.starry.greenstash.ui.navigation.Screens
import com.starry.greenstash.ui.screens.settings.viewmodels.DateStyle
import com.starry.greenstash.ui.screens.settings.viewmodels.ThemeMode
import com.starry.greenstash.ui.theme.greenstashFont
import com.starry.greenstash.utils.Utils
import com.starry.greenstash.utils.getActivity
import com.starry.greenstash.utils.toToast
Expand Down Expand Up @@ -110,7 +111,8 @@ fun SettingsScreen(navController: NavController) {
Text(
stringResource(id = R.string.settings_screen_header),
maxLines = 1,
overflow = TextOverflow.Ellipsis
overflow = TextOverflow.Ellipsis,
fontFamily = greenstashFont
)
}, navigationIcon = {
IconButton(onClick = { navController.navigateUp() }) {
Expand Down
37 changes: 36 additions & 1 deletion app/src/main/java/com/starry/greenstash/ui/theme/Type.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,49 @@ package com.starry.greenstash.ui.theme

import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
import com.starry.greenstash.R

val greenstashFont = FontFamily(
listOf(
Font(
resId = R.font.redhatdisplay_black,
weight = FontWeight.Black
),
Font(
resId = R.font.redhatdisplay_bold,
weight = FontWeight.Bold
),
Font(
resId = R.font.redhatdisplay_extrabold,
weight = FontWeight.ExtraBold
),
Font(
resId = R.font.redhatdisplay_light,
weight = FontWeight.Light
),
Font(
resId = R.font.redhatdisplay_medium,
weight = FontWeight.Medium
),
Font(
resId = R.font.redhatdisplay_regular,
weight = FontWeight.Normal
),
Font(
resId = R.font.redhatdisplay_semibold,
weight = FontWeight.SemiBold
),
)
)

// Set of Material typography styles to start with
val Typography = Typography(
bodyLarge = TextStyle(
fontFamily = FontFamily.Default,
fontFamily = greenstashFont,
fontWeight =
FontWeight.Normal,
fontSize = 16.sp,
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/com/starry/greenstash/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTIAL
import java.math.RoundingMode
import java.text.DecimalFormat
import java.text.DecimalFormatSymbols
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale

object Utils {
Expand Down Expand Up @@ -75,4 +77,17 @@ object Utils {
} else {
BIOMETRIC_STRONG or DEVICE_CREDENTIAL
}

fun getGreeting(): String {
val currentTime = System.currentTimeMillis()
val simpleDateFormat = SimpleDateFormat("HH", Locale.US)

return when (simpleDateFormat.format(Date(currentTime)).toInt()) {
in 0..11 -> "Good Morning!"
in 12..16 -> "Good Afternoon!"
in 17..20 -> "Good Evening!"
else -> "Good Night!"
}
}

}
10 changes: 8 additions & 2 deletions app/src/main/res/drawable/ic_goal_delete.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="@android:color/white"
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z" />
android:fillColor="#1C274C"
android:pathData="M3 6.38597C3 5.90152 3.34538 5.50879 3.77143 5.50879L6.43567 5.50832C6.96502 5.49306 7.43202 5.11033 7.61214 4.54412C7.61688 4.52923 7.62232 4.51087 7.64185 4.44424L7.75665 4.05256C7.8269 3.81241 7.8881 3.60318 7.97375 3.41617C8.31209 2.67736 8.93808 2.16432 9.66147 2.03297C9.84457 1.99972 10.0385 1.99986 10.2611 2.00002H13.7391C13.9617 1.99986 14.1556 1.99972 14.3387 2.03297C15.0621 2.16432 15.6881 2.67736 16.0264 3.41617C16.1121 3.60318 16.1733 3.81241 16.2435 4.05256L16.3583 4.44424C16.3778 4.51087 16.3833 4.52923 16.388 4.54412C16.5682 5.11033 17.1278 5.49353 17.6571 5.50879H20.2286C20.6546 5.50879 21 5.90152 21 6.38597C21 6.87043 20.6546 7.26316 20.2286 7.26316H3.77143C3.34538 7.26316 3 6.87043 3 6.38597Z" />
<path
android:fillColor="#1C274C"
android:fillType="evenOdd"
android:pathData="M11.5956 22.0001H12.4044C15.1871 22.0001 16.5785 22.0001 17.4831 21.1142C18.3878 20.2283 18.4803 18.7751 18.6654 15.8686L18.9321 11.6807C19.0326 10.1037 19.0828 9.31524 18.6289 8.81558C18.1751 8.31592 17.4087 8.31592 15.876 8.31592H8.12404C6.59127 8.31592 5.82488 8.31592 5.37105 8.81558C4.91722 9.31524 4.96744 10.1037 5.06788 11.6807L5.33459 15.8686C5.5197 18.7751 5.61225 20.2283 6.51689 21.1142C7.42153 22.0001 8.81289 22.0001 11.5956 22.0001ZM10.2463 12.1886C10.2051 11.7548 9.83753 11.4382 9.42537 11.4816C9.01321 11.525 8.71251 11.9119 8.75372 12.3457L9.25372 17.6089C9.29494 18.0427 9.66247 18.3593 10.0746 18.3159C10.4868 18.2725 10.7875 17.8856 10.7463 17.4518L10.2463 12.1886ZM14.5746 11.4816C14.9868 11.525 15.2875 11.9119 15.2463 12.3457L14.7463 17.6089C14.7051 18.0427 14.3375 18.3593 13.9254 18.3159C13.5132 18.2725 13.2125 17.8856 13.2537 17.4518L13.7537 12.1886C13.7949 11.7548 14.1625 11.4382 14.5746 11.4816Z" />
</vector>
9 changes: 7 additions & 2 deletions app/src/main/res/drawable/ic_goal_edit.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="@android:color/white"
android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z" />
android:fillColor="#1C274C"
android:pathData="M11.4001 18.1612L11.4001 18.1612L18.796 10.7653C17.7894 10.3464 16.5972 9.6582 15.4697 8.53068C14.342 7.40298 13.6537 6.21058 13.2348 5.2039L5.83882 12.5999L5.83879 12.5999C5.26166 13.1771 4.97307 13.4657 4.7249 13.7838C4.43213 14.1592 4.18114 14.5653 3.97634 14.995C3.80273 15.3593 3.67368 15.7465 3.41556 16.5208L2.05445 20.6042C1.92743 20.9852 2.0266 21.4053 2.31063 21.6894C2.59466 21.9734 3.01478 22.0726 3.39584 21.9456L7.47918 20.5844C8.25351 20.3263 8.6407 20.1973 9.00498 20.0237C9.43469 19.8189 9.84082 19.5679 10.2162 19.2751C10.5343 19.0269 10.823 18.7383 11.4001 18.1612Z" />
<path
android:fillColor="#1C274C"
android:pathData="M20.8482 8.71306C22.3839 7.17735 22.3839 4.68748 20.8482 3.15178C19.3125 1.61607 16.8226 1.61607 15.2869 3.15178L14.3999 4.03882C14.4121 4.0755 14.4246 4.11268 14.4377 4.15035C14.7628 5.0875 15.3763 6.31601 16.5303 7.47002C17.6843 8.62403 18.9128 9.23749 19.85 9.56262C19.8875 9.57563 19.9245 9.58817 19.961 9.60026L20.8482 8.71306Z" />
</vector>
7 changes: 5 additions & 2 deletions app/src/main/res/drawable/ic_goal_info.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="@android:color/white"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z" />
android:fillColor="#1C274C"
android:fillType="evenOdd"
android:pathData="M22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12ZM12 17.75C12.4142 17.75 12.75 17.4142 12.75 17V11C12.75 10.5858 12.4142 10.25 12 10.25C11.5858 10.25 11.25 10.5858 11.25 11V17C11.25 17.4142 11.5858 17.75 12 17.75ZM12 7C12.5523 7 13 7.44772 13 8C13 8.55228 12.5523 9 12 9C11.4477 9 11 8.55228 11 8C11 7.44772 11.4477 7 12 7Z" />
</vector>
12 changes: 8 additions & 4 deletions app/src/main/res/drawable/ic_nav_backups.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#000000"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="@android:color/white"
android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM14,13v4h-4v-4H7l5,-5 5,5h-3z" />
</vector>
android:fillColor="#1C274C"
android:pathData="M16.7137 2.12656C15.8784 1.69663 14.7918 2.39036 12.6187 3.77783L12.0565 4.13679C11.4389 4.53106 11.1301 4.7282 10.7836 4.78478C10.4371 4.84135 10.092 4.75097 9.40191 4.57019L8.77361 4.4056C6.34506 3.76944 5.13079 3.45136 4.43551 4.1312C3.74024 4.81103 4.02442 6.03855 4.59279 8.4936L4.73983 9.12875C4.90135 9.82639 4.9821 10.1752 4.91653 10.5216C4.85096 10.868 4.64648 11.1727 4.23754 11.7821L3.86521 12.3369C2.42609 14.4815 1.70653 15.5538 2.11218 16.4039C2.51782 17.254 3.78002 17.3189 6.30442 17.4487L6.95753 17.4823C7.67487 17.5192 8.03356 17.5377 8.33956 17.6952C8.64557 17.8526 8.86425 18.1314 9.30163 18.6888L9.69981 19.1963C11.2389 21.1578 12.0085 22.1386 12.9545 21.9842C13.9005 21.8297 14.3964 20.6423 15.3882 18.2675L15.6448 17.6531C15.9266 16.9783 16.0675 16.6409 16.3222 16.3918C16.5769 16.1428 16.9165 16.0104 17.5958 15.7454L18.2142 15.5043C20.6046 14.572 21.7997 14.1059 21.9787 13.1603C22.1577 12.2148 21.202 11.416 19.2906 9.81846L18.7961 9.40516C18.2529 8.9512 17.9813 8.7242 17.8327 8.4128C17.6841 8.10139 17.6753 7.74082 17.6578 7.01967L17.6418 6.36312C17.58 3.82537 17.5491 2.5565 16.7137 2.12656Z" />
<path
android:fillColor="#1C274C"
android:pathData="M19.5303 18.4697C19.2374 18.1768 18.7626 18.1768 18.4697 18.4697C18.1768 18.7626 18.1768 19.2374 18.4697 19.5303L20.4697 21.5303C20.7626 21.8232 21.2374 21.8232 21.5303 21.5303C21.8232 21.2374 21.8232 20.7626 21.5303 20.4697L19.5303 18.4697Z" />
</vector>
8 changes: 4 additions & 4 deletions app/src/main/res/drawable/ic_nav_home.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#000000"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z" />
</vector>
android:fillColor="#1C274C"
android:fillType="evenOdd"
android:pathData="M2.519,7.823C2,8.771 2,9.915 2,12.204V13.725C2,17.626 2,19.576 3.172,20.788C4.343,22 6.229,22 10,22H14C17.771,22 19.657,22 20.828,20.788C22,19.576 22,17.626 22,13.725V12.204C22,9.915 22,8.771 21.481,7.823C20.962,6.874 20.013,6.286 18.116,5.108L16.116,3.867C14.111,2.622 13.108,2 12,2C10.892,2 9.889,2.622 7.884,3.867L5.884,5.108C3.987,6.286 3.038,6.874 2.519,7.823ZM9.447,15.398C9.114,15.151 8.644,15.221 8.397,15.553C8.151,15.886 8.221,16.356 8.553,16.603C9.526,17.323 10.715,17.75 12,17.75C13.285,17.75 14.474,17.323 15.447,16.603C15.779,16.356 15.849,15.886 15.602,15.553C15.356,15.221 14.886,15.151 14.553,15.398C13.825,15.937 12.946,16.25 12,16.25C11.054,16.25 10.175,15.937 9.447,15.398Z" />
</vector>
Loading

0 comments on commit e3ca60a

Please sign in to comment.