Skip to content

Commit 2303626

Browse files
authored
Merge branch 'fix/primary-bt-width' into feat/numpad-button-v59
2 parents 630be83 + a6a6c85 commit 2303626

File tree

4 files changed

+72
-17
lines changed

4 files changed

+72
-17
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
2121
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
2222
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
23+
<!-- Required for E2E tests connecting to local Electrum server (Android 16+) -->
24+
<uses-permission
25+
android:name="android.permission.NEARBY_WIFI_DEVICES"
26+
android:usesPermissionFlags="neverForLocation"
27+
tools:targetApi="31" />
2328

2429
<application
2530
android:name=".App"
@@ -33,7 +38,7 @@
3338
android:name=".androidServices.LightningNodeService"
3439
android:foregroundServiceType="dataSync"
3540
android:enabled="true"
36-
android:exported="false"/>
41+
android:exported="false" />
3742

3843
<service
3944
android:name="androidx.appcompat.app.AppLocalesMetadataHolderService"
@@ -59,27 +64,33 @@
5964
<!-- Universal Links -->
6065
<intent-filter android:autoVerify="true">
6166
<action android:name="android.intent.action.VIEW" />
67+
6268
<category android:name="android.intent.category.DEFAULT" />
6369
<category android:name="android.intent.category.BROWSABLE" />
70+
6471
<data
6572
android:scheme="https"
6673
android:host="www.bitkit.to"
6774
android:pathPattern="/treasure-hunt" />
6875
</intent-filter>
6976

70-
<!-- Deeplinks -->
77+
<!-- Deep Links -->
7178
<intent-filter>
7279
<action android:name="android.intent.action.VIEW" />
80+
7381
<category android:name="android.intent.category.DEFAULT" />
7482
<category android:name="android.intent.category.BROWSABLE" />
83+
7584
<data android:scheme="bitkit" />
7685
<data android:scheme="slash" />
7786
<data android:scheme="slashauth" />
7887
<data android:scheme="bitcoin" />
79-
<data android:scheme="BITCOIN"
88+
<data
89+
android:scheme="BITCOIN"
8090
tools:ignore="AppLinkUrlError" />
8191
<data android:scheme="lightning" />
82-
<data android:scheme="LIGHTNING"
92+
<data
93+
android:scheme="LIGHTNING"
8394
tools:ignore="AppLinkUrlError" />
8495
<data android:scheme="lnurl" />
8596
<data android:scheme="lnurlw" />
@@ -90,16 +101,20 @@
90101
<!-- NFC -->
91102
<intent-filter>
92103
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
104+
93105
<category android:name="android.intent.category.DEFAULT" />
94106
<category android:name="android.intent.category.BROWSABLE" />
107+
95108
<data android:scheme="bitkit" />
96109
<data android:scheme="slash" />
97110
<data android:scheme="slashauth" />
98111
<data android:scheme="bitcoin" />
99-
<data android:scheme="BITCOIN"
112+
<data
113+
android:scheme="BITCOIN"
100114
tools:ignore="AppLinkUrlError" />
101115
<data android:scheme="lightning" />
102-
<data android:scheme="LIGHTNING"
116+
<data
117+
android:scheme="LIGHTNING"
103118
tools:ignore="AppLinkUrlError" />
104119
<data android:scheme="lnurl" />
105120
<data android:scheme="lnurlw" />

app/src/main/java/to/bitkit/ext/ByteArray.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ fun ByteArray.toHex(): String = this.toHexString()
1212
fun String.fromHex(): ByteArray = this.hexToByteArray()
1313
// endregion
1414

15-
// region base64
1615
@OptIn(ExperimentalEncodingApi::class)
1716
fun ByteArray.toBase64(): String = Base64.encode(this)
1817

1918
@OptIn(ExperimentalEncodingApi::class)
2019
fun String.fromBase64(): ByteArray = Base64.decode(this)
21-
// endregion
2220

2321
val String.uByteList get() = this.toByteArray().map { it.toUByte() }
2422

