1
1
(ns status-im.ui.components.tabbar.core
2
- (:require [oops.core :refer [oget]]
3
- [quo.gesture-handler :as gesture-handler]
4
- [re-frame.core :as re-frame]
5
- [reagent.core :as reagent]
6
- [cljs-bean.core :refer [bean]]
7
- [status-im.i18n.i18n :as i18n]
8
- [quo.components.safe-area :as safe-area]
9
- [status-im.ui.screens.routing.core :as navigation]
10
- [quo.animated :as animated]
11
- [quo.react-native :as rn]
12
- [status-im.ui.components.badge :as badge]
13
- [status-im.ui.components.icons.icons :as icons]
14
- [status-im.ui.components.react :as react]
15
- [status-im.ui.components.tabbar.styles :as tabs.styles]
16
- [status-im.utils.platform :as platform]))
2
+ (:require [re-frame.core :as re-frame]))
17
3
18
- (defn main -tab? [view-id ]
19
- (contains?
20
- #{ :chat-stack :browser-stack :wallet-stack :profile-stack :status-stack
21
- :status :home :wallet :empty -tab :my-profile :wallet-onboarding-setup }
22
- view-id ))
4
+ (defn chat -tab [ ]
5
+ (let [count-subscription @( re-frame/subscribe [ :chats/unread-messages-number ])]
6
+ ( println " CHAT TAB " count-subscription)
7
+ ( re-frame/dispatch [ :change -tab-count :chat count-subscription])
8
+ nil ))
23
9
24
- (def tabs-list-data
25
- (->>
26
- [{:nav-stack :chat-stack
27
- :content {:title (i18n/label :t/chat )
28
- :icon :main-icons/message }
29
- :count-subscription :chats/unread-messages-number
30
- :accessibility-label :home-tab-button }
31
- {:nav-stack :browser-stack
32
- :content {:title (i18n/label :t/browser )
33
- :icon :main-icons/browser }
34
- :accessibility-label :dapp-tab-button }
35
- {:nav-stack :wallet-stack
36
- :content {:title (i18n/label :t/wallet )
37
- :icon :main-icons/wallet }
38
- :accessibility-label :wallet-tab-button }
39
- {:nav-stack :status-stack
40
- :content {:title (i18n/label :t/status )
41
- :icon :main-icons/status }
42
- :accessibility-label :status-tab-button }
43
- {:nav-stack :profile-stack
44
- :content {:title (i18n/label :t/profile )
45
- :icon :main-icons/user-profile }
46
- :count-subscription :get-profile-unread-messages-number
47
- :accessibility-label :profile-tab-button }]
48
- (remove nil?)
49
- (map-indexed vector)))
10
+ (defn profile-tab []
11
+ (let [count-subscription @(re-frame/subscribe [:get-profile-unread-messages-number ])]
12
+ (println " PROFILE TAB" count-subscription)
13
+ (re-frame/dispatch [:change-tab-count :profile count-subscription])
14
+ nil ))
50
15
51
- (defn tab []
52
- (fn [{:keys [icon label active? nav-stack on-press
53
- accessibility-label count-subscription]}]
54
- (let [count (when count-subscription @(re-frame/subscribe [count-subscription]))]
55
- [react/view {:style tabs.styles/touchable-container}
56
- [gesture-handler/touchable-without-feedback
57
- {:style {:height " 100%"
58
- :width " 100%" }
59
- :on-press on-press
60
- :accessibility-label accessibility-label}
61
- [react/view {:style tabs.styles/tab-container}
62
- [react/view {:style tabs.styles/icon-container}
63
- [icons/icon icon (tabs.styles/icon active?)]
64
- (when count
65
- (cond
66
- (or (pos? count) (pos? (:other count)))
67
- [react/view {:style (if (= nav-stack :chat-stack )
68
- tabs.styles/message-counter
69
- tabs.styles/counter)}
70
- [badge/message-counter (or (:other count) count) true ]]
71
- (pos? (:public count))
72
- [react/view {:style (tabs.styles/counter-public-container )}
73
- [react/view {:style tabs.styles/counter-public
74
- :accessibility-label :public-unread-badge }]]))]
75
- [react/view {:style tabs.styles/tab-title-container}
76
- [react/text {:style (tabs.styles/tab-title active?)}
77
- label]]]]])))
78
-
79
- (def tabs
80
- (reagent/adapt-react-class
81
- (fn [props]
82
- (let [{:keys [navigate index route popToTop]} (bean props)
83
- {:keys [keyboard-shown]
84
- :or {keyboard-shown false }} (when platform/android? (rn/use-keyboard ))
85
- {:keys [bottom]} (safe-area/use-safe-area )
86
- animated-visible (animated/use-timing-transition
87
- (main-tab? (keyword route))
88
- {:duration 150 })
89
- keyboard-visible (animated/use-timing-transition
90
- keyboard-shown
91
- {:duration 200 })]
92
- (reagent/as-element
93
- [animated/view {:style (tabs.styles/tabs-wrapper keyboard-shown keyboard-visible)
94
- :pointer-events (if keyboard-shown " none" " auto" )}
95
- [animated/view {:style (tabs.styles/space-handler bottom)
96
- :pointer-events " none" }]
97
- [animated/view {:style (tabs.styles/animated-container animated-visible bottom)}
98
- (for [[route-index
99
- {:keys [nav-stack accessibility-label count-subscription content]}]
100
- tabs-list-data
101
- :let [{:keys [icon title]} content]]
102
- ^{:key nav-stack}
103
- [tab
104
- {:icon icon
105
- :label title
106
- :on-press #(if (= (str index) (str route-index))
107
- (popToTop )
108
- (navigate (name nav-stack)))
109
- :accessibility-label accessibility-label
110
- :count-subscription count-subscription
111
- :active? (= (str index) (str route-index))
112
- :nav-stack nav-stack}])]
113
- [react/view
114
- {:style (tabs.styles/ios-titles-cover bottom)}]])))))
115
-
116
- (defn tabbar [props]
117
- (let [navigate (oget props " navigation" " navigate" )
118
- pop-to-top (oget props " navigation" " popToTop" )
119
- state (bean (oget props " state" ))
120
- index (get state :index )]
121
- (reagent/as-element
122
- [tabs {:navigate navigate
123
- :state (oget props " state" )
124
- :popToTop pop-to-top
125
- :route (navigation/get-active-route-name state)
126
- :index index}])))
16
+ (defn tabs-counts-subscriptions []
17
+ [:<>
18
+ [chat-tab]
19
+ [profile-tab]])
0 commit comments