Loading spinner for sign up confirmation view

Former-commit-id: 81b1d6440a
This commit is contained in:
virvar 2016-03-21 15:27:50 +03:00
parent 1595b0b00c
commit ff91912a7a
1 changed files with 49 additions and 42 deletions

View File

@ -10,12 +10,14 @@
[messenger.state :as state] [messenger.state :as state]
[messenger.utils.utils :refer [log toast]] [messenger.utils.utils :refer [log toast]]
[messenger.utils.resources :as res] [messenger.utils.resources :as res]
[messenger.components.spinner :refer [spinner]]
[messenger.comm.intercom :as intercom :refer [set-confirmation-code]] [messenger.comm.intercom :as intercom :refer [set-confirmation-code]]
[messenger.android.contacts-list :refer [contacts-list]])) [messenger.android.contacts-list :refer [contacts-list]]))
(def nav-atom (atom nil)) (def nav-atom (atom nil))
(defn show-home-view [] (defn show-home-view []
(swap! state/app-state assoc :loading false)
(binding [state/*nav-render* false] (binding [state/*nav-render* false]
(.replace @nav-atom (clj->js {:component contacts-list (.replace @nav-atom (clj->js {:component contacts-list
:name "contacts-list"})))) :name "contacts-list"}))))
@ -37,6 +39,7 @@
(defn send-code [code] (defn send-code [code]
(when (code-valid? code) (when (code-valid? code)
(swap! state/app-state assoc :loading true)
(intercom/sign-up-confirm code on-send-code-response))) (intercom/sign-up-confirm code on-send-code-response)))
(defn update-code [value] (defn update-code [value]
@ -46,54 +49,58 @@
(defui SignUpConfirm (defui SignUpConfirm
static om/IQuery static om/IQuery
(query [this] (query [this]
'[:confirmation-code]) '[:confirmation-code :loading])
Object Object
(render (render
[this] [this]
(let [{:keys [confirmation-code]} (om/props this) (let [{:keys [confirmation-code loading]} (om/props this)
{:keys [nav]} (om/get-computed this)] {:keys [nav]} (om/get-computed this)]
(reset! nav-atom nav) (reset! nav-atom nav)
(view (view
{:style {:flex 1 {:style {:flex 1}}
:backgroundColor "white"}} (view
(toolbar-android {:logo res/logo-icon {:style {:flex 1
:title "Confirm" :backgroundColor "white"}}
:titleColor "#4A5258" (toolbar-android {:logo res/logo-icon
:style {:backgroundColor "white" :title "Confirm"
:height 56 :titleColor "#4A5258"
:elevation 2}}) :style {:backgroundColor "white"
(view {} :height 56
(text-input {:underlineColorAndroid "#9CBFC0" :elevation 2}})
:placeholder "Enter confirmation code" (view {}
:keyboardType "number-pad" (text-input {:underlineColorAndroid "#9CBFC0"
:maxLength 4 :placeholder "Enter confirmation code"
:onChangeText (fn [value] :keyboardType "number-pad"
(update-code value)) :maxLength 4
:style {:flex 1 :onChangeText (fn [value]
:marginHorizontal 18 (update-code value))
:lineHeight 42 :style {:flex 1
:fontSize 14 :marginHorizontal 18
:fontFamily "Avenir-Roman" :lineHeight 42
:color "#9CBFC0"}} :fontSize 14
confirmation-code) :fontFamily "Avenir-Roman"
(if (code-valid? confirmation-code) :color "#9CBFC0"}}
(touchable-highlight confirmation-code)
{:onPress #(send-code confirmation-code) (if (code-valid? confirmation-code)
:style {:alignSelf "center" (touchable-highlight
:borderRadius 7 {:onPress #(send-code confirmation-code)
:backgroundColor "#E5F5F6" :style {:alignSelf "center"
:borderRadius 7
:backgroundColor "#E5F5F6"
:width 100}} :width 100}}
(text {:style {:marginVertical 10 (text {:style {:marginVertical 10
:textAlign "center"}} :textAlign "center"}}
"Confirm")) "Confirm"))
(view (view
{:style {:alignSelf "center" {:style {:alignSelf "center"
:borderRadius 7 :borderRadius 7
:backgroundColor "#AAB2B2" :backgroundColor "#AAB2B2"
:width 100}} :width 100}}
(text {:style {:marginVertical 10 (text {:style {:marginVertical 10
:textAlign "center"}} :textAlign "center"}}
"Confirm")))))))) "Confirm")))))
(when loading
(spinner {:visible true}))))))
(def sign-up-confirm (om/factory SignUpConfirm)) (def sign-up-confirm (om/factory SignUpConfirm))