parent
a1e47ce00f
commit
c015d260e8
|
@ -32,13 +32,19 @@
|
||||||
(assoc msg :text-color text-color
|
(assoc msg :text-color text-color
|
||||||
:background-color background-color))))
|
:background-color background-color))))
|
||||||
|
|
||||||
(defn chat-photo [{:keys [photo-path]}]
|
(defview default-chat-icon []
|
||||||
[view {:margin 10
|
[name [:chat :name]
|
||||||
:borderRadius 50}
|
color [:chat :color]]
|
||||||
[image {:source (if (s/blank? photo-path)
|
[view (st/default-chat-icon color)
|
||||||
res/user-no-photo
|
[text {:style st/default-chat-icon-text} (nth name 0)]])
|
||||||
{:uri photo-path})
|
|
||||||
:style st/chat-photo}]])
|
(defview chat-photo []
|
||||||
|
[photo-path [:chat-photo]]
|
||||||
|
(if photo-path
|
||||||
|
[view st/contact-photo-container
|
||||||
|
[image {:source {:uri photo-path}
|
||||||
|
:style st/chat-photo}]]
|
||||||
|
[default-chat-icon]))
|
||||||
|
|
||||||
(defn contact-online [{:keys [online]}]
|
(defn contact-online [{:keys [online]}]
|
||||||
(when online
|
(when online
|
||||||
|
|
|
@ -22,7 +22,9 @@
|
||||||
|
|
||||||
(def icon-view
|
(def icon-view
|
||||||
{:width 56
|
{:width 56
|
||||||
:height 56})
|
:height 56
|
||||||
|
:paddingTop 10
|
||||||
|
:paddingLeft 10})
|
||||||
|
|
||||||
(def back-icon
|
(def back-icon
|
||||||
{:marginTop 21
|
{:marginTop 21
|
||||||
|
@ -153,6 +155,24 @@
|
||||||
:fontFamily font
|
:fontFamily font
|
||||||
:color text2-color})
|
:color text2-color})
|
||||||
|
|
||||||
|
(defn default-chat-icon [color]
|
||||||
|
{:width 36
|
||||||
|
:height 36
|
||||||
|
:alignItems :center
|
||||||
|
:justifyContent :center
|
||||||
|
:borderRadius 50
|
||||||
|
:backgroundColor color})
|
||||||
|
|
||||||
|
(def default-chat-icon-text
|
||||||
|
{:marginTop -2
|
||||||
|
:color color-white
|
||||||
|
:fontFamily font
|
||||||
|
:fontSize 16
|
||||||
|
:lineHeight 20})
|
||||||
|
|
||||||
|
(def contact-photo-container
|
||||||
|
{:borderRadius 50})
|
||||||
|
|
||||||
(def chat-photo
|
(def chat-photo
|
||||||
{:borderRadius 50
|
{:borderRadius 50
|
||||||
:width 36
|
:width 36
|
||||||
|
|
|
@ -8,6 +8,21 @@
|
||||||
text2-color
|
text2-color
|
||||||
new-messages-count-color]]))
|
new-messages-count-color]]))
|
||||||
|
|
||||||
|
(defn default-chat-icon [color]
|
||||||
|
{:width 40
|
||||||
|
:height 40
|
||||||
|
:alignItems :center
|
||||||
|
:justifyContent :center
|
||||||
|
:borderRadius 50
|
||||||
|
:backgroundColor color})
|
||||||
|
|
||||||
|
(def default-chat-icon-text
|
||||||
|
{:marginTop -2
|
||||||
|
:color color-white
|
||||||
|
:fontFamily font
|
||||||
|
:fontSize 16
|
||||||
|
:lineHeight 20})
|
||||||
|
|
||||||
(def contact-photo-container
|
(def contact-photo-container
|
||||||
{:borderRadius 50})
|
{:borderRadius 50})
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
{:on-press #(dispatch [:show-chat chat-id :push])}
|
{:on-press #(dispatch [:show-chat chat-id :push])}
|
||||||
;; TODO add [photo-path delivery-status new-messages-count online] values to chat-obj
|
;; TODO add [photo-path delivery-status new-messages-count online] values to chat-obj
|
||||||
[view [chat-list-item-inner-view (merge chat
|
[view [chat-list-item-inner-view (merge chat
|
||||||
{:photo-path nil
|
;; TODO stub data
|
||||||
:delivery-status :seen
|
{:delivery-status :seen
|
||||||
:new-messages-count 3
|
:new-messages-count 3
|
||||||
:timestamp "13:54"
|
:timestamp "13:54"
|
||||||
:online true})]]])
|
:online true})]]])
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
(ns syng-im.chats-list.views.inner-item
|
(ns syng-im.chats-list.views.inner-item
|
||||||
(:require [clojure.string :as s]
|
(:require-macros [syng-im.utils.views :refer [defview]])
|
||||||
[syng-im.components.react :refer [view image icon text]]
|
(:require [syng-im.components.react :refer [view image icon text]]
|
||||||
[syng-im.chats-list.styles :as st]
|
[syng-im.chats-list.styles :as st]))
|
||||||
[syng-im.resources :as res]))
|
|
||||||
|
|
||||||
|
(defn default-chat-icon [{:keys [name color]}]
|
||||||
|
[view (st/default-chat-icon color)
|
||||||
|
[text {:style st/default-chat-icon-text} (nth name 0)]])
|
||||||
|
|
||||||
(defn contact-photo [photo-path]
|
(defview contact-photo [chat]
|
||||||
|
[photo-path [:chat-photo (:chat-id chat)]]
|
||||||
|
(if photo-path
|
||||||
[view st/contact-photo-container
|
[view st/contact-photo-container
|
||||||
[image {:source (if (s/blank? photo-path)
|
[image {:source {:uri photo-path}
|
||||||
res/user-no-photo
|
:style st/contact-photo-image}]]
|
||||||
{:uri photo-path})
|
[default-chat-icon chat]))
|
||||||
:style st/contact-photo-image}]])
|
|
||||||
|
|
||||||
(defn contact-online [online]
|
(defn contact-online [online]
|
||||||
(when online
|
(when online
|
||||||
|
@ -19,11 +22,11 @@
|
||||||
[view st/online-dot-right]]))
|
[view st/online-dot-right]]))
|
||||||
|
|
||||||
(defn chat-list-item-inner-view
|
(defn chat-list-item-inner-view
|
||||||
[{:keys [name photo-path delivery-status timestamp new-messages-count online
|
[{:keys [chat-id name photo-path delivery-status timestamp new-messages-count online
|
||||||
group-chat contacts]}]
|
group-chat contacts] :as chat}]
|
||||||
[view st/chat-container
|
[view st/chat-container
|
||||||
[view st/photo-container
|
[view st/photo-container
|
||||||
[contact-photo photo-path]
|
[contact-photo chat]
|
||||||
[contact-online online]]
|
[contact-online online]]
|
||||||
[view st/item-container
|
[view st/item-container
|
||||||
[view st/name-view
|
[view st/name-view
|
||||||
|
@ -37,7 +40,8 @@
|
||||||
"1 member")])]
|
"1 member")])]
|
||||||
[text {:style st/last-message-text
|
[text {:style st/last-message-text
|
||||||
:numberOfLines 2}
|
:numberOfLines 2}
|
||||||
(repeatedly 5 #(str "Hi, I'm " name "! "))]]
|
(when-let [last-message (first (:messages chat))]
|
||||||
|
(:content last-message))]]
|
||||||
[view
|
[view
|
||||||
[view st/status-container
|
[view st/status-container
|
||||||
(when delivery-status
|
(when delivery-status
|
||||||
|
|
|
@ -4,18 +4,9 @@
|
||||||
|
|
||||||
(def server-address "http://rpc0.syng.im:20000/")
|
(def server-address "http://rpc0.syng.im:20000/")
|
||||||
;; (def server-address "http://10.0.3.2:3000/")
|
;; (def server-address "http://10.0.3.2:3000/")
|
||||||
|
;; (def server-address "http://localhost:3000/")
|
||||||
|
|
||||||
(def text-content-type "text/plain")
|
(def text-content-type "text/plain")
|
||||||
(def content-type-command "command")
|
(def content-type-command "command")
|
||||||
(def content-type-command-request "command-request")
|
(def content-type-command-request "command-request")
|
||||||
(def content-type-status "status")
|
(def content-type-status "status")
|
||||||
|
|
||||||
|
|
||||||
(comment
|
|
||||||
|
|
||||||
(map (fn [c]
|
|
||||||
{:background c
|
|
||||||
:foreground c}) group-chat-colors)
|
|
||||||
(reverse group-chat-colors)
|
|
||||||
|
|
||||||
)
|
|
||||||
|
|
|
@ -12,9 +12,8 @@
|
||||||
(let [contacts (reaction (:contacts @db))]
|
(let [contacts (reaction (:contacts @db))]
|
||||||
(reaction (sort-by :name (vals @contacts))))))
|
(reaction (sort-by :name (vals @contacts))))))
|
||||||
|
|
||||||
(defn contacts-by-current-chat [fn db]
|
(defn contacts-by-chat [fn db chat-id]
|
||||||
(let [current-chat-id (:current-chat-id @db)
|
(let [chat (reaction (get-in @db [:chats chat-id]))
|
||||||
chat (reaction (get-in @db [:chats current-chat-id]))
|
|
||||||
contacts (reaction (:contacts @db))]
|
contacts (reaction (:contacts @db))]
|
||||||
(reaction
|
(reaction
|
||||||
(when @chat
|
(when @chat
|
||||||
|
@ -25,6 +24,10 @@
|
||||||
(fn #(current-participants (:whisper-identity %))
|
(fn #(current-participants (:whisper-identity %))
|
||||||
(vals @contacts)))))))
|
(vals @contacts)))))))
|
||||||
|
|
||||||
|
(defn contacts-by-current-chat [fn db]
|
||||||
|
(let [current-chat-id (:current-chat-id @db)]
|
||||||
|
(contacts-by-chat fn db current-chat-id)))
|
||||||
|
|
||||||
(register-sub :contact
|
(register-sub :contact
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(let [identity (:contact-identity @db)]
|
(let [identity (:contact-identity @db)]
|
||||||
|
@ -37,3 +40,15 @@
|
||||||
(register-sub :current-chat-contacts
|
(register-sub :current-chat-contacts
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(contacts-by-current-chat filter db)))
|
(contacts-by-current-chat filter db)))
|
||||||
|
|
||||||
|
(register-sub :chat-photo
|
||||||
|
(fn [db [_ chat-id]]
|
||||||
|
(let [chat-id (or chat-id (:current-chat-id @db))
|
||||||
|
chat (reaction (get-in @db [:chats chat-id]))
|
||||||
|
contacts (contacts-by-chat filter db chat-id)]
|
||||||
|
(reaction
|
||||||
|
(when @chat
|
||||||
|
(if (:group-chat @chat)
|
||||||
|
;; TODO return group chat icon
|
||||||
|
nil
|
||||||
|
(:photo-path (first @contacts))))))))
|
||||||
|
|
|
@ -56,12 +56,13 @@
|
||||||
{:margin 10
|
{:margin 10
|
||||||
:width 36
|
:width 36
|
||||||
:height 36
|
:height 36
|
||||||
|
:alignItems :center
|
||||||
|
:justifyContent :center
|
||||||
:borderRadius 50
|
:borderRadius 50
|
||||||
:backgroundColor color})
|
:backgroundColor color})
|
||||||
|
|
||||||
(def chat-icon-text
|
(def chat-icon-text
|
||||||
{:marginTop 7
|
{:marginTop -2
|
||||||
:marginLeft 13
|
|
||||||
:color color-white
|
:color color-white
|
||||||
:fontFamily font
|
:fontFamily font
|
||||||
:fontSize 16
|
:fontSize 16
|
||||||
|
|
Loading…
Reference in New Issue