Skip to content

Commit

Permalink
Restore gallery screen as past event list (#1398)
Browse files Browse the repository at this point in the history
* Restore gallery screen as past event list

* Update screenshot references for bottom bar navigation icons

---------

Co-authored-by: Ashley Davies <[email protected]>
  • Loading branch information
ashdavies and ashdavies authored Dec 14, 2024
1 parent 0bfdb34 commit 16b134f
Show file tree
Hide file tree
Showing 17 changed files with 359 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ package io.ashdavies.party.config

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.paging.Pager
import com.slack.circuit.foundation.Circuit
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.CircuitUiState
import com.slack.circuit.runtime.Navigator
import com.slack.circuit.runtime.presenter.Presenter
import com.slack.circuit.runtime.presenter.presenterOf
import com.slack.circuit.runtime.screen.Screen
import io.ashdavies.content.PlatformContext
import io.ashdavies.content.reportFullyDrawn
import io.ashdavies.http.DefaultHttpConfiguration
import io.ashdavies.identity.IdentityManager
import io.ashdavies.party.coroutines.rememberRetainedCoroutineScope
import io.ashdavies.party.events.EventsPresenter
import io.ashdavies.party.events.EventsScreen
import io.ashdavies.party.events.paging.rememberEventPager
import io.ashdavies.party.gallery.File
import io.ashdavies.party.gallery.GalleryPresenter
import io.ashdavies.party.gallery.GalleryScreen
import io.ashdavies.party.gallery.ImageManager
import io.ashdavies.party.gallery.PathProvider
import io.ashdavies.party.gallery.StorageManager
Expand All @@ -24,6 +26,11 @@ import io.ashdavies.party.gallery.inMemoryHttpClientEngine
import io.ashdavies.party.gallery.readChannel
import io.ashdavies.party.home.HomePresenter
import io.ashdavies.party.home.HomeScreen
import io.ashdavies.party.past.GalleryScreen
import io.ashdavies.party.past.PastEventListScreen
import io.ashdavies.party.past.PastEventsPresenter
import io.ashdavies.party.upcoming.UpcomingEventsPresenter
import io.ashdavies.party.upcoming.UpcomingEventsScreen
import io.ashdavies.playground.PlaygroundDatabase
import io.ashdavies.sql.LocalTransacter
import io.ktor.client.HttpClient
Expand All @@ -44,23 +51,36 @@ public fun rememberCircuit(
val storageManager = StorageManager(PathProvider(platformContext))

Circuit.Builder()
.addPresenter<HomeScreen, HomeScreen.State> { _, navigator, _ ->
presenterOf { HomePresenter(identityManager, coroutineScope, navigator) }
}
.addPresenter<EventsScreen, EventsScreen.State> { _, _, _ ->
presenterOf { EventsPresenter(eventPager, coroutineScope) }
}
.addPresenter<GalleryScreen, GalleryScreen.State> { _, _, _ ->
presenterOf { GalleryPresenter(imageManager, syncManager) }
}
.addUi<HomeScreen, HomeScreen.State> { state, modifier ->
HomeScreen(state, modifier, platformContext::reportFullyDrawn)
}
.addUi<EventsScreen, EventsScreen.State> { state, modifier ->
EventsScreen(state, modifier)
}
.addUi<GalleryScreen, GalleryScreen.State> { state, modifier ->
GalleryScreen(state, storageManager, modifier)
}
.addCircuit<HomeScreen, HomeScreen.State>(
presenterFactory = { _, navigator, _ ->
presenterOf { HomePresenter(identityManager, coroutineScope, navigator) }
},
uiFactory = { state, modifier ->
HomeScreen(state, modifier, platformContext::reportFullyDrawn)
},
)
.addCircuit<UpcomingEventsScreen, UpcomingEventsScreen.State>(
presenterFactory = { _, _, _ ->
presenterOf { UpcomingEventsPresenter(eventPager, coroutineScope) }
},
uiFactory = { state, modifier ->
UpcomingEventsScreen(state, modifier)
},
)
.addCircuit<GalleryScreen, GalleryScreen.State>(
presenterFactory = { _, _, _ ->
presenterOf { PastEventsPresenter(imageManager, syncManager) }
},
uiFactory = { state, modifier ->
PastEventListScreen(state, storageManager, modifier)
},
)
.build()
}

private inline fun <reified S : Screen, UiState : CircuitUiState> Circuit.Builder.addCircuit(
crossinline presenterFactory: (screen: S, navigator: Navigator, context: CircuitContext) -> Presenter<UiState>,
crossinline uiFactory: @Composable (state: UiState, modifier: Modifier) -> Unit,
): Circuit.Builder = this
.addPresenter(presenterFactory)
.addUi<S, _>(uiFactory)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import io.ashdavies.config.getBoolean

internal suspend fun RemoteConfig.isProfileEnabled() = getBoolean("profile_enabled")

internal suspend fun RemoteConfig.isHomeEnabled() = getBoolean("home_enabled")
internal suspend fun RemoteConfig.galleryCapture() = getBoolean("gallery_capture")

internal suspend fun RemoteConfig.showPastEvents() = getBoolean("past_events")

@Composable
internal fun booleanConfigAsState(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.ashdavies.party.events
package io.ashdavies.party.events.paging

import androidx.paging.CombinedLoadStates
import androidx.paging.LoadState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import io.ashdavies.analytics.OnClick
import io.ashdavies.material.BottomSheetItem
import io.ashdavies.party.past.GalleryScreen

@Composable
internal fun GallerySheetContent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import com.slack.circuit.runtime.screen.Screen
import io.ashdavies.identity.IdentityManager
import io.ashdavies.identity.IdentityState
import io.ashdavies.party.config.booleanConfigAsState
import io.ashdavies.party.config.isHomeEnabled
import io.ashdavies.party.events.EventsScreen
import io.ashdavies.party.gallery.GalleryScreen
import io.ashdavies.party.config.showPastEvents
import io.ashdavies.party.past.GalleryScreen
import io.ashdavies.party.upcoming.UpcomingEventsScreen
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

Expand All @@ -25,9 +25,9 @@ internal fun HomePresenter(
navigator: Navigator,
): HomeScreen.State {
val identityState by identityManager.state.collectAsState(IdentityState.Unauthenticated)
val isHomeEnabled by booleanConfigAsState { isHomeEnabled() }
val isHomeEnabled by booleanConfigAsState { showPastEvents() }

val initialScreen = if (isHomeEnabled) GalleryScreen else EventsScreen
val initialScreen = if (isHomeEnabled) GalleryScreen else UpcomingEventsScreen
var screen by rememberRetained { mutableStateOf<Screen>(initialScreen) }

return HomeScreen.State(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.List
import androidx.compose.material.icons.filled.Home
import androidx.compose.material.icons.filled.Warning
import androidx.compose.material3.BottomAppBar
import androidx.compose.material3.CenterAlignedTopAppBar
Expand All @@ -15,6 +13,7 @@ import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.TopAppBarDefaults.enterAlwaysScrollBehavior
Expand All @@ -34,17 +33,17 @@ import com.slack.circuit.runtime.CircuitUiState
import com.slack.circuit.runtime.screen.Screen
import io.ashdavies.analytics.OnClick
import io.ashdavies.identity.IdentityState
import io.ashdavies.material.BottomSheetScaffold
import io.ashdavies.parcelable.Parcelable
import io.ashdavies.parcelable.Parcelize
import io.ashdavies.party.animation.FadeVisibility
import io.ashdavies.party.config.booleanConfigAsState
import io.ashdavies.party.config.isHomeEnabled
import io.ashdavies.party.config.isProfileEnabled
import io.ashdavies.party.events.EventsScreen
import io.ashdavies.party.gallery.GalleryScreen
import io.ashdavies.party.gallery.GallerySheetContent
import io.ashdavies.party.config.showPastEvents
import io.ashdavies.party.material.icons.EventList
import io.ashdavies.party.material.icons.EventUpcoming
import io.ashdavies.party.past.GalleryScreen
import io.ashdavies.party.profile.ProfileActionButton
import io.ashdavies.party.upcoming.UpcomingEventsScreen

@Parcelize
internal object HomeScreen : Parcelable, Screen {
Expand All @@ -70,13 +69,11 @@ internal fun HomeScreen(
reportFullyDrawn: () -> Unit,
) {
val isProfileEnabled by booleanConfigAsState { isProfileEnabled() }
val isHomeEnabled by booleanConfigAsState { isHomeEnabled() }
val showPastEvents by booleanConfigAsState { showPastEvents() }
val eventSink = state.eventSink

BottomSheetScaffold(
sheetContent = { GallerySheetContent({ }) },
Scaffold(
modifier = modifier,
showDragHandle = false,
topBar = {
HomeTopBar(
actions = {
Expand All @@ -96,14 +93,13 @@ internal fun HomeScreen(
)
},
bottomBar = {
FadeVisibility(isHomeEnabled) {
FadeVisibility(showPastEvents) {
HomeBottomBar { screen ->
eventSink(HomeScreen.Event.BottomNav(screen))
}
}
},
floatingActionButton = { },
isExpanded = false,
) { contentPadding ->
CircuitContent(
screen = state.screen,
Expand Down Expand Up @@ -155,15 +151,15 @@ internal fun HomeBottomBar(
BottomAppBar(modifier) {
NavigationBar {
NavigationBarItem(
selected = selected is GalleryScreen,
onClick = { onClick(GalleryScreen) },
icon = { NavigationBarImage(Icons.Default.Home) },
selected = selected is UpcomingEventsScreen,
onClick = { onClick(UpcomingEventsScreen) },
icon = { NavigationBarImage(Icons.Outlined.EventUpcoming) },
)

NavigationBarItem(
selected = selected is EventsScreen,
onClick = { onClick(EventsScreen) },
icon = { NavigationBarImage(Icons.AutoMirrored.Filled.List) },
selected = selected is GalleryScreen,
onClick = { onClick(GalleryScreen) },
icon = { NavigationBarImage(Icons.Outlined.EventList) },
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package io.ashdavies.party.material.icons

import androidx.compose.material.icons.Icons
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathFillType
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.StrokeJoin
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp

@Suppress("UnusedReceiverParameter")
public val Icons.Outlined.EventList: ImageVector
get() {
if (_eventList != null) {
return _eventList!!
}
_eventList = ImageVector.Builder(
name = "Event_list",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
viewportWidth = 960f,
viewportHeight = 960f,
).apply {
path(
fill = SolidColor(Color.Black),
fillAlpha = 1.0f,
stroke = null,
strokeAlpha = 1.0f,
strokeLineWidth = 1.0f,
strokeLineCap = StrokeCap.Butt,
strokeLineJoin = StrokeJoin.Miter,
strokeLineMiter = 1.0f,
pathFillType = PathFillType.NonZero,
) {
moveTo(640f, 840f)
quadToRelative(-33f, 0f, -56.5f, -23.5f)
reflectiveQuadTo(560f, 760f)
verticalLineToRelative(-160f)
quadToRelative(0f, -33f, 23.5f, -56.5f)
reflectiveQuadTo(640f, 520f)
horizontalLineToRelative(160f)
quadToRelative(33f, 0f, 56.5f, 23.5f)
reflectiveQuadTo(880f, 600f)
verticalLineToRelative(160f)
quadToRelative(0f, 33f, -23.5f, 56.5f)
reflectiveQuadTo(800f, 840f)
close()
moveToRelative(0f, -80f)
horizontalLineToRelative(160f)
verticalLineToRelative(-160f)
horizontalLineTo(640f)
close()
moveTo(80f, 720f)
verticalLineToRelative(-80f)
horizontalLineToRelative(360f)
verticalLineToRelative(80f)
close()
moveToRelative(560f, -280f)
quadToRelative(-33f, 0f, -56.5f, -23.5f)
reflectiveQuadTo(560f, 360f)
verticalLineToRelative(-160f)
quadToRelative(0f, -33f, 23.5f, -56.5f)
reflectiveQuadTo(640f, 120f)
horizontalLineToRelative(160f)
quadToRelative(33f, 0f, 56.5f, 23.5f)
reflectiveQuadTo(880f, 200f)
verticalLineToRelative(160f)
quadToRelative(0f, 33f, -23.5f, 56.5f)
reflectiveQuadTo(800f, 440f)
close()
moveToRelative(0f, -80f)
horizontalLineToRelative(160f)
verticalLineToRelative(-160f)
horizontalLineTo(640f)
close()
moveTo(80f, 320f)
verticalLineToRelative(-80f)
horizontalLineToRelative(360f)
verticalLineToRelative(80f)
close()
moveToRelative(640f, -40f)
}
}.build()
return _eventList!!
}

@Suppress("ObjectPropertyName")
private var _eventList: ImageVector? = null
Loading

0 comments on commit 16b134f

Please sign in to comment.