desktop: fix onboarding when choosing random password (#3523)
This commit is contained in:
parent
ee163a6540
commit
a9b36e8e39
@ -2,7 +2,6 @@ package chat.simplex.common.model
|
|||||||
|
|
||||||
import androidx.compose.material.*
|
import androidx.compose.material.*
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
|
||||||
import androidx.compose.runtime.snapshots.SnapshotStateMap
|
import androidx.compose.runtime.snapshots.SnapshotStateMap
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.text.SpanStyle
|
import androidx.compose.ui.text.SpanStyle
|
||||||
@ -68,6 +67,9 @@ object ChatModel {
|
|||||||
// set when app opened from external intent
|
// set when app opened from external intent
|
||||||
val clearOverlays = mutableStateOf<Boolean>(false)
|
val clearOverlays = mutableStateOf<Boolean>(false)
|
||||||
|
|
||||||
|
// Only needed during onboarding when user skipped password setup (left as random password)
|
||||||
|
val desktopOnboardingRandomPassword = mutableStateOf(false)
|
||||||
|
|
||||||
// set when app is opened via contact or invitation URI
|
// set when app is opened via contact or invitation URI
|
||||||
val appOpenUrl = mutableStateOf<URI?>(null)
|
val appOpenUrl = mutableStateOf<URI?>(null)
|
||||||
|
|
||||||
|
@ -207,12 +207,12 @@ fun createProfileInProfiles(chatModel: ChatModel, displayName: String, close: ()
|
|||||||
|
|
||||||
fun createProfileOnboarding(chatModel: ChatModel, displayName: String, close: () -> Unit) {
|
fun createProfileOnboarding(chatModel: ChatModel, displayName: String, close: () -> Unit) {
|
||||||
withApi {
|
withApi {
|
||||||
chatModel.controller.apiCreateActiveUser(
|
chatModel.currentUser.value = chatModel.controller.apiCreateActiveUser(
|
||||||
null, Profile(displayName.trim(), "", null)
|
null, Profile(displayName.trim(), "", null)
|
||||||
) ?: return@withApi
|
) ?: return@withApi
|
||||||
val onboardingStage = chatModel.controller.appPrefs.onboardingStage
|
val onboardingStage = chatModel.controller.appPrefs.onboardingStage
|
||||||
if (chatModel.users.isEmpty()) {
|
if (chatModel.users.isEmpty()) {
|
||||||
onboardingStage.set(if (appPlatform.isDesktop && chatModel.controller.appPrefs.initialRandomDBPassphrase.get()) {
|
onboardingStage.set(if (appPlatform.isDesktop && chatModel.controller.appPrefs.initialRandomDBPassphrase.get() && !chatModel.desktopOnboardingRandomPassword.value) {
|
||||||
OnboardingStage.Step2_5_SetupDatabasePassphrase
|
OnboardingStage.Step2_5_SetupDatabasePassphrase
|
||||||
} else {
|
} else {
|
||||||
OnboardingStage.Step3_CreateSimpleXAddress
|
OnboardingStage.Step3_CreateSimpleXAddress
|
||||||
|
@ -73,7 +73,8 @@ private fun LinkAMobileLayout(
|
|||||||
}
|
}
|
||||||
Box(Modifier.weight(0.7f)) {
|
Box(Modifier.weight(0.7f)) {
|
||||||
AddingMobileDevice(false, staleQrCode, connecting) {
|
AddingMobileDevice(false, staleQrCode, connecting) {
|
||||||
if (chatModel.remoteHosts.isEmpty()) {
|
// currentRemoteHost will be set instantly but remoteHosts may be delayed
|
||||||
|
if (chatModel.remoteHosts.isEmpty() && chatModel.currentRemoteHost.value == null) {
|
||||||
chatModel.controller.appPrefs.onboardingStage.set(OnboardingStage.Step1_SimpleXInfo)
|
chatModel.controller.appPrefs.onboardingStage.set(OnboardingStage.Step1_SimpleXInfo)
|
||||||
} else {
|
} else {
|
||||||
chatModel.controller.appPrefs.onboardingStage.set(OnboardingStage.OnboardingComplete)
|
chatModel.controller.appPrefs.onboardingStage.set(OnboardingStage.OnboardingComplete)
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package chat.simplex.common.views.onboarding
|
package chat.simplex.common.views.onboarding
|
||||||
|
|
||||||
import SectionBottomSpacer
|
import SectionBottomSpacer
|
||||||
import SectionItemView
|
|
||||||
import SectionItemViewSpaceBetween
|
|
||||||
import SectionTextFooter
|
import SectionTextFooter
|
||||||
import SectionView
|
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.text.KeyboardActions
|
import androidx.compose.foundation.text.KeyboardActions
|
||||||
@ -15,14 +12,12 @@ import androidx.compose.runtime.saveable.rememberSaveable
|
|||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.focus.*
|
import androidx.compose.ui.focus.*
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.input.key.*
|
import androidx.compose.ui.input.key.*
|
||||||
import androidx.compose.ui.platform.LocalFocusManager
|
import androidx.compose.ui.platform.LocalFocusManager
|
||||||
import androidx.compose.ui.text.input.ImeAction
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
import dev.icerock.moko.resources.compose.painterResource
|
import dev.icerock.moko.resources.compose.painterResource
|
||||||
import dev.icerock.moko.resources.compose.stringResource
|
import dev.icerock.moko.resources.compose.stringResource
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.Dp
|
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import chat.simplex.common.model.*
|
import chat.simplex.common.model.*
|
||||||
import chat.simplex.common.platform.*
|
import chat.simplex.common.platform.*
|
||||||
@ -177,7 +172,10 @@ private fun SetupDatabasePassphraseLayout(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Spacer(Modifier.weight(1f))
|
Spacer(Modifier.weight(1f))
|
||||||
SkipButton(progressIndicator.value, nextStep)
|
SkipButton(progressIndicator.value) {
|
||||||
|
chatModel.desktopOnboardingRandomPassword.value = true
|
||||||
|
nextStep()
|
||||||
|
}
|
||||||
|
|
||||||
SectionBottomSpacer()
|
SectionBottomSpacer()
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import androidx.compose.runtime.Composable
|
|||||||
import chat.simplex.common.model.ChatModel.controller
|
import chat.simplex.common.model.ChatModel.controller
|
||||||
import chat.simplex.common.model.SharedPreference
|
import chat.simplex.common.model.SharedPreference
|
||||||
import chat.simplex.common.model.User
|
import chat.simplex.common.model.User
|
||||||
|
import chat.simplex.common.platform.chatModel
|
||||||
import chat.simplex.common.ui.theme.DEFAULT_PADDING
|
import chat.simplex.common.ui.theme.DEFAULT_PADDING
|
||||||
import chat.simplex.res.MR
|
import chat.simplex.res.MR
|
||||||
import dev.icerock.moko.resources.compose.painterResource
|
import dev.icerock.moko.resources.compose.painterResource
|
||||||
@ -14,7 +15,7 @@ import dev.icerock.moko.resources.compose.painterResource
|
|||||||
actual fun OnboardingActionButton(user: User?, onboardingStage: SharedPreference<OnboardingStage>, onclick: (() -> Unit)?) {
|
actual fun OnboardingActionButton(user: User?, onboardingStage: SharedPreference<OnboardingStage>, onclick: (() -> Unit)?) {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
Row(horizontalArrangement = Arrangement.spacedBy(DEFAULT_PADDING * 2.5f)) {
|
Row(horizontalArrangement = Arrangement.spacedBy(DEFAULT_PADDING * 2.5f)) {
|
||||||
OnboardingActionButton(MR.strings.link_a_mobile, onboarding = if (controller.appPrefs.initialRandomDBPassphrase.get()) OnboardingStage.Step2_5_SetupDatabasePassphrase else OnboardingStage.LinkAMobile, true, icon = painterResource(MR.images.ic_smartphone_300), onclick = onclick)
|
OnboardingActionButton(MR.strings.link_a_mobile, onboarding = if (controller.appPrefs.initialRandomDBPassphrase.get() && !chatModel.desktopOnboardingRandomPassword.value) OnboardingStage.Step2_5_SetupDatabasePassphrase else OnboardingStage.LinkAMobile, true, icon = painterResource(MR.images.ic_smartphone_300), onclick = onclick)
|
||||||
OnboardingActionButton(MR.strings.create_your_profile, onboarding = OnboardingStage.Step2_CreateProfile, true, icon = painterResource(MR.images.ic_desktop), onclick = onclick)
|
OnboardingActionButton(MR.strings.create_your_profile, onboarding = OnboardingStage.Step2_CreateProfile, true, icon = painterResource(MR.images.ic_desktop), onclick = onclick)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user