@@ -9,6 +9,9 @@ import androidx.compose.animation.fadeIn
99import androidx.compose.animation.fadeOut
1010import androidx.compose.animation.shrinkHorizontally
1111import androidx.compose.animation.shrinkVertically
12+ import androidx.compose.foundation.gestures.Orientation
13+ import androidx.compose.foundation.gestures.draggable
14+ import androidx.compose.foundation.gestures.rememberDraggableState
1215import androidx.compose.foundation.layout.Arrangement
1316import androidx.compose.foundation.layout.Box
1417import androidx.compose.foundation.layout.BoxWithConstraints
@@ -38,6 +41,7 @@ import androidx.compose.runtime.CompositionLocalProvider
3841import androidx.compose.runtime.MutableState
3942import androidx.compose.runtime.compositionLocalOf
4043import androidx.compose.runtime.getValue
44+ import androidx.compose.runtime.mutableFloatStateOf
4145import androidx.compose.runtime.mutableStateOf
4246import androidx.compose.runtime.remember
4347import androidx.compose.runtime.rememberCoroutineScope
@@ -49,6 +53,7 @@ import androidx.compose.ui.Modifier
4953import androidx.compose.ui.graphics.Color
5054import androidx.compose.ui.hapticfeedback.HapticFeedbackType
5155import androidx.compose.ui.input.nestedscroll.nestedScroll
56+ import androidx.compose.ui.platform.LocalDensity
5257import androidx.compose.ui.platform.LocalHapticFeedback
5358import androidx.compose.ui.platform.LocalLayoutDirection
5459import androidx.compose.ui.platform.LocalUriHandler
@@ -165,7 +170,10 @@ fun UITest(
165170
166171 val handlePageChange: (Int ) -> Unit = remember(pagerState, coroutineScope) {
167172 { page ->
168- coroutineScope.launch { pagerState.animateScrollToPage(page) }
173+ coroutineScope.launch {
174+ if (uiState.isWideScreen) pagerState.scrollToPage(page)
175+ else pagerState.animateScrollToPage(page)
176+ }
169177 }
170178 }
171179
@@ -229,12 +237,31 @@ private fun WideScreenLayout(
229237 windowSize : WindowSize ,
230238 colorMode : MutableState <Int >
231239) {
240+ val density = LocalDensity .current
232241 val layoutDirection = LocalLayoutDirection .current
233242
243+ val windowWidth = getWindowSize().width
244+ val defaultWeight = remember(windowWidth, density) {
245+ val minPx = with (density) { UIConstants .WIDE_SCREEN_THRESHOLD .toPx() }
246+ val maxPx = with (density) { 1920 .dp.toPx() }
247+ val t = (windowWidth - minPx) / 2500
248+ 0.3f - 0.2f * t
249+ }
250+ var weight by remember(windowWidth) { mutableStateOf(defaultWeight) }
251+ var potentialWeight by remember { mutableFloatStateOf(weight) }
252+ val dragState = rememberDraggableState { delta ->
253+ val nextPotentialWeight = potentialWeight + delta / windowWidth
254+ potentialWeight = nextPotentialWeight
255+ val clampedWeight = nextPotentialWeight.coerceIn(0.2f , 0.5f )
256+ if (clampedWeight == nextPotentialWeight) {
257+ weight = clampedWeight
258+ }
259+ }
260+
234261 Scaffold {
235262 val barScrollBehavior = MiuixScrollBehavior ()
236263 Row {
237- Box (modifier = Modifier .weight(0.4f )) {
264+ Box (modifier = Modifier .weight(weight )) {
238265 WideScreenPanel (
239266 barScrollBehavior = barScrollBehavior,
240267 uiState = uiState,
@@ -243,9 +270,14 @@ private fun WideScreenLayout(
243270 )
244271 }
245272 VerticalDivider (
246- modifier = Modifier .padding(horizontal = 6 .dp)
273+ modifier = Modifier
274+ .draggable(
275+ state = dragState,
276+ orientation = Orientation .Horizontal
277+ )
278+ .padding(horizontal = 6 .dp)
247279 )
248- Box (modifier = Modifier .weight(0.6f )) {
280+ Box (modifier = Modifier .weight(1f - weight )) {
249281 WideScreenContent (
250282 navigationItems = navigationItems,
251283 uiState = uiState,
0 commit comments