Skip to content

Commit

Permalink
Added BNB cryptocurrency & Improved time entry in the template editor
Browse files Browse the repository at this point in the history
  • Loading branch information
v1tzor committed Sep 25, 2023
1 parent ab408d4 commit 46591d1
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 23 deletions.
15 changes: 1 addition & 14 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified app/debug/app-debug.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/debug/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 19,
"versionName": "0.7.3",
"versionCode": 20,
"versionName": "0.7.4",
"outputFile": "app-debug.apk"
}
],
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 19,
"versionName": "0.7.3",
"versionCode": 20,
"versionName": "0.7.4",
"outputFile": "app-release.apk"
}
],
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ object Config {
const val targetSdkVersion = 33
const val minSdkVersion = 24

const val versionCode = 19
const val versionName = "0.7.3"
const val versionCode = 20
const val versionName = "0.7.4"

const val testInstrumentRunner = "androidx.test.runner.AndroidJUnitRunner"
const val consumerProguardFiles = "consumer-rules.pro"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package ru.aleshin.features.home.impl.presentation.ui.templates.views

import android.text.format.DateFormat
import android.util.Log
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Arrangement
Expand All @@ -30,6 +31,7 @@ import androidx.compose.foundation.layout.sizeIn
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.AlertDialog
Expand All @@ -48,9 +50,12 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.input.KeyboardType
Expand Down Expand Up @@ -373,6 +378,8 @@ internal fun TemplateEditorStartTimeChooser(
minutes: Int?,
onTimeChange: (hours: Int?, minutes: Int?) -> Unit,
) {
val minutesFocusRequester = remember { FocusRequester() }
var lastHours by rememberSaveable { mutableStateOf<Int?>(null) }
val is24Format = DateFormat.is24HourFormat(LocalContext.current)
var format by remember {
mutableStateOf(if (hours != null && hours > 11) TimeFormat.PM else TimeFormat.AM)
Expand Down Expand Up @@ -407,12 +414,20 @@ internal fun TemplateEditorStartTimeChooser(
onValueChange = {
val time = it.toIntOrNull()
if (time != null && is24Format && time in 0..23) {
if (lastHours != null && lastHours.toString().length == 1 && it.length == 2) {
minutesFocusRequester.requestFocus()
}
lastHours = time
onTimeChange(time, minutes)
} else if (time != null && !is24Format && time in 1..12) {
val formatTime = when (format) {
TimeFormat.PM -> if (time != 12) time + 12 else 12
TimeFormat.AM -> if (time != 12) time else 0
}
if (lastHours != null && lastHours.toString().length == 1 && it.length == 2) {
minutesFocusRequester.requestFocus()
}
lastHours = time
onTimeChange(formatTime, minutes)
} else if (it.isBlank()) {
onTimeChange(null, minutes)
Expand All @@ -427,7 +442,7 @@ internal fun TemplateEditorStartTimeChooser(
color = MaterialTheme.colorScheme.onSurface,
)
OutlinedTextField(
modifier = Modifier.weight(1f).align(Alignment.Bottom),
modifier = Modifier.weight(1f).align(Alignment.Bottom).focusRequester(minutesFocusRequester),
value = minutes?.toString() ?: "",
onValueChange = {
val time = it.toIntOrNull()
Expand Down Expand Up @@ -459,6 +474,8 @@ internal fun TemplateEditorEndTimeChooser(
minutes: Int?,
onTimeChange: (hours: Int?, minutes: Int?) -> Unit,
) {
val minutesFocusRequester = remember { FocusRequester() }
var lastHours by rememberSaveable { mutableStateOf<Int?>(null) }
val is24Format = DateFormat.is24HourFormat(LocalContext.current)
var format by remember {
mutableStateOf(if (hours != null && hours > 11) TimeFormat.PM else TimeFormat.AM)
Expand Down Expand Up @@ -493,6 +510,10 @@ internal fun TemplateEditorEndTimeChooser(
onValueChange = {
val time = it.toIntOrNull()
if (time != null && is24Format && time in 0..23) {
if (lastHours != null && lastHours.toString().length == 1 && it.length == 2) {
minutesFocusRequester.requestFocus()
}
lastHours = time
onTimeChange(time, minutes)
} else if (time != null && !is24Format && time in 1..12) {
if ((time in 1..12 && format == TimeFormat.PM) ||
Expand All @@ -502,6 +523,10 @@ internal fun TemplateEditorEndTimeChooser(
TimeFormat.PM -> if (time != 12) time + 12 else 12
TimeFormat.AM -> if (time != 12) time else 0
}
if (lastHours != null && lastHours.toString().length == 1 && it.length == 2) {
minutesFocusRequester.requestFocus()
}
lastHours = time
onTimeChange(formatTime, minutes)
}
} else if (it.isBlank()) {
Expand All @@ -517,7 +542,7 @@ internal fun TemplateEditorEndTimeChooser(
color = MaterialTheme.colorScheme.onSurface,
)
OutlinedTextField(
modifier = Modifier.weight(1f).align(Alignment.Bottom),
modifier = Modifier.weight(1f).align(Alignment.Bottom).focusRequester(minutesFocusRequester),
value = minutes?.toString() ?: "",
onValueChange = {
val time = it.toIntOrNull()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package ru.aleshin.features.settings.impl.presentation.models
*/
enum class CryptoAddress(val crypto: String, val address: String) {
BTC("BTC", "bc1qu0a5ujldf8rpc8yz8atlgphrj9wutgfxw82dql"),
BNB("BNB/BTCB", "0xbA08E4905B3d52f480419A8444C4de3E91BC98df"),
ETH("ETH", "0x4cAfa6De0D1968cA8C2a7aB06CE28d0A1aD2C7b9"),
TRX("TRX", "TKC3NsKSS9hJRvofeJKceT5wC2bqTkPRUE"),
LTC("LTC", "ltc1qj9fsz4pxrvr3eqyel4q8jnsnfpcfwdsj3mvpec"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ internal fun CryptoList(
onCopyCryptoAddress: (String) -> Unit,
) {
Surface(
modifier = modifier.height(265.dp),
modifier = modifier.height(310.dp),
shape = MaterialTheme.shapes.large,
color = MaterialTheme.colorScheme.surfaceTwo(),
) {
Expand Down

0 comments on commit 46591d1

Please sign in to comment.