mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 08:01:20 +02:00
Move code into coroutines
This commit is contained in:
parent
8437ddb51d
commit
bec833b0e8
1 changed files with 42 additions and 36 deletions
|
|
@ -176,13 +176,15 @@ class HomeSettingsViewModel
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteRow(index: Int) {
|
fun deleteRow(index: Int) {
|
||||||
updateState {
|
viewModelScope.launchIO {
|
||||||
val rows = it.rows.toMutableList().apply { removeAt(index) }
|
updateState {
|
||||||
val rowData = it.rowData.toMutableList().apply { removeAt(index) }
|
val rows = it.rows.toMutableList().apply { removeAt(index) }
|
||||||
it.copy(
|
val rowData = it.rowData.toMutableList().apply { removeAt(index) }
|
||||||
rows = rows,
|
it.copy(
|
||||||
rowData = rowData,
|
rows = rows,
|
||||||
)
|
rowData = rowData,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -341,17 +343,19 @@ class HomeSettingsViewModel
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateViewOptionsForAll(viewOptions: HomeRowViewOptions) {
|
fun updateViewOptionsForAll(viewOptions: HomeRowViewOptions) {
|
||||||
updateState {
|
viewModelScope.launchIO {
|
||||||
it.copy(
|
updateState {
|
||||||
rowData =
|
it.copy(
|
||||||
it.rowData.toMutableList().map { row ->
|
rowData =
|
||||||
if (row is HomeRowLoadingState.Success) {
|
it.rowData.toMutableList().map { row ->
|
||||||
row.copy(viewOptions = viewOptions)
|
if (row is HomeRowLoadingState.Success) {
|
||||||
} else {
|
row.copy(viewOptions = viewOptions)
|
||||||
row
|
} else {
|
||||||
}
|
row
|
||||||
},
|
}
|
||||||
)
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -456,24 +460,26 @@ class HomeSettingsViewModel
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resizeCards(relative: Int) {
|
fun resizeCards(relative: Int) {
|
||||||
updateState {
|
viewModelScope.launchIO {
|
||||||
val newRows =
|
updateState {
|
||||||
it.rows.toMutableList().map { row ->
|
val newRows =
|
||||||
val vo = row.config.viewOptions
|
it.rows.toMutableList().map { row ->
|
||||||
val newVo = vo.copy(heightDp = vo.heightDp + (4 * relative))
|
val vo = row.config.viewOptions
|
||||||
row.copy(config = row.config.updateViewOptions(newVo))
|
val newVo = vo.copy(heightDp = vo.heightDp + (4 * relative))
|
||||||
}
|
row.copy(config = row.config.updateViewOptions(newVo))
|
||||||
it.copy(
|
}
|
||||||
rows = newRows,
|
it.copy(
|
||||||
rowData =
|
rows = newRows,
|
||||||
it.rowData.toMutableList().mapIndexed { index, row ->
|
rowData =
|
||||||
if (row is HomeRowLoadingState.Success) {
|
it.rowData.toMutableList().mapIndexed { index, row ->
|
||||||
row.copy(viewOptions = newRows[index].config.viewOptions)
|
if (row is HomeRowLoadingState.Success) {
|
||||||
} else {
|
row.copy(viewOptions = newRows[index].config.viewOptions)
|
||||||
row
|
} else {
|
||||||
}
|
row
|
||||||
},
|
}
|
||||||
)
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue