Skip to content

Commit

Permalink
Carousel - add customization of page spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
Tweener committed Oct 18, 2024
1 parent 159efb5 commit e5e01cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package com.tweener.czan.preview.designsystem.molecule.carousel

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.runtime.Composable
import com.tweener.czan.preview.UiModePreviews
import com.tweener.czan.designsystem.atom.text.Text
import com.tweener.czan.designsystem.molecule.carousel.Carousel
import com.tweener.czan.preview.CzanThemePreview
import com.tweener.czan.preview.UiModePreviews

/**
* @author Vivien Mahe
* @since 01/01/2024
*/

@OptIn(ExperimentalFoundationApi::class)
@UiModePreviews
@Composable
private fun CarouselWithDotsPreview() {
Expand All @@ -24,7 +22,6 @@ private fun CarouselWithDotsPreview() {
}
}

@OptIn(ExperimentalFoundationApi::class)
@UiModePreviews
@Composable
private fun CarouselWithoutDotsPreview() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.tweener.czan.designsystem.molecule.carousel

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.gestures.awaitEachGesture
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.gestures.waitForUpOrCancellation
Expand All @@ -21,24 +20,25 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.unit.Dp
import com.tweener.czan.theme.CzanUiDefaults
import com.tweener.czan.theme.Size
import kotlin.time.Duration
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlin.time.Duration

/**
* @author Vivien Mahe
* @since 13/05/2023
*/

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun Carousel(
modifier: Modifier = Modifier,
userScrollEnabled: Boolean = true,
userTapHalfScreenEnabled: Boolean = false,
showDots: Boolean = true,
pageSpacing: Dp = Size.Padding.Default,
animationType: CarouselAnimationType = CarouselAnimationType.NONE,
slideDuration: Duration = CzanUiDefaults.Carousel.slideDuration(),
pagerState: PagerState = rememberPagerState { 0 },
Expand Down Expand Up @@ -106,7 +106,7 @@ fun Carousel(
HorizontalPager(
modifier = Modifier.fillMaxWidth(),
state = pagerState,
pageSpacing = Size.Padding.Default,
pageSpacing = pageSpacing,
userScrollEnabled = userScrollEnabled
) { index ->
itemContent(index)
Expand Down

0 comments on commit e5e01cf

Please sign in to comment.