Delete old sign up forms

This commit is contained in:
virvar 2016-04-07 13:28:02 +03:00
parent d5c7c9b768
commit 2c8cfa8212
3 changed files with 1 additions and 150 deletions

View File

@ -9,8 +9,6 @@
[syng-im.components.react :refer [navigator app-registry]]
[syng-im.components.contact-list.contact-list :refer [contact-list]]
[syng-im.components.chat :refer [chat]]
[syng-im.components.sign-up :refer [sign-up-view]]
[syng-im.components.sign-up-confirm :refer [sign-up-confirm-view]]
[syng-im.components.chats.chats-list :refer [chats-list]]
[syng-im.components.chats.new-group :refer [new-group]]
[syng-im.utils.logging :as log]
@ -45,9 +43,7 @@
:chat-list (r/as-element [chats-list {:navigator nav}])
:new-group (r/as-element [new-group {:navigator nav}])
:contact-list (r/as-element [contact-list {:navigator nav}])
:chat (r/as-element [chat {:navigator nav}])
:sign-up (r/as-element [sign-up-view {:navigator nav}])
:sign-up-confirm (r/as-element [sign-up-confirm-view {:navigator nav}])))))}])
:chat (r/as-element [chat {:navigator nav}])))))}])
(defn init []
(dispatch-sync [:initialize-db])

View File

@ -1,59 +0,0 @@
(ns syng-im.components.sign-up
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
[syng-im.components.react :refer [view text image touchable-highlight
toolbar-android text-input]]
[syng-im.components.spinner :refer [spinner]]
[syng-im.resources :as res]
[syng-im.navigation :as nav]
[syng-im.utils.utils :refer [log toast http-post]]
[syng-im.utils.phone-number :refer [format-phone-number]]))
(defn show-confirm-view [navigator]
(dispatch [:set-loading false])
(nav/nav-replace navigator {:view-id :sign-up-confirm}))
(defn sign-up [user-phone-number user-identity navigator]
(dispatch [:set-loading true])
(dispatch [:sign-up user-phone-number user-identity #(show-confirm-view navigator)]))
(defn update-phone-number [value]
(let [formatted (format-phone-number value)]
(dispatch [:set-user-phone-number formatted])))
(defn sign-up-view [{:keys [navigator]}]
(let [loading (subscribe [:get-loading])
user-phone-number (subscribe [:get-user-phone-number])
user-identity (subscribe [:get-user-identity])]
(fn []
[view {:style {:flex 1}}
[view {:style {:flex 1
:backgroundColor "white"}}
[toolbar-android {:logo res/logo-icon
:title "Sign up"
:titleColor "#4A5258"
:style {:backgroundColor "white"
:height 56
:elevation 2}}]
[view {}
[text-input {:underlineColorAndroid "#9CBFC0"
:placeholder "Enter your phone number"
:keyboardType "phone-pad"
:onChangeText (fn [value]
(update-phone-number value))
:style {:flex 1
:marginHorizontal 18
:lineHeight 42
:fontSize 14
:fontFamily "Avenir-Roman"
:color "#9CBFC0"}}
@user-phone-number]
[touchable-highlight {:onPress #(sign-up @user-phone-number @user-identity navigator)
:style {:alignSelf "center"
:borderRadius 7
:backgroundColor "#E5F5F6"
:width 100}}
[text {:style {:marginVertical 10
:textAlign "center"}}
"Sign up"]]]]
(when (or @loading (not @user-identity))
[spinner {:visible true}])])))

View File

@ -1,86 +0,0 @@
(ns syng-im.components.sign-up-confirm
(:require-macros
[natal-shell.core :refer [with-error-view]])
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
[syng-im.components.react :refer [view text image touchable-highlight list-view
toolbar-android text-input]]
[syng-im.components.spinner :refer [spinner]]
[syng-im.resources :as res]
[syng-im.navigation :as nav]
[syng-im.utils.utils :refer [log toast http-post]]))
(defn show-home-view [navigator]
(dispatch [:set-loading false])
(nav/nav-replace navigator {:view-id :contact-list}))
(defn sync-contacts [navigator]
(dispatch [:sync-contacts #(show-home-view navigator)]))
(defn on-send-code-response [navigator body]
(log body)
(toast (if (:confirmed body)
"Confirmed"
"Wrong code"))
(if (:confirmed body)
;; TODO user action required
(sync-contacts navigator)
(dispatch [:set-loading false])))
(defn code-valid? [code]
(= 4 (count code)))
(defn send-code [code navigator]
(when (code-valid? code)
(dispatch [:set-loading true])
(dispatch [:sign-up-confirm code (partial on-send-code-response navigator)])))
(defn update-code [value]
(let [formatted value]
(dispatch [:set-confirmation-code formatted])))
(defn sign-up-confirm-view [{:keys [navigator]}]
(let [loading (subscribe [:get-loading])
confirmation-code (subscribe [:get-confirmation-code])]
(fn []
[view {:style {:flex 1}}
[view {:style {:flex 1
:backgroundColor "white"}}
[toolbar-android {:logo res/logo-icon
:title "Confirm"
:titleColor "#4A5258"
:style {:backgroundColor "white"
:height 56
:elevation 2}}]
[view {}
[text-input {:underlineColorAndroid "#9CBFC0"
:placeholder "Enter confirmation code"
:keyboardType "number-pad"
:maxLength 4
:onChangeText (fn [value]
(update-code value))
:style {:flex 1
:marginHorizontal 18
:lineHeight 42
:fontSize 14
:fontFamily "Avenir-Roman"
:color "#9CBFC0"}}
@confirmation-code]
(if (code-valid? @confirmation-code)
[touchable-highlight {:onPress #(send-code @confirmation-code navigator)
:style {:alignSelf "center"
:borderRadius 7
:backgroundColor "#E5F5F6"
:width 100}}
[text {:style {:marginVertical 10
:textAlign "center"}}
"Confirm"]]
[view {:style {:alignSelf "center"
:borderRadius 7
:backgroundColor "#AAB2B2"
:width 100}}
[text {:style {:marginVertical 10
:textAlign "center"}}
"Confirm"]])]]
(when @loading
[spinner {:visible true}])])))