Skip to content

Commit 2d85ca5

Browse files
committed
Merge remote-tracking branch 'origin/develop' into HEAD
* origin/develop: chore: align badge with new sizing chore: simplify badge handling to reduce size chore: tweak bill asset placements more
2 parents 974b10d + ca20fb5 commit 2d85ca5

5 files changed

Lines changed: 80 additions & 61 deletions

File tree

app/build.gradle.kts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ android {
4747
}
4848

4949
buildFeatures {
50+
buildConfig = true
5051
viewBinding = true
5152
dataBinding = true
5253
compose = true
5354
}
55+
5456
composeOptions {
5557
kotlinCompilerExtensionVersion = Versions.compose_compiler
5658
}
@@ -95,10 +97,6 @@ android {
9597
resources.excludes.add("META-INF/LICENSE.md")
9698
resources.excludes.add("META-INF/LICENSE-notice.md")
9799
}
98-
99-
buildFeatures {
100-
buildConfig = true
101-
}
102100
}
103101

104102

app/src/main/java/com/getcode/ui/components/Badge.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@ import androidx.compose.animation.fadeIn
55
import androidx.compose.animation.fadeOut
66
import androidx.compose.animation.scaleIn
77
import androidx.compose.animation.scaleOut
8+
import androidx.compose.foundation.layout.padding
9+
import androidx.compose.foundation.layout.size
810
import androidx.compose.material.Text
911
import androidx.compose.runtime.Composable
1012
import androidx.compose.ui.Modifier
13+
import androidx.compose.ui.draw.drawBehind
1114
import androidx.compose.ui.graphics.Color
1215
import androidx.compose.ui.text.font.FontWeight
16+
import androidx.compose.ui.unit.dp
1317
import com.getcode.theme.CodeTheme
18+
import com.getcode.ui.components.chat.ChatNodeDefaults
1419
import com.getcode.ui.utils.circleBackground
1520

1621

@@ -31,7 +36,13 @@ fun Badge(
3136
text = text,
3237
color = contentColor,
3338
style = CodeTheme.typography.body1.copy(fontWeight = FontWeight.W700),
34-
modifier = modifier.circleBackground(color = color, padding = CodeTheme.dimens.staticGrid.x1)
39+
modifier = modifier
40+
.drawBehind {
41+
drawCircle(
42+
color = color,
43+
radius = this.size.maxDimension / 2f
44+
)
45+
}.padding(2.dp)
3546
)
3647
}
3748
}

app/src/main/java/com/getcode/view/login/PhoneVerifyViewModel.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class PhoneVerifyViewModel @Inject constructor(
155155

156156
val phoneNumberCombined = areaCode.toString() + phoneInput
157157

158-
Timber.d("phoneNumber=$phoneNumberCombined")
158+
159159
val phoneNumber = phoneNumberCombined.makeE164(
160160
java.util.Locale(java.util.Locale.getDefault().language, countryCode)
161161
)
@@ -168,6 +168,7 @@ class PhoneVerifyViewModel @Inject constructor(
168168
client.startSmsRetriever()
169169
}
170170

171+
Timber.d("phoneNumber=$phoneNumber")
171172
phoneRepository.sendVerificationCode(phoneNumber)
172173
.firstElement()
173174
.observeOn(AndroidSchedulers.mainThread())
@@ -220,6 +221,7 @@ class PhoneVerifyViewModel @Inject constructor(
220221
)
221222
}
222223
}, {
224+
it.printStackTrace()
223225
setIsLoading(false)
224226
TopBarManager.showMessage(getGenericError())
225227
}

