Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

commandiron/ExpandableHorizontalPagerCompose

Repository files navigation

ExpandableHorizontalPagerCompose

Add Expandable Horizontal Pager in Android Jetpack Compose.

How it looks

Usage

BoxWithConstraints(
 modifier = Modifier.fillMaxSize(),
 contentAlignment = Alignment.Center
) {
 ExpandableHorizontalPager(
 count = films.size,
 initialHorizontalPadding = 64.dp,
 initialWidth = 240.dp,
 targetWidth = maxWidth,
 mainContent = { page, isExpanded ->
 AsyncImage(
 modifier = Modifier.fillMaxSize(),
 model = ImageRequest.Builder(LocalContext.current)
 .data(films[page].imageUrl)
 .crossfade(true)
 .build(),
 contentDescription = null,
 contentScale = ContentScale.FillHeight
 )
 },
 overMainContentCollapsed = { page ->
 OverMainContent(
 title = "Details",
 imageVector = Icons.Default.KeyboardArrowDown
 )
 },
 overMainContentExpanded = { page ->
 OverMainContent(
 title = "Close",
 imageVector = Icons.Default.KeyboardArrowUp,
 iconOnTop = true
 )
 },
 hiddenContent = { page ->
 HiddenContent(
 title = films[page].title,
 overview = films[page].overview
 )
 },
 onTransform = { isExpanded -> }
 )
}

Setup

  1. Open the file settings.gradle (it looks like that)
dependencyResolutionManagement {
 repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
 repositories {
 google()
 mavenCentral()
 // add jitpack here πŸ‘‡πŸ½
 maven { url 'https://jitpack.io' }
 ...
 }
} 
...
  1. Sync the project
  2. Add dependencies
dependencies {
 implementation "com.google.accompanist:accompanist-pager:0.26.5-rc"
 implementation 'com.github.commandiron:ExpandableHorizontalPagerCompose:1.0.11'
}

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /