[#11395] Inapp Keycard upsell MVP

Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
andrey 2021-03-01 12:07:46 +01:00
parent c625e95d5e
commit 106e9112e0
No known key found for this signature in database
GPG Key ID: 89B67245FD2F0272
6 changed files with 50 additions and 22 deletions

View File

@ -12,10 +12,11 @@
(fx/defn initialize-app-db
"Initialize db to initial state"
[{{:keys [keycard supported-biometric-auth app-active-since]
:network/keys [type]} :db
:network/keys [type] :keycard/keys [banner-hidden]} :db
now :now}]
{:db (assoc app-db
:network/type type
:keycard/banner-hidden banner-hidden
:keycard (dissoc keycard :secrets)
:supported-biometric-auth supported-biometric-auth
:app-active-since (or app-active-since now)
@ -60,7 +61,9 @@
(fx/merge cofx
{:get-supported-biometric-auth nil
::init-theme nil
::open-multiaccounts #(re-frame/dispatch [::initialize-multiaccounts % {:logout? false}])
::open-multiaccounts #(do
(re-frame/dispatch [::initialize-multiaccounts % {:logout? false}])
(re-frame/dispatch [:get-keycard-banner-preference]))
:ui/listen-to-window-dimensions-change nil
::network/listen-to-network-info nil
:keycard/register-card-events nil

View File

@ -31,7 +31,8 @@
[taoensso.timbre :as log]
[status-im.data-store.invitations :as data-store.invitations]
[status-im.chat.models.link-preview :as link-preview]
[status-im.utils.mobile-sync :as utils.mobile-sync]))
[status-im.utils.mobile-sync :as utils.mobile-sync]
[status-im.async-storage.core :as async-storage]))
(re-frame/reg-fx
::login
@ -506,3 +507,20 @@
(dissoc :intro-wizard)
(update :keycard dissoc :application-info))}
(open-login (select-keys multiaccount [:key-uid :name :public-key :identicon :images])))))
(fx/defn hide-keycard-banner
{:events [:hide-keycard-banner]}
[{:keys [db]}]
{:db (assoc db :keycard/banner-hidden true)
::async-storage/set! {:keycard-banner-hidden true}})
(fx/defn get-keycard-banner-preference-cb
{:events [:get-keycard-banner-preference-cb]}
[{:keys [db]} {:keys [keycard-banner-hidden]}]
{:db (assoc db :keycard/banner-hidden keycard-banner-hidden)})
(fx/defn get-keycard-banner-preference
{:events [:get-keycard-banner-preference]}
[_]
{::async-storage/get {:keys [:keycard-banner-hidden]
:cb #(re-frame/dispatch [:get-keycard-banner-preference-cb %])}})

View File

@ -200,6 +200,7 @@
;; keycard
(reg-root-key-sub :keycard/new-account-sheet? :keycard/new-account-sheet?)
(reg-root-key-sub :keycard/banner-hidden :keycard/banner-hidden)
;; delete profile
(reg-root-key-sub :delete-profile/error :delete-profile/error)

View File

@ -138,25 +138,30 @@
:height 16}]]])
(defn keycard-upsell-banner []
[react/touchable-highlight {:on-press #(.openURL ^js react/linking "https://get-keycard.status.im/")}
[react/view {:background-color (if (= :dark @colors/theme) "#2C5955" "#DDF8F4")
:border-radius 16
:margin 16
:padding-horizontal 12
:padding-vertical 8
:flex-direction :row}
[react/view
[react/view {:background-color (if (= :dark @colors/theme) "#2C5955" "#DDF8F4")
:border-radius 16 :padding-left 12 :padding-right 50 :margin 16}
[react/touchable-highlight {:on-press #(do
(re-frame/dispatch [:hide-keycard-banner])
(.openURL ^js react/linking "https://get-keycard.status.im/"))}
[react/view {:padding-vertical 8
:flex-direction :row}
[react/image {:source (resources/get-theme-image :keycard)
:resize-mode :contain
:style {:width 48
:height 48}}]]
[react/view {:flex 1
:margin-left 12}
[react/text {:style {:font-size 20
:font-weight "700"}}
(i18n/label :t/get-a-keycard)]
[react/text {:style {:color (colors/alpha colors/text 0.8)}}
(i18n/label :t/keycard-upsell-subtitle)]]]])
:height 48}}]
[react/view {:flex 1
:margin-left 12}
[react/text {:style {:font-size 20
:font-weight "700"}}
(i18n/label :t/get-a-keycard)]
[react/text {:style {:color (colors/alpha colors/text 0.8)}}
(i18n/label :t/keycard-upsell-subtitle)]]]]
[react/touchable-highlight
{:style {:position :absolute :right 0 :top 0
:align-items :center :justify-content :center :margin 2}
:on-press #(re-frame/dispatch [:hide-keycard-banner])
:accessibility-label :hide-home-button}
[icons/icon :main-icons/close-circle {:color colors/gray}]]])
(defview storage []
(letsubs

View File

@ -45,7 +45,8 @@
auth-method [:auth-method]
view-id [:view-id]
supported-biometric-auth [:supported-biometric-auth]
keycard? [:keycard-multiaccount?]]
keycard? [:keycard-multiaccount?]
banner-hidden [:keycard/banner-hidden]]
[react/keyboard-avoiding-view {:style ast/multiaccounts-view}
[topbar/topbar {:border-bottom false
:right-accessories [{:icon :more
@ -98,7 +99,7 @@
[react/view styles/processing-view
[react/activity-indicator {:animating true}]
[react/i18n-text {:style styles/processing :key :processing}]]
(when-not keycard?
(when-not (or keycard? banner-hidden)
[key-storage/keycard-upsell-banner]))
[toolbar/toolbar

View File

@ -1440,7 +1440,7 @@
"choose-storage": "Choose storage",
"choose-new-location-for-keystore": "Choose a new location to save your keystore file",
"get-a-keycard": "Get a Keycard",
"keycard-upsell-subtitle": "Your portable, easy to use hardware wallet",
"keycard-upsell-subtitle": "Enhanced security and convenience",
"actions": "Actions",
"move-keystore-file": "Move keystore file",
"select-new-location-for-keys": "Select a new location to save your private key(s)",