Skip to content

Commit

Permalink
Improve widget UI
Browse files Browse the repository at this point in the history
Signed-off-by: starry-shivam <[email protected]>
  • Loading branch information
starry-shivam committed Mar 30, 2024
1 parent f795bf5 commit 05117d4
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ import com.starry.greenstash.R
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.ui.theme.greenstashFont
import com.starry.greenstash.widget.GoalWidget
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.ExperimentalCoroutinesApi
Expand All @@ -109,7 +110,6 @@ class WidgetConfigActivity : AppCompatActivity() {

private val viewModel: WidgetConfigViewModel by viewModels()
private lateinit var settingsViewModel: SettingsViewModel

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Expand Down Expand Up @@ -162,6 +162,7 @@ class WidgetConfigActivity : AppCompatActivity() {
text = stringResource(id = R.string.widget_config_screen_header),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
fontFamily = greenstashFont
)
}, navigationIcon = {
IconButton(onClick = {
Expand Down Expand Up @@ -222,6 +223,7 @@ class WidgetConfigActivity : AppCompatActivity() {
text = stringResource(id = R.string.no_goal_set),
fontWeight = FontWeight.Medium,
fontSize = 18.sp,
fontFamily = greenstashFont,
modifier = Modifier.padding(start = 12.dp, end = 12.dp)
)

Expand Down Expand Up @@ -320,10 +322,10 @@ class WidgetConfigActivity : AppCompatActivity() {
Column(modifier = Modifier.padding(8.dp)) {
Text(
text = title,
fontStyle = MaterialTheme.typography.headlineMedium.fontStyle,
fontSize = 20.sp,
fontWeight = FontWeight.SemiBold,
maxLines = 1,
fontFamily = greenstashFont,
overflow = TextOverflow.Ellipsis,
color = MaterialTheme.colorScheme.onSurface,
)
Expand All @@ -332,9 +334,9 @@ class WidgetConfigActivity : AppCompatActivity() {
text = description,
color = MaterialTheme.colorScheme.onSurface,
maxLines = 1,
fontStyle = MaterialTheme.typography.bodySmall.fontStyle,
fontFamily = greenstashFont,
fontWeight = FontWeight.Medium,
fontSize = 16.sp,
fontSize = 14.sp,
)

Spacer(modifier = Modifier.height(8.dp))
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/progress_bar_rounded_corners.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<scale android:scaleWidth="100%">
<shape>
<corners android:radius="8dp" />
<solid android:color="?android:attr/colorAccent" />
<solid android:color="?android:attr/colorPrimary" />
</shape>
</scale>
</item>
Expand Down
10 changes: 4 additions & 6 deletions app/src/main/res/drawable/textview_border.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/transparent" />
<stroke
android:width="2dp"
android:color="?android:attr/colorPrimary" />
<corners android:radius="8dp" />
<solid android:color="?attr/colorPrimaryContainer" /> <!-- Use the colorPrimaryContainer tonal color -->
<corners android:radius="8dp" /> <!-- Keep the rounded corners -->
<padding
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp" />
android:top="5dp" /> <!-- Keep the padding -->
</shape>
Binary file modified app/src/main/res/drawable/widget_preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/widget_rounded_corners.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="?android:attr/colorBackground" />
<corners android:radius="16dp" />
</shape>
40 changes: 35 additions & 5 deletions app/src/main/res/layout/goal_widget.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
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.
-->

<!-- This layout is used to display the goal widget on the home screen. -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/colorBackground"
android:background="@drawable/widget_rounded_corners"
android:orientation="vertical"
android:theme="@style/Theme.Material3.DynamicColors.DayNight">

Expand All @@ -25,11 +51,11 @@
android:orientation="vertical">

<TextView

android:id="@+id/widgetTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="@font/poppins_medium"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.AppCompat.Title"
android:textColor="?android:attr/textColorPrimary"
Expand All @@ -40,6 +66,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="@font/poppins_regular"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textColor="?android:attr/textColorPrimary"
Expand Down Expand Up @@ -90,7 +117,7 @@
android:layout_width="match_parent"
android:layout_height="8dp"
android:layout_marginTop="6dp"
android:layout_marginBottom="8dp"
android:layout_marginBottom="10dp"
android:progressDrawable="@drawable/progress_bar_rounded_corners"
android:scaleY="0.8"
app:indicatorColor="?android:attr/colorAccent"
Expand All @@ -108,7 +135,8 @@
android:layout_height="wrap_content"
android:layout_marginEnd="3dp"
android:background="@drawable/textview_border"
android:textColor="?android:attr/textColorPrimary"
android:fontFamily="@font/poppins_light"
android:textColor="?attr/colorOnPrimaryContainer"
android:visibility="gone"
tools:text="$153.45/day"
tools:visibility="visible" />
Expand All @@ -119,7 +147,8 @@
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:background="@drawable/textview_border"
android:textColor="?android:attr/textColorPrimary"
android:fontFamily="@font/poppins_light"
android:textColor="?attr/colorOnPrimaryContainer"
android:visibility="gone"
tools:text="$253.45/week"
tools:visibility="visible" />
Expand All @@ -130,6 +159,7 @@
android:id="@+id/widgetGoalAchieved"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/poppins_regular"
android:text="@string/info_card_goal_achieved"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textColor="?android:attr/textColorPrimary"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!-- Other Strings -->
<string name="confirm">Confirm</string>
<string name="cancel">Cancel</string>
<string name="ok" >OK</string>
<string name="ok">OK</string>
<string name="unknown_error">Oops! something went wrong.</string>

<!-- Navigation Drawer -->
Expand Down Expand Up @@ -45,7 +45,7 @@

<!-- Congratulations Screen -->
<string name="goal_achieved_heading">Congratulations 🥳</string>
<string name="goal_achieved_subtext">You\'ve reached your saving goal! Your hard work and commitment have led to this well-deserved accomplishment. Celebrate your success!</string>
<string name="goal_achieved_subtext">You\'ve reached your saving goal! Your hard work and commitment have led to this well-deserved accomplishment. Celebrate your success! 🎉</string>
<string name="goal_achieved_button">Go back to home</string>

<!-- Strings used for dashboard saving goals cards -->
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/xml/goal_widget_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
android:configure="com.starry.greenstash.widget.configuration.WidgetConfigActivity"
android:description="@string/app_name"
android:initialKeyguardLayout="@layout/goal_widget"
android:minWidth="110dp"
android:minWidth="160dp"
android:minHeight="40dp"
android:minResizeWidth="40dp"
android:previewImage="@drawable/widget_preview"
android:resizeMode="vertical|horizontal"
android:targetCellWidth="3"
android:targetCellWidth="4"
android:targetCellHeight="2"
android:updatePeriodMillis="3600000"
android:widgetCategory="home_screen" />

0 comments on commit 05117d4

Please sign in to comment.