-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
254 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
app/src/main/kotlin/cloud/mike/divelog/localization/Parsing.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package cloud.mike.divelog.localization | ||
|
||
import java.text.NumberFormat | ||
import java.text.ParseException | ||
import java.util.Locale | ||
|
||
fun String.isValidNumber(locale: Locale) = toNumberOrNull(locale) != null | ||
|
||
fun String.toNumberOrNull(locale: Locale): Number? = try { | ||
NumberFormat.getInstance(locale).parse(this)?.toFloat() | ||
} catch (e: ParseException) { | ||
null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
app/src/main/kotlin/cloud/mike/divelog/ui/detail/items/MaxDepthItem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package cloud.mike.divelog.ui.detail.items | ||
|
||
import android.content.res.Configuration | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Height | ||
import androidx.compose.material3.Card | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import cloud.mike.divelog.R | ||
import cloud.mike.divelog.data.dives.Dive | ||
import cloud.mike.divelog.localization.formatDepthMeters | ||
import cloud.mike.divelog.ui.DiveTheme | ||
import cloud.mike.divelog.ui.common.card.CardHeadline | ||
import cloud.mike.divelog.ui.spacing | ||
|
||
@Composable | ||
fun MaxDepthItem( | ||
maxDepthMeters: Float, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Card(modifier = modifier.fillMaxWidth()) { | ||
Column( | ||
modifier = Modifier.padding(MaterialTheme.spacing.cardPadding), | ||
) { | ||
CardHeadline( | ||
imageVector = Icons.Default.Height, | ||
title = stringResource(R.string.dive_detail_label_max_depth), | ||
) | ||
Spacer(Modifier.height(8.dp)) | ||
Text( | ||
text = maxDepthMeters.formatDepthMeters(), | ||
style = MaterialTheme.typography.bodyMedium, | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) | ||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO) | ||
@Composable | ||
private fun Preview() { | ||
DiveTheme { | ||
MaxDepthItem( | ||
maxDepthMeters = Dive.sample.maxDepthMeters ?: 12.34f, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.