Skip to content

Commit 1bc7742

Browse files
committed
chore: simplify click
1 parent 55e66f9 commit 1bc7742

File tree

3 files changed

+12
-26
lines changed

3 files changed

+12
-26
lines changed

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package to.bitkit.ui.components
22

33
import androidx.compose.foundation.BorderStroke
4-
import androidx.compose.foundation.interaction.MutableInteractionSource
5-
import androidx.compose.foundation.interaction.collectIsPressedAsState
64
import androidx.compose.foundation.layout.Arrangement
75
import androidx.compose.foundation.layout.Box
86
import androidx.compose.foundation.layout.Column
@@ -23,8 +21,6 @@ import androidx.compose.material3.OutlinedButton
2321
import androidx.compose.material3.Text
2422
import androidx.compose.material3.TextButton
2523
import androidx.compose.runtime.Composable
26-
import androidx.compose.runtime.getValue
27-
import androidx.compose.runtime.remember
2824
import androidx.compose.ui.Alignment
2925
import androidx.compose.ui.Modifier
3026
import androidx.compose.ui.draw.alpha
@@ -67,8 +63,6 @@ fun PrimaryButton(
6763
color: Color = Colors.White16, // Deprecated: Color customization no longer supported
6864
) {
6965
val contentPadding = PaddingValues(horizontal = size.horizontalPadding.takeIf { text != null } ?: 0.dp)
70-
val interactionSource = remember { MutableInteractionSource() }
71-
val isPressed by interactionSource.collectIsPressedAsState()
7266
val buttonShape = MaterialTheme.shapes.large
7367

7468
Button(
@@ -79,13 +73,11 @@ fun PrimaryButton(
7973
disabledContainerColor = Color.Transparent
8074
),
8175
contentPadding = contentPadding,
82-
interactionSource = interactionSource,
8376
shape = buttonShape,
8477
modifier = Modifier
8578
.then(if (fullWidth) Modifier.fillMaxWidth() else Modifier)
8679
.requiredHeight(size.height)
8780
.primaryButtonStyle(
88-
isPressed = isPressed,
8981
isEnabled = enabled && !isLoading,
9082
shape = buttonShape
9183
)

app/src/main/java/to/bitkit/ui/shared/util/Modifiers.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ package to.bitkit.ui.shared.util
22

33
import androidx.compose.animation.core.animateFloatAsState
44
import androidx.compose.foundation.background
5-
import androidx.compose.foundation.border
65
import androidx.compose.foundation.clickable
76
import androidx.compose.foundation.interaction.MutableInteractionSource
87
import androidx.compose.foundation.interaction.collectIsPressedAsState
9-
import androidx.compose.foundation.layout.Box
108
import androidx.compose.foundation.layout.WindowInsets
119
import androidx.compose.foundation.layout.fillMaxSize
1210
import androidx.compose.foundation.layout.systemBars
@@ -21,16 +19,15 @@ import androidx.compose.ui.Modifier
2119
import androidx.compose.ui.composed
2220
import androidx.compose.ui.draw.clip
2321
import androidx.compose.ui.draw.drawWithContent
22+
import androidx.compose.ui.draw.shadow
2423
import androidx.compose.ui.geometry.Offset
2524
import androidx.compose.ui.geometry.Size
26-
import androidx.compose.ui.draw.shadow
2725
import androidx.compose.ui.graphics.Brush
2826
import androidx.compose.ui.graphics.Color
2927
import androidx.compose.ui.graphics.Shape
3028
import androidx.compose.ui.graphics.graphicsLayer
3129
import androidx.compose.ui.input.pointer.pointerInput
3230
import androidx.compose.ui.unit.dp
33-
import to.bitkit.ui.theme.ButtonGradients
3431
import to.bitkit.ui.theme.Colors
3532

3633
/**
@@ -109,7 +106,6 @@ fun Modifier.screen(
109106
.then(if (insets == null) Modifier else Modifier.windowInsetsPadding(insets))
110107

111108
fun Modifier.primaryButtonStyle(
112-
isPressed: Boolean,
113109
isEnabled: Boolean,
114110
shape: Shape
115111
): Modifier {
@@ -132,9 +128,17 @@ fun Modifier.primaryButtonStyle(
132128
.then(
133129
if (isEnabled) {
134130
Modifier.drawWithContent {
135-
// Draw the main gradient background
136-
val mainBrush = if (isPressed) ButtonGradients.Pressed else ButtonGradients.Active
137-
drawRect(brush = mainBrush)
131+
// Draw the main gradient background filling entire button
132+
val mainBrush = Brush.verticalGradient(
133+
colors = listOf(Color(0xFF2A2A2A), Color(0xFF1C1C1C)),
134+
startY = 0f,
135+
endY = size.height
136+
)
137+
drawRect(
138+
brush = mainBrush,
139+
topLeft = Offset.Zero,
140+
size = size
141+
)
138142

139143
// Draw top border highlight (2dp gradient fade)
140144
val borderHeight = 2.dp.toPx()

app/src/main/java/to/bitkit/ui/theme/Colors.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package to.bitkit.ui.theme
22

3-
import androidx.compose.ui.graphics.Brush
43
import androidx.compose.ui.graphics.Color
54

65
object Colors {
@@ -56,12 +55,3 @@ object Colors {
5655
val Yellow16 = Yellow.copy(alpha = 0.16f)
5756
val Yellow24 = Yellow.copy(alpha = 0.24f)
5857
}
59-
60-
object ButtonGradients {
61-
val Active = Brush.verticalGradient(
62-
colors = listOf(Color(0xFF2A2A2A), Color(0xFF1C1C1C))
63-
)
64-
val Pressed = Brush.verticalGradient(
65-
colors = listOf(Color(0xFF3A3A3A), Color(0xFF2A2A2A))
66-
)
67-
}

0 commit comments

Comments
 (0)