diff --git a/after-party/src/androidDebug/kotlin/io/ashdavies/profile/Profile.android.kt b/after-party/src/androidDebug/kotlin/io/ashdavies/profile/Profile.android.kt deleted file mode 100644 index edaf9c5fe..000000000 --- a/after-party/src/androidDebug/kotlin/io/ashdavies/profile/Profile.android.kt +++ /dev/null @@ -1,21 +0,0 @@ -package io.ashdavies.profile - -internal val KordulaLaube = Profile( - name = "Kordula Laube", - location = "Berlin, Germany", - email = "kordula.laube@example.com", - uuid = "883a3a72-84e3-4e46-8548-040db9b4f9e6", - username = "lazybear341", - registered = "2019-03-10T13:13:39.654Z", - picture = "https://randomuser.me/api/portraits/women/69.jpg", -) - -internal val LucasHale = Profile( - name = "Lucas Hale", - location = "Listowel, Ireland", - email = "lucas.hale@example.com", - uuid = "a578c951-eeac-4e5f-b1ce-b39086fc9c43", - username = "silvertiger720", - registered = "2014-06-26T12:18:00.129Z", - picture = "https://randomuser.me/api/portraits/men/5.jpg", -) diff --git a/after-party/src/androidDebug/kotlin/io/ashdavies/profile/ProfileScreen.android.kt b/after-party/src/androidDebug/kotlin/io/ashdavies/profile/ProfileScreen.android.kt deleted file mode 100644 index 955ed784d..000000000 --- a/after-party/src/androidDebug/kotlin/io/ashdavies/profile/ProfileScreen.android.kt +++ /dev/null @@ -1,16 +0,0 @@ -package io.ashdavies.profile - -import androidx.compose.runtime.Composable -import androidx.compose.ui.tooling.preview.Preview - -@Preview -@Composable -internal fun EmptyProfileScreenPreview() { - ProfileScreen(ProfileScreen.State(null) { }) -} - -@Preview -@Composable -internal fun ProfileScreenPreview() { - ProfileScreen(ProfileScreen.State(KordulaLaube) { }) -} diff --git a/after-party/src/commonMain/kotlin/io/ashdavies/events/EventsFactory.kt b/after-party/src/commonMain/kotlin/io/ashdavies/events/EventsFactory.kt index fd2120f72..cb62b6abe 100644 --- a/after-party/src/commonMain/kotlin/io/ashdavies/events/EventsFactory.kt +++ b/after-party/src/commonMain/kotlin/io/ashdavies/events/EventsFactory.kt @@ -6,13 +6,10 @@ import com.slack.circuit.runtime.ui.Ui import com.slack.circuit.runtime.ui.ui import io.ashdavies.activity.ActivityPresenter import io.ashdavies.activity.ActivityScreen -import io.ashdavies.profile.ProfilePresenter -import io.ashdavies.profile.ProfileScreen public fun eventsPresenterFactory(): Presenter.Factory = Presenter.Factory { screen, _, _ -> when (screen) { is ActivityScreen -> presenterOf { ActivityPresenter() } - is ProfileScreen -> presenterOf { ProfilePresenter() } else -> null } } @@ -23,10 +20,6 @@ public fun eventsUiFactory(): Ui.Factory = Ui.Factory { screen, _ -> ActivityScreen(state, modifier) } - is ProfileScreen -> ui { state, modifier -> - ProfileScreen(state, modifier) - } - else -> null } } diff --git a/after-party/src/commonMain/kotlin/io/ashdavies/gallery/AuthState.kt b/after-party/src/commonMain/kotlin/io/ashdavies/gallery/AuthState.kt deleted file mode 100644 index 44329788b..000000000 --- a/after-party/src/commonMain/kotlin/io/ashdavies/gallery/AuthState.kt +++ /dev/null @@ -1,8 +0,0 @@ -package io.ashdavies.gallery - -internal sealed interface AuthState { - data class Authenticated(val profilePictureUrl: String) : AuthState - - data object Unauthenticated : AuthState - data object Unsupported : AuthState -} diff --git a/after-party/src/commonMain/kotlin/io/ashdavies/party/AfterPartyScreen.kt b/after-party/src/commonMain/kotlin/io/ashdavies/party/AfterPartyScreen.kt index 23a13ad51..0076b4891 100644 --- a/after-party/src/commonMain/kotlin/io/ashdavies/party/AfterPartyScreen.kt +++ b/after-party/src/commonMain/kotlin/io/ashdavies/party/AfterPartyScreen.kt @@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.RowScope import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Edit import androidx.compose.material.icons.filled.Home -import androidx.compose.material.icons.filled.Person import androidx.compose.material3.BottomAppBar import androidx.compose.material3.CenterAlignedTopAppBar import androidx.compose.material3.ExperimentalMaterial3Api @@ -33,7 +32,6 @@ import io.ashdavies.identity.IdentityState import io.ashdavies.material.BottomSheetScaffold import io.ashdavies.parcelable.Parcelable import io.ashdavies.parcelable.Parcelize -import io.ashdavies.profile.ProfileScreen public fun afterPartyScreen(): Screen = AfterPartyScreen @@ -67,7 +65,7 @@ internal fun AfterPartyScreen( actions = { ProfileActionButton( identityState = state.identityState, - onClick = { eventSink(AfterPartyScreen.Event.BottomNav(ProfileScreen)) }, + onClick = { }, ) }, ) @@ -134,12 +132,6 @@ internal fun AfterPartyBottomBar( onClick = { onClick(GalleryScreen) }, selected = selected is GalleryScreen, ) - - NavigationBarItem( - icon = { NavigationBarImage(Icons.Default.Person) }, - onClick = { onClick(ProfileScreen) }, - selected = selected is ProfileScreen, - ) } } } diff --git a/after-party/src/commonMain/kotlin/io/ashdavies/profile/ProfilePresenter.kt b/after-party/src/commonMain/kotlin/io/ashdavies/profile/ProfilePresenter.kt deleted file mode 100644 index f5f3b09e2..000000000 --- a/after-party/src/commonMain/kotlin/io/ashdavies/profile/ProfilePresenter.kt +++ /dev/null @@ -1,21 +0,0 @@ -package io.ashdavies.profile - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.ui.platform.LocalUriHandler -import androidx.compose.ui.platform.UriHandler -import com.slack.circuit.retained.produceRetainedState - -@Composable -internal fun ProfilePresenter( - repository: ProfileRepository = rememberProfileRepository(), - uriHandler: UriHandler = LocalUriHandler.current, -): ProfileScreen.State { - val profile by produceRetainedState(null) { - repository.getProfile(generateRandomIfEmpty = true).collect { value = it } - } - - return ProfileScreen.State(profile) { - if (it is ProfileScreen.Event.Login) uriHandler.openUri("http://localhost:8080/callback") - } -} diff --git a/after-party/src/commonMain/kotlin/io/ashdavies/profile/ProfileRepository.kt b/after-party/src/commonMain/kotlin/io/ashdavies/profile/ProfileRepository.kt deleted file mode 100644 index 21588e09c..000000000 --- a/after-party/src/commonMain/kotlin/io/ashdavies/profile/ProfileRepository.kt +++ /dev/null @@ -1,37 +0,0 @@ -package io.ashdavies.profile - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember -import io.ashdavies.http.LocalHttpClient -import io.ashdavies.random.Profile -import io.ashdavies.random.RandomProvider -import io.ashdavies.random.getRandomUser -import io.ashdavies.sql.mapToOneOrNull -import io.ashdavies.sql.rememberLocalQueries -import io.ktor.client.HttpClient -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.filterNotNull - -internal fun interface ProfileRepository { - fun getProfile(generateRandomIfEmpty: Boolean): Flow -} - -internal fun ProfileRepository( - profileQueries: ProfileQueries, - randomProvider: RandomProvider, -) = ProfileRepository { generateRandomIfEmpty -> - profileQueries.selectAll().mapToOneOrNull { - it ?: if (generateRandomIfEmpty) Profile(randomProvider.getRandomUser()) else null - }.filterNotNull() -} - -@Composable -internal fun rememberProfileRepository( - profileQueries: ProfileQueries = rememberLocalQueries { it.profileQueries }, - httpClient: HttpClient = LocalHttpClient.current, -): ProfileRepository = remember(httpClient, profileQueries) { - ProfileRepository( - randomProvider = RandomProvider(httpClient), - profileQueries = profileQueries, - ) -} diff --git a/after-party/src/commonMain/kotlin/io/ashdavies/profile/ProfileScreen.kt b/after-party/src/commonMain/kotlin/io/ashdavies/profile/ProfileScreen.kt deleted file mode 100644 index a591684cb..000000000 --- a/after-party/src/commonMain/kotlin/io/ashdavies/profile/ProfileScreen.kt +++ /dev/null @@ -1,142 +0,0 @@ -package io.ashdavies.profile - -import androidx.compose.foundation.background -import androidx.compose.foundation.border -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material3.Button -import androidx.compose.material3.Card -import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Scaffold -import androidx.compose.material3.Text -import androidx.compose.material3.TopAppBar -import androidx.compose.material3.TopAppBarDefaults -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment.Companion.CenterHorizontally -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.input.nestedscroll.nestedScroll -import androidx.compose.ui.unit.dp -import com.slack.circuit.runtime.CircuitUiEvent -import com.slack.circuit.runtime.CircuitUiState -import com.slack.circuit.runtime.screen.Screen -import io.ashdavies.android.FlowRow -import io.ashdavies.parcelable.Parcelize -import io.ashdavies.placeholder.PlaceholderHighlight -import io.ashdavies.placeholder.fade -import io.ashdavies.placeholder.placeholder -import kotlin.random.Random.Default.nextInt - -@Parcelize -internal object ProfileScreen : Screen { - internal sealed interface Event : CircuitUiEvent { - data object Login : Event - } - - internal data class State( - val profile: Profile? = null, - val eventSink: (Event) -> Unit, - ) : CircuitUiState -} - -@Composable -@OptIn(ExperimentalMaterial3Api::class) -internal fun ProfileScreen(state: ProfileScreen.State, modifier: Modifier = Modifier) { - val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior() - val eventSink = state.eventSink - - Scaffold( - modifier = modifier.nestedScroll(scrollBehavior.nestedScrollConnection), - topBar = { TopAppBar(title = { Text("Profile") }) }, - ) { contentPadding -> - ProfileScreen( - onLogin = { eventSink(ProfileScreen.Event.Login) }, - modifier = Modifier.padding(contentPadding), - state = state, - ) - } -} - -@Composable -@ExperimentalMaterial3Api -private fun ProfileScreen( - state: ProfileScreen.State, - modifier: Modifier = Modifier, - onLogin: () -> Unit, -) { - Box(modifier) { - Column(Modifier.padding(16.dp)) { - when (state.profile) { - null -> LoggedOutScreen(onLogin) - else -> { - ProfileHeader(state.profile.name) - StubLanyardFlow() - } - } - } - } -} - -@Composable -@ExperimentalMaterial3Api -private fun ProfileHeader( - text: String, - modifier: Modifier = Modifier, -) { - Card( - modifier = modifier - .padding(top = 64.dp, bottom = 12.dp) - .fillMaxWidth(), - ) { - Column( - horizontalAlignment = CenterHorizontally, - modifier = Modifier.fillMaxWidth(), - ) { - Text( - text = text, - modifier = Modifier.padding(4.dp, 64.dp, 4.dp, 4.dp), - style = MaterialTheme.typography.headlineSmall, - ) - } - } - - Text( - modifier = Modifier.padding(bottom = 4.dp), - style = MaterialTheme.typography.headlineSmall, - text = "Events", - ) -} - -@Composable -private fun StubLanyardFlow(until: Int = 30) { - FlowRow { - repeat(nextInt(until)) { - Box( - modifier = Modifier - .background(Color.DarkGray) - .border(1.dp, Color.LightGray, CircleShape) - .size(64.dp, 64.dp) - .clip(CircleShape) - .placeholder(true, highlight = PlaceholderHighlight.fade()) - .padding(4.dp), - ) - } - } -} - -@Composable -private fun LoggedOutScreen(onLogin: () -> Unit) { - Column { - Text("Not logged in") - - Button(onClick = onLogin) { - Text("Login") - } - } -} diff --git a/after-party/src/commonMain/kotlin/io/ashdavies/random/Profile.kt b/after-party/src/commonMain/kotlin/io/ashdavies/random/Profile.kt deleted file mode 100644 index 3a6ec8b7d..000000000 --- a/after-party/src/commonMain/kotlin/io/ashdavies/random/Profile.kt +++ /dev/null @@ -1,13 +0,0 @@ -package io.ashdavies.random - -import io.ashdavies.profile.Profile - -internal fun Profile(value: RandomUser) = Profile( - name = "${value.name.first} ${value.name.last}", - location = "${value.location.city}, ${value.location.country}", - email = value.email, - uuid = value.login.uuid, - username = value.login.username, - registered = value.registered.date, - picture = value.picture.large, -) diff --git a/after-party/src/commonMain/kotlin/io/ashdavies/random/RandomProvider.kt b/after-party/src/commonMain/kotlin/io/ashdavies/random/RandomProvider.kt deleted file mode 100644 index 4dd46634a..000000000 --- a/after-party/src/commonMain/kotlin/io/ashdavies/random/RandomProvider.kt +++ /dev/null @@ -1,26 +0,0 @@ -package io.ashdavies.random - -import io.ktor.client.HttpClient -import io.ktor.client.call.body -import io.ktor.client.request.get -import kotlinx.serialization.Serializable - -internal fun interface RandomProvider { - suspend fun getRandomUsers(size: Int): List -} - -internal fun RandomProvider(client: HttpClient) = RandomProvider { size -> - client - .get("https://randomuser.me/api/?results=$size") - .body>() - .results -} - -internal suspend fun RandomProvider.getRandomUser(): RandomUser { - return getRandomUsers(1).first() -} - -@Serializable -private data class Envelope( - val results: List, -) diff --git a/after-party/src/commonMain/kotlin/io/ashdavies/random/RandomUser.kt b/after-party/src/commonMain/kotlin/io/ashdavies/random/RandomUser.kt deleted file mode 100644 index 343c74926..000000000 --- a/after-party/src/commonMain/kotlin/io/ashdavies/random/RandomUser.kt +++ /dev/null @@ -1,42 +0,0 @@ -package io.ashdavies.random - -import kotlinx.serialization.Serializable - -@Serializable -internal data class RandomUser( - val name: Name, - val location: Location, - val email: String, - val login: Login, - val registered: Registered, - val picture: Picture, -) { - - @Serializable - data class Name( - val first: String, - val last: String, - ) - - @Serializable - data class Location( - val city: String, - val country: String, - ) - - @Serializable - data class Login( - val uuid: String, - val username: String, - ) - - @Serializable - data class Registered( - val date: String, - ) - - @Serializable - data class Picture( - val large: String, - ) -}