Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
flexsurfer committed Jun 8, 2021
1 parent 73b9140 commit 4f8abbe
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 80 deletions.
107 changes: 47 additions & 60 deletions src/status_im/multiaccounts/login/core_test.cljs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(ns status-im.multiaccounts.login.core-test
(:require [cljs.test :as test]
[status-im.multiaccounts.login.core :as login]
;[status-im.multiaccounts.biometric.core :as biometric]
[status-im.utils.keychain.core :as keychain]))
;[status-im.utils.fx :as fx]))
[status-im.multiaccounts.biometric.core :as biometric]
[status-im.utils.keychain.core :as keychain]
[status-im.utils.fx :as fx]))

(test/deftest save-password-test
(test/testing "check save password, biometric unavailable"
Expand All @@ -16,60 +16,47 @@
(let [{:keys [db]} (login/save-password {:db db} false)]
(test/is (= false (contains? db :popover/popover)))
(test/is (= false (get-in db [:multiaccounts/login :save-password?])))))))
#_(test/testing "check save password, biometric available"
(let [initial-cofx {:db {:auth-method keychain/auth-method-none
:supported-biometric-auth true}}
{:keys [db]} (login/save-password initial-cofx true)]
(test/is (= :secure-with-biometric
(get-in db [:popover/popover :view])))
(test/is (= true (get-in db [:multiaccounts/login :save-password?])))
(test/testing "enable biometric auth"
(let [{:keys [db] :as res} (biometric/enable {:db db})]
(test/is (contains? res :biometric-auth/authenticate))
(test/is (= false (contains? db :popover/popover)))
(test/testing "biometric auth successfully enabled"
(let [{:keys [db]} (biometric/setup-done
{:db db}
{:bioauth-success true
:bioauth-message nil
:bioauth-code nil})]
(test/is (= keychain/auth-method-biometric-prepare
(:auth-method db)))))
(test/testing "biometric auth canceled"
(let [{:keys [db]} (biometric/setup-done
{:db db}
{:bioauth-success false
:bioauth-message nil
:bioauth-code "USER_CANCELED"})]
(test/is (= nil db) "no db changes")))))))
#_(test/testing (str "check save password, enable biometric auth,"
"uncheck save password")
(let [initial-cofx {:db {:auth-method keychain/auth-method-none
:supported-biometric-auth true}}
{:keys [db]} (fx/merge
initial-cofx
(login/save-password true)
(biometric/enable)
(biometric/setup-done
{:bioauth-success true
:bioauth-message nil
:bioauth-code nil})
(login/save-password false))]
(test/is (= true (get-in db [:multiaccounts/login :save-password?])))
;; case 2 from https://github.com/status-im/status-react/issues/9573
(test/is (= keychain/auth-method-biometric-prepare (:auth-method db)))
(test/testing "disable biometric"
(let [{:keys [db]} (biometric/disable {:db db})]
(test/is (= false (get-in db [:multiaccounts/login :save-password?])))
(test/is (= keychain/auth-method-none) (:auth-method db))))))
#_(test/testing (str "check save password, skip biometric auth"
"uncheck save password, check again")
(let [initial-cofx {:db {:auth-method keychain/auth-method-none
:supported-biometric-auth true}}
{:keys [db]} (fx/merge
initial-cofx
(login/save-password true)
(login/save-password false)
(login/save-password false))]
;; case 3 from https://github.com/status-im/status-react/issues/9573
(test/is (= :secure-with-biometric (get-in db [:popover/popover :view]))))))
(test/testing "check save password, biometric available"
(let [initial-cofx {:db {:auth-method keychain/auth-method-none
:supported-biometric-auth true}}
{:keys [db]} (login/save-password initial-cofx true)]
(test/is (= true (get-in db [:multiaccounts/login :save-password?])))
(test/testing "enable biometric auth"
(let [{:keys [db] :as res} (biometric/enable {:db db})]
(test/is (contains? res :biometric-auth/authenticate))
(test/is (= false (contains? db :popover/popover)))
(test/testing "biometric auth successfully enabled"
(let [{:keys [db]} (biometric/setup-done
{:db db}
{:bioauth-success true
:bioauth-message nil
:bioauth-code nil})]
(test/is (= keychain/auth-method-biometric-prepare
(:auth-method db)))))
(test/testing "biometric auth canceled"
(let [{:keys [db]} (biometric/setup-done
{:db db}
{:bioauth-success false
:bioauth-message nil
:bioauth-code "USER_CANCELED"})]
(test/is (= nil db) "no db changes")))))))
(test/testing (str "check save password, enable biometric auth,"
"uncheck save password")
(let [initial-cofx {:db {:auth-method keychain/auth-method-none
:supported-biometric-auth true}}
{:keys [db]} (login/save-password (fx/merge
initial-cofx
(login/save-password true)
(biometric/enable)
(biometric/setup-done
{:bioauth-success true
:bioauth-message nil
:bioauth-code nil}))
false)]
(test/is (= true (get-in db [:multiaccounts/login :save-password?])))
;; case 2 from https://github.com/status-im/status-react/issues/9573
(test/is (= keychain/auth-method-biometric-prepare (:auth-method db)))
(test/testing "disable biometric"
(let [{:keys [db]} (biometric/disable {:db db})]
(test/is (= false (get-in db [:multiaccounts/login :save-password?])))
(test/is (= keychain/auth-method-none) (:auth-method db)))))))
4 changes: 3 additions & 1 deletion src/status_im/ui/components/bottom_panel/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@
(hide-panel-anim bottom-anim-value alpha-value (- window-height))))))
:reagent-render (fn []
(if @current-obj
[react/keyboard-avoiding-view {:style {:position :absolute :top 0 :bottom 0 :left 0 :right 0}}
[react/keyboard-avoiding-view {:style {:position :absolute :top 0 :bottom 0 :left 0 :right 0}
:ignore-offset true}

[react/view {:flex 1}
(when platform/ios?
[react/animated-view {:flex 1 :background-color colors/black-persist :opacity alpha-value}])
Expand Down
4 changes: 3 additions & 1 deletion src/status_im/ui/components/react.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@
(defn keyboard-avoiding-view [props & children]
(into [keyboard-avoiding-view-class
(merge (when platform/ios? {:behavior :padding})
(update props :keyboardVerticalOffset + 44 (:status-bar-height @navigation-const)))]
(if (:ignore-offset props)
props
(update props :keyboardVerticalOffset + 44 (:status-bar-height @navigation-const))))]
children))

(defn scroll-view [props & children]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
name (get-in manage-bootnode [:name :value])
is-valid? (empty? validation-errors)
invalid-url? (contains? validation-errors :url)]
[react/keyboard-avoiding-view {:flex 1}
[react/keyboard-avoiding-view {:style {:flex 1}
:ignore-offset true}
[topbar/topbar {:title (i18n/label (if id :t/bootnode-details :t/add-bootnode))}]
[react/scroll-view {:keyboard-should-persist-taps :handled}
[react/view styles/edit-bootnode-view
Expand Down
3 changes: 2 additions & 1 deletion src/status_im/ui/screens/browser/empty_tab/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@
dapps-account [:dapps-account]
url-text (atom nil)]
(let [bookmarks (vals bookmarks)]
[react/keyboard-avoiding-view {:style {:flex 1}}
[react/keyboard-avoiding-view {:style {:flex 1}
:ignore-offset true}
[quo/text-input {:on-change-text #(reset! url-text %)
:on-submit-editing #(re-frame/dispatch [:browser.ui/open-url @url-text])
:placeholder (i18n/label :t/enter-url)
Expand Down
2 changes: 1 addition & 1 deletion src/status_im/ui/screens/browser/options/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
:accessibility-label :open-chat
:title (str "#" topic)
:subtitle (i18n/label :t/open-chat)
:on-press #(do ;;TODO these all should be in one event, and also confusion with chat and home-root
:on-press #(do
(re-frame/dispatch [:navigate-change-tab :chat])
(re-frame/dispatch [:pop-to-root-tab :chat-stack])
(hide-sheet-and-dispatch [:chat.ui/start-public-chat topic {:navigation-reset? true}]))
Expand Down
3 changes: 0 additions & 3 deletions src/status_im/ui/screens/group/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,6 @@
(views/letsubs [{:keys [name chat-id]} [:chats/current-chat]
new-group-chat-name (reagent/atom nil)]
[kb-presentation/keyboard-avoiding-view {:style styles/group-container}
#_[topbar/topbar
{:title (i18n/label :t/edit-group)
:modal? true}]
[react/scroll-view {:style {:padding 16
:flex 1}}
[quo/text-input
Expand Down
3 changes: 2 additions & 1 deletion src/status_im/ui/screens/home/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@
:accessibility-label :notifications-unread-badge}]])]))

(defn home []
[react/keyboard-avoiding-view {:style {:flex 1}}
[react/keyboard-avoiding-view {:style {:flex 1}
:ignore-offset true}
[topbar/topbar {:title (i18n/label :t/chat)
:navigation :none
:right-component [react/view {:flex-direction :row :margin-right 16}
Expand Down
3 changes: 2 additions & 1 deletion src/status_im/ui/screens/keycard/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@
[react/view
{:style {:width 260
:margin-bottom 15}}
[react/view ;TODO intro-styles/buttons-container
[react/view {:align-items :center
:padding-horizontal 32}
[quo/button {:on-press #(re-frame/dispatch
[::keycard.login/login-after-reset])}
(i18n/label :t/open)]]])])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
(letsubs
[{:keys [seed-word-count seed-shape-invalid?]} [:multiaccounts/key-storage]
{:keys [creating-backup?]} [:keycard]]
[react/keyboard-avoiding-view {:flex 1}
[react/keyboard-avoiding-view {:style {:flex 1}
:ignore-offset true}
[local-topbar (i18n/label :t/enter-seed-phrase) ::multiaccounts.key-storage/navigate-back]
[multiaccounts.views/seed-phrase-input
{:on-change-event [::multiaccounts.key-storage/seed-phrase-input-changed]
Expand Down
3 changes: 2 additions & 1 deletion src/status_im/ui/screens/notifications_center/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
:component-did-mount #(re-frame/dispatch [:get-activity-center-notifications])
:reagent-render (fn []
(let [{:keys [notifications]} @(re-frame/subscribe [:activity.center/notifications])]
[react/keyboard-avoiding-view {:style {:flex 1}}
[react/keyboard-avoiding-view {:style {:flex 1}
:ignore-offset true}
[topbar/topbar {:navigation {:on-press #(do
(reset-state)
(re-frame/dispatch [:close-notifications-center])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
(not (string/blank? name))
(empty? validation-errors))
invalid-url? (contains? validation-errors :url)]
[react/keyboard-avoiding-view {:style {:flex 1}}
[react/keyboard-avoiding-view {:style {:flex 1}
:ignore-offset true}
[topbar/topbar {:title (i18n/label (if id :t/mailserver-details :t/add-mailserver))}]
[react/scroll-view {:keyboard-should-persist-taps :handled}
[react/view styles/edit-mailserver-view
Expand Down
3 changes: 1 addition & 2 deletions src/status_im/ui/screens/onboarding/phrase/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@
next-button-disabled?
passphrase-error]}
@(re-frame/subscribe [:intro-wizard/enter-phrase])]
[react/keyboard-avoiding-view {:flex 1
:background-color colors/white}
[react/keyboard-avoiding-view {:flex 1}
[quo/text {:weight :bold
:align :center
:size :x-large}
Expand Down
3 changes: 2 additions & 1 deletion src/status_im/ui/screens/profile/seed/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@
(defview backup-seed []
(letsubs [current-multiaccount [:multiaccount]
{:keys [step first-word second-word error word]} [:my-profile/recovery]]
[react/keyboard-avoiding-view {:style {:flex 1}}
[react/keyboard-avoiding-view {:style {:flex 1}
:ignore-offset true}
[topbar/topbar {:title (i18n/label :t/backup-recovery-phrase)
:subtitle (i18n/label :t/step-i-of-n {:step (steps-numbers step) :number 3})
:navigation (if (= :finish step)
Expand Down
3 changes: 2 additions & 1 deletion src/status_im/ui/screens/wallet/account_settings/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
(letsubs [{:keys [address color path type] :as account} [:multiaccount/current-account]
new-account (reagent/atom nil)
keycard? [:keycard-multiaccount?]]
[react/keyboard-avoiding-view {:flex 1}
[react/keyboard-avoiding-view {:style {:flex 1}
:ignore-offset true}
[topbar/topbar
(cond-> {:title (i18n/label :t/account-settings)}
(and @new-account (not= "" (:name @new-account)))
Expand Down
6 changes: 4 additions & 2 deletions src/status_im/ui/screens/wallet/add_new/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@
status [:keycard/pin-status]
error-label [:keycard/pin-error-label]
retry-counter [:keycard/retry-counter]]
[react/keyboard-avoiding-view {:style {:flex 1}}
[react/keyboard-avoiding-view {:style {:flex 1}
:ignore-offset true}
[topbar/topbar
{:navigation :none
:right-accessories
Expand Down Expand Up @@ -156,7 +157,8 @@
add-account-disabled? [:add-account-disabled?]
entered-password (reagent/atom "")
keycard? [:keycard-multiaccount?]]
[react/keyboard-avoiding-view {:style {:flex 1}}
[react/keyboard-avoiding-view {:style {:flex 1}
:ignore-offset true}
[add-account-topbar type]
[react/scroll-view {:keyboard-should-persist-taps :handled
:style {:flex 1}}
Expand Down
3 changes: 2 additions & 1 deletion src/status_im/ui/screens/wallet/custom_tokens/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@
(defview custom-token-details []
(letsubs [{:keys [address name symbol decimals custom?] :as token}
[:get-screen-params]]
[react/keyboard-avoiding-view {:flex 1}
[react/keyboard-avoiding-view {:style {:flex 1}
:ignore-offset true}
[topbar/topbar {:title name}]
[react/scroll-view {:keyboard-should-persist-taps :handled
:style {:flex 1}}
Expand Down

0 comments on commit 4f8abbe

Please sign in to comment.