Skip to content

Commit

Permalink
Add hint about ability to remove deadlines from existing goals (#103)
Browse files Browse the repository at this point in the history
Signed-off-by: starry-shivam <[email protected]>
  • Loading branch information
starry-shivam authored Apr 22, 2024
1 parent 9f779cb commit 80293d7
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ fun ExpandableCard(
text = title,
fontSize = titleFontSize,
fontWeight = titleFontWeight,
fontFamily = titleFontFamily,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ class InputViewModel @Inject constructor(
PreferenceUtil.DATE_FORMAT_STR, DateStyle.DateMonthYear.pattern
)

// Icon picker ==============

fun updateIconSearch(context: Context, search: String) {
_iconState.value = _iconState.value.copy(searchText = search)
iconSearchJob?.cancel()
Expand Down Expand Up @@ -232,9 +234,21 @@ class InputViewModel @Inject constructor(
return lines
}

// Onboarding ==============

fun onboardingTapTargetsShown() {
preferenceUtil.putBoolean(PreferenceUtil.INPUT_SCREEN_ONBOARDING_BOOL, false)
_showOnboardingTapTargets.value = false
}

fun shouldShowRemoveDeadlineTip(): Boolean {
return state.deadline.isNotBlank() && preferenceUtil.getBoolean(
PreferenceUtil.INPUT_REMOVE_DEADLINE_TIP_BOOL, true
)
}

fun removeDeadlineTipShown() {
preferenceUtil.putBoolean(PreferenceUtil.INPUT_REMOVE_DEADLINE_TIP_BOOL, false)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package com.starry.greenstash.ui.screens.input.composables

import android.Manifest
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.net.Uri
Expand Down Expand Up @@ -236,7 +237,7 @@ fun InputScreen(editGoalId: String?, navController: NavController) {
showRemoveDeadlineDialog.value = false
}, title = {
Text(
text = stringResource(id = R.string.goal_remove_deadline),
text = stringResource(id = R.string.input_goal_remove_deadline),
color = MaterialTheme.colorScheme.onSurface,
fontFamily = greenstashFont
)
Expand Down Expand Up @@ -303,6 +304,20 @@ fun InputScreen(editGoalId: String?, navController: NavController) {
scrollState.scrollTo(scrollState.maxValue)
}

// Show onboarding tip for removing deadline.
LaunchedEffect(key1 = viewModel.state.deadline) {
if (editGoalId != null && viewModel.shouldShowRemoveDeadlineTip()) {
val snackResult = snackBarHostState.showSnackbar(
message = context.getString(R.string.input_remove_deadline_tip),
actionLabel = context.getString(R.string.ok)
)
if (snackResult == SnackbarResult.ActionPerformed) {
viewModel.removeDeadlineTipShown()
}

}
}

Column(
modifier = Modifier
.fillMaxSize()
Expand Down Expand Up @@ -457,7 +472,8 @@ fun InputScreen(editGoalId: String?, navController: NavController) {
private fun GoalImagePicker(
goalImage: Any?,
photoPicker: ActivityResultLauncher<PickVisualMediaRequest>,
fabModifier: Modifier // To be used for onboarding tap target.
// To be used for onboarding tap target.
@SuppressLint("ModifierParameter") fabModifier: Modifier
) {
val context = LocalContext.current
Box(
Expand Down Expand Up @@ -733,7 +749,7 @@ private fun InputTextFields(
showRemoveDeadlineDialog: MutableState<Boolean>
) {
val haptic = LocalHapticFeedback.current
val textFeildSpacing = 8.dp
val textFieldSpacing = 8.dp

OutlinedTextField(
value = viewModel.state.goalTitleText,
Expand Down Expand Up @@ -762,7 +778,7 @@ private fun InputTextFields(
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
)

Spacer(modifier = Modifier.height(textFeildSpacing))
Spacer(modifier = Modifier.height(textFieldSpacing))

OutlinedTextField(
value = viewModel.state.targetAmount,
Expand Down Expand Up @@ -796,7 +812,7 @@ private fun InputTextFields(
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
)

Spacer(modifier = Modifier.height(textFeildSpacing))
Spacer(modifier = Modifier.height(textFieldSpacing))

val interactionSource = remember { MutableInteractionSource() }

Expand Down Expand Up @@ -846,7 +862,7 @@ private fun InputTextFields(
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
)

Spacer(modifier = Modifier.height(textFeildSpacing))
Spacer(modifier = Modifier.height(textFieldSpacing))

OutlinedTextField(
value = viewModel.state.additionalNotes,
Expand Down Expand Up @@ -899,9 +915,9 @@ private fun GoalAddedOREditedAnimation(editGoalId: String?) {
modifier = Modifier.size(320.dp)
)
val textStr = if (editGoalId == null) {
stringResource(id = R.string.goal_saved_success)
stringResource(id = R.string.input_goal_saved_success)
} else {
stringResource(id = R.string.goad_edit_success)
stringResource(id = R.string.input_goad_edit_success)
}
Text(
text = textStr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class PreferenceUtil(context: Context) {
// Onboarding preferences
const val HOME_SCREEN_ONBOARDING_BOOL = "show_home_screen_onboarding"
const val INPUT_SCREEN_ONBOARDING_BOOL = "show_input_onboarding"
const val INPUT_REMOVE_DEADLINE_TIP_BOOL = "show_input_remove_deadline_tip"
const val INFO_TRANSACTION_SWIPE_TIP_BOOL = "show_info_transaction_swipe_tip"
}

Expand Down
7 changes: 4 additions & 3 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@
<string name="input_additional_notes">Notas (Opcional)</string>
<string name="input_add_goal_button">Agregar Nueva Meta</string>
<string name="input_edit_goal_button">Actualizar Meta</string>
<string name="goal_saved_success">¡Buen trabajo! Meta agregada.</string>
<string name="goad_edit_success">Meta actualizada.</string>
<string name="goal_remove_deadline">¿Quieres quitar la fecha límite de este objetivo?</string>
<string name="input_goal_saved_success">¡Buen trabajo! Meta agregada.</string>
<string name="input_goad_edit_success">Meta actualizada.</string>
<string name="input_goal_remove_deadline">¿Quieres quitar la fecha límite de este objetivo?</string>
<string name="input_remove_deadline_tip">Consejo: Puedes eliminar la fecha límite de los objetivos existentes manteniendo pulsado el campo de fecha límite.</string>

<!-- Backup Screen -->
<string name="backup_screen_header">Respaldar y recuperar datos</string>
Expand Down
8 changes: 5 additions & 3 deletions app/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<string name="info_edit_transaction_button">İşlemi Güncelle</string>
<string name="info_transaction_onboarding_tip">İpucu: İşlemleri düzenlemek veya silmek için sola veya sağa kaydırın.</string>


<!-- Input (New/Edit Goal) Screen -->
<string name="input_screen_header">Birikim yapma zamanı!</string>
<string name="input_edit_goal_header">Birikim Hedefini Düzenle</string>
Expand All @@ -126,9 +127,10 @@
<string name="input_additional_notes">Notlar (Opsiyonel)</string>
<string name="input_add_goal_button">Yeni Birikim Hedefi Belirle</string>
<string name="input_edit_goal_button">Birikim Hedefini Güncelle</string>
<string name="goal_saved_success">Harika iş! Birikim hedefi belirlendi.</string>
<string name="goad_edit_success">Birikim hedefi güncellendi.</string>
<string name="goal_remove_deadline">Bu hedeften son tarihi kaldırmak istiyor musun?</string>
<string name="input_goal_saved_success">Harika iş! Birikim hedefi belirlendi.</string>
<string name="input_goad_edit_success">Birikim hedefi güncellendi.</string>
<string name="input_goal_remove_deadline">Bu hedeften son tarihi kaldırmak istiyor musun?</string>
<string name="input_remove_deadline_tip">İpucu: Var olan hedeflerden birinin son tarihini kaldırmak için son tarih alanında uzun basılı tutabilirsiniz.</string>

<!-- Backup Screen -->
<string name="backup_screen_header">Yedekle &amp; Geri yükle</string>
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@
<string name="input_additional_notes">备注(可选)</string>
<string name="input_add_goal_button">设置新的省钱目标</string>
<string name="input_edit_goal_button">更新省钱目标</string>
<string name="goal_saved_success">干得漂亮!省钱目标已经设置。</string>
<string name="goad_edit_success">省钱目标已经更新</string>
<string name="goal_remove_deadline">想要删除此目标的截止日期吗?</string>
<string name="input_goal_saved_success">干得漂亮!省钱目标已经设置。</string>
<string name="input_goad_edit_success">省钱目标已经更新</string>
<string name="input_goal_remove_deadline">想要删除此目标的截止日期吗?</string>
<string name="input_remove_deadline_tip">提示:您可以长按截止日期字段来删除现有目标的截止日期。</string>

<!-- Backup Screen -->
<string name="backup_screen_header">备份与恢复</string>
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@
<string name="input_additional_notes">筆記(選填)</string>
<string name="input_add_goal_button">設定新的儲蓄目標</string>
<string name="input_edit_goal_button">更新儲蓄目標</string>
<string name="goal_saved_success">做得好!已設定儲蓄目標。</string>
<string name="goad_edit_success">儲蓄目標已更新。</string>
<string name="goal_remove_deadline">您是否要從此目標中移除期限?</string>
<string name="input_goal_saved_success">做得好!已設定儲蓄目標。</string>
<string name="input_goad_edit_success">儲蓄目標已更新。</string>
<string name="input_goal_remove_deadline">您是否要從此目標中移除期限?</string>
<string name="input_remove_deadline_tip">提示:您可以長按截止日期欄位來移除現有目標的截止日期。</string>

<!-- Backup Screen -->
<string name="backup_screen_header">備份與還原</string>
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@
<string name="input_additional_notes">Notes (Optional)</string>
<string name="input_add_goal_button">Set New Saving Goal</string>
<string name="input_edit_goal_button">Update Saving Goal</string>
<string name="goal_saved_success">Great job! Saving goal set.</string>
<string name="goad_edit_success">Saving goal updated.</string>
<string name="goal_remove_deadline">Do you want to remove deadline from this goal?</string>
<string name="input_goal_saved_success">Great job! Saving goal set.</string>
<string name="input_goad_edit_success">Saving goal updated.</string>
<string name="input_goal_remove_deadline">Do you want to remove deadline from this goal?</string>
<string name="input_remove_deadline_tip">Tip: You can remove the deadline from existing goals by long-pressing on the deadline field.</string>

<!-- Backup Screen -->
<string name="backup_screen_header">Backup &amp; Restore</string>
Expand Down

0 comments on commit 80293d7

Please sign in to comment.