Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing apply button on filter selection when font is enlarged #240

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import androidx.compose.material3.MenuItemColors
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.OutlinedTextFieldDefaults
import androidx.compose.material3.OutlinedTextFieldDefaults.Container
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SheetState
import androidx.compose.material3.Slider
import androidx.compose.material3.SliderDefaults
Expand Down Expand Up @@ -90,78 +91,90 @@ fun FilterPicker(
sheetState = sheetState,
containerColor = AppTheme.extraColorScheme.surfaceVariantAlt2,
) {
Column(
modifier = Modifier
.fillMaxWidth()
.background(AppTheme.extraColorScheme.surfaceVariantAlt2),
) {
CenterAlignedTopAppBar(
title = {
Text(
text = stringResource(id = R.string.asearch_filter_sheet_title),
)
},
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
containerColor = AppTheme.extraColorScheme.surfaceVariantAlt2,
),
)

Scaffold(
topBar = {
FilterPickerTopBar()
},
bottomBar = {
FilterPickerBottomBar(
sheetState = sheetState,
onDismissRequest = onDismissRequest,
onFiltersSelected = { filterSelected(filterState) },
)
},
) { paddingValues ->
Column(
verticalArrangement = Arrangement.spacedBy(12.dp),
modifier = Modifier
.padding(paddingValues)
.fillMaxWidth()
.padding(24.dp)
.verticalScroll(rememberScrollState()),
.background(AppTheme.extraColorScheme.surfaceVariantAlt2),
) {
if (searchKind.isReads()) {
SliderColumn(
label = stringResource(id = R.string.asearch_filter_min_read_time),
value = filterState.minReadTime,
onValueChange = { filterState = filterState.copy(minReadTime = it) },
maxValue = 20,
)
SliderColumn(
label = stringResource(id = R.string.asearch_filter_max_read_time),
value = filterState.maxReadTime,
onValueChange = { filterState = filterState.copy(maxReadTime = it) },
maxValue = 20,
)
}
if (searchKind.isImages() || searchKind.isVideos()) {
OrientationRow(
orientation = filterState.orientation,
onOrientationSelected = { filterState = filterState.copy(orientation = it) },
)
}
if (searchKind.isVideos() || searchKind.isSound()) {
SliderColumn(
label = stringResource(id = R.string.asearch_filter_min_duration),
value = filterState.minDuration,
onValueChange = { filterState = filterState.copy(minDuration = it) },
maxValue = 600,
)
SliderColumn(
label = stringResource(id = R.string.asearch_filter_max_duration),
value = filterState.maxDuration,
onValueChange = { filterState = filterState.copy(maxDuration = it) },
maxValue = 600,
Column(
verticalArrangement = Arrangement.spacedBy(12.dp),
modifier = Modifier
.fillMaxWidth()
.padding(24.dp)
.verticalScroll(rememberScrollState()),
) {
if (searchKind.isReads()) {
SliderColumn(
label = stringResource(id = R.string.asearch_filter_min_read_time),
value = filterState.minReadTime,
onValueChange = { filterState = filterState.copy(minReadTime = it) },
maxValue = 20,
)
SliderColumn(
label = stringResource(id = R.string.asearch_filter_max_read_time),
value = filterState.maxReadTime,
onValueChange = { filterState = filterState.copy(maxReadTime = it) },
maxValue = 20,
)
}
if (searchKind.isImages() || searchKind.isVideos()) {
OrientationRow(
orientation = filterState.orientation,
onOrientationSelected = { filterState = filterState.copy(orientation = it) },
)
}
if (searchKind.isVideos() || searchKind.isSound()) {
SliderColumn(
label = stringResource(id = R.string.asearch_filter_min_duration),
value = filterState.minDuration,
onValueChange = { filterState = filterState.copy(minDuration = it) },
maxValue = 600,
)
SliderColumn(
label = stringResource(id = R.string.asearch_filter_max_duration),
value = filterState.maxDuration,
onValueChange = { filterState = filterState.copy(maxDuration = it) },
maxValue = 600,
)
}
CommonSliders(
filterState = filterState,
onFilterStateChange = { reducer -> filterState = filterState.reducer() },
)
}
CommonSliders(
filterState = filterState,
onFilterStateChange = { reducer -> filterState = filterState.reducer() },
)
}

FilterPickerBottomBar(
sheetState = sheetState,
onDismissRequest = onDismissRequest,
onFiltersSelected = { filterSelected(filterState) },
)
}
}
}

@Composable
@OptIn(ExperimentalMaterial3Api::class)
private fun FilterPickerTopBar() {
CenterAlignedTopAppBar(
title = {
Text(
text = stringResource(id = R.string.asearch_filter_sheet_title),
)
},
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
containerColor = AppTheme.extraColorScheme.surfaceVariantAlt2,
),
)
}

@Composable
private fun CommonSliders(
filterState: AdvancedSearchContract.SearchFilter,
Expand Down