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
|
||||||
[view {:style {:alignSelf :center
|
:height 14}}]]]
|
||||||
:alignItems :center
|
|
||||||
:width 249}}
|
[view {:style {:alignSelf :center
|
||||||
[view {:marginTop 26}
|
:alignItems :center
|
||||||
[user-photo {}]
|
:width 249}}
|
||||||
[user-online {:online true}]]
|
[view {:marginTop 26}
|
||||||
[text {:style {:marginTop 20
|
[user-photo {}]
|
||||||
:fontSize 18
|
[user-online {:online true}]]
|
||||||
:fontFamily font
|
[text {:style {:marginTop 20
|
||||||
:color text1-color}}
|
:fontSize 18
|
||||||
name]
|
:fontFamily font
|
||||||
[text {:style {:marginTop 10
|
:color text1-color}}
|
||||||
:fontFamily font
|
(:name @contact)]
|
||||||
:fontSize 14
|
[text {:style {:marginTop 10
|
||||||
:lineHeight 20
|
:fontFamily font
|
||||||
:textAlign :center
|
:fontSize 14
|
||||||
:color text2-color}}
|
:lineHeight 20
|
||||||
status]
|
:textAlign :center
|
||||||
[view {:style {:marginTop 18
|
:color text2-color}}
|
||||||
:flexDirection :row}}
|
"!not implemented"]
|
||||||
[touchable-highlight {:onPress (fn []
|
[view {:style {:marginTop 18
|
||||||
;; TODO not implemented
|
:flexDirection :row}}
|
||||||
)
|
[touchable-highlight {:onPress (fn []
|
||||||
:underlay-color :transparent}
|
;; TODO not implemented
|
||||||
[view {:style {:height 40
|
)
|
||||||
:justifyContent :center
|
:underlay-color :transparent}
|
||||||
:backgroundColor color-blue
|
[view {:style {:height 40
|
||||||
:paddingLeft 25
|
:justifyContent :center
|
||||||
:paddingRight 25
|
:backgroundColor color-blue
|
||||||
:borderRadius 50}}
|
:paddingLeft 25
|
||||||
[text {:style {:marginTop -2.5
|
:paddingRight 25
|
||||||
:fontSize 14
|
:borderRadius 50}}
|
||||||
:fontFamily font
|
[text {:style {:marginTop -2.5
|
||||||
:color color-white}}
|
:fontSize 14
|
||||||
"Message"]]]
|
:fontFamily font
|
||||||
[touchable-highlight {:onPress (fn []
|
:color color-white}}
|
||||||
;; TODO not implemented
|
"Message"]]]
|
||||||
)
|
[touchable-highlight {:onPress (fn []
|
||||||
:underlay-color :transparent}
|
;; TODO not implemented
|
||||||
[view {:style {:marginLeft 10
|
)
|
||||||
:width 40
|
:underlay-color :transparent}
|
||||||
:height 40
|
[view {:style {:marginLeft 10
|
||||||
:alignItems :center
|
:width 40
|
||||||
:justifyContent :center
|
:height 40
|
||||||
:backgroundColor color-blue-transparent
|
:alignItems :center
|
||||||
:padding 8
|
:justifyContent :center
|
||||||
:borderRadius 50}}
|
:backgroundColor color-blue-transparent
|
||||||
[image {:source {:uri "icon_more_vertical_blue"}
|
:padding 8
|
||||||
:style {:width 4
|
:borderRadius 50}}
|
||||||
:height 16}}]]]]]
|
[image {:source {:uri "icon_more_vertical_blue"}
|
||||||
[view {:style {:marginTop 20
|
:style {:width 4
|
||||||
:alignItems :stretch
|
:height 16}}]]]]]
|
||||||
:flexDirection :column}}
|
[view {:style {:marginTop 20
|
||||||
[profile-property-view {:name "Username"
|
:alignItems :stretch
|
||||||
:value name}]
|
:flexDirection :column}}
|
||||||
[profile-property-view {:name "Phone number"
|
[profile-property-view {:name "Username"
|
||||||
:value phone-number}]
|
:value (:name @contact)}]
|
||||||
[profile-property-view {:name "Email"
|
[profile-property-view {:name "Phone number"
|
||||||
:value email}]
|
:value (:phone-number @contact)}]
|
||||||
[view {:style {:marginTop 50
|
[profile-property-view {:name "Email"
|
||||||
:marginBottom 43
|
:value "!not implemented"}]
|
||||||
:alignItems :center}}
|
[view {:style {:marginTop 50
|
||||||
[touchable-opacity {}
|
:marginBottom 43
|
||||||
[text {:style {:fontSize 14
|
:alignItems :center}}
|
||||||
:fontFamily font
|
[touchable-opacity {}
|
||||||
:lineHeight 21
|
[text {:style {:fontSize 14
|
||||||
:color text2-color
|
:fontFamily font
|
||||||
;; IOS:
|
:lineHeight 21
|
||||||
:letterSpacing 0.5}}
|
:color text2-color
|
||||||
"REPORT USER"]]]]])
|
;; IOS:
|
||||||
|
:letterSpacing 0.5}}
|
||||||
|
"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