diff --git a/src/syng_im/chats_list/screen.cljs b/src/syng_im/chats_list/screen.cljs index 55c4457540..023422efe4 100644 --- a/src/syng_im/chats_list/screen.cljs +++ b/src/syng_im/chats_list/screen.cljs @@ -14,6 +14,7 @@ [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.main-tabs :refer [main-tabs]] [syng-im.components.icons.ionicons :refer [icon]] [syng-im.chats-list.styles :as st])) @@ -37,7 +38,9 @@ :renderRow (fn [row _ _] (list-item [chat-list-item row])) :style st/list-container}] - [action-button {:buttonColor color-blue} + [action-button {:buttonColor color-blue + :offsetY 72 + :offsetX 16} [action-button-item {:title "New Chat" :buttonColor :#9b59b6 @@ -49,4 +52,5 @@ :buttonColor :#1abc9c :onPress #(dispatch [:show-group-new])} [icon {:name :person-stalker - :style st/person-stalker-icon}]]]]]))) + :style st/person-stalker-icon}]]] + [main-tabs]]]))) diff --git a/src/syng_im/components/main-tabs.cljs b/src/syng_im/components/main-tabs.cljs index 479ba57511..7116b6a3fe 100644 --- a/src/syng_im/components/main-tabs.cljs +++ b/src/syng_im/components/main-tabs.cljs @@ -1,4 +1,5 @@ (ns syng-im.components.main-tabs + (:require-macros [syng-im.utils.views :refer [defview]]) (:require [re-frame.core :refer [subscribe dispatch dispatch-sync]] [syng-im.components.react :refer [view text-input @@ -8,23 +9,22 @@ [syng-im.components.tabs.tabs :refer [tabs]] [syng-im.utils.logging :as log])) -(defn main-tabs [] - (let [view-id (subscribe [:view-id])] - (fn [] - [tabs {:selected-index (case @view-id - :chat-list 0 - :discovery 1 - :contact-list 2 - 0) - :tab-list [{:handler #(dispatch [:navigate-to - :chat-list]) - :title "Chats" - :icon "icon_tab_chats"} - {:handler #(dispatch [:navigate-to - :discovery]) - :title "Discover" - :icon "icon_tab_discovery"} - {:handler #(dispatch [:navigate-to - :contact-list]) - :title "Contacts" - :icon "icon_tab_contacts"}]}]))) +(defview main-tabs [] + [view-id [:get :view-id]] + [tabs {:selected-index (case view-id + :chat-list 0 + :discovery 1 + :contact-list 2 + 0) + :tab-list [{:handler #(dispatch [:navigate-to + :chat-list]) + :title "Chats" + :icon "icon_tab_chats"} + {:handler #(dispatch [:navigate-to + :discovery]) + :title "Discover" + :icon "icon_tab_discovery"} + {:handler #(dispatch [:navigate-to + :contact-list]) + :title "Contacts" + :icon "icon_tab_contacts"}]}]) diff --git a/src/syng_im/components/tabs/tab.cljs b/src/syng_im/components/tabs/tab.cljs index af9aeab37c..bdc4043a13 100644 --- a/src/syng_im/components/tabs/tab.cljs +++ b/src/syng_im/components/tabs/tab.cljs @@ -1,4 +1,5 @@ (ns syng-im.components.tabs.tab + (:require-macros [syng-im.utils.views :refer [defview]]) (:require [re-frame.core :refer [subscribe dispatch dispatch-sync]] [syng-im.components.react :refer [view text-input @@ -8,13 +9,11 @@ [reagent.core :as r] [syng-im.components.tabs.styles :as st])) -(defn tab [{:keys [handler title icon selected-index index]}] - (fn [{:keys [handler title icon selected-index index]}] - [touchable-highlight {:style st/tab - :onPress #(do (reset! selected-index index) - (handler))} - [view {:style st/tab-container} +(defview tab [{:keys [handler title icon selected-index index]}] + [touchable-highlight {:style st/tab + :onPress handler} + [view {:style st/tab-container} [image {:source {:uri icon} :style st/tab-icon}] - (when (= @selected-index index) - [text {:style st/tab-title} title])]])) + (when (= selected-index index) + [text {:style st/tab-title} title])]]) diff --git a/src/syng_im/components/tabs/tabs.cljs b/src/syng_im/components/tabs/tabs.cljs index d9fd94be55..257cd60260 100644 --- a/src/syng_im/components/tabs/tabs.cljs +++ b/src/syng_im/components/tabs/tabs.cljs @@ -1,4 +1,5 @@ (ns syng-im.components.tabs.tabs + (:require-macros [syng-im.utils.views :refer [defview]]) (:require [re-frame.core :refer [subscribe dispatch dispatch-sync]] [syng-im.components.react :refer [view text-input @@ -10,14 +11,12 @@ [syng-im.components.tabs.tab :refer [tab]])) (defn create-tab [index data selected-index] - (let [data (merge data {:key index - :index index + (let [data (merge data {:key index + :index index :selected-index selected-index})] [tab data])) -(defn tabs [{:keys [style tab-list selected-index]}] - (let [selected-index (r/atom selected-index)] - (fn [{:keys [style tab-list]}] - (let [style (merge st/tabs style)] - [view {:style style} - (doall (map-indexed #(create-tab %1 %2 selected-index) tab-list))])))) +(defview tabs [{:keys [style tab-list selected-index]}] + (let [style (merge st/tabs style)] + [view {:style style} + (doall (map-indexed #(create-tab %1 %2 selected-index) tab-list))])) diff --git a/src/syng_im/contacts/screen.cljs b/src/syng_im/contacts/screen.cljs index 3e16b78380..74f9ec23cf 100644 --- a/src/syng_im/contacts/screen.cljs +++ b/src/syng_im/contacts/screen.cljs @@ -9,6 +9,7 @@ [syng-im.contacts.views.contact :refer [contact-view]] [syng-im.components.styles :refer [toolbar-background2]] [syng-im.components.toolbar :refer [toolbar]] + [syng-im.components.main-tabs :refer [main-tabs]] [syng-im.contacts.styles :as st] [syng-im.utils.listview :as lw])) @@ -32,4 +33,5 @@ [list-view {:dataSource (lw/to-datasource contacts) :enableEmptySections true :renderRow render-row - :style st/contacts-list}])]) + :style st/contacts-list}]) + [main-tabs]]) diff --git a/src/syng_im/discovery/screen.cljs b/src/syng_im/discovery/screen.cljs index 8f51f391ac..c7f4948c1f 100644 --- a/src/syng_im/discovery/screen.cljs +++ b/src/syng_im/discovery/screen.cljs @@ -9,6 +9,7 @@ [syng-im.components.toolbar :refer [toolbar]] [syng-im.discovery.views.popular :refer [popular]] [syng-im.discovery.views.recent :refer [discovery-recent]] + [syng-im.components.main-tabs :refer [main-tabs]] [syng-im.discovery.styles :as st])) (defn get-hashtags [status] @@ -49,4 +50,5 @@ [popular] [view st/section-spacing [text {:style st/discovery-subtitle} "Recent"]] - [discovery-recent]]]) + [discovery-recent]] + [main-tabs]])