Split the currency picker's browsable list into Priced/Unpriced
The "Currencies" section (not-yet-added currencies) is now two: "Priced Currencies" and "Unpriced Currencies", partitioned by whether the active source quotes a rate for each one. "Current Currency" and "Selected Currencies" are unaffected. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FXcrACM5sok3M1KQJ8kByy
This commit is contained in:
@@ -36,9 +36,20 @@ struct CurrencyPickerSheet: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let matchingUnselected = unselectedCurrencies.filter(matches)
|
let matchingUnselected = unselectedCurrencies.filter(matches)
|
||||||
if !matchingUnselected.isEmpty {
|
let unselectedPriced = matchingUnselected.filter { pricedCurrencyCodes.contains($0.code) }
|
||||||
Section(IosLocalizationKt.localizedString(resource: MR.strings.shared.currencies_section_title)) {
|
let unselectedUnpriced = matchingUnselected.filter { !pricedCurrencyCodes.contains($0.code) }
|
||||||
ForEach(matchingUnselected, id: \.code) { info in
|
|
||||||
|
if !unselectedPriced.isEmpty {
|
||||||
|
Section(IosLocalizationKt.localizedString(resource: MR.strings.shared.priced_currencies_section_title)) {
|
||||||
|
ForEach(unselectedPriced, id: \.code) { info in
|
||||||
|
currencyRow(for: info, isSelected: false, onTap: { onToggle(info.code) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !unselectedUnpriced.isEmpty {
|
||||||
|
Section(IosLocalizationKt.localizedString(resource: MR.strings.shared.unpriced_currencies_section_title)) {
|
||||||
|
ForEach(unselectedUnpriced, id: \.code) { info in
|
||||||
currencyRow(for: info, isSelected: false, onTap: { onToggle(info.code) })
|
currencyRow(for: info, isSelected: false, onTap: { onToggle(info.code) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -591,19 +591,43 @@ private fun CurrencyPickerScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unselected.isNotEmpty()) {
|
val (unselectedPriced, unselectedUnpriced) = unselected.partition { state.isPriced(it.code) }
|
||||||
|
|
||||||
|
if (unselectedPriced.isNotEmpty()) {
|
||||||
Column {
|
Column {
|
||||||
Text(
|
Text(
|
||||||
stringResource(MR.strings.currencies_section_title).uppercase(),
|
stringResource(MR.strings.priced_currencies_section_title).uppercase(),
|
||||||
style = SectionHeaderStyle,
|
style = SectionHeaderStyle,
|
||||||
modifier = Modifier.padding(bottom = 4.dp),
|
modifier = Modifier.padding(bottom = 4.dp),
|
||||||
)
|
)
|
||||||
unselected.forEach { info ->
|
unselectedPriced.forEach { info ->
|
||||||
key(info.code) {
|
key(info.code) {
|
||||||
CurrencyRow(
|
CurrencyRow(
|
||||||
info = info,
|
info = info,
|
||||||
isSelected = false,
|
isSelected = false,
|
||||||
isPriced = state.isPriced(info.code),
|
isPriced = true,
|
||||||
|
sourceName = state.sourceName,
|
||||||
|
localeCurrencyCode = state.localeCurrencyCode,
|
||||||
|
onClick = { onToggle(info.code) },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unselectedUnpriced.isNotEmpty()) {
|
||||||
|
Column {
|
||||||
|
Text(
|
||||||
|
stringResource(MR.strings.unpriced_currencies_section_title).uppercase(),
|
||||||
|
style = SectionHeaderStyle,
|
||||||
|
modifier = Modifier.padding(bottom = 4.dp),
|
||||||
|
)
|
||||||
|
unselectedUnpriced.forEach { info ->
|
||||||
|
key(info.code) {
|
||||||
|
CurrencyRow(
|
||||||
|
info = info,
|
||||||
|
isSelected = false,
|
||||||
|
isPriced = false,
|
||||||
sourceName = state.sourceName,
|
sourceName = state.sourceName,
|
||||||
localeCurrencyCode = state.localeCurrencyCode,
|
localeCurrencyCode = state.localeCurrencyCode,
|
||||||
onClick = { onToggle(info.code) },
|
onClick = { onToggle(info.code) },
|
||||||
|
|||||||
@@ -19,10 +19,12 @@
|
|||||||
<string name="move_currency_to_top_content_description">Move to top</string>
|
<string name="move_currency_to_top_content_description">Move to top</string>
|
||||||
<string name="move_currency_up_content_description">Move up</string>
|
<string name="move_currency_up_content_description">Move up</string>
|
||||||
<string name="price_source">Price Source</string>
|
<string name="price_source">Price Source</string>
|
||||||
|
<string name="priced_currencies_section_title">Priced Currencies</string>
|
||||||
<string name="refresh_content_description">Refresh</string>
|
<string name="refresh_content_description">Refresh</string>
|
||||||
<string name="remove_currency_content_description">Remove</string>
|
<string name="remove_currency_content_description">Remove</string>
|
||||||
<string name="retry">Retry</string>
|
<string name="retry">Retry</string>
|
||||||
<string name="sats_label">Sats</string>
|
<string name="sats_label">Sats</string>
|
||||||
<string name="search_currencies_placeholder">Search currencies</string>
|
<string name="search_currencies_placeholder">Search currencies</string>
|
||||||
<string name="selected_currencies_section_title">Selected Currencies</string>
|
<string name="selected_currencies_section_title">Selected Currencies</string>
|
||||||
|
<string name="unpriced_currencies_section_title">Unpriced Currencies</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user