-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from fmasa/password-reset
Add password reset dialog to desktop version
- Loading branch information
Showing
14 changed files
with
323 additions
and
49 deletions.
There are no files selected for viewing
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
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
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
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
31 changes: 31 additions & 0 deletions
31
common/src/commonMain/kotlin/cz/frantisekmasa/wfrp_master/common/shell/SnackbarScaffold.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,31 @@ | ||
package cz.frantisekmasa.wfrp_master.common.shell | ||
|
||
import androidx.compose.material.Scaffold | ||
import androidx.compose.material.SnackbarHostState | ||
import androidx.compose.material.rememberScaffoldState | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.CompositionLocalProvider | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.rememberCoroutineScope | ||
import cz.frantisekmasa.wfrp_master.common.core.ui.scaffolding.LocalPersistentSnackbarHolder | ||
import cz.frantisekmasa.wfrp_master.common.core.ui.scaffolding.PersistentSnackbarHolder | ||
|
||
@Composable | ||
fun SnackbarScaffold(content: @Composable () -> Unit) { | ||
val coroutineScope = rememberCoroutineScope() | ||
val snackbarHostState = remember { SnackbarHostState() } | ||
val persistentSnackbarHolder = | ||
remember(coroutineScope, snackbarHostState) { | ||
PersistentSnackbarHolder(coroutineScope, snackbarHostState) | ||
} | ||
|
||
Scaffold( | ||
scaffoldState = rememberScaffoldState(snackbarHostState = snackbarHostState), | ||
content = { | ||
CompositionLocalProvider( | ||
LocalPersistentSnackbarHolder provides persistentSnackbarHolder, | ||
content = content, | ||
) | ||
}, | ||
) | ||
} |
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
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
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
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
52 changes: 51 additions & 1 deletion
52
common/src/jvmMain/kotlin/cz/frantisekmasa/wfrp_master/common/settings/SignInCard.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 |
---|---|---|
@@ -1,8 +1,58 @@ | ||
package cz.frantisekmasa.wfrp_master.common.settings | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.rememberCoroutineScope | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import cz.frantisekmasa.wfrp_master.common.Str | ||
import cz.frantisekmasa.wfrp_master.common.auth.AuthenticationManager | ||
import cz.frantisekmasa.wfrp_master.common.core.auth.LocalUser | ||
import cz.frantisekmasa.wfrp_master.common.core.ui.buttons.CardButton | ||
import cz.frantisekmasa.wfrp_master.common.core.ui.cards.CardContainer | ||
import cz.frantisekmasa.wfrp_master.common.core.ui.cards.CardTitle | ||
import cz.frantisekmasa.wfrp_master.common.core.ui.text.SingleLineTextValue | ||
import cz.frantisekmasa.wfrp_master.common.core.utils.launchLogged | ||
import dev.icerock.moko.resources.compose.stringResource | ||
import kotlinx.coroutines.Dispatchers | ||
import org.kodein.di.compose.localDI | ||
import org.kodein.di.instance | ||
|
||
@Composable | ||
actual fun SignInCard(settingsScreenModel: SettingsScreenModel) { | ||
// Add support for Google auth | ||
CardContainer( | ||
Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 8.dp) | ||
) { | ||
Column( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 8.dp), | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
) { | ||
CardTitle(stringResource(Str.settings_title_account)) | ||
|
||
val email = LocalUser.current.email | ||
|
||
if (email != null) { | ||
SingleLineTextValue(stringResource(Str.authentication_label_email), email) | ||
} | ||
|
||
val auth: AuthenticationManager by localDI().instance() | ||
val coroutineScope = rememberCoroutineScope() | ||
|
||
CardButton( | ||
text = stringResource(Str.authentication_button_log_out), | ||
onClick = { | ||
coroutineScope.launchLogged(Dispatchers.IO) { | ||
auth.logout() | ||
} | ||
} | ||
) | ||
} | ||
} | ||
} |
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.