Merge pull request #4 from Myzel394/fix-currency-base

Fix base
This commit is contained in:
Myzel394 2024-05-02 23:36:51 +02:00 committed by GitHub
commit 30b2e3d5dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 4 deletions

View File

@ -342,7 +342,9 @@ class UnitsRepositoryImpl @Inject constructor(
val conversion = unitFrom.convert(unitTo, value) val conversion = unitFrom.convert(unitTo, value)
ConverterResult.NumberBase(conversion) ConverterResult.NumberBase(conversion)
} catch (e: Exception) { } catch (error: Exception) {
Log.e("UnitsRepositoryImpl", "Failed to convert number base $unitFromId -> $unitToId: $error")
error.printStackTrace()
ConverterResult.Error.ConversionError ConverterResult.Error.ConversionError
} }
} }

View File

@ -23,6 +23,7 @@ import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import app.myzel394.numberhub.core.base.OutputFormat import app.myzel394.numberhub.core.base.OutputFormat
import app.myzel394.numberhub.core.base.Token
import app.myzel394.numberhub.core.ui.common.textfield.getTextField import app.myzel394.numberhub.core.ui.common.textfield.getTextField
import app.myzel394.numberhub.data.common.combine import app.myzel394.numberhub.data.common.combine
import app.myzel394.numberhub.data.common.stateIn import app.myzel394.numberhub.data.common.stateIn
@ -175,11 +176,13 @@ internal class ConverterViewModel @Inject constructor(
fun convertNumberBase() { fun convertNumberBase() {
conversionJob?.cancel() conversionJob?.cancel()
conversionJob = viewModelScope.launch { conversionJob = viewModelScope.launch {
unitsRepo.convertNumberBase( val result = unitsRepo.convertNumberBase(
unitFromId = unitFromId.value ?: return@launch, unitFromId = unitFromId.value ?: return@launch,
unitToId = unitToId.value ?: return@launch, unitToId = unitToId.value ?: return@launch,
value = input1.value.text, value = input1.value.text.ifEmpty { Token.Digit._0 }
) )
output.update { result }
} }
} }

View File

@ -248,7 +248,8 @@ private fun SettingsScreen(
} }
AnimatedVisibility( AnimatedVisibility(
visible = uiState.showUpdateChangelog, // TODO: Restore this line for next update
visible = false,
enter = expandVertically() + fadeIn(), enter = expandVertically() + fadeIn(),
exit = shrinkVertically() + fadeOut(), exit = shrinkVertically() + fadeOut(),
) { ) {