Show contact profile from chat menu. Fix chat creation.
This commit is contained in:
parent
9ec8f70cfe
commit
e4e9bcfc1a
|
@ -57,14 +57,7 @@
|
||||||
:new-group (r/as-element [new-group {:navigator nav}])
|
:new-group (r/as-element [new-group {:navigator nav}])
|
||||||
:contact-list (r/as-element [contact-list {:navigator nav}])
|
:contact-list (r/as-element [contact-list {:navigator nav}])
|
||||||
:chat (r/as-element [chat {:navigator nav}])
|
:chat (r/as-element [chat {:navigator nav}])
|
||||||
;; TODO pass profile
|
:profile (r/as-element [profile {:navigator nav}])))
|
||||||
: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"}])))
|
|
||||||
(r/as-element [chat {:navigator nav}]))))}]))))
|
(r/as-element [chat {:navigator nav}]))))}]))))
|
||||||
|
|
||||||
(defn init []
|
(defn init []
|
||||||
|
|
|
@ -128,8 +128,7 @@
|
||||||
subtitle])]]])
|
subtitle])]]])
|
||||||
|
|
||||||
(defn actions-list-view [navigator chat]
|
(defn actions-list-view [navigator chat]
|
||||||
(when-let [actions (when (and (:group-chat chat)
|
(when-let [actions (if (:group-chat chat)
|
||||||
(:is-active chat))
|
|
||||||
[{:title "Add Contact to chat"
|
[{:title "Add Contact to chat"
|
||||||
:icon "icon_menu_group"
|
:icon "icon_menu_group"
|
||||||
:icon-style {:width 25
|
:icon-style {:width 25
|
||||||
|
@ -151,7 +150,12 @@
|
||||||
:icon "icon_settings"
|
:icon "icon_settings"
|
||||||
:icon-style {:width 20
|
:icon-style {:width 20
|
||||||
:height 13}
|
: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
|
[view {:style {:backgroundColor toolbar-background1
|
||||||
:elevation 2
|
:elevation 2
|
||||||
:position "absolute"
|
:position "absolute"
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
(ns syng-im.components.contact-list.contact
|
(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.resources :as res]
|
||||||
[syng-im.navigation :as nav]
|
|
||||||
[syng-im.components.contact-list.contact-inner :refer [contact-inner-view]]))
|
[syng-im.components.contact-list.contact-inner :refer [contact-inner-view]]))
|
||||||
|
|
||||||
(defn show-chat [navigator whisper-identity]
|
(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]}]
|
(defn contact-view [{:keys [navigator contact]}]
|
||||||
(let [{:keys [whisper-identity]} contact]
|
(let [{:keys [whisper-identity]} contact]
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
(fn []
|
(fn []
|
||||||
(let [contacts-ds (get-data-source @contacts)]
|
(let [contacts-ds (get-data-source @contacts)]
|
||||||
[view {:style {:flex 1
|
[view {:style {:flex 1
|
||||||
:backgroundColor "white"}}
|
:backgroundColor color-white}}
|
||||||
[contact-list-toolbar navigator]
|
[contact-list-toolbar navigator]
|
||||||
(when contacts-ds
|
(when contacts-ds
|
||||||
[list-view {:dataSource contacts-ds
|
[list-view {:dataSource contacts-ds
|
||||||
|
|
|
@ -73,9 +73,16 @@
|
||||||
:handler (fn []
|
:handler (fn []
|
||||||
(dispatch [:show-profile navigator]))}]
|
(dispatch [:show-profile navigator]))}]
|
||||||
[menu-item {:name "Settings"
|
[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"
|
[menu-item {:name "Invite friends"
|
||||||
:handler (fn [])}]
|
:handler (fn []
|
||||||
|
;; TODO not implemented
|
||||||
|
)}]
|
||||||
[menu-item {:name "FAQ"
|
[menu-item {:name "FAQ"
|
||||||
:handler (fn [])}]]
|
:handler (fn [])}]]
|
||||||
[view {:style {:paddingVertical 36
|
[view {:style {:paddingVertical 36
|
||||||
|
|
|
@ -77,89 +77,91 @@
|
||||||
:color text1-color}}
|
:color text1-color}}
|
||||||
value]]])
|
value]]])
|
||||||
|
|
||||||
(defn profile [{:keys [navigator]} {:keys [name status phone-number email]}]
|
(defn profile [{:keys [navigator]}]
|
||||||
[scroll-view {:style {:flex 1
|
(let [contact (subscribe [:contact])]
|
||||||
:backgroundColor color-white
|
(fn [{:keys [navigator]}]
|
||||||
:flexDirection :column}}
|
[scroll-view {:style {:flex 1
|
||||||
[touchable-highlight {:style {:position :absolute}
|
:backgroundColor color-white
|
||||||
:on-press (fn []
|
:flexDirection :column}}
|
||||||
(nav-pop navigator))
|
[touchable-highlight {:style {:position :absolute}
|
||||||
:underlay-color :transparent}
|
:on-press (fn []
|
||||||
[view {:width 56
|
(nav-pop navigator))
|
||||||
:height 56}
|
:underlay-color :transparent}
|
||||||
[image {:source {:uri "icon_back"}
|
[view {:width 56
|
||||||
:style {:marginTop 21
|
:height 56}
|
||||||
:marginLeft 23
|
[image {:source {:uri "icon_back"}
|
||||||
:width 8
|
:style {:marginTop 21
|
||||||
:height 14}}]]]
|
:marginLeft 23
|
||||||
|
:width 8
|
||||||
|
:height 14}}]]]
|
||||||
|
|
||||||
[view {:style {:alignSelf :center
|
[view {:style {:alignSelf :center
|
||||||
:alignItems :center
|
:alignItems :center
|
||||||
:width 249}}
|
:width 249}}
|
||||||
[view {:marginTop 26}
|
[view {:marginTop 26}
|
||||||
[user-photo {}]
|
[user-photo {}]
|
||||||
[user-online {:online true}]]
|
[user-online {:online true}]]
|
||||||
[text {:style {:marginTop 20
|
[text {:style {:marginTop 20
|
||||||
:fontSize 18
|
:fontSize 18
|
||||||
:fontFamily font
|
:fontFamily font
|
||||||
:color text1-color}}
|
:color text1-color}}
|
||||||
name]
|
(:name @contact)]
|
||||||
[text {:style {:marginTop 10
|
[text {:style {:marginTop 10
|
||||||
:fontFamily font
|
:fontFamily font
|
||||||
:fontSize 14
|
:fontSize 14
|
||||||
:lineHeight 20
|
:lineHeight 20
|
||||||
:textAlign :center
|
:textAlign :center
|
||||||
:color text2-color}}
|
:color text2-color}}
|
||||||
status]
|
"!not implemented"]
|
||||||
[view {:style {:marginTop 18
|
[view {:style {:marginTop 18
|
||||||
:flexDirection :row}}
|
:flexDirection :row}}
|
||||||
[touchable-highlight {:onPress (fn []
|
[touchable-highlight {:onPress (fn []
|
||||||
;; TODO not implemented
|
;; TODO not implemented
|
||||||
)
|
)
|
||||||
:underlay-color :transparent}
|
:underlay-color :transparent}
|
||||||
[view {:style {:height 40
|
[view {:style {:height 40
|
||||||
:justifyContent :center
|
:justifyContent :center
|
||||||
:backgroundColor color-blue
|
:backgroundColor color-blue
|
||||||
:paddingLeft 25
|
:paddingLeft 25
|
||||||
:paddingRight 25
|
:paddingRight 25
|
||||||
:borderRadius 50}}
|
:borderRadius 50}}
|
||||||
[text {:style {:marginTop -2.5
|
[text {:style {:marginTop -2.5
|
||||||
:fontSize 14
|
:fontSize 14
|
||||||
:fontFamily font
|
:fontFamily font
|
||||||
:color color-white}}
|
:color color-white}}
|
||||||
"Message"]]]
|
"Message"]]]
|
||||||
[touchable-highlight {:onPress (fn []
|
[touchable-highlight {:onPress (fn []
|
||||||
;; TODO not implemented
|
;; TODO not implemented
|
||||||
)
|
)
|
||||||
:underlay-color :transparent}
|
:underlay-color :transparent}
|
||||||
[view {:style {:marginLeft 10
|
[view {:style {:marginLeft 10
|
||||||
:width 40
|
:width 40
|
||||||
:height 40
|
:height 40
|
||||||
:alignItems :center
|
:alignItems :center
|
||||||
:justifyContent :center
|
:justifyContent :center
|
||||||
:backgroundColor color-blue-transparent
|
:backgroundColor color-blue-transparent
|
||||||
:padding 8
|
:padding 8
|
||||||
:borderRadius 50}}
|
:borderRadius 50}}
|
||||||
[image {:source {:uri "icon_more_vertical_blue"}
|
[image {:source {:uri "icon_more_vertical_blue"}
|
||||||
:style {:width 4
|
:style {:width 4
|
||||||
:height 16}}]]]]]
|
:height 16}}]]]]]
|
||||||
[view {:style {:marginTop 20
|
[view {:style {:marginTop 20
|
||||||
:alignItems :stretch
|
:alignItems :stretch
|
||||||
:flexDirection :column}}
|
:flexDirection :column}}
|
||||||
[profile-property-view {:name "Username"
|
[profile-property-view {:name "Username"
|
||||||
:value name}]
|
:value (:name @contact)}]
|
||||||
[profile-property-view {:name "Phone number"
|
[profile-property-view {:name "Phone number"
|
||||||
:value phone-number}]
|
:value (:phone-number @contact)}]
|
||||||
[profile-property-view {:name "Email"
|
[profile-property-view {:name "Email"
|
||||||
:value email}]
|
:value "!not implemented"}]
|
||||||
[view {:style {:marginTop 50
|
[view {:style {:marginTop 50
|
||||||
:marginBottom 43
|
:marginBottom 43
|
||||||
:alignItems :center}}
|
:alignItems :center}}
|
||||||
[touchable-opacity {}
|
[touchable-opacity {}
|
||||||
[text {:style {:fontSize 14
|
[text {:style {:fontSize 14
|
||||||
:fontFamily font
|
:fontFamily font
|
||||||
:lineHeight 21
|
:lineHeight 21
|
||||||
:color text2-color
|
:color text2-color
|
||||||
;; IOS:
|
;; IOS:
|
||||||
:letterSpacing 0.5}}
|
:letterSpacing 0.5}}
|
||||||
"REPORT USER"]]]]])
|
"REPORT USER"]]]]])))
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
(def protocol-initialized-path [:protocol-initialized])
|
(def protocol-initialized-path [:protocol-initialized])
|
||||||
(def identity-password-path [:identity-password])
|
(def identity-password-path [:identity-password])
|
||||||
|
(def contact-identity-path [:contact-identity])
|
||||||
(def current-chat-id-path [:chat :current-chat-id])
|
(def current-chat-id-path [:chat :current-chat-id])
|
||||||
(def updated-chats-signal-path [:chats-updated-signal])
|
(def updated-chats-signal-path [:chats-updated-signal])
|
||||||
(defn updated-chat-signal-path [chat-id]
|
(defn updated-chat-signal-path [chat-id]
|
||||||
|
|
|
@ -382,18 +382,21 @@
|
||||||
(fn [db [_ value]]
|
(fn [db [_ value]]
|
||||||
(contacts/load-syng-contacts db)))
|
(contacts/load-syng-contacts db)))
|
||||||
|
|
||||||
;; -- Chats --------------------------------------------------------------
|
|
||||||
|
|
||||||
(register-handler :show-profile
|
(register-handler :show-profile
|
||||||
(fn [db [action navigator]]
|
(fn [db [action navigator identity]]
|
||||||
(log/debug action)
|
(log/debug action)
|
||||||
(nav-push navigator {:view-id :profile})
|
(let [db (contacts/set-contact-identity db identity)]
|
||||||
db))
|
(dispatch [:navigate-to navigator {:view-id :profile} :push])
|
||||||
|
db)))
|
||||||
|
|
||||||
|
;; -- Chats --------------------------------------------------------------
|
||||||
|
|
||||||
(register-handler :show-chat
|
(register-handler :show-chat
|
||||||
(fn [db [action chat-id navigator nav-type]]
|
(fn [db [action chat-id navigator nav-type]]
|
||||||
(log/debug action "chat-id" chat-id)
|
(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])
|
(dispatch [:navigate-to navigator {:view-id :chat} nav-type])
|
||||||
db)))
|
db)))
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
(ns syng-im.models.contacts
|
(ns syng-im.models.contacts
|
||||||
(:require [cljs.core.async :as async :refer [chan put! <! >!]]
|
(:require [cljs.core.async :as async :refer [chan put! <! >!]]
|
||||||
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
||||||
|
[syng-im.db :as db]
|
||||||
[syng-im.utils.utils :refer [log toast]]
|
[syng-im.utils.utils :refer [log toast]]
|
||||||
[syng-im.persistence.realm :as realm]
|
[syng-im.persistence.realm :as realm]
|
||||||
[syng-im.persistence.realm :as r]
|
[syng-im.persistence.realm :as r]
|
||||||
|
@ -108,6 +109,14 @@
|
||||||
(defn contact-by-identity [identity]
|
(defn contact-by-identity [identity]
|
||||||
(r/single-cljs (r/get-by-field :contacts :whisper-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
|
(comment
|
||||||
|
|
||||||
(r/write #(create-contact {:phone-number "0543072333"
|
(r/write #(create-contact {:phone-number "0543072333"
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
[syng-im.models.messages :refer [get-messages]]
|
[syng-im.models.messages :refer [get-messages]]
|
||||||
[syng-im.models.contacts :refer [contacts-list
|
[syng-im.models.contacts :refer [contacts-list
|
||||||
contacts-list-exclude
|
contacts-list-exclude
|
||||||
contacts-list-include]]
|
contacts-list-include
|
||||||
|
contact-identity
|
||||||
|
contact-by-identity]]
|
||||||
[syng-im.models.commands :refer [get-commands
|
[syng-im.models.commands :refer [get-commands
|
||||||
get-chat-command
|
get-chat-command
|
||||||
get-chat-command-content
|
get-chat-command-content
|
||||||
|
@ -125,6 +127,11 @@
|
||||||
(reaction
|
(reaction
|
||||||
(contacts-list))))
|
(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
|
(register-sub :all-new-contacts
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(let [current-chat-id (reaction (current-chat-id @db))
|
(let [current-chat-id (reaction (current-chat-id @db))
|
||||||
|
|
Loading…
Reference in New Issue