-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LMN-965 Add image gallery slideshow (#1839)
* LMN-965 Add image gallery slideshow * Updated snapshots for 'rtl' * Updated snapshots for 'default' * LMN-965 Change API to initial image * Updated snapshots for 'dm' * Trigger CI * Updated snapshots for 'dm' * Trigger CI * LMN-965 Fix bottom padding for carousel badge * Updated snapshots for 'rtl' * Updated snapshots for 'dm' * Updated snapshots for 'default' * Trigger CI * Updated snapshots for 'rtl' * LMN-965 Reset orientation --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
832f5ff
commit 0c2b1b9
Showing
21 changed files
with
485 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+818 KB
.../net.skyscanner.backpack.compose.imagegallery.BpkImageGalleryTest_slideshow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+544 KB
...anner.backpack.compose.imagegallery.BpkImageGalleryTest_slideshow_landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+721 KB
...ner.backpack.compose.imagegallery.BpkImageGalleryTest_slideshow_second_page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+817 KB
.../net.skyscanner.backpack.compose.imagegallery.BpkImageGalleryTest_slideshow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+543 KB
...anner.backpack.compose.imagegallery.BpkImageGalleryTest_slideshow_landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+721 KB
...ner.backpack.compose.imagegallery.BpkImageGalleryTest_slideshow_second_page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+818 KB
.../net.skyscanner.backpack.compose.imagegallery.BpkImageGalleryTest_slideshow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+497 KB
...anner.backpack.compose.imagegallery.BpkImageGalleryTest_slideshow_landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+721 KB
...ner.backpack.compose.imagegallery.BpkImageGalleryTest_slideshow_second_page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...e/src/main/kotlin/net/skyscanner/backpack/compose/imagegallery/BpkImageGalleryCarousel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** | ||
* Backpack for Android - Skyscanner's Design System | ||
* | ||
* Copyright 2018 Skyscanner Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.skyscanner.backpack.compose.imagegallery | ||
|
||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.interaction.MutableInteractionSource | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.BoxScope | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import net.skyscanner.backpack.compose.badge.BpkBadge | ||
import net.skyscanner.backpack.compose.badge.BpkBadgeType | ||
import net.skyscanner.backpack.compose.carousel.BpkCarousel | ||
import net.skyscanner.backpack.compose.carousel.BpkCarouselState | ||
import net.skyscanner.backpack.compose.tokens.BpkSpacing | ||
|
||
@Composable | ||
fun BpkImageGalleryCarousel( | ||
state: BpkCarouselState, | ||
modifier: Modifier = Modifier, | ||
onImageClicked: ((Int) -> Unit)? = null, | ||
content: @Composable (BoxScope.(Int) -> Unit), | ||
) { | ||
val interactionSource = remember { MutableInteractionSource() } | ||
|
||
BpkCarousel( | ||
modifier = modifier.clickable(interactionSource = interactionSource, indication = null) { | ||
onImageClicked?.invoke( | ||
state.currentPage, | ||
) | ||
}, | ||
state = state, | ||
content = content, | ||
overlayContent = { pageIndicator -> | ||
Box( | ||
modifier = Modifier | ||
.align(Alignment.BottomCenter) | ||
.fillMaxWidth() | ||
.padding( | ||
horizontal = BpkSpacing.Base, | ||
vertical = ImageGalleryPreviewVerticalSpacing, | ||
), | ||
) { | ||
pageIndicator?.invoke() | ||
BpkBadge( | ||
modifier = Modifier | ||
.align(Alignment.BottomEnd), | ||
text = "${state.currentPage + 1}/${state.pageCount}", | ||
type = BpkBadgeType.Inverse, | ||
) | ||
} | ||
}, | ||
) | ||
} | ||
|
||
private val ImageGalleryPreviewVerticalSpacing = 48.dp |
Oops, something went wrong.