Skip to content

Commit

Permalink
(feature) Gallery Screen Preview (#637)
Browse files Browse the repository at this point in the history
* 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
ashdavies authored Nov 10, 2023
1 parent 047736f commit 9e248d8
Show file tree
Hide file tree
Showing 7 changed files with 244 additions and 131 deletions.
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.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public object GalleryScreen : Parcelable, Screen {

data class Item(
val name: String,
val file: File,
val imageModel: Any?,
val isSelected: Boolean,
val state: SyncState,
)
Expand Down Expand Up @@ -105,7 +105,7 @@ internal fun GalleryPresenter(
itemList = itemList.map {
GalleryScreen.State.Item(
name = it.name,
file = File(it.path),
imageModel = File(it.path),
isSelected = it in selected,
state = syncState[it.name] ?: SyncState.NOT_SYNCED,
)
Expand Down
Loading

0 comments on commit 9e248d8

Please sign in to comment.