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
|
|
|
|
image
|
|
|
|
touchable-highlight]]
|
2016-05-19 18:31:56 +02:00
|
|
|
[status-im.utils.listview :refer [to-datasource]]
|
|
|
|
[status-im.chats-list.views.chat-list-item :refer [chat-list-item]]
|
|
|
|
[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-10-05 11:56:53 +03:00
|
|
|
[status-im.components.toolbar.view :refer [toolbar]]
|
|
|
|
[status-im.components.toolbar.styles :refer [toolbar-background1
|
|
|
|
toolbar-background2]]
|
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-05-25 18:57:06 +03:00
|
|
|
[status-im.i18n :refer [label]]
|
2016-06-15 16:41:08 +03:00
|
|
|
[status-im.chats-list.styles :as st]
|
2016-10-05 11:56:53 +03:00
|
|
|
[status-im.utils.platform :refer [platform-specific]]
|
2016-07-26 11:06:55 +03:00
|
|
|
[status-im.components.tabs.bottom-gradient :refer [bottom-gradient]]
|
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-09-15 15:33:19 +03:00
|
|
|
(defview chats-list-toolbar []
|
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?])
|
|
|
|
actions (cond->> [{:image {:source {:uri :icon_search}
|
|
|
|
:style st/toolbar-icon}
|
|
|
|
:handler (fn [])}]
|
|
|
|
new-chat?
|
|
|
|
(into [{:image {:source {:uri :icon_add}
|
|
|
|
:style st/toolbar-icon}
|
|
|
|
:handler #(dispatch [:navigate-forget :group-contacts :people])}]))]
|
|
|
|
[toolbar {:nav-action {:image {:source {:uri :icon_hamburger}
|
|
|
|
:style st/hamburger-icon}
|
|
|
|
:handler open-drawer}
|
|
|
|
:title (label :t/chats)
|
|
|
|
:style (get-in platform-specific [:component-styles :toolbar])
|
|
|
|
:background-color (if chats-scrolled?
|
|
|
|
toolbar-background1
|
|
|
|
toolbar-background2)
|
|
|
|
:actions actions}]))
|
|
|
|
|
|
|
|
(defn chats-action-button []
|
|
|
|
[view {:style (st/action-buttons-container false 0)
|
|
|
|
:pointerEvents :box-none}
|
|
|
|
[action-button {:buttonColor color-blue
|
|
|
|
:offsetY 16
|
|
|
|
:offsetX 16}
|
|
|
|
[action-button-item
|
|
|
|
{:title (label :t/new-chat)
|
|
|
|
:buttonColor :#9b59b6
|
|
|
|
:onPress #(dispatch [:navigate-forget :group-contacts :people])}
|
|
|
|
[ion-icon {:name :md-create
|
|
|
|
:style st/create-icon}]]
|
|
|
|
[action-button-item
|
|
|
|
{:title (label :t/new-group-chat)
|
|
|
|
:buttonColor :#1abc9c
|
|
|
|
:onPress #(dispatch [:navigate-to :new-group])}
|
|
|
|
[ion-icon {:name :md-person
|
|
|
|
:style st/person-stalker-icon}]]]])
|
|
|
|
|
|
|
|
(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-09-15 15:33:19 +03:00
|
|
|
[chats-list-toolbar]
|
2016-10-05 11:56:53 +03:00
|
|
|
[list-view {:dataSource (to-datasource chats)
|
|
|
|
:renderRow (fn [row _ _]
|
|
|
|
(list-item [chat-list-item row]))
|
|
|
|
:renderFooter #(list-item [chat-shadow-item])
|
|
|
|
:renderSeparator #(list-item
|
|
|
|
(when (< %2 (- (count chats) 1))
|
|
|
|
^{:key (str "separator-" %2)}
|
|
|
|
[view st/chat-separator-wrapper
|
|
|
|
[view st/chat-separator-item]]))
|
|
|
|
:style st/list-container}]
|
|
|
|
(when (get-in platform-specific [:chats :action-button?])
|
|
|
|
[chats-action-button])
|
2016-08-26 12:37:13 +03:00
|
|
|
[bottom-gradient]])
|