app/src/main/java/com/getcode/view/main/bill/CashBill.kt

Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ import androidx.compose.foundation.layout.fillMaxWidth
2020
import androidx.compose.foundation.layout.height
2121
import androidx.compose.foundation.layout.offset
2222
import androidx.compose.foundation.layout.padding
23+
import androidx.compose.foundation.layout.requiredWidth
2324
import androidx.compose.foundation.layout.size
2425
import androidx.compose.foundation.layout.statusBarsIgnoringVisibility
2526
import androidx.compose.foundation.layout.width
2627
import androidx.compose.foundation.layout.windowInsetsPadding
28+
import androidx.compose.foundation.layout.wrapContentHeight
2729
import androidx.compose.material.Text
2830
import androidx.compose.runtime.Composable
2931
import androidx.compose.runtime.getValue
@@ -59,6 +61,7 @@ import com.getcode.model.KinAmount
5961
import com.getcode.solana.keys.Key32.Companion.kinMint
6062
import com.getcode.solana.keys.base58
6163
import com.getcode.theme.CodeTheme
64+
import com.getcode.ui.utils.debugBounds
6265
import com.getcode.util.formattedRaw
6366
import com.getcode.ui.utils.nonScaledSp
6467
import com.getcode.ui.utils.punchCircle
@@ -167,12 +170,16 @@ private class CashBillGeometry(width: Dp, height: Dp) {
167170
val codeSize: Dp
168171
get() = size.width * 0.6f
169172

173+
val globeWidth: Dp
174+
get() = size.width * 1.45f
170175
val globePosition: Offset
171176
get() = Offset(
172-
x = -(size.width.value * 1.25f),
173-
y = size.height.value * 0.5f
177+
x = -(size.width.value * 0.75f),
178+
y = size.height.value * 0.65f
174179
)
175180

181+
val gridWidth: Dp
182+
get() = size.width * 1.75f
176183

177184
val linesHeight: Dp
178185
get() = (topStripHeight.value - 2).dp
@@ -235,41 +242,49 @@ internal fun CashBill(
235242
image = ImageBitmap.imageResource(R.drawable.ic_bill_hexagons),
236243
blendMode = BlendMode.Multiply,
237244
alpha = 0.6f,
238-
fill = true,
239-
)
240-
241-
// Waves
242-
BillDecorImage(
243-
modifier = Modifier
244-
.matchParentSize()
245-
.clipToBounds(),
246-
image = ImageBitmap.imageResource(R.drawable.ic_bill_waves),
247-
fill = true,
248-
topLeft = Offset(
249-
x = 0f,
250-
y = with(LocalDensity.current) { geometry.securityStripPosition.y.toPx() }),
251245
)
246+
// Grid pattern
247+
CashBillAssets.grid?.let {
248+
Image(
249+
modifier = Modifier
250+
.requiredWidth(geometry.gridWidth)
251+
.clipToBounds(),
252+
alpha = 0.5f,
253+
bitmap = it,
254+
contentDescription = null
255+
)
256+
}
252257

253258
// Globe
254-
BillDecorImage(
255-
modifier = Modifier
256-
.matchParentSize()
257-
.clipToBounds(),
258-
size = DpSize(width = geometry.size.width * 1.45f, height = Dp.Unspecified),
259-
image = CashBillAssets.globe,
260-
topLeft = geometry.globePosition
261-
)
259+
CashBillAssets.globe?.let {
260+
Image(
261+
modifier = Modifier
262+
.requiredWidth(geometry.globeWidth)
263+
.offset {
264+
IntOffset(
265+
x = geometry.globePosition.x.toInt(),
266+
y = geometry.globePosition.y.toInt()
267+
)
268+
},
269+
bitmap = it,
270+
contentDescription = null
271+
)
272+
}
262273

263-
// Grid pattern
264-
BillDecorImage(
274+
// Waves
275+
Image(
265276
modifier = Modifier
266277
.matchParentSize()
278+
.offset {
279+
IntOffset(
280+
x = 0,
281+
y = geometry.securityStripPosition.y.roundToPx(),
282+
)
283+
}
267284
.clipToBounds(),
268-
image = CashBillAssets.grid,
269-
alpha = 0.5f,
270-
topLeft = Offset(
271-
x = 0f,
272-
y = with(LocalDensity.current) { geometry.securityStripPosition.y.toPx() }),
285+
contentDescription = null,
286+
contentScale = ContentScale.FillBounds,
287+
bitmap = ImageBitmap.imageResource(R.drawable.ic_bill_waves),
273288
)
274289

275290
// Security strip
@@ -408,36 +423,22 @@ private fun BillDecorImage(
408423
size: DpSize = DpSize.Unspecified,
409424
topLeft: Offset = Offset.Zero,
410425
blendMode: BlendMode = DrawScope.DefaultBlendMode,
411-
fill: Boolean = false,
412426
) {
413427
Canvas(
414428
modifier = modifier,
415429
) {
416430
// Hexagons
417431
image?.let {
418-
if (fill) {
419-
drawImage(
420-
image = it,
421-
dstSize = IntSize(
422-
width = if (size.isSpecified && size.width.isSpecified) size.width.roundToPx() else this.size.width.toInt(),
423-
height = if (size.isSpecified && size.height.isSpecified) size.height.roundToPx() else this.size.height.toInt(),
424-
),
425-
alpha = alpha,
426-
dstOffset = IntOffset(topLeft.x.roundToInt(), topLeft.y.roundToInt()),
427-
blendMode = blendMode,
428-
)
429-
} else {
430-
drawImage(
431-
image = it,
432-
alpha = alpha,
433-
dstSize = IntSize(
434-
width = if (size.isSpecified && size.width.isSpecified) size.width.roundToPx() else this.size.width.toInt(),
435-
height = if (size.isSpecified && size.height.isSpecified) size.height.roundToPx() else this.size.height.toInt(),
436-
),
437-
dstOffset = IntOffset(topLeft.x.roundToInt(), topLeft.y.roundToInt()),
438-
blendMode = blendMode,
439-
)
440-
}
432+
drawImage(
433+
image = it,
434+
dstSize = IntSize(
435+
width = if (size.isSpecified && size.width.isSpecified) size.width.roundToPx() else this.size.width.toInt(),
436+
height = if (size.isSpecified && size.height.isSpecified) size.height.roundToPx() else this.size.height.toInt(),
437+
),
438+
alpha = alpha,
439+
dstOffset = IntOffset(topLeft.x.roundToInt(), topLeft.y.roundToInt()),
440+
blendMode = blendMode,
441+
)
441442
}
442443
}
443444
}

app/src/main/java/com/getcode/view/main/home/components/HomeBottom.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import androidx.compose.ui.res.painterResource
2020
import androidx.compose.ui.res.stringResource
2121
import androidx.compose.ui.tooling.preview.Preview
2222
import androidx.compose.ui.unit.Dp
23+
import androidx.compose.ui.unit.dp
2324
import com.getcode.R
2425
import com.getcode.theme.CodeTheme
2526
import com.getcode.ui.utils.heightOrZero
@@ -77,7 +78,13 @@ internal fun HomeBottom(
7778
imageSize = CodeTheme.dimens.grid.x9,
7879
painter = painterResource(R.drawable.ic_history),
7980
onClick = { onPress(HomeBottomSheet.BALANCE) },
80-
badge = { Badge(count = state.chatUnreadCount, color = ChatNodeDefaults.UnreadIndicator) }
81+
badge = {
82+
Badge(
83+
modifier = Modifier.padding(top = 2.dp, end = 2.dp),
84+
count = state.chatUnreadCount,
85+
color = ChatNodeDefaults.UnreadIndicator
86+
)
87+
}
8188
)
8289
}
8390
}

0 commit comments

Comments
 (0)