From 235046cba08328c72a93b8ed2b75085d3031ce9c Mon Sep 17 00:00:00 2001 From: Boris Melnik Date: Fri, 3 Jun 2022 13:48:03 +0300 Subject: [PATCH] feat(settings): Add back up seed phrase banner in profile settings Closes: #5743 --- .../local_account_sensitive_settings.nim | 15 +++++++++++ ui/app/AppLayouts/Profile/ProfileLayout.qml | 25 +++++++++++++++++-- .../Profile/stores/ProfileStore.qml | 6 +++++ ui/imports/shared/panels/ModuleWarning.qml | 3 +++ 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/app/global/local_account_sensitive_settings.nim b/src/app/global/local_account_sensitive_settings.nim index 6627a620de..566a31c180 100644 --- a/src/app/global/local_account_sensitive_settings.nim +++ b/src/app/global/local_account_sensitive_settings.nim @@ -92,6 +92,8 @@ const LSS_KEY_IS_DDMMYY_DATE_FORMAT* = "is_DDMMYY_date_format" const DEFAULT_IS_DDMMYY_DATE_FORMAT = false const LSS_KEY_IS_24H_TIME_FORMAT* = "is_24h_time_format" const DEFAULT_IS_24H_TIME_FORMAT = false +const LSS_KEY_USER_DECLINED_BACKUP_BANNER* = "userDeclinedBackupBanner" +const DEFAULT_USER_DECLINED_BACKUP_BANNER = false logScope: @@ -742,6 +744,18 @@ QtObject: read = getIs24hTimeFormat write = setIs24hTimeFormat notify = is24hTimeFormatChanged + + proc userDeclinedBackupBannerChanged*(self: LocalAccountSensitiveSettings) {.signal.} + proc getUserDeclinedBackupBanner*(self: LocalAccountSensitiveSettings): bool {.slot.} = + getSettingsProp[bool](self, LSS_KEY_USER_DECLINED_BACKUP_BANNER, newQVariant(DEFAULT_USER_DECLINED_BACKUP_BANNER)) + proc setUserDeclinedBackupBanner*(self: LocalAccountSensitiveSettings, value: bool) {.slot.} = + setSettingsProp(self, LSS_KEY_USER_DECLINED_BACKUP_BANNER, newQVariant(value)): + self.userDeclinedBackupBannerChanged() + + QtProperty[bool] userDeclinedBackupBanner: + read = getUserDeclinedBackupBanner + write = setUserDeclinedBackupBanner + notify = userDeclinedBackupBannerChanged proc removeKey*(self: LocalAccountSensitiveSettings, key: string) = if(self.settings.isNil): @@ -796,3 +810,4 @@ QtObject: of LSS_KEY_STICKERS_ENS_ROPSTEN: self.stickersEnsRopstenChanged() of LSS_KEY_IS_DDMMYY_DATE_FORMAT: self.isDDMMYYDateFormatChanged() of LSS_KEY_IS_24H_TIME_FORMAT: self.is24hTimeFormatChanged() + of LSS_KEY_USER_DECLINED_BACKUP_BANNER: self.userDeclinedBackupBannerChanged() diff --git a/ui/app/AppLayouts/Profile/ProfileLayout.qml b/ui/app/AppLayouts/Profile/ProfileLayout.qml index 3a5724fc52..70d1a70c7f 100644 --- a/ui/app/AppLayouts/Profile/ProfileLayout.qml +++ b/ui/app/AppLayouts/Profile/ProfileLayout.qml @@ -4,6 +4,7 @@ import QtQuick.Layouts 1.13 import utils 1.0 import shared 1.0 +import shared.panels 1.0 import "stores" import "popups" @@ -27,7 +28,7 @@ StatusAppTwoPanelLayout { QtObject { id: d - readonly property int topMargin: 0 + readonly property int topMargin: secureYourSeedPhrase.visible ? secureYourSeedPhrase.height : 0 readonly property int bottomMargin: 56 readonly property int leftMargin: 48 readonly property int rightMargin: 48 @@ -39,6 +40,7 @@ StatusAppTwoPanelLayout { id: leftTab store: profileView.store anchors.fill: parent + anchors.topMargin: d.topMargin } rightPanel: Item { @@ -225,5 +227,24 @@ StatusAppTwoPanelLayout { contentWidth: d.contentWidth } } + } // Item + ModuleWarning { + id: secureYourSeedPhrase + width: parent.width + visible: profileContainer.currentIndex === Constants.settingsSubsection.profile && + !profileView.store.profileStore.userDeclinedBackupBanner + color: Style.current.red + btnWidth: 100 + text: qsTr("Secure your seed phrase") + btnText: qsTr("Back up now") + + onClick: function(){ + Global.openBackUpSeedPopup(); + } + + onClosed: { + profileView.store.profileStore.userDeclinedBackupBanner = true + } + } -} +} // StatusAppTwoPanelLayout diff --git a/ui/app/AppLayouts/Profile/stores/ProfileStore.qml b/ui/app/AppLayouts/Profile/stores/ProfileStore.qml index 1e98f855f2..6a5251d773 100644 --- a/ui/app/AppLayouts/Profile/stores/ProfileStore.qml +++ b/ui/app/AppLayouts/Profile/stores/ProfileStore.qml @@ -13,6 +13,12 @@ QtObject { property string ensName: userProfile.preferredName || userProfile.firstEnsName || userProfile.ensName property string profileLargeImage: userProfile.largeImage property string icon: userProfile.icon + property bool userDeclinedBackupBanner: localAccountSensitiveSettings.userDeclinedBackupBanner + onUserDeclinedBackupBannerChanged: { + if (userDeclinedBackupBanner !== localAccountSensitiveSettings.userDeclinedBackupBanner) { + localAccountSensitiveSettings.userDeclinedBackupBanner = userDeclinedBackupBanner + } + } function uploadImage(source, aX, aY, bX, bY) { return root.profileModule.upload(source, aX, aY, bX, bY) diff --git a/ui/imports/shared/panels/ModuleWarning.qml b/ui/imports/shared/panels/ModuleWarning.qml index 204d37b472..51dba0fbd7 100644 --- a/ui/imports/shared/panels/ModuleWarning.qml +++ b/ui/imports/shared/panels/ModuleWarning.qml @@ -22,6 +22,8 @@ Rectangle { closeBtn.clicked(null) } + signal closed + Row { spacing: Style.current.halfPadding anchors.horizontalCenter: parent.horizontalCenter @@ -90,6 +92,7 @@ Rectangle { onClicked: ParallelAnimation { PropertyAnimation { target: root; property: "visible"; to: false; } PropertyAnimation { target: root; property: "y"; to: -1 * root.height } + onFinished: root.closed() } } }