Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

170 changes: 0 additions & 170 deletions composeApp/src/androidMain/res/drawable/ic_launcher_background.xml

This file was deleted.

13 changes: 13 additions & 0 deletions composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import zed.rainxch.githubstore.app.deeplink.DeepLinkParser
import zed.rainxch.githubstore.app.navigation.AppNavigation
import zed.rainxch.githubstore.app.navigation.GithubStoreGraph
import zed.rainxch.githubstore.app.components.RateLimitDialog
import zed.rainxch.githubstore.app.components.SessionExpiredDialog

@OptIn(ExperimentalMaterial3ExpressiveApi::class)
@Composable
Expand Down Expand Up @@ -70,6 +71,18 @@ fun App(deepLinkUri: String? = null) {
}
}

if (state.showSessionExpiredDialog) {
SessionExpiredDialog(
onDismiss = {
viewModel.onAction(MainAction.DismissSessionExpiredDialog)
},
onSignIn = {
viewModel.onAction(MainAction.DismissSessionExpiredDialog)
navBackStack.navigate(GithubStoreGraph.AuthenticationScreen)
}
)
}

AppNavigation(
navController = navBackStack
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ package zed.rainxch.githubstore

sealed interface MainAction {
data object DismissRateLimitDialog : MainAction
data object DismissSessionExpiredDialog : MainAction
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ data class MainState(
val isLoggedIn: Boolean = false,
val rateLimitInfo: RateLimitInfo? = null,
val showRateLimitDialog: Boolean = false,
val showSessionExpiredDialog: Boolean = false,
val currentColorTheme: AppTheme = AppTheme.OCEAN,
val isAmoledTheme: Boolean = false,
val isDarkTheme: Boolean? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ class MainViewModel(
}
}

viewModelScope.launch {
authenticationState.sessionExpiredEvent.collect {
_state.update { it.copy(showSessionExpiredDialog = true) }
}
}

viewModelScope.launch(Dispatchers.IO) {
syncUseCase().onSuccess {
installedAppsRepository.checkAllForUpdates()
Expand All @@ -101,6 +107,9 @@ class MainViewModel(
MainAction.DismissRateLimitDialog -> {
_state.update { it.copy(showRateLimitDialog = false) }
}
MainAction.DismissSessionExpiredDialog -> {
_state.update { it.copy(showSessionExpiredDialog = false) }
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package zed.rainxch.githubstore.app.components

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.LockOpen
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import org.jetbrains.compose.resources.stringResource
import zed.rainxch.githubstore.core.presentation.res.*

@Composable
fun SessionExpiredDialog(
onDismiss: () -> Unit,
onSignIn: () -> Unit
) {
AlertDialog(
onDismissRequest = onDismiss,
icon = {
Icon(
imageVector = Icons.Default.LockOpen,
contentDescription = null,
tint = MaterialTheme.colorScheme.error
)
},
title = {
Text(
text = stringResource(Res.string.session_expired_title),
style = MaterialTheme.typography.headlineSmall,
fontWeight = FontWeight.Black,
color = MaterialTheme.colorScheme.onSurface
)
},
text = {
Column(
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
Text(
text = stringResource(Res.string.session_expired_message),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.outline
)

Text(
text = stringResource(Res.string.session_expired_hint),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.primary
)
}
},
confirmButton = {
Button(onClick = onSignIn) {
Text(
text = stringResource(Res.string.sign_in_again),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onPrimary
)
}
},
dismissButton = {
TextButton(onClick = onDismiss) {
Text(
text = stringResource(Res.string.continue_as_guest),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurface
)
}
}
)
}
Loading