2016-03-29 23:45:31 +03:00
|
|
|
(ns syng-im.components.chats.chats-list
|
|
|
|
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
|
|
|
[syng-im.components.react :refer [android?
|
|
|
|
view
|
|
|
|
text
|
|
|
|
image
|
|
|
|
navigator
|
|
|
|
toolbar-android]]
|
|
|
|
[syng-im.components.realm :refer [list-view]]
|
|
|
|
[syng-im.utils.logging :as log]
|
|
|
|
[syng-im.navigation :refer [nav-pop]]
|
|
|
|
[syng-im.resources :as res]
|
|
|
|
[syng-im.utils.listview :refer [to-realm-datasource]]
|
|
|
|
[reagent.core :as r]
|
2016-04-01 18:05:55 +03:00
|
|
|
[syng-im.components.chats.chat-list-item :refer [chat-list-item]]
|
|
|
|
[syng-im.components.action-button :refer [action-button
|
|
|
|
action-button-item]]
|
2016-04-18 13:38:38 +03:00
|
|
|
[syng-im.components.styles :refer [font
|
|
|
|
title-font
|
|
|
|
color-white
|
|
|
|
color-black
|
|
|
|
color-blue
|
|
|
|
text1-color
|
|
|
|
text2-color]]
|
2016-04-01 18:05:55 +03:00
|
|
|
[syng-im.components.icons.ionicons :refer [icon]]))
|
2016-03-29 23:45:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
(defn chats-list [{:keys [navigator]}]
|
|
|
|
(let [chats (subscribe [:get-chats])]
|
|
|
|
(fn []
|
|
|
|
(let [chats @chats
|
|
|
|
_ (log/debug "chats=" chats)
|
|
|
|
datasource (to-realm-datasource chats)]
|
|
|
|
[view {:style {:flex 1
|
|
|
|
:backgroundColor "white"}}
|
|
|
|
(when android?
|
|
|
|
;; TODO add IOS version
|
2016-04-25 20:31:10 +03:00
|
|
|
[toolbar-android {:navIcon {:uri "icon_hamburger"}
|
2016-04-21 23:08:07 +03:00
|
|
|
:style {:backgroundColor color-white
|
2016-03-29 23:45:31 +03:00
|
|
|
:height 56
|
|
|
|
:elevation 2}
|
|
|
|
:onIconClicked (fn []
|
2016-04-18 13:38:38 +03:00
|
|
|
(nav-pop navigator))
|
|
|
|
:actions [{:title "Search"
|
2016-04-25 20:31:10 +03:00
|
|
|
:icon {:uri "icon_search"}
|
|
|
|
:show "always"}]}
|
2016-04-18 13:38:38 +03:00
|
|
|
[view {:style {:flex 1
|
|
|
|
:alignItems "center"
|
|
|
|
:justifyContent "center"
|
|
|
|
:marginRight 112
|
|
|
|
:backgroundColor "transparent"}}
|
|
|
|
[text {:style {:marginTop -2.5
|
|
|
|
:color text1-color
|
|
|
|
:fontSize 16
|
|
|
|
:fontFamily font}}
|
|
|
|
"Chats"]]])
|
2016-03-29 23:45:31 +03:00
|
|
|
[list-view {:dataSource datasource
|
|
|
|
:renderRow (fn [row section-id row-id]
|
|
|
|
(r/as-element [chat-list-item row navigator]))
|
2016-04-01 18:05:55 +03:00
|
|
|
:style {:backgroundColor "white"}}]
|
2016-04-18 13:38:38 +03:00
|
|
|
[action-button {:buttonColor color-blue}
|
2016-04-01 18:05:55 +03:00
|
|
|
[action-button-item {:title "New Chat"
|
|
|
|
:buttonColor "#9b59b6"
|
|
|
|
:onPress (fn []
|
|
|
|
(dispatch [:show-contacts navigator]))}
|
|
|
|
[icon {:name "android-create"
|
|
|
|
:style {:fontSize 20
|
|
|
|
:height 22
|
|
|
|
:color "white"}}]]
|
|
|
|
[action-button-item {:title "New Group Chat"
|
|
|
|
:buttonColor "#1abc9c"
|
|
|
|
:onPress (fn []
|
|
|
|
(dispatch [:show-group-new navigator]))}
|
|
|
|
[icon {:name "person-stalker"
|
|
|
|
:style {:fontSize 20
|
|
|
|
:height 22
|
|
|
|
:color "white"}}]]]]))))
|