Skip to content

Commit

Permalink
v2.6.0 (#44)
Browse files Browse the repository at this point in the history
* Add priority info in goal info screen
* Bump version & some minor adjustments
---------
Signed-off-by: starry-shivam <[email protected]>
  • Loading branch information
starry-shivam authored Jun 22, 2023
1 parent 366303f commit ecddfbd
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
applicationId "com.starry.greenstash"
minSdk 24
targetSdk 33
versionCode 25
versionName "2.5.0"
versionCode 26
versionName "2.6.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"formatVersion": 1,
"database": {
"version": 3,
"identityHash": "730ce78e01df7d2b7398eb347da4e8c7",
"identityHash": "82e84f629e5b01a708e4770f85a5b488",
"entities": [
{
"tableName": "saving_goal",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`title` TEXT NOT NULL, `targetAmount` REAL NOT NULL, `deadline` TEXT NOT NULL, `goalImage` BLOB, `additionalNotes` TEXT NOT NULL, `priority` INTEGER NOT NULL DEFAULT 1, `goalId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`title` TEXT NOT NULL, `targetAmount` REAL NOT NULL, `deadline` TEXT NOT NULL, `goalImage` BLOB, `additionalNotes` TEXT NOT NULL, `priority` INTEGER NOT NULL DEFAULT 2, `goalId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)",
"fields": [
{
"fieldPath": "title",
Expand Down Expand Up @@ -43,7 +43,7 @@
"columnName": "priority",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "1"
"defaultValue": "2"
},
{
"fieldPath": "goalId",
Expand Down Expand Up @@ -163,7 +163,7 @@
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '730ce78e01df7d2b7398eb347da4e8c7')"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '82e84f629e5b01a708e4770f85a5b488')"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ data class Goal(
val goalImage: Bitmap?,
val additionalNotes: String,
// Added in database schema v3
@ColumnInfo(defaultValue = "1")
@ColumnInfo(defaultValue = "2")
val priority: GoalPriority
) {
@PrimaryKey(autoGenerate = true)
Expand Down
75 changes: 75 additions & 0 deletions app/src/main/java/com/starry/greenstash/ui/common/DotIndicator.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* MIT License
*
* Copyright (c) [2022 - Present] Stɑrry Shivɑm
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.starry.greenstash.ui.common

import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp

@Composable
fun DotIndicator(modifier: Modifier = Modifier, color: Color) {
val glowColor by animateColorAsState(
targetValue = color.copy(alpha = 0.5f),
animationSpec = infiniteRepeatable(
animation = tween(durationMillis = 1000, easing = FastOutSlowInEasing),
repeatMode = RepeatMode.Reverse
)
)

Canvas(modifier = modifier) {
val radius = size.width / 2

drawCircle(
color = color,
radius = radius,
center = Offset(size.width / 2, size.height / 2)
)

drawCircle(
color = glowColor,
radius = radius * 1.5f,
style = Stroke(width = 4.dp.toPx()),
center = Offset(size.width / 2, size.height / 2)
)
}
}

@Preview(showBackground = true)
@Composable
private fun DotIndicatorPV() {
DotIndicator(modifier = Modifier.size(18.dp), color = Color.Red)
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
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
Expand All @@ -85,8 +84,13 @@ import com.airbnb.lottie.compose.rememberLottieComposition
import com.starry.greenstash.MainActivity
import com.starry.greenstash.R
import com.starry.greenstash.database.core.GoalWithTransactions
import com.starry.greenstash.database.goal.GoalPriority
import com.starry.greenstash.database.goal.GoalPriority.High
import com.starry.greenstash.database.goal.GoalPriority.Low
import com.starry.greenstash.database.goal.GoalPriority.Normal
import com.starry.greenstash.database.transaction.Transaction
import com.starry.greenstash.database.transaction.TransactionType
import com.starry.greenstash.ui.common.DotIndicator
import com.starry.greenstash.ui.common.ExpandableCard
import com.starry.greenstash.ui.common.ExpandableTextCard
import com.starry.greenstash.ui.screens.info.viewmodels.InfoViewModel
Expand Down Expand Up @@ -159,6 +163,7 @@ fun GoalInfoScreen(goalId: String, navController: NavController) {
daysLeft = getRemainingDaysText(context, state.goalData),
progress = progressPercent.toFloat() / 100
)
GoalPriorityCard(goalPriority = state.goalData.goal.priority)
if (state.goalData.goal.additionalNotes.isNotEmpty() && state.goalData.goal.additionalNotes.isNotBlank()) {
GoalNotesCard(
notesText = state.goalData.goal.additionalNotes
Expand Down Expand Up @@ -221,7 +226,7 @@ fun GoalInfoCard(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
.padding(12.dp),
.padding(top = 12.dp, bottom = 4.dp, start = 12.dp, end = 12.dp),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(
4.dp
Expand Down Expand Up @@ -294,6 +299,42 @@ fun GoalInfoCard(
}
}

@Composable
fun GoalPriorityCard(goalPriority: GoalPriority) {
Card(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
.padding(bottom = 12.dp, start = 12.dp, end = 12.dp, top = 2.dp),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(
4.dp
)
),
shape = RoundedCornerShape(8.dp)
) {
Row(modifier = Modifier.padding(12.dp), verticalAlignment = Alignment.CenterVertically) {
val indicatorColor = when (goalPriority) {
High -> Color.Red
Normal -> Color.Green
Low -> Color.Blue
}
Box(modifier = Modifier.padding(start = 8.dp)) {
DotIndicator(
modifier = Modifier
.size(12.dp)
.padding(start = 4.dp), color = indicatorColor
)
}
Text(
modifier = Modifier.padding(start = 14.dp),
text = stringResource(id = R.string.info_goal_priority).format(goalPriority.name),
fontWeight = FontWeight.Medium
)
}
}
}

@ExperimentalMaterial3Api
@Composable
fun GoalNotesCard(notesText: String) {
Expand Down Expand Up @@ -377,7 +418,7 @@ fun TransactionItem(transactionType: TransactionType, amount: String, date: Stri
}


fun getRemainingDaysText(context: Context, goalItem: GoalWithTransactions): String {
private fun getRemainingDaysText(context: Context, goalItem: GoalWithTransactions): String {
return if (goalItem.getCurrentlySavedAmount() >= goalItem.goal.targetAmount) {
context.getString(R.string.info_card_goal_achieved)
} else {
Expand All @@ -397,7 +438,8 @@ fun getRemainingDaysText(context: Context, goalItem: GoalWithTransactions): Stri
@ExperimentalMaterial3Api
@ExperimentalMaterialApi
@Composable
@Preview(showBackground = true)
@Preview
fun GoalInfoPV() {
GoalInfoScreen(goalId = "", navController = rememberNavController())
GoalPriorityCard(High)
//GoalInfoScreen(goalId = "", navController = rememberNavController())
}
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,9 @@ fun InputScreen(editGoalId: String?, navController: NavController) {
haptic.performHapticFeedback(
HapticFeedbackType.LongPress
)
showRemoveDeadlineDialog.value = true
if (viewModel.state.deadline.isNotEmpty()) {
showRemoveDeadlineDialog.value = true
}
},
interactionSource = interactionSource,
indication = null
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<string name="info_card_remaining_days">%s días restantes.</string>
<string name="info_card_no_deadline_set">Sin fecha objetivo.</string>
<string name="info_card_goal_achieved">Meta alcanzada. ¡Felicitaciones!</string>
<string name="info_goal_priority">Goal Priority is %s</string>
<string name="info_notes_card_title">Notas</string>
<string name="info_transaction_card_title">Transacciones</string>
<string name="info_goal_no_transactions">Sin transacciones aún.</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<string name="info_card_remaining_days">%s days left.</string>
<string name="info_card_no_deadline_set">No deadline set.</string>
<string name="info_card_goal_achieved">Goal achieved. Congrats!</string>
<string name="info_goal_priority">Goal Priority is %s</string>
<string name="info_notes_card_title">Notes</string>
<string name="info_transaction_card_title">Transactions</string>
<string name="info_goal_no_transactions">No Transactions Yet.</string>
Expand Down
5 changes: 5 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/26.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Add ability to set importance level/priority to saving goals.
- Added ability to filter goals by; name, amount & priority.
- Now you can remove the deadline from an existing goal by long pressing the deadline field in edit-goal screen.
- Accessible enhancements; added TalkBack strings to menu and goal buttons.
- Some other minor fixes and improvements.

0 comments on commit ecddfbd

Please sign in to comment.