mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-19 08:45:27 +02:00
Updated placeholder
This commit is contained in:
parent
9120fa649d
commit
16df812ccb
@ -133,6 +133,7 @@ fun UnittoApp(
|
||||
currentUnit = mainViewModel.unitTo,
|
||||
navigateUp = { navController.navigateUp() },
|
||||
selectAction = { mainViewModel.changeUnitTo(it) },
|
||||
navigateToSettingsActtion = { navController.navigate(UNIT_GROUPS_SCREEN) },
|
||||
viewModel = secondViewModel,
|
||||
inputValue = mainViewModel.mainUIState.inputValue.toBigDecimal(),
|
||||
unitFrom = mainViewModel.unitFrom
|
||||
|
@ -49,6 +49,7 @@ import java.math.BigDecimal
|
||||
*
|
||||
* @param currentUnit Currently selected [AbstractUnit].
|
||||
* @param navigateUp Action to navigate up. Called when user click back button.
|
||||
* @param navigateToSettingsActtion Action to perform when clicking open settings in placeholder.
|
||||
* @param selectAction Action to perform when user clicks on [UnitListItem].
|
||||
* @param viewModel [SecondViewModel].
|
||||
* @param chipsRow Composable that is placed under TopAppBar. See [ChipsRow]
|
||||
@ -61,6 +62,7 @@ import java.math.BigDecimal
|
||||
private fun BasicUnitListScreen(
|
||||
currentUnit: AbstractUnit,
|
||||
navigateUp: () -> Unit,
|
||||
navigateToSettingsActtion: () -> Unit,
|
||||
selectAction: (AbstractUnit) -> Unit,
|
||||
viewModel: SecondViewModel,
|
||||
chipsRow: @Composable (UnitGroup?, LazyListState) -> Unit = {_, _->},
|
||||
@ -102,7 +104,7 @@ private fun BasicUnitListScreen(
|
||||
)
|
||||
}
|
||||
if (uiState.unitsToShow.isEmpty()) {
|
||||
item { SearchPlaceholder() }
|
||||
item { SearchPlaceholder(navigateToSettingsActtion) }
|
||||
return@LazyColumn
|
||||
}
|
||||
uiState.unitsToShow.forEach { (unitGroup, listOfUnits) ->
|
||||
@ -149,6 +151,7 @@ fun LeftSideScreen(
|
||||
) = BasicUnitListScreen(
|
||||
currentUnit = currentUnit,
|
||||
navigateUp = navigateUp,
|
||||
navigateToSettingsActtion = navigateToSettingsActtion,
|
||||
selectAction = selectAction,
|
||||
viewModel = viewModel,
|
||||
chipsRow = { unitGroup, lazyListState ->
|
||||
@ -180,6 +183,7 @@ fun LeftSideScreen(
|
||||
*
|
||||
* @param currentUnit Currently selected [AbstractUnit].
|
||||
* @param navigateUp Action to navigate up. Called when user click back button.
|
||||
* @param navigateToSettingsActtion Action to perform when clicking settings chip at the end.
|
||||
* @param selectAction Action to perform when user clicks on [UnitListItem].
|
||||
* @param viewModel [SecondViewModel].
|
||||
* @param inputValue Current input value (upper text field on MainScreen)
|
||||
@ -189,6 +193,7 @@ fun LeftSideScreen(
|
||||
fun RightSideScreen(
|
||||
currentUnit: AbstractUnit,
|
||||
navigateUp: () -> Unit,
|
||||
navigateToSettingsActtion: () -> Unit,
|
||||
selectAction: (AbstractUnit) -> Unit,
|
||||
viewModel: SecondViewModel,
|
||||
inputValue: BigDecimal,
|
||||
@ -196,6 +201,7 @@ fun RightSideScreen(
|
||||
) = BasicUnitListScreen(
|
||||
currentUnit = currentUnit,
|
||||
navigateUp = navigateUp,
|
||||
navigateToSettingsActtion = navigateToSettingsActtion,
|
||||
selectAction = selectAction,
|
||||
viewModel = viewModel,
|
||||
unitsListItem = { unit, selectUnitAction ->
|
||||
|
@ -25,6 +25,7 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.SearchOff
|
||||
import androidx.compose.material3.ElevatedButton
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
@ -39,15 +40,16 @@ import com.sadellie.unitto.R
|
||||
/**
|
||||
* Placeholder that can be seen when there are no units found
|
||||
*
|
||||
* @param navigateToSettingsActtion Action to perform when clicking open settings button.
|
||||
*/
|
||||
@Composable
|
||||
fun SearchPlaceholder() {
|
||||
fun SearchPlaceholder(navigateToSettingsActtion: () -> Unit) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
// Big icon in the middle
|
||||
Icon(
|
||||
@ -67,5 +69,9 @@ fun SearchPlaceholder() {
|
||||
textAlign = TextAlign.Center,
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
// Open settings button
|
||||
ElevatedButton(onClick = navigateToSettingsActtion) {
|
||||
Text(text = stringResource(id = R.string.search_placeholder_button_label))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -724,7 +724,7 @@
|
||||
<string name="cancel_label">Cancel</string>
|
||||
<string name="search_bar_placeholder">Search units</string>
|
||||
<string name="search_placeholder">No results found</string>
|
||||
<string name="search_placeholder_secondary">Make sure there are no typos or try different filters</string>
|
||||
<string name="search_placeholder_secondary">Make sure there are no typos, try different filters or check for disabled unit groups.</string>
|
||||
|
||||
<!--Content descriptions-->
|
||||
<string name="navigate_up_description">Navigate up</string>
|
||||
@ -742,5 +742,6 @@
|
||||
<string name="drop_down_description">Open or close drop down menu</string>
|
||||
<string name="hello_label">Hello!</string>
|
||||
<string name="unit_groups_setting">Unit groups</string>
|
||||
<string name="search_placeholder_button_label">Open settings</string>
|
||||
|
||||
</resources>
|
@ -528,7 +528,7 @@
|
||||
<string name="cancel_label">Отмена</string>
|
||||
<string name="search_bar_placeholder">Поиск величин</string>
|
||||
<string name="search_placeholder">Не найдено</string>
|
||||
<string name="search_placeholder_secondary">Убедитесь в отсутствии опечаток или попробуйте другие фильтры</string>
|
||||
<string name="search_placeholder_secondary">Убедитесь в отсутствии опечаток, попробуйте другие фильтры или проверьте отключенные величины.</string>
|
||||
<string name="navigate_up_description">Навигация наверх</string>
|
||||
<string name="checked_filter_description">Выбранный фильтр</string>
|
||||
<string name="open_settings_description">Открыть настройки</string>
|
||||
@ -677,5 +677,6 @@
|
||||
<string name="drop_down_description">Открыть или закрыть меню</string>
|
||||
<string name="hello_label">Привет!</string>
|
||||
<string name="unit_groups_setting">Группы величин</string>
|
||||
<string name="search_placeholder_button_label">Открыть настройки</string>
|
||||
|
||||
</resources>
|
@ -1004,7 +1004,8 @@
|
||||
<string name="ok_label" translatable="false">OK</string>
|
||||
<string name="search_bar_placeholder">Search units</string>
|
||||
<string name="search_placeholder">No results found</string>
|
||||
<string name="search_placeholder_secondary">Make sure there are no typos or try different filters</string>
|
||||
<string name="search_placeholder_button_label">Open settings</string>
|
||||
<string name="search_placeholder_secondary">Make sure there are no typos, try different filters or check for disabled unit groups.</string>
|
||||
<string name="hello_label">Hello!</string>
|
||||
|
||||
<!--Content descriptions-->
|
||||
|
Loading…
x
Reference in New Issue
Block a user