app/src/main/java/to/bitkit/ui/components/Button.kt

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import androidx.compose.ui.text.style.TextOverflow
3030
import androidx.compose.ui.tooling.preview.Preview
3131
import androidx.compose.ui.unit.Dp
3232
import androidx.compose.ui.unit.dp
33-
import to.bitkit.ui.shared.modifiers.clickableAlpha
33+
import to.bitkit.ui.shared.modifiers.alphaFeedback
3434
import to.bitkit.ui.shared.util.primaryButtonStyle
3535
import to.bitkit.ui.theme.AppButtonDefaults
3636
import to.bitkit.ui.theme.AppThemeSurface
@@ -67,24 +67,23 @@ fun PrimaryButton(
6767
val buttonShape = MaterialTheme.shapes.large
6868

6969
Button(
70-
onClick = {},
70+
onClick = onClick,
7171
enabled = enabled && !isLoading,
7272
colors = AppButtonDefaults.primaryColors.copy(
7373
containerColor = Color.Transparent,
7474
disabledContainerColor = Color.Transparent
7575
),
7676
contentPadding = contentPadding,
7777
shape = buttonShape,
78-
modifier = Modifier
78+
modifier = modifier
7979
.then(if (fullWidth) Modifier.fillMaxWidth() else Modifier)
8080
.requiredHeight(size.height)
8181
.primaryButtonStyle(
8282
isEnabled = enabled && !isLoading,
8383
shape = buttonShape,
8484
primaryColor = color
8585
)
86-
.clickableAlpha { onClick() }
87-
.then(modifier)
86+
.alphaFeedback(enabled = enabled && !isLoading)
8887
) {
8988
if (isLoading) {
9089
CircularProgressIndicator(
@@ -141,10 +140,9 @@ fun SecondaryButton(
141140
colors = AppButtonDefaults.secondaryColors,
142141
contentPadding = contentPadding,
143142
border = border,
144-
modifier = Modifier
143+
modifier = modifier
145144
.then(if (fullWidth) Modifier.fillMaxWidth() else Modifier)
146145
.requiredHeight(size.height)
147-
.then(modifier)
148146
) {
149147
if (isLoading) {
150148
CircularProgressIndicator(
@@ -199,10 +197,9 @@ fun TertiaryButton(
199197
enabled = enabled && !isLoading,
200198
colors = AppButtonDefaults.tertiaryColors,
201199
contentPadding = contentPadding,
202-
modifier = Modifier
200+
modifier = modifier
203201
.then(if (fullWidth) Modifier.fillMaxWidth() else Modifier)
204202
.requiredHeight(size.height)
205-
.then(modifier)
206203
) {
207204
if (isLoading) {
208205
CircularProgressIndicator(
@@ -252,6 +249,11 @@ private fun PrimaryButtonPreview() {
252249
text = "Primary",
253250
onClick = {},
254251
)
252+
PrimaryButton(
253+
text = "Primary with padding",
254+
modifier = Modifier.padding(horizontal = 32.dp),
255+
onClick = {},
256+
)
255257
PrimaryButton(
256258
text = "Primary With Icon",
257259
onClick = {},
@@ -373,6 +375,11 @@ private fun SecondaryButtonPreview() {
373375
text = "Secondary",
374376
onClick = {},
375377
)
378+
SecondaryButton(
379+
text = "Secondary With padding",
380+
modifier = Modifier.padding(horizontal = 32.dp),
381+
onClick = {},
382+
)
376383
SecondaryButton(
377384
text = "Secondary With Icon",
378385
onClick = {},

app/src/main/java/to/bitkit/ui/shared/modifiers/ClickableAlpha.kt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@ package to.bitkit.ui.shared.modifiers
22

33
import androidx.compose.animation.core.Animatable
44
import androidx.compose.foundation.gestures.detectTapGestures
5+
import androidx.compose.runtime.Composable
6+
import androidx.compose.runtime.remember
7+
import androidx.compose.runtime.rememberCoroutineScope
58
import androidx.compose.ui.Modifier
9+
import androidx.compose.ui.graphics.graphicsLayer
610
import androidx.compose.ui.input.pointer.SuspendingPointerInputModifierNode
11+
import androidx.compose.ui.input.pointer.pointerInput
712
import androidx.compose.ui.layout.Measurable
813
import androidx.compose.ui.layout.MeasureResult
914
import androidx.compose.ui.layout.MeasureScope
@@ -101,3 +106,33 @@ private class ClickableAlphaNode(
101106
}
102107
}
103108
}
109+
110+
/**
111+
* Applies alpha animation feedback on press without consuming click events.
112+
* This allows the Button's onClick to work while providing full-area visual feedback.
113+
*/
114+
@Composable
115+
fun Modifier.alphaFeedback(
116+
pressedAlpha: Float = 0.7f,
117+
enabled: Boolean = true,
118+
): Modifier = if (enabled) {
119+
val animatable = remember { Animatable(1f) }
120+
val scope = rememberCoroutineScope()
121+
122+
this
123+
.pointerInput(Unit) {
124+
detectTapGestures(
125+
onPress = {
126+
scope.launch { animatable.animateTo(pressedAlpha) }
127+
tryAwaitRelease()
128+
scope.launch { animatable.animateTo(1f) }
129+
},
130+
onTap = null // Don't consume tap - let Button handle it
131+
)
132+
}
133+
.graphicsLayer {
134+
alpha = animatable.value
135+
}
136+
} else {
137+
this
138+
}

0 commit comments

Comments
 (0)