Show contact profile from chat menu. Fix chat creation.
Former-commit-id: e4e9bcfc1a
This commit is contained in:
parent
21eaa78878
commit
34bd8bebe7
|
@ -57,14 +57,7 @@
|
|||
:new-group (r/as-element [new-group {:navigator nav}])
|
||||
:contact-list (r/as-element [contact-list {:navigator nav}])
|
||||
:chat (r/as-element [chat {:navigator nav}])
|
||||
;; TODO pass profile
|
||||
:profile (r/as-element [profile {:navigator nav}
|
||||
{:name "Status"
|
||||
:status (str "The brash businessman’s braggadocio "
|
||||
"and public exchange with candidates "
|
||||
"in the US presidential election")
|
||||
:phone-number "+1 548 093 98 66"
|
||||
:email "christonphe_t@gmail.com"}])))
|
||||
:profile (r/as-element [profile {:navigator nav}])))
|
||||
(r/as-element [chat {:navigator nav}]))))}]))))
|
||||
|
||||
(defn init []
|
||||
|
|
|
@ -128,8 +128,7 @@
|
|||
subtitle])]]])
|
||||
|
||||
(defn actions-list-view [navigator chat]
|
||||
(when-let [actions (when (and (:group-chat chat)
|
||||
(:is-active chat))
|
||||
(when-let [actions (if (:group-chat chat)
|
||||
[{:title "Add Contact to chat"
|
||||
:icon "icon_menu_group"
|
||||
:icon-style {:width 25
|
||||
|
@ -151,7 +150,12 @@
|
|||
:icon "icon_settings"
|
||||
:icon-style {:width 20
|
||||
:height 13}
|
||||
:handler (fn [] )}])]
|
||||
:handler (fn [] )}]
|
||||
[{:title "Profile"
|
||||
:icon "icon_menu_group"
|
||||
:icon-style {:width 25
|
||||
:height 19}
|
||||
:handler #(dispatch [:show-profile navigator (:chat-id chat)])}])]
|
||||
[view {:style {:backgroundColor toolbar-background1
|
||||
:elevation 2
|
||||
:position "absolute"
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
(ns syng-im.components.contact-list.contact
|
||||
(:require [syng-im.components.react :refer [view text image touchable-highlight]]
|
||||
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
||||
[syng-im.components.react :refer [view text image touchable-highlight]]
|
||||
[syng-im.resources :as res]
|
||||
[syng-im.navigation :as nav]
|
||||
[syng-im.components.contact-list.contact-inner :refer [contact-inner-view]]))
|
||||
|
||||
(defn show-chat [navigator whisper-identity]
|
||||
(nav/nav-push navigator {:view-id :chat}))
|
||||
(dispatch [:show-chat whisper-identity navigator :push]))
|
||||
|
||||
(defn contact-view [{:keys [navigator contact]}]
|
||||
(let [{:keys [whisper-identity]} contact]
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
(fn []
|
||||
(let [contacts-ds (get-data-source @contacts)]
|
||||
[view {:style {:flex 1
|
||||
:backgroundColor "white"}}
|
||||
:backgroundColor color-white}}
|
||||
[contact-list-toolbar navigator]
|
||||
(when contacts-ds
|
||||
[list-view {:dataSource contacts-ds
|
||||
|
|
|
@ -73,9 +73,16 @@
|
|||
:handler (fn []
|
||||
(dispatch [:show-profile navigator]))}]
|
||||
[menu-item {:name "Settings"
|
||||
:handler (fn [])}]
|
||||
:handler (fn []
|
||||
;; TODO not implemented
|
||||
)}]
|
||||
[menu-item {:name "Contacts"
|
||||
:handler (fn []
|
||||
(dispatch [:show-contacts navigator]))}]
|
||||
[menu-item {:name "Invite friends"
|
||||
:handler (fn [])}]
|
||||
:handler (fn []
|
||||
;; TODO not implemented
|
||||
)}]
|
||||
[menu-item {:name "FAQ"
|
||||
:handler (fn [])}]]
|
||||
[view {:style {:paddingVertical 36
|
||||
|
|
|
@ -77,7 +77,9 @@
|
|||
:color text1-color}}
|
||||
value]]])
|
||||
|
||||
(defn profile [{:keys [navigator]} {:keys [name status phone-number email]}]
|
||||
(defn profile [{:keys [navigator]}]
|
||||
(let [contact (subscribe [:contact])]
|
||||
(fn [{:keys [navigator]}]
|
||||
[scroll-view {:style {:flex 1
|
||||
:backgroundColor color-white
|
||||
:flexDirection :column}}
|
||||
|
@ -103,14 +105,14 @@
|
|||
:fontSize 18
|
||||
:fontFamily font
|
||||
:color text1-color}}
|
||||
name]
|
||||
(:name @contact)]
|
||||
[text {:style {:marginTop 10
|
||||
:fontFamily font
|
||||
:fontSize 14
|
||||
:lineHeight 20
|
||||
:textAlign :center
|
||||
:color text2-color}}
|
||||
status]
|
||||
"!not implemented"]
|
||||
[view {:style {:marginTop 18
|
||||
:flexDirection :row}}
|
||||
[touchable-highlight {:onPress (fn []
|
||||
|
@ -147,11 +149,11 @@
|
|||
:alignItems :stretch
|
||||
:flexDirection :column}}
|
||||
[profile-property-view {:name "Username"
|
||||
:value name}]
|
||||
:value (:name @contact)}]
|
||||
[profile-property-view {:name "Phone number"
|
||||
:value phone-number}]
|
||||
:value (:phone-number @contact)}]
|
||||
[profile-property-view {:name "Email"
|
||||
:value email}]
|
||||
:value "!not implemented"}]
|
||||
[view {:style {:marginTop 50
|
||||
:marginBottom 43
|
||||
:alignItems :center}}
|
||||
|
@ -162,4 +164,4 @@
|
|||
:color text2-color
|
||||
;; IOS:
|
||||
:letterSpacing 0.5}}
|
||||
"REPORT USER"]]]]])
|
||||
"REPORT USER"]]]]])))
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
(def protocol-initialized-path [:protocol-initialized])
|
||||
(def identity-password-path [:identity-password])
|
||||
(def contact-identity-path [:contact-identity])
|
||||
(def current-chat-id-path [:chat :current-chat-id])
|
||||
(def updated-chats-signal-path [:chats-updated-signal])
|
||||
(defn updated-chat-signal-path [chat-id]
|
||||
|
|
|
@ -382,18 +382,21 @@
|
|||
(fn [db [_ value]]
|
||||
(contacts/load-syng-contacts db)))
|
||||
|
||||
;; -- Chats --------------------------------------------------------------
|
||||
|
||||
(register-handler :show-profile
|
||||
(fn [db [action navigator]]
|
||||
(fn [db [action navigator identity]]
|
||||
(log/debug action)
|
||||
(nav-push navigator {:view-id :profile})
|
||||
db))
|
||||
(let [db (contacts/set-contact-identity db identity)]
|
||||
(dispatch [:navigate-to navigator {:view-id :profile} :push])
|
||||
db)))
|
||||
|
||||
;; -- Chats --------------------------------------------------------------
|
||||
|
||||
(register-handler :show-chat
|
||||
(fn [db [action chat-id navigator nav-type]]
|
||||
(log/debug action "chat-id" chat-id)
|
||||
(let [db (set-current-chat-id db chat-id)]
|
||||
(let [db (-> db
|
||||
(create-chat chat-id [chat-id] false)
|
||||
(set-current-chat-id chat-id))]
|
||||
(dispatch [:navigate-to navigator {:view-id :chat} nav-type])
|
||||
db)))
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
(ns syng-im.models.contacts
|
||||
(:require [cljs.core.async :as async :refer [chan put! <! >!]]
|
||||
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
||||
[syng-im.db :as db]
|
||||
[syng-im.utils.utils :refer [log toast]]
|
||||
[syng-im.persistence.realm :as realm]
|
||||
[syng-im.persistence.realm :as r]
|
||||
|
@ -108,6 +109,14 @@
|
|||
(defn contact-by-identity [identity]
|
||||
(r/single-cljs (r/get-by-field :contacts :whisper-identity identity)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;----------------------------------------------
|
||||
|
||||
(defn set-contact-identity [db contact-id]
|
||||
(assoc-in db db/contact-identity-path contact-id))
|
||||
|
||||
(defn contact-identity [db]
|
||||
(get-in db db/contact-identity-path))
|
||||
|
||||
(comment
|
||||
|
||||
(r/write #(create-contact {:phone-number "0543072333"
|
||||
|
|
|
@ -10,7 +10,9 @@
|
|||
[syng-im.models.messages :refer [get-messages]]
|
||||
[syng-im.models.contacts :refer [contacts-list
|
||||
contacts-list-exclude
|
||||
contacts-list-include]]
|
||||
contacts-list-include
|
||||
contact-identity
|
||||
contact-by-identity]]
|
||||
[syng-im.models.commands :refer [get-commands
|
||||
get-chat-command
|
||||
get-chat-command-content
|
||||
|
@ -125,6 +127,11 @@
|
|||
(reaction
|
||||
(contacts-list))))
|
||||
|
||||
(register-sub :contact
|
||||
(fn [db _]
|
||||
(let [identity (reaction (get-in @db db/contact-identity-path))]
|
||||
(reaction (contact-by-identity @identity)))))
|
||||
|
||||
(register-sub :all-new-contacts
|
||||
(fn [db _]
|
||||
(let [current-chat-id (reaction (current-chat-id @db))
|
||||
|
|
Loading…
Reference in New Issue