Skip to content

Commit 00957f3

Browse files
feat: add shortcuts customization (#1385)
* fix: don't add dash prefix to shared address * feat: shortcuts UI and customization * feat: handle SECURE_NOW removal properly * chore: cleanup * chore: coderabbit ai suggestions * feat: shortcuts info panel (#1392) * feat: info panel * feat: show on second launch logic * fix: clear shortcuts when the wallet is reset * fix: fonts --------- Co-authored-by: HashEngineering <[email protected]>
1 parent 61488bd commit 00957f3

File tree

83 files changed

+1290
-1045
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1290
-1045
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ buildscript {
2828
// UI
2929
materialVersion = "1.6.1"
3030
browserVersion = "1.3.0"
31-
constrainLayoutVersion = '2.1.4'
31+
constrainLayoutVersion = '2.2.1'
3232
recyclerViewVersion = "1.2.1"
3333
glideVersion = '4.12.0'
3434
zxingVersion = '3.3.3' // Don't update. 3.3.3 is the maximum to support Android 6.x

common/src/main/java/org/dash/wallet/common/data/WalletUIConfig.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import org.dash.wallet.common.services.ExchangeRatesProvider
2727
import org.dash.wallet.common.util.Constants
2828
import javax.inject.Inject
2929
import javax.inject.Singleton
30+
import androidx.core.content.edit
3031

3132
@Singleton
3233
// Intended for the UI settings which affect what the user sees on the screen.
@@ -65,6 +66,8 @@ open class WalletUIConfig @Inject constructor(
6566
val EXCHANGE_CURRENCY_DETECTED = booleanPreferencesKey("exchange_currency_detected")
6667
val LAST_TOTAL_BALANCE = longPreferencesKey("last_total_balance")
6768
val LAST_MIXED_BALANCE = longPreferencesKey("last_mixed_balance")
69+
val CUSTOMIZED_SHORTCUTS = stringPreferencesKey("customized_shortcuts")
70+
val IS_SHORTCUT_INFO_HIDDEN = booleanPreferencesKey("is_shortcut_info_hidden")
6871
}
6972

7073
suspend fun getExchangeCurrencyCode(): String {
@@ -111,7 +114,7 @@ class ExchangeCurrencyMigration(
111114
} else {
112115
otherName
113116
}
114-
sharedPreferences.edit().putString(WalletUIConfig.SELECTED_CURRENCY.name, fixedValue).apply()
117+
sharedPreferences.edit { putString(WalletUIConfig.SELECTED_CURRENCY.name, fixedValue) }
115118
}
116119
// The database might have obsolete currencies as well
117120
exchangeRates.cleanupObsoleteCurrencies()

common/src/main/java/org/dash/wallet/common/services/analytics/AnalyticsConstants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ object AnalyticsConstants {
126126
const val SHORTCUT_SCAN_TO_PAY = "shortcut_scan_to_pay"
127127
const val SHORTCUT_SEND_TO_ADDRESS = "shortcut_send_to_address"
128128
const val SHORTCUT_RECEIVE = "shortcut_receive"
129+
const val SHORTCUT_SEND = "shortcut_send"
129130
const val SHORTCUT_BUY_AND_SELL = "shortcut_buy_and_sell_dash"
130131
const val SHORTCUT_EXPLORE = "shortcut_explore"
131132
const val HIDE_BALANCE = "home_hide_balance"
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/*
2+
* Copyright 2024 Dash Core Group.
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package org.dash.wallet.common.ui.components
19+
20+
import androidx.annotation.DrawableRes
21+
import androidx.compose.foundation.background
22+
import androidx.compose.foundation.clickable
23+
import androidx.compose.foundation.layout.Arrangement
24+
import androidx.compose.foundation.layout.Box
25+
import androidx.compose.foundation.layout.Column
26+
import androidx.compose.foundation.layout.Row
27+
import androidx.compose.foundation.layout.fillMaxWidth
28+
import androidx.compose.foundation.layout.padding
29+
import androidx.compose.foundation.layout.size
30+
import androidx.compose.foundation.shape.RoundedCornerShape
31+
import androidx.compose.material3.Icon
32+
import androidx.compose.material3.Text
33+
import androidx.compose.runtime.Composable
34+
import androidx.compose.ui.Alignment
35+
import androidx.compose.ui.Modifier
36+
import androidx.compose.ui.draw.shadow
37+
import androidx.compose.ui.graphics.Color
38+
import androidx.compose.ui.res.painterResource
39+
import androidx.compose.ui.tooling.preview.Preview
40+
import androidx.compose.ui.unit.dp
41+
import org.dash.wallet.common.R
42+
43+
@Composable
44+
fun InfoPanel(
45+
title: String,
46+
description: String,
47+
modifier: Modifier = Modifier,
48+
@DrawableRes leftIconRes: Int? = null,
49+
@DrawableRes actionIconRes: Int? = null,
50+
onAction: (() -> Unit)? = null
51+
) {
52+
Box(
53+
modifier = modifier
54+
.fillMaxWidth()
55+
.background(MyTheme.Colors.backgroundSecondary, RoundedCornerShape(16.dp))
56+
.shadow(elevation = 20.dp, spotColor = Color(0x1AB8C1CC), ambientColor = Color(0x1AB8C1CC)),
57+
) {
58+
Row(
59+
modifier = Modifier
60+
.fillMaxWidth()
61+
.padding(14.dp, 15.dp),
62+
verticalAlignment = Alignment.CenterVertically,
63+
horizontalArrangement = Arrangement.spacedBy(10.dp)
64+
) {
65+
leftIconRes?.let {
66+
Box(
67+
modifier = Modifier
68+
.size(34.dp),
69+
contentAlignment = Alignment.Center
70+
) {
71+
Icon(
72+
painter = painterResource(id = leftIconRes),
73+
contentDescription = null,
74+
tint = Color.Unspecified
75+
)
76+
}
77+
}
78+
79+
Column(
80+
modifier = Modifier.weight(1f),
81+
verticalArrangement = Arrangement.spacedBy(2.dp)
82+
) {
83+
Text(
84+
text = title,
85+
style = MyTheme.CaptionMedium
86+
)
87+
88+
Text(
89+
text = description,
90+
style = MyTheme.Caption,
91+
color = MyTheme.Colors.textSecondary
92+
)
93+
}
94+
95+
if (actionIconRes != null && onAction != null) {
96+
Box(
97+
modifier = Modifier
98+
.size(28.dp)
99+
.clickable { onAction() },
100+
contentAlignment = Alignment.Center
101+
) {
102+
Icon(
103+
painter = painterResource(id = actionIconRes),
104+
contentDescription = "Close",
105+
tint = MyTheme.Colors.gray
106+
)
107+
}
108+
}
109+
}
110+
}
111+
}
112+
113+
@Preview
114+
@Composable
115+
fun InfoPanelPreview() {
116+
InfoPanel(
117+
title = "Customize shortcut bar",
118+
description = "Hold any button above to replace it with the function you need",
119+
leftIconRes = R.drawable.ic_dash_blue_filled,
120+
actionIconRes = R.drawable.ic_popup_close,
121+
onAction = {}
122+
)
123+
}

common/src/main/java/org/dash/wallet/common/ui/components/MenuItem.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fun MenuItem(
5656
modifier = Modifier
5757
.fillMaxWidth()
5858
.padding(10.dp)
59-
.background(Color.White, RoundedCornerShape(8.dp))
59+
.background(MyTheme.Colors.backgroundSecondary, RoundedCornerShape(8.dp))
6060
.clickable { action?.invoke() }
6161
.padding(10.dp),
6262
verticalAlignment = Alignment.CenterVertically

common/src/main/java/org/dash/wallet/common/ui/components/MyTheme.kt

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,57 +28,75 @@ import org.dash.wallet.common.R
2828

2929
object MyTheme {
3030
val ToastBackground = Color(0xff191c1f).copy(alpha = 0.9f)
31-
val InterFont = FontFamily(Font(R.font.inter))
31+
private val interRegular = FontFamily(Font(R.font.inter_regular))
32+
private val interMedium = FontFamily(Font(R.font.inter_medium))
33+
private val interSemibold = FontFamily(Font(R.font.inter_semibold))
34+
private val interBold = FontFamily(Font(R.font.inter_bold))
3235

3336
val Micro = TextStyle(
3437
fontSize = 10.sp,
3538
lineHeight = 16.sp,
36-
fontFamily = InterFont,
39+
fontFamily = interRegular,
3740
fontWeight = FontWeight(500),
3841
textAlign = TextAlign.Center,
3942
)
4043

4144
val CaptionMedium = TextStyle(
4245
fontSize = 13.sp,
4346
lineHeight = 18.sp,
44-
fontFamily = InterFont,
47+
fontFamily = interMedium,
4548
fontWeight = FontWeight(500)
4649
)
4750

51+
val Overline = TextStyle(
52+
fontSize = 12.sp,
53+
lineHeight = 16.sp,
54+
fontFamily = interMedium,
55+
fontWeight = FontWeight(500),
56+
textAlign = TextAlign.Center
57+
)
58+
4859
val OverlineSemibold = TextStyle(
4960
fontSize = 12.sp,
5061
lineHeight = 16.sp,
51-
fontFamily = InterFont,
62+
fontFamily = interSemibold,
5263
fontWeight = FontWeight(600),
5364
textAlign = TextAlign.Center
5465
)
5566

67+
val Caption = TextStyle(
68+
fontSize = 13.sp,
69+
lineHeight = 18.sp,
70+
fontFamily = interRegular,
71+
fontWeight = FontWeight(400)
72+
)
73+
5674
val OverlineMedium = TextStyle(
5775
fontSize = 12.sp,
5876
lineHeight = 16.sp,
59-
fontFamily = InterFont,
77+
fontFamily = interMedium,
6078
fontWeight = FontWeight(500),
6179
textAlign = TextAlign.Center
6280
)
6381

6482
val Body2Regular = TextStyle(
6583
fontSize = 14.sp,
6684
lineHeight = 20.sp,
67-
fontFamily = InterFont,
85+
fontFamily = interRegular,
6886
fontWeight = FontWeight(400)
6987
)
7088

7189
val SubtitleSemibold = TextStyle(
7290
fontSize = 16.sp,
7391
lineHeight = 22.sp,
74-
fontFamily = InterFont,
92+
fontFamily = interSemibold,
7593
fontWeight = FontWeight(600)
7694
)
7795

7896
val H6Bold = TextStyle(
7997
fontSize = 20.sp,
8098
lineHeight = 26.sp,
81-
fontFamily = InterFont,
99+
fontFamily = interBold,
82100
fontWeight = FontWeight(700)
83101
)
84102

@@ -93,6 +111,7 @@ object MyTheme {
93111
val primary40 = Color(0x66191C1F)
94112
val dashBlue = Color(0xFF008DE4)
95113
val dashBlue5 = Color(0x0D008DE4)
114+
val gray = Color(0xFFB0B6BC)
96115
val gray400 = Color(0xFF75808A)
97116
}
98117
}

common/src/main/java/org/dash/wallet/common/ui/receive/ReceiveInfoView.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class ReceiveInfoView(context: Context, attrs: AttributeSet?) : ConstraintLayout
8080
}
8181
binding.shareButton.setOnClickListener {
8282
onShareClicked?.invoke()
83-
handleShare(paymentRequestUri)
83+
address?.let { handleShare(it.toBase58()) }
8484
}
8585

8686
refresh()

0 commit comments

Comments
 (0)