This commit is contained in:
virvar 2016-02-24 16:05:21 +03:00
parent f4af8beb15
commit bf31fed4ea
2 changed files with 23 additions and 18 deletions

Binary file not shown.

View File

@ -9,6 +9,8 @@
[re-natal.support :as sup] [re-natal.support :as sup]
[messenger.state :as state])) [messenger.state :as state]))
(def fake-contacts? true)
(set! js/React (js/require "react-native")) (set! js/React (js/require "react-native"))
(def react-native-contacts (js/require "react-native-contacts")) (def react-native-contacts (js/require "react-native-contacts"))
@ -71,21 +73,23 @@
(image {:source online-icon (image {:source online-icon
:style {:width 12 :style {:width 12
:height 12}})))) :height 12}}))))
;;; name
(view {:style {:flexDirection "column" (view {:style {:flexDirection "column"
:marginLeft 7 :marginLeft 7
:marginRight 10 :marginRight 10
:flex 1 :flex 1
:position "relative"}} :position "relative"}}
(text {:style {:fontSize 15}} name) ;;; name
(text {:style {:fontSize 15
:fontFamily "Avenir-Roman"}} name)
;;; last message
(text {:style {:color "#AAB2B2" (text {:style {:color "#AAB2B2"
;; TODO not available for android
:fontFamily "Avenir-Roman" :fontFamily "Avenir-Roman"
:fontSize 14 :fontSize 14
:marginTop 2 :marginTop 2
:paddingRight 10}} :paddingRight 10}}
(str "Hi, I'm " name))) (str "Hi, I'm " name)))
(view {:style {:flexDirection "column"}} (view {:style {:flexDirection "column"}}
;;; delivery status
(view {:style {:flexDirection "row" (view {:style {:flexDirection "row"
:position "absolute" :position "absolute"
:top 0 :top 0
@ -95,6 +99,7 @@
seen-icon seen-icon
delivered-icon) delivered-icon)
:style {:marginTop 5}})) :style {:marginTop 5}}))
;;; datetime
(text {:style {:fontFamily "Avenir-Roman" (text {:style {:fontFamily "Avenir-Roman"
:fontSize 11 :fontSize 11
:color "#AAB2B2" :color "#AAB2B2"
@ -102,6 +107,7 @@
:lineHeight 15 :lineHeight 15
:marginLeft 5}} :marginLeft 5}}
datetime)) datetime))
;;; new messages count
(when (< 0 new-messages-count) (when (< 0 new-messages-count)
(view {:style {:position "absolute" (view {:style {:position "absolute"
:right 0 :right 0
@ -139,21 +145,20 @@
(map generate-contact (range 1 (inc n)))) (map generate-contact (range 1 (inc n))))
(defn load-contacts [] (defn load-contacts []
(if fake-contacts?
(swap! state/app-state update :contacts-ds (swap! state/app-state update :contacts-ds
#(clone-with-rows % #(clone-with-rows %
(vec (generate-contacts 100)))) (vec (generate-contacts 100))))
(.getAll react-native-contacts
;; (.getAll react-native-contacts (fn [error raw-contacts]
;; (fn [error raw-contacts] (when (not error)
;; (when (not error) (let [contacts (map (fn [contact]
;; (let [contacts (map (fn [contact] (merge (generate-contact 1)
;; (merge (generate-contact 1) {:name (:givenName contact)
;; {:name (:givenName contact) :photo (:thumbnailPath contact)}))
;; :photo (:thumbnailPath contact)})) (js->clj raw-contacts :keywordize-keys true))]
;; (js->clj raw-contacts :keywordize-keys true))] (swap! state/app-state update :contacts-ds
;; (swap! state/app-state update :contacts-ds #(clone-with-rows % contacts))))))))
;; #(clone-with-rows % contacts))))))
)
(defui AppRoot (defui AppRoot
static om/IQuery static om/IQuery