-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feature) Gallery Screen Preview (#637)
* Split and improve preview for gallery screen * Include profile action bar button * Show capture outside of empty list state * Redesign selection indicators * Profile button onBackground color filter
- Loading branch information
Showing
7 changed files
with
244 additions
and
131 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
gallery-app/src/androidDebug/kotlin/io/ashdavies/gallery/GalleryScreen.preview.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,84 @@ | ||
package io.ashdavies.gallery | ||
|
||
import android.content.res.Configuration | ||
import androidx.compose.foundation.ExperimentalFoundationApi | ||
import androidx.compose.foundation.isSystemInDarkTheme | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.material3.TopAppBarDefaults.enterAlwaysScrollBehavior | ||
import androidx.compose.material3.darkColorScheme | ||
import androidx.compose.material3.lightColorScheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import kotlinx.collections.immutable.persistentListOf | ||
|
||
@Preview | ||
@Composable | ||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) | ||
@OptIn(ExperimentalMaterial3Api::class) | ||
internal fun GalleryTopAppBarPreview() { | ||
GalleryPreviewTheme { | ||
GalleryTopAppBar(enterAlwaysScrollBehavior()) { } | ||
} | ||
} | ||
|
||
@Composable | ||
@Preview(heightDp = 120) | ||
@OptIn(ExperimentalFoundationApi::class) | ||
@Preview(heightDp = 120, uiMode = Configuration.UI_MODE_NIGHT_YES) | ||
internal fun GalleryGridPreview() { | ||
GalleryPreviewTheme { | ||
Surface { | ||
GalleryGrid( | ||
itemList = persistentListOf( | ||
GalleryScreenStateItem(), | ||
GalleryScreenStateItem(isSelected = true), | ||
GalleryScreenStateItem(state = SyncState.SYNCING), | ||
GalleryScreenStateItem(state = SyncState.SYNCED), | ||
), | ||
isSelecting = true, | ||
) { } | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) | ||
internal fun GalleryBottomBarSelectingPreview() { | ||
GalleryPreviewTheme { | ||
GalleryBottomBar( | ||
state = GalleryScreenState(), | ||
isSelecting = true, | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
private fun GalleryPreviewTheme(content: @Composable () -> Unit) { | ||
MaterialTheme(if (isSystemInDarkTheme()) darkColorScheme() else lightColorScheme()) { | ||
content() | ||
} | ||
} | ||
|
||
private fun GalleryScreenState( | ||
itemList: List<GalleryScreen.State.Item> = emptyList(), | ||
showCapture: Boolean = false, | ||
isLoggedIn: Boolean = false, | ||
) = GalleryScreen.State( | ||
itemList = itemList, | ||
showCapture = showCapture, | ||
isLoggedIn = isLoggedIn, | ||
) { } | ||
|
||
private fun GalleryScreenStateItem( | ||
name: String = "Sample Image", | ||
isSelected: Boolean = false, | ||
state: SyncState = SyncState.NOT_SYNCED, | ||
) = GalleryScreen.State.Item( | ||
name = name, | ||
imageModel = "https://picsum.photos/200", | ||
isSelected = isSelected, | ||
state = state, | ||
) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
40 changes: 0 additions & 40 deletions
40
gallery-app/src/androidMain/kotlin/io/ashdavies/gallery/GalleryScreen.preview.kt
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.