Skip to content

Commit 4b2a36a

Browse files
committed
Scope drag indication
1 parent cc7b11e commit 4b2a36a

4 files changed

Lines changed: 33 additions & 17 deletions

File tree

composeunstyled-bottom-sheet/src/commonMain/kotlin/com/composeunstyled/BottomSheet.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ private fun ConsumeSwipeWithinBottomSheetBoundsNestedScrollConnection(
773773
}
774774

775775
@Composable
776-
fun UnstyledDragIndication(
776+
fun BottomSheetScope.DragIndication(
777777
modifier: Modifier = Modifier,
778778
indication: Indication? = LocalIndication.current,
779779
interactionSource: MutableInteractionSource? = null,

composeunstyled-bottom-sheet/src/commonTest/kotlin/BottomSheet.test.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ class BottomSheetCommonTest {
13381338

13391339
UnstyledBottomSheet(state) {
13401340
Sheet {
1341-
UnstyledDragIndication(Modifier.testTag("drag_indication").size(32.dp))
1341+
DragIndication(Modifier.testTag("drag_indication").size(32.dp))
13421342
Box(Modifier.fillMaxWidth().height(300.dp))
13431343
}
13441344
}
@@ -1360,7 +1360,7 @@ class BottomSheetCommonTest {
13601360

13611361
UnstyledBottomSheet(state) {
13621362
Sheet {
1363-
UnstyledDragIndication(Modifier.testTag("drag_indication").size(32.dp))
1363+
DragIndication(Modifier.testTag("drag_indication").size(32.dp))
13641364
Box(Modifier.fillMaxWidth().height(300.dp))
13651365
}
13661366
}
@@ -1382,7 +1382,7 @@ class BottomSheetCommonTest {
13821382

13831383
UnstyledBottomSheet(state) {
13841384
Sheet {
1385-
UnstyledDragIndication(Modifier.testTag("drag_indication").size(32.dp))
1385+
DragIndication(Modifier.testTag("drag_indication").size(32.dp))
13861386
Box(Modifier.fillMaxWidth().height(300.dp))
13871387
}
13881388
}
@@ -1404,7 +1404,7 @@ class BottomSheetCommonTest {
14041404

14051405
UnstyledBottomSheet(state) {
14061406
Sheet {
1407-
UnstyledDragIndication(Modifier.testTag("drag_indication").size(32.dp))
1407+
DragIndication(Modifier.testTag("drag_indication").size(32.dp))
14081408
Box(Modifier.fillMaxWidth().height(300.dp))
14091409
}
14101410
}
@@ -2165,7 +2165,7 @@ class BottomSheetCommonTest {
21652165

21662166
UnstyledBottomSheet(state) {
21672167
Sheet {
2168-
UnstyledDragIndication(Modifier.testTag("drag_indication").size(32.dp))
2168+
DragIndication(Modifier.testTag("drag_indication").size(32.dp))
21692169
Box(Modifier.fillMaxWidth().height(400.dp))
21702170
}
21712171
}
@@ -2195,7 +2195,7 @@ class BottomSheetCommonTest {
21952195

21962196
UnstyledBottomSheet(state) {
21972197
Sheet {
2198-
UnstyledDragIndication(Modifier.testTag("drag_indication").size(32.dp))
2198+
DragIndication(Modifier.testTag("drag_indication").size(32.dp))
21992199
Box(Modifier.fillMaxWidth().height(400.dp))
22002200
}
22012201
}
@@ -2223,7 +2223,7 @@ class BottomSheetCommonTest {
22232223

22242224
UnstyledBottomSheet(state) {
22252225
Sheet {
2226-
UnstyledDragIndication(Modifier.testTag("drag_indication").size(32.dp))
2226+
DragIndication(Modifier.testTag("drag_indication").size(32.dp))
22272227
Box(Modifier.fillMaxWidth().height(400.dp))
22282228
}
22292229
}
@@ -2250,7 +2250,7 @@ class BottomSheetCommonTest {
22502250

22512251
UnstyledBottomSheet(state) {
22522252
Sheet {
2253-
UnstyledDragIndication(Modifier.testTag("drag_indication").size(32.dp))
2253+
DragIndication(Modifier.testTag("drag_indication").size(32.dp))
22542254
Box(Modifier.fillMaxWidth().height(400.dp))
22552255
}
22562256
}
@@ -2285,7 +2285,7 @@ class BottomSheetCommonTest {
22852285

22862286
UnstyledBottomSheet(state) {
22872287
Sheet {
2288-
UnstyledDragIndication(Modifier.testTag("drag_indication").size(32.dp))
2288+
DragIndication(Modifier.testTag("drag_indication").size(32.dp))
22892289
Box(Modifier.fillMaxWidth().height(400.dp))
22902290
}
22912291
}
@@ -2319,7 +2319,7 @@ class BottomSheetCommonTest {
23192319

23202320
UnstyledBottomSheet(state) {
23212321
Sheet {
2322-
UnstyledDragIndication(Modifier.testTag("drag_indication").size(32.dp))
2322+
DragIndication(Modifier.testTag("drag_indication").size(32.dp))
23232323
Box(Modifier.fillMaxWidth().height(400.dp))
23242324
}
23252325
}
@@ -2364,7 +2364,7 @@ class BottomSheetCommonTest {
23642364

23652365
UnstyledBottomSheet(state) {
23662366
Sheet {
2367-
UnstyledDragIndication(Modifier.testTag("drag_indication").size(32.dp))
2367+
DragIndication(Modifier.testTag("drag_indication").size(32.dp))
23682368
Box(Modifier.fillMaxWidth().height(400.dp))
23692369
}
23702370
}
@@ -2402,7 +2402,7 @@ class BottomSheetCommonTest {
24022402

24032403
UnstyledBottomSheet(state) {
24042404
Sheet {
2405-
UnstyledDragIndication(Modifier.testTag("drag_indication").size(32.dp))
2405+
DragIndication(Modifier.testTag("drag_indication").size(32.dp))
24062406
Box(Modifier.fillMaxWidth().height(500.dp))
24072407
}
24082408
}
@@ -2432,7 +2432,7 @@ class BottomSheetCommonTest {
24322432

24332433
UnstyledBottomSheet(state) {
24342434
Sheet {
2435-
UnstyledDragIndication(Modifier.testTag("drag_indication").size(32.dp))
2435+
DragIndication(Modifier.testTag("drag_indication").size(32.dp))
24362436
Box(Modifier.fillMaxWidth().height(400.dp))
24372437
}
24382438
}
@@ -2459,7 +2459,7 @@ class BottomSheetCommonTest {
24592459

24602460
UnstyledBottomSheet(state) {
24612461
Sheet {
2462-
UnstyledDragIndication(Modifier.testTag("drag_indication").size(32.dp))
2462+
DragIndication(Modifier.testTag("drag_indication").size(32.dp))
24632463
Box(Modifier.fillMaxWidth().height(400.dp))
24642464
}
24652465
}

composeunstyled-modal-bottom-sheet/src/commonMain/kotlin/com/composeunstyled/ModalBottomSheet.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ import androidx.compose.animation.core.AnimationSpec
2727
import androidx.compose.animation.core.DecayAnimationSpec
2828
import androidx.compose.animation.core.tween
2929
import androidx.compose.animation.rememberSplineBasedDecay
30+
import androidx.compose.foundation.Indication
31+
import androidx.compose.foundation.LocalIndication
3032
import androidx.compose.foundation.gestures.detectTapGestures
33+
import androidx.compose.foundation.interaction.MutableInteractionSource
3134
import androidx.compose.foundation.layout.Box
3235
import androidx.compose.foundation.layout.PaddingValues
3336
import androidx.compose.foundation.layout.fillMaxSize
@@ -325,3 +328,16 @@ fun ModalBottomSheetScope.Sheet(
325328
content = content,
326329
)
327330
}
331+
332+
@Composable
333+
fun ModalBottomSheetScope.DragIndication(
334+
modifier: Modifier = Modifier,
335+
indication: Indication? = LocalIndication.current,
336+
interactionSource: MutableInteractionSource? = null,
337+
) {
338+
bottomSheetScope.DragIndication(
339+
modifier = modifier,
340+
indication = indication,
341+
interactionSource = interactionSource,
342+
)
343+
}

demo/src/commonMain/kotlin/ModalBottomSheetDemo.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ import androidx.compose.ui.draw.shadow
5353
import androidx.compose.ui.graphics.Brush
5454
import androidx.compose.ui.graphics.Color
5555
import androidx.compose.ui.unit.dp
56+
import com.composeunstyled.DragIndication
5657
import com.composeunstyled.Scrim
5758
import com.composeunstyled.Sheet
5859
import com.composeunstyled.SheetDetent
5960
import com.composeunstyled.SheetDetent.Companion.FullyExpanded
6061
import com.composeunstyled.SheetDetent.Companion.Hidden
6162
import com.composeunstyled.UnstyledButton
62-
import com.composeunstyled.UnstyledDragIndication
6363
import com.composeunstyled.UnstyledModalBottomSheet
6464
import com.composeunstyled.currentWindowContainerSize
6565
import com.composeunstyled.focusRing
@@ -124,7 +124,7 @@ fun ModalBottomSheetDemo() {
124124
Box(Modifier.fillMaxWidth().height(600.dp), contentAlignment = Alignment.TopCenter) {
125125
val interactionSource = remember { MutableInteractionSource() }
126126

127-
UnstyledDragIndication(
127+
DragIndication(
128128
interactionSource = interactionSource,
129129
modifier = Modifier
130130
.padding(top = 22.dp)

0 commit comments

Comments
 (0)