mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
Add global reset to default
This commit is contained in:
parent
1828e94fae
commit
682b81d936
5 changed files with 37 additions and 3 deletions
|
|
@ -226,7 +226,7 @@ class HomeSettingsService
|
||||||
}
|
}
|
||||||
HomePageResolvedSettings(resolvedRows)
|
HomePageResolvedSettings(resolvedRows)
|
||||||
} else {
|
} else {
|
||||||
createDefault(userId)
|
createDefault()
|
||||||
}
|
}
|
||||||
|
|
||||||
currentSettings.update { resolvedSettings }
|
currentSettings.update { resolvedSettings }
|
||||||
|
|
@ -235,7 +235,7 @@ class HomeSettingsService
|
||||||
/**
|
/**
|
||||||
* Create a default [HomePageResolvedSettings] using the available libraries
|
* Create a default [HomePageResolvedSettings] using the available libraries
|
||||||
*/
|
*/
|
||||||
private suspend fun createDefault(userId: UUID): HomePageResolvedSettings {
|
suspend fun createDefault(): HomePageResolvedSettings {
|
||||||
Timber.v("Creating default settings")
|
Timber.v("Creating default settings")
|
||||||
val navDrawerItems = navDrawerItemRepository.getNavDrawerItems()
|
val navDrawerItems = navDrawerItemRepository.getNavDrawerItems()
|
||||||
val libraries =
|
val libraries =
|
||||||
|
|
|
||||||
|
|
@ -72,13 +72,15 @@ fun HomeRowSettings(
|
||||||
|
|
||||||
Options.ViewOptionsUseThumb -> {
|
Options.ViewOptionsUseThumb -> {
|
||||||
onViewOptionsChange.invoke(
|
onViewOptionsChange.invoke(
|
||||||
HomeRowViewOptions(
|
viewOptions.copy(
|
||||||
heightDp = Cards.HEIGHT_EPISODE,
|
heightDp = Cards.HEIGHT_EPISODE,
|
||||||
spacing = 20,
|
spacing = 20,
|
||||||
imageType = ViewOptionImageType.THUMB,
|
imageType = ViewOptionImageType.THUMB,
|
||||||
aspectRatio = AspectRatio.WIDE,
|
aspectRatio = AspectRatio.WIDE,
|
||||||
|
contentScale = PrefContentScale.FIT,
|
||||||
episodeImageType = ViewOptionImageType.THUMB,
|
episodeImageType = ViewOptionImageType.THUMB,
|
||||||
episodeAspectRatio = AspectRatio.WIDE,
|
episodeAspectRatio = AspectRatio.WIDE,
|
||||||
|
episodeContentScale = PrefContentScale.FIT,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ fun HomeSettingsGlobal(
|
||||||
onClickSave: () -> Unit,
|
onClickSave: () -> Unit,
|
||||||
onClickLoad: () -> Unit,
|
onClickLoad: () -> Unit,
|
||||||
onClickLoadWeb: () -> Unit,
|
onClickLoadWeb: () -> Unit,
|
||||||
|
onClickReset: () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
val firstFocus: FocusRequester = remember { FocusRequester() }
|
val firstFocus: FocusRequester = remember { FocusRequester() }
|
||||||
|
|
@ -122,6 +123,20 @@ fun HomeSettingsGlobal(
|
||||||
modifier = Modifier,
|
modifier = Modifier,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
item {
|
||||||
|
HomeSettingsListItem(
|
||||||
|
selected = false,
|
||||||
|
headlineText = stringResource(R.string.reset),
|
||||||
|
leadingContent = {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.fa_arrows_rotate),
|
||||||
|
fontFamily = FontAwesome,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
onClick = onClickReset,
|
||||||
|
modifier = Modifier,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,12 @@ fun HomeSettingsPage(
|
||||||
viewModel.loadFromRemoteWeb()
|
viewModel.loadFromRemoteWeb()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onClickReset = {
|
||||||
|
showConfirmDialog =
|
||||||
|
ShowConfirm(R.string.overwrite_local_settings) {
|
||||||
|
viewModel.resetToDefault()
|
||||||
|
}
|
||||||
|
},
|
||||||
modifier = destModifier,
|
modifier = destModifier,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -500,6 +500,17 @@ class HomeSettingsViewModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun resetToDefault() {
|
||||||
|
viewModelScope.launchIO {
|
||||||
|
_state.update { it.copy(loading = LoadingState.Loading) }
|
||||||
|
val result = homeSettingsService.createDefault()
|
||||||
|
_state.update {
|
||||||
|
it.copy(rows = result.rows)
|
||||||
|
}
|
||||||
|
fetchRowData()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class HomePageSettingsState(
|
data class HomePageSettingsState(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue