Skip to content

Commit 9eb6b3f

Browse files
Merge pull request #63 from nimblehq/release/0.6.0
Release - 0.6.0
2 parents a4308a0 + 470937f commit 9eb6b3f

File tree

10 files changed

+310
-114
lines changed

10 files changed

+310
-114
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package co.nimblehq.compose.crypto.extension
2+
3+
import android.graphics.BlurMaskFilter
4+
import androidx.compose.ui.Modifier
5+
import androidx.compose.ui.draw.drawBehind
6+
import androidx.compose.ui.graphics.Color
7+
import androidx.compose.ui.graphics.Paint
8+
import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
9+
import androidx.compose.ui.graphics.toArgb
10+
import androidx.compose.ui.unit.Dp
11+
import co.nimblehq.compose.crypto.ui.theme.Dimension.Dp0
12+
13+
/**
14+
* Original solution: https://github.com/wasim15185/jetpack-compose-crypto/blob/develop/app/src/main/java/co/nimblehq/compose/crypto/extension/BoxShadow.kt
15+
* Draw a shadow affect under component
16+
*
17+
* borderRadius: Border radius of shadow
18+
* blurRadius: Blur the shadow
19+
* offsetY: Position of shadow according to Y axis
20+
* offsetX: Position of shadow according to X axis
21+
* spread: Squeeze or release the shadow of CardView
22+
*/
23+
fun Modifier.boxShadow(
24+
color: Color = Color.Black,
25+
borderRadius: Dp = Dp0,
26+
blurRadius: Dp = Dp0,
27+
offsetY: Dp = Dp0,
28+
offsetX: Dp = Dp0,
29+
spread: Dp = Dp0,
30+
modifier: Modifier = Modifier,
31+
) = this.then(
32+
modifier.drawBehind {
33+
this.drawIntoCanvas {
34+
val paint = Paint()
35+
val frameworkPaint = paint.asFrameworkPaint()
36+
val spreadPixel = spread.toPx()
37+
val leftPixel = (0f - spreadPixel) + offsetX.toPx()
38+
val topPixel = (0f - spreadPixel) + offsetY.toPx()
39+
val rightPixel = (this.size.width + spreadPixel)
40+
val bottomPixel = (this.size.height + spreadPixel)
41+
42+
if (blurRadius != Dp0) {
43+
/* The feature maskFilter used below to apply the blur effect only works
44+
with hardware acceleration disabled.
45+
*/
46+
frameworkPaint.maskFilter =
47+
(BlurMaskFilter(blurRadius.toPx(), BlurMaskFilter.Blur.NORMAL))
48+
}
49+
50+
frameworkPaint.color = color.toArgb()
51+
it.drawRoundRect(
52+
left = leftPixel,
53+
top = topPixel,
54+
right = rightPixel,
55+
bottom = bottomPixel,
56+
radiusX = borderRadius.toPx(),
57+
radiusY = borderRadius.toPx(),
58+
paint
59+
)
60+
}
61+
}
62+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package co.nimblehq.compose.crypto.ui.base
2+
3+
sealed class LoadingState {
4+
object Idle : LoadingState()
5+
object Loading : LoadingState()
6+
object LoadingMore : LoadingState()
7+
}

app/src/main/java/co/nimblehq/compose/crypto/ui/components/chartintervals/ChartIntervalsButton.kt

+16-4
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ import androidx.compose.runtime.Composable
99
import androidx.compose.runtime.mutableStateOf
1010
import androidx.compose.runtime.remember
1111
import androidx.compose.ui.Modifier
12+
import androidx.compose.ui.graphics.Color
1213
import androidx.compose.ui.text.style.TextAlign
1314
import androidx.compose.ui.tooling.preview.Preview
14-
import co.nimblehq.compose.crypto.ui.theme.Color
15+
import co.nimblehq.compose.crypto.ui.theme.Color.CaribbeanGreen
16+
import co.nimblehq.compose.crypto.ui.theme.Color.OsloGray
17+
import co.nimblehq.compose.crypto.ui.theme.Color.Transparent
18+
import co.nimblehq.compose.crypto.ui.theme.Color.White
1519
import co.nimblehq.compose.crypto.ui.theme.Dimension.Dp12
1620
import co.nimblehq.compose.crypto.ui.theme.Dimension.Dp14
1721
import co.nimblehq.compose.crypto.ui.theme.Dimension.Dp4
@@ -33,9 +37,15 @@ fun ChartIntervalsButtonGroup(
3337

3438
TimeIntervals.values().forEachIndexed { index, interval ->
3539
val backgroundColor = if (selectedColor.value == index) {
36-
Color.CaribbeanGreen
40+
CaribbeanGreen
3741
} else {
38-
Color.Transparent
42+
Transparent
43+
}
44+
45+
val textColor = if (selectedColor.value == index) {
46+
White
47+
} else {
48+
OsloGray
3949
}
4050

4151
ChartIntervalsButton(
@@ -45,6 +55,7 @@ fun ChartIntervalsButtonGroup(
4555
color = backgroundColor,
4656
shape = RoundedCornerShape(Dp12)
4757
),
58+
textColor = textColor,
4859
interval = interval,
4960
onClick = {
5061
if (selectedColor.value != index) {
@@ -60,6 +71,7 @@ fun ChartIntervalsButtonGroup(
6071
@Composable
6172
fun ChartIntervalsButton(
6273
modifier: Modifier,
74+
textColor: Color,
6375
interval: TimeIntervals,
6476
onClick: () -> Unit
6577
) {
@@ -69,7 +81,7 @@ fun ChartIntervalsButton(
6981
.padding(vertical = Dp4, horizontal = Dp8),
7082
textAlign = TextAlign.Center,
7183
text = interval.text,
72-
color = Color.White,
84+
color = textColor,
7385
style = Style.medium14()
7486
)
7587
}

app/src/main/java/co/nimblehq/compose/crypto/ui/preview/HomeScreenPreviewParameterProvider.kt

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,29 @@ package co.nimblehq.compose.crypto.ui.preview
22

33
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
44
import co.nimblehq.compose.crypto.lib.IsLoading
5+
import co.nimblehq.compose.crypto.ui.base.LoadingState
56
import co.nimblehq.compose.crypto.ui.uimodel.CoinItemUiModel
67

78
class HomeScreenPreviewParameterProvider : PreviewParameterProvider<HomeScreenParams> {
89
override val values = sequenceOf(
910
HomeScreenParams(
1011
listOf(coinItemPreview),
1112
listOf(coinItemPreview),
12-
false
13+
false,
14+
LoadingState.Idle
1315
),
1416
HomeScreenParams(
1517
listOf(coinItemPreview),
1618
listOf(coinItemPreview),
17-
true
19+
true,
20+
LoadingState.Loading
1821
),
1922
)
2023
}
2124

2225
data class HomeScreenParams(
2326
val myCoins: List<CoinItemUiModel>,
2427
val trendingCoins: List<CoinItemUiModel>,
25-
val isLoading: IsLoading
28+
val isMyCoinsLoading: IsLoading,
29+
val isTrendingCoinsLoading: LoadingState
2630
)

0 commit comments

Comments
 (0)