2016-05-19 18:31:56 +02:00
|
|
|
(ns status-im.chats-list.screen
|
2016-06-15 16:41:08 +03:00
|
|
|
(:require-macros [status-im.utils.views :refer [defview]])
|
2016-05-11 16:06:37 +03:00
|
|
|
(:require [re-frame.core :refer [subscribe dispatch]]
|
2016-05-19 18:31:56 +02:00
|
|
|
[status-im.components.react :refer [list-view
|
2016-05-20 22:12:08 +03:00
|
|
|
list-item
|
|
|
|
view
|
2016-06-16 12:44:56 +03:00
|
|
|
animated-view
|
2016-05-20 22:12:08 +03:00
|
|
|
text
|
2017-02-07 12:56:39 +02:00
|
|
|
icon
|
2016-05-20 22:12:08 +03:00
|
|
|
image
|
|
|
|
touchable-highlight]]
|
2016-05-19 18:31:56 +02:00
|
|
|
[status-im.components.action-button :refer [action-button
|
2016-05-20 22:12:08 +03:00
|
|
|
action-button-item]]
|
2016-06-16 13:11:01 +03:00
|
|
|
[status-im.components.drawer.view :refer [open-drawer]]
|
2016-10-05 11:56:53 +03:00
|
|
|
[status-im.components.styles :refer [color-blue]]
|
2016-07-22 11:53:12 +03:00
|
|
|
[status-im.components.status-bar :refer [status-bar]]
|
2016-12-05 13:50:47 +03:00
|
|
|
[status-im.components.toolbar.view :refer [toolbar-with-search]]
|
|
|
|
[status-im.components.toolbar.actions :as act]
|
2016-08-01 13:29:10 +03:00
|
|
|
[status-im.components.icons.custom-icons :refer [ion-icon]]
|
2016-10-05 11:56:53 +03:00
|
|
|
[status-im.components.react :refer [linear-gradient]]
|
2016-12-05 13:50:47 +03:00
|
|
|
[status-im.components.sync-state.offline :refer [offline-view]]
|
|
|
|
[status-im.utils.listview :refer [to-datasource]]
|
|
|
|
[status-im.chats-list.views.chat-list-item :refer [chat-list-item]]
|
2016-05-25 18:57:06 +03:00
|
|
|
[status-im.i18n :refer [label]]
|
2016-10-05 11:56:53 +03:00
|
|
|
[status-im.utils.platform :refer [platform-specific]]
|
2016-12-05 13:50:47 +03:00
|
|
|
[status-im.chats-list.styles :as st]
|
2016-06-15 16:41:08 +03:00
|
|
|
[status-im.components.tabs.styles :refer [tabs-height]]))
|
2016-03-29 23:45:31 +03:00
|
|
|
|
2016-12-05 13:50:47 +03:00
|
|
|
(defview toolbar-view []
|
2016-06-15 16:41:08 +03:00
|
|
|
[chats-scrolled? [:get :chats-scrolled?]]
|
2016-10-05 11:56:53 +03:00
|
|
|
(let [new-chat? (get-in platform-specific [:chats :new-chat-in-toolbar?])
|
2016-12-05 13:50:47 +03:00
|
|
|
actions (if new-chat?
|
|
|
|
[(act/add #(dispatch [:navigate-to :group-contacts :people]))])]
|
|
|
|
[toolbar-with-search
|
|
|
|
{:show-search? false
|
|
|
|
:search-key :chat-list
|
|
|
|
:title (label :t/chats)
|
|
|
|
:search-placeholder (label :t/search-for)
|
|
|
|
:nav-action (act/hamburger open-drawer)
|
2017-03-01 17:02:48 +03:00
|
|
|
:style (st/toolbar chats-scrolled?)
|
|
|
|
:actions actions}]))
|
2016-10-05 11:56:53 +03:00
|
|
|
|
|
|
|
(defn chats-action-button []
|
2017-01-30 19:32:25 +03:00
|
|
|
[action-button {:button-color color-blue
|
|
|
|
:offset-x 16
|
|
|
|
:offset-y 22
|
|
|
|
:hide-shadow true
|
|
|
|
:spacing 13}
|
|
|
|
[action-button-item
|
|
|
|
{:title (label :t/new-chat)
|
|
|
|
:buttonColor :#9b59b6
|
|
|
|
:onPress #(dispatch [:navigate-to :group-contacts :people])}
|
|
|
|
[ion-icon {:name :md-create
|
|
|
|
:style st/create-icon}]]
|
|
|
|
[action-button-item
|
|
|
|
{:title (label :t/new-group-chat)
|
|
|
|
:buttonColor :#1abc9c
|
2017-03-13 12:21:27 +03:00
|
|
|
:onPress #(dispatch [:open-contact-toggle-list :chat-group])}
|
2017-02-07 12:56:39 +02:00
|
|
|
[icon :private_group_big st/group-icon]]
|
|
|
|
[action-button-item
|
|
|
|
{:title (label :t/new-public-group-chat)
|
|
|
|
:buttonColor :#1abc9c
|
|
|
|
:onPress #(dispatch [:navigate-to :new-public-group])}
|
|
|
|
[icon :public_group_big st/group-icon]]])
|
2016-10-05 11:56:53 +03:00
|
|
|
|
|
|
|
(defn chat-shadow-item []
|
|
|
|
[view {:height 3}
|
|
|
|
[linear-gradient {:style {:height 3}
|
|
|
|
:colors st/gradient-top-bottom-shadow}]])
|
2016-03-29 23:45:31 +03:00
|
|
|
|
2016-09-15 15:33:19 +03:00
|
|
|
(defview chats-list []
|
2016-08-26 12:37:13 +03:00
|
|
|
[chats [:get :chats]]
|
|
|
|
[view st/chats-container
|
2016-12-05 13:50:47 +03:00
|
|
|
[toolbar-view]
|
2016-10-05 11:56:53 +03:00
|
|
|
[list-view {:dataSource (to-datasource chats)
|
2016-11-30 09:42:51 +02:00
|
|
|
:renderRow (fn [[id :as row] _ _]
|
|
|
|
(list-item ^{:key id} [chat-list-item row]))
|
2016-10-05 11:56:53 +03:00
|
|
|
:renderFooter #(list-item [chat-shadow-item])
|
|
|
|
:renderSeparator #(list-item
|
2016-11-30 09:42:51 +02:00
|
|
|
(when (< %2 (- (count chats) 1))
|
|
|
|
^{:key (str "separator-" %2)}
|
|
|
|
[view st/chat-separator-wrapper
|
|
|
|
[view st/chat-separator-item]]))
|
2016-10-05 11:56:53 +03:00
|
|
|
:style st/list-container}]
|
|
|
|
(when (get-in platform-specific [:chats :action-button?])
|
|
|
|
[chats-action-button])
|
2016-10-06 12:52:58 +03:00
|
|
|
[offline-view]])
|