Add reverse pager layout
This commit is contained in:
parent
8b0e96b628
commit
18539c5f64
1
base/src/main/res/raw/lottie_scaffold_pager_reverse.json
Normal file
1
base/src/main/res/raw/lottie_scaffold_pager_reverse.json
Normal file
File diff suppressed because one or more lines are too long
@ -68,6 +68,7 @@ message Settings {
|
|||||||
enum Layout {
|
enum Layout {
|
||||||
PullDown = 0;
|
PullDown = 0;
|
||||||
Pager = 1;
|
Pager = 1;
|
||||||
|
PagerReversed = 2;
|
||||||
}
|
}
|
||||||
Layout layout = 9;
|
Layout layout = 9;
|
||||||
|
|
||||||
|
|||||||
@ -122,7 +122,8 @@ class LauncherActivity : BaseActivity() {
|
|||||||
darkNavBarIcons = lightNav,
|
darkNavBarIcons = lightNav,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Settings.AppearanceSettings.Layout.Pager -> {
|
Settings.AppearanceSettings.Layout.Pager,
|
||||||
|
Settings.AppearanceSettings.Layout.PagerReversed -> {
|
||||||
PagerScaffold(
|
PagerScaffold(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
@ -133,6 +134,7 @@ class LauncherActivity : BaseActivity() {
|
|||||||
},
|
},
|
||||||
darkStatusBarIcons = lightStatus,
|
darkStatusBarIcons = lightStatus,
|
||||||
darkNavBarIcons = lightNav,
|
darkNavBarIcons = lightNav,
|
||||||
|
reverse = layout == Settings.AppearanceSettings.Layout.PagerReversed
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else -> {}
|
else -> {}
|
||||||
|
|||||||
@ -28,8 +28,10 @@ import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
|||||||
import androidx.compose.ui.input.nestedscroll.NestedScrollSource
|
import androidx.compose.ui.input.nestedscroll.NestedScrollSource
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.platform.LocalDensity
|
import androidx.compose.ui.platform.LocalDensity
|
||||||
|
import androidx.compose.ui.platform.LocalLayoutDirection
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.IntOffset
|
import androidx.compose.ui.unit.IntOffset
|
||||||
|
import androidx.compose.ui.unit.LayoutDirection
|
||||||
import androidx.compose.ui.unit.Velocity
|
import androidx.compose.ui.unit.Velocity
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
@ -53,6 +55,7 @@ fun PagerScaffold(
|
|||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
darkStatusBarIcons: Boolean = false,
|
darkStatusBarIcons: Boolean = false,
|
||||||
darkNavBarIcons: Boolean = false,
|
darkNavBarIcons: Boolean = false,
|
||||||
|
reverse: Boolean = false,
|
||||||
) {
|
) {
|
||||||
val viewModel: LauncherScaffoldVM = viewModel()
|
val viewModel: LauncherScaffoldVM = viewModel()
|
||||||
val searchVM: SearchVM = viewModel()
|
val searchVM: SearchVM = viewModel()
|
||||||
@ -213,9 +216,11 @@ fun PagerScaffold(
|
|||||||
|
|
||||||
val widthPx = width.toPixels()
|
val widthPx = width.toPixels()
|
||||||
|
|
||||||
|
val originalLayoutDirection = LocalLayoutDirection.current
|
||||||
|
|
||||||
CompositionLocalProvider(
|
CompositionLocalProvider(
|
||||||
LocalOverscrollConfiguration provides null
|
LocalOverscrollConfiguration provides null,
|
||||||
|
LocalLayoutDirection provides if (reverse) LayoutDirection.Rtl else LayoutDirection.Ltr
|
||||||
) {
|
) {
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
@ -232,11 +237,16 @@ fun PagerScaffold(
|
|||||||
thresholds = { _, _ ->
|
thresholds = { _, _ ->
|
||||||
FractionalThreshold(0.5f)
|
FractionalThreshold(0.5f)
|
||||||
},
|
},
|
||||||
enabled = !isWidgetEditMode
|
enabled = !isWidgetEditMode,
|
||||||
|
reverseDirection = reverse,
|
||||||
)
|
)
|
||||||
.offset {
|
.offset {
|
||||||
IntOffset(swipeableState.offset.value.roundToInt(), 0)
|
IntOffset(swipeableState.offset.value.roundToInt(), 0)
|
||||||
}
|
},
|
||||||
|
) {
|
||||||
|
|
||||||
|
CompositionLocalProvider(
|
||||||
|
LocalLayoutDirection provides originalLayoutDirection
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
||||||
@ -290,6 +300,7 @@ fun PagerScaffold(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
AnimatedVisibility(visible = isWidgetEditMode,
|
AnimatedVisibility(visible = isWidgetEditMode,
|
||||||
enter = slideIn { IntOffset(0, -it.height) },
|
enter = slideIn { IntOffset(0, -it.height) },
|
||||||
exit = slideOut { IntOffset(0, -it.height) }
|
exit = slideOut { IntOffset(0, -it.height) }
|
||||||
|
|||||||
@ -29,6 +29,7 @@ internal fun placeRightOrBottom(
|
|||||||
current += it
|
current += it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private inline fun IntArray.forEachIndexed(reversed: Boolean, action: (Int, Int) -> Unit) {
|
private inline fun IntArray.forEachIndexed(reversed: Boolean, action: (Int, Int) -> Unit) {
|
||||||
if (!reversed) {
|
if (!reversed) {
|
||||||
forEachIndexed(action)
|
forEachIndexed(action)
|
||||||
|
|||||||
@ -481,6 +481,7 @@ fun LayoutPreference(
|
|||||||
when (layouts[it]) {
|
when (layouts[it]) {
|
||||||
AppearanceSettings.Layout.PullDown -> R.raw.lottie_scaffold_pulldown
|
AppearanceSettings.Layout.PullDown -> R.raw.lottie_scaffold_pulldown
|
||||||
AppearanceSettings.Layout.Pager -> R.raw.lottie_scaffold_pager
|
AppearanceSettings.Layout.Pager -> R.raw.lottie_scaffold_pager
|
||||||
|
AppearanceSettings.Layout.PagerReversed -> R.raw.lottie_scaffold_pager_reverse
|
||||||
else -> 0
|
else -> 0
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user