diff --git a/src/syng_im/android/core.cljs b/src/syng_im/android/core.cljs index 0805f7504b..f1bb1815fb 100644 --- a/src/syng_im/android/core.cljs +++ b/src/syng_im/android/core.cljs @@ -14,7 +14,7 @@ [syng-im.new-group.screen :refer [new-group]] [syng-im.participants.views.create :refer [new-participants]] [syng-im.participants.views.remove :refer [remove-participants]] - [syng-im.components.profile :refer [profile my-profile]] + [syng-im.profile.screen :refer [profile my-profile]] [syng-im.utils.utils :refer [toast]] [syng-im.utils.encryption])) diff --git a/src/syng_im/chats_list/screen.cljs b/src/syng_im/chats_list/screen.cljs index f13e07c24c..55c4457540 100644 --- a/src/syng_im/chats_list/screen.cljs +++ b/src/syng_im/chats_list/screen.cljs @@ -11,7 +11,7 @@ [syng-im.chats-list.views.chat-list-item :refer [chat-list-item]] [syng-im.components.action-button :refer [action-button action-button-item]] - [syng-im.components.drawer :refer [drawer-view open-drawer]] + [syng-im.components.drawer.view :refer [drawer-view open-drawer]] [syng-im.components.styles :refer [color-blue]] [syng-im.components.toolbar :refer [toolbar]] [syng-im.components.icons.ionicons :refer [icon]] diff --git a/src/syng_im/components/drawer_styles.cljs b/src/syng_im/components/drawer/styles.cljs similarity index 97% rename from src/syng_im/components/drawer_styles.cljs rename to src/syng_im/components/drawer/styles.cljs index b6ee3c0808..4e26767b26 100644 --- a/src/syng_im/components/drawer_styles.cljs +++ b/src/syng_im/components/drawer/styles.cljs @@ -1,4 +1,4 @@ -(ns syng-im.components.drawer-styles +(ns syng-im.components.drawer.styles (:require [syng-im.components.styles :refer [font color-light-blue-transparent color-white diff --git a/src/syng_im/components/drawer.cljs b/src/syng_im/components/drawer/view.cljs similarity index 97% rename from src/syng_im/components/drawer.cljs rename to src/syng_im/components/drawer/view.cljs index 74d38d8f4e..3c96ce3395 100644 --- a/src/syng_im/components/drawer.cljs +++ b/src/syng_im/components/drawer/view.cljs @@ -1,4 +1,4 @@ -(ns syng-im.components.drawer +(ns syng-im.components.drawer.view (:require [clojure.string :as s] [re-frame.core :refer [subscribe dispatch dispatch-sync]] [reagent.core :as r] @@ -11,7 +11,7 @@ drawer-layout-android touchable-opacity]] [syng-im.resources :as res] - [syng-im.components.drawer-styles :as st])) + [syng-im.components.drawer.styles :as st])) (defonce drawer-atom (atom)) diff --git a/src/syng_im/components/profile.cljs b/src/syng_im/components/profile.cljs deleted file mode 100644 index bec17f16fe..0000000000 --- a/src/syng_im/components/profile.cljs +++ /dev/null @@ -1,109 +0,0 @@ -(ns syng-im.components.profile - (:require [clojure.string :as s] - [re-frame.core :refer [subscribe dispatch dispatch-sync]] - [syng-im.components.react :refer [android? - view - text - text-input - image - icon - scroll-view - touchable-highlight - touchable-opacity]] - [syng-im.resources :as res] - [syng-im.components.profile-styles :as st])) - -(defn user-photo [{:keys [photo-path]}] - [image {:source (if (s/blank? photo-path) - res/user-no-photo - {:uri photo-path}) - :style st/user-photo}]) - -(defn user-online [{:keys [online]}] - (when online - [view st/user-online-container - [view st/user-online-dot-left] - [view st/user-online-dot-right]])) - -(defn profile-property-view [{:keys [name value]}] - [view st/profile-property-view-container - [view st/profile-property-view-sub-container - [text {:style st/profile-property-view-label} - name] - [text {:style st/profile-property-view-value} - value]]]) - -(defn message-user [identity] - (when identity - (dispatch [:show-chat identity nil :push]))) - -(defn profile [] - (let [contact (subscribe [:contact])] - (fn [] - [scroll-view {:style st/profile} - [touchable-highlight {:style st/back-btn-touchable - :on-press #(dispatch [:navigate-back])} - [view st/back-btn-container - [icon :back st/back-btn-icon]]] - [view st/status-block - [view st/user-photo-container - [user-photo {}] - [user-online {:online true}]] - [text {:style st/user-name} - (:name @contact)] - [text {:style st/status} - "!not implemented"] - [view st/btns-container - [touchable-highlight {:onPress #(message-user (:whisper-identity @contact))} - [view st/message-btn - [text {:style st/message-btn-text} - "Message"]]] - [touchable-highlight {:onPress (fn [] - ;; TODO not implemented - )} - [view st/more-btn - [icon :more_vertical_blue st/more-btn-image]]]]] - [view st/profile-properties-container - [profile-property-view {:name "Username" - :value (:name @contact)}] - [profile-property-view {:name "Phone number" - :value (:phone-number @contact)}] - [profile-property-view {:name "Email" - :value "!not implemented"}] - [view st/report-user-container - [touchable-opacity {} - [text {:style st/report-user-text} - "REPORT USER"]]]]]))) - -(defn my-profile [] - (let [username (subscribe [:get :username]) - phone-number (subscribe [:get :phone-number]) - email (subscribe [:get :email]) - status (subscribe [:get :status])] - (fn [] - [scroll-view {:style st/profile} - [touchable-highlight {:style st/back-btn-touchable - :on-press #(dispatch [:navigate-back])} - [view st/back-btn-container - [icon :back st/back-btn-icon]]] - [touchable-highlight {:style st/actions-btn-touchable - :on-press (fn [] - ;; TODO not implemented - )} - [view st/actions-btn-container - [icon :dots st/actions-btn-icon]]] - [view st/status-block - [view st/user-photo-container - [user-photo {}] - [user-online {:online true}]] - [text {:style st/user-name} - @username] - [text {:style st/status} - @status]] - [view st/profile-properties-container - [profile-property-view {:name "Username" - :value @username}] - [profile-property-view {:name "Phone number" - :value @phone-number}] - [profile-property-view {:name "Email" - :value @email}]]]))) diff --git a/src/syng_im/contacts/subs.cljs b/src/syng_im/contacts/subs.cljs index 848b85f7d7..d889f12b60 100644 --- a/src/syng_im/contacts/subs.cljs +++ b/src/syng_im/contacts/subs.cljs @@ -28,7 +28,7 @@ (register-sub :contact (fn [db _] (let [identity (:contact-identity @db)] - (reaction (get-in db [:contacts identity]))))) + (reaction (get-in @db [:contacts identity]))))) (register-sub :all-new-contacts (fn [db _] diff --git a/src/syng_im/navigation/handlers.cljs b/src/syng_im/navigation/handlers.cljs index 404059cf2e..217bd88136 100644 --- a/src/syng_im/navigation/handlers.cljs +++ b/src/syng_im/navigation/handlers.cljs @@ -72,10 +72,11 @@ clear-new-participants))) (register-handler :show-profile - (fn [db [_ identity]] - (let [db (assoc db :contact-identity identity)] - (dispatch [:navigate-to :profile]) - db))) + (debug + (fn [db [_ identity]] + (let [db (assoc db :contact-identity identity)] + (dispatch [:navigate-to :profile]) + db)))) (register-handler :show-my-profile (fn [db _] diff --git a/src/syng_im/profile/screen.cljs b/src/syng_im/profile/screen.cljs new file mode 100644 index 0000000000..9d075c4999 --- /dev/null +++ b/src/syng_im/profile/screen.cljs @@ -0,0 +1,98 @@ +(ns syng-im.profile.screen + (:require-macros [syng-im.utils.views :refer [defview]]) + (:require [clojure.string :as s] + [re-frame.core :refer [subscribe dispatch]] + [syng-im.components.react :refer [view + text + image + icon + scroll-view + touchable-highlight + touchable-opacity]] + [syng-im.resources :as res] + [syng-im.profile.styles :as st])) + +(defn user-photo [{:keys [photo-path]}] + [image {:source (if (s/blank? photo-path) + res/user-no-photo + {:uri photo-path}) + :style st/user-photo}]) + +(defn user-online [{:keys [online]}] + (when online + [view st/user-online-container + [view st/user-online-dot-left] + [view st/user-online-dot-right]])) + +(defn profile-property-view [{:keys [name value]}] + [view st/profile-property-view-container + [view st/profile-property-view-sub-container + [text {:style st/profile-property-view-label} name] + [text {:style st/profile-property-view-value} value]]]) + +(defn message-user [identity] + (when identity + (dispatch [:show-chat identity :push]))) + +(defview profile [] + [{:keys [name whisper-identity phone-number]} [:contact]] + [scroll-view {:style st/profile} + [touchable-highlight {:style st/back-btn-touchable + :on-press #(dispatch [:navigate-back])} + [view st/back-btn-container + [icon :back st/back-btn-icon]]] + [view st/status-block + [view st/user-photo-container + [user-photo {}] + [user-online {:online true}]] + [text {:style st/user-name} name] + [text {:style st/status} "!not implemented"] + [view st/btns-container + [touchable-highlight {:onPress #(message-user whisper-identity)} + [view st/message-btn + [text {:style st/message-btn-text} "Message"]]] + [touchable-highlight {:onPress (fn [] + ;; TODO not implemented + )} + [view st/more-btn + [icon :more_vertical_blue st/more-btn-image]]]]] + [view st/profile-properties-container + [profile-property-view {:name "Username" + :value name}] + [profile-property-view {:name "Phone number" + :value phone-number}] + [profile-property-view {:name "Email" + :value "!not implemented"}] + [view st/report-user-container + [touchable-opacity {} + [text {:style st/report-user-text} "REPORT USER"]]]]]) + +(defview my-profile [] + [username [:get :username] + phone-number [:get :phone-number] + email [:get :email] + status [:get :status]] + [scroll-view {:style st/profile} + [touchable-highlight {:style st/back-btn-touchable + :on-press #(dispatch [:navigate-back])} + [view st/back-btn-container + [icon :back st/back-btn-icon]]] + [touchable-highlight {:style st/actions-btn-touchable + :on-press (fn [] + ;; TODO not implemented + )} + [view st/actions-btn-container + [icon :dots st/actions-btn-icon]]] + [view st/status-block + [view st/user-photo-container + [user-photo {}] + [user-online {:online true}]] + [text {:style st/user-name} username] + [text {:style st/status} status]] + [view st/profile-properties-container + [profile-property-view {:name "Username" + :value username}] + [profile-property-view {:name "Phone number" + :value phone-number}] + [profile-property-view {:name "Email" + :value email}]]]) diff --git a/src/syng_im/components/profile_styles.cljs b/src/syng_im/profile/styles.cljs similarity index 98% rename from src/syng_im/components/profile_styles.cljs rename to src/syng_im/profile/styles.cljs index 347b89c282..545016ca4d 100644 --- a/src/syng_im/components/profile_styles.cljs +++ b/src/syng_im/profile/styles.cljs @@ -1,4 +1,4 @@ -(ns syng-im.components.profile-styles +(ns syng-im.profile.styles (:require [syng-im.components.styles :refer [font color-light-blue-transparent color-white