|
34 | 34 |
|
35 | 35 | (defn screen-title
|
36 | 36 | []
|
37 |
| - [rn/view |
38 |
| - {:style (style/screen-title-container (safe-area/get-top))} |
| 37 | + [rn/view {:style (style/screen-title-container (safe-area/get-top))} |
39 | 38 | [quo/text
|
40 | 39 | {:accessibility-label :communities-screen-title
|
41 | 40 | :weight :semi-bold
|
|
95 | 94 |
|
96 | 95 | (defn featured-list
|
97 | 96 | [communities view-type]
|
98 |
| - (let [view-size (reagent/atom 0) |
99 |
| - loaded? (and communities (pos? (count communities)))] |
| 97 | + (let [view-size (reagent/atom 0) |
| 98 | + set-view-size (fn [e] |
| 99 | + (reset! view-size (- (oops/oget e "nativeEvent.layout.width") 40))) |
| 100 | + loaded? (and communities (pos? (count communities)))] |
100 | 101 | (fn []
|
101 | 102 | [rn/view
|
102 | 103 | {:style style/featured-list-container
|
103 |
| - :on-layout #(swap! view-size |
104 |
| - (fn [_] |
105 |
| - (- (oops/oget % "nativeEvent.layout.width") 40)))} |
| 104 | + :on-layout set-view-size} |
106 | 105 | (when-not (= @view-size 0)
|
107 | 106 | [rn/flat-list
|
108 | 107 | {:key-fn :id
|
|
132 | 131 | [discover-communities-segments selected-tab false]])
|
133 | 132 |
|
134 | 133 | (defn other-communities-list
|
135 |
| - [{:keys [communities communities-ids view-type]}] |
| 134 | + [{:keys [communities view-type]}] |
136 | 135 | [rn/view {:style style/other-communities-container}
|
137 |
| - (if (and communities (pos? (count communities))) |
138 |
| - (map-indexed |
139 |
| - (fn [inner-index item] |
140 |
| - (let [community-id (when communities-ids item) |
141 |
| - community (if communities |
142 |
| - item |
143 |
| - (rf/sub [:communities/home-item community-id])) |
144 |
| - cover {:uri (get-in (:images item) [:banner :uri])}] |
145 |
| - [rn/view |
146 |
| - {:key (str inner-index (:id community)) |
147 |
| - :margin-bottom 16} |
148 |
| - (if (= view-type :card-view) |
149 |
| - [quo/community-card-view-item |
150 |
| - {:community (assoc community :cover cover) |
151 |
| - :on-press #(rf/dispatch [:communities/navigate-to-community-overview (:id community)])}] |
152 |
| - |
153 |
| - [quo/community-list |
154 |
| - {:on-press (fn [] |
155 |
| - (rf/dispatch [:dismiss-keyboard]) |
156 |
| - (rf/dispatch [:communities/navigate-to-community-overview |
157 |
| - (:id community)])) |
158 |
| - :on-long-press #(js/alert "TODO: to be implemented")} |
159 |
| - community])])) |
160 |
| - (if communities communities communities-ids)) |
| 136 | + (if (seq communities) |
| 137 | + (map-indexed (fn [inner-index {community-id :id :as community}] |
| 138 | + (let [cover {:uri (-> community :images :banner :uri)}] |
| 139 | + [rn/view |
| 140 | + {:key (str inner-index community-id) |
| 141 | + :style {:margin-bottom 16}} |
| 142 | + (if (= view-type :card-view) |
| 143 | + [quo/community-card-view-item |
| 144 | + {:community (assoc community :cover cover |
| 145 | + :members-count (count (:members community))) |
| 146 | + :on-press #(rf/dispatch [:communities/navigate-to-community-overview community-id])}] |
| 147 | + [quo/community-list |
| 148 | + {:on-press (fn [] |
| 149 | + (rf/dispatch [:dismiss-keyboard]) |
| 150 | + (rf/dispatch [:communities/navigate-to-community-overview |
| 151 | + community-id])) |
| 152 | + :on-long-press #(js/alert "TODO: to be implemented")} |
| 153 | + community])])) |
| 154 | + communities) |
161 | 155 | [:<>
|
162 | 156 | [rn/view {:margin-bottom 16} [quo/community-card-view-item {:loading? true}]]
|
163 | 157 | [rn/view {:margin-bottom 16} [quo/community-card-view-item {:loading? true}]]
|
|
168 | 162 | [rn/view {:style {:flex 1}}
|
169 | 163 | (case @selected-tab
|
170 | 164 | :all
|
171 |
| - (other-communities-list {:communities (rf/sub [:communities/other-contract-communities]) |
172 |
| - :view-type view-type}) |
| 165 | + [other-communities-list {:communities (rf/sub [:communities/other-contract-communities]) |
| 166 | + :view-type view-type}] |
173 | 167 |
|
174 | 168 | :open
|
175 | 169 | [:<>]
|
|
183 | 177 | (i18n/label :t/error)])])
|
184 | 178 |
|
185 | 179 | (defn render-communities
|
186 |
| - [selected-tab |
187 |
| - featured-communities-count |
188 |
| - featured-communities |
189 |
| - view-type] |
190 |
| - (fn [] |
191 |
| - [rn/view |
192 |
| - [discover-communities-header |
193 |
| - {:selected-tab selected-tab |
194 |
| - :view-type view-type |
195 |
| - :featured-communities-count featured-communities-count |
196 |
| - :featured-communities featured-communities}] |
197 |
| - [communities-lists selected-tab view-type]])) |
| 180 | + [{:keys [selected-tab featured-communities-count featured-communities view-type]}] |
| 181 | + [rn/view |
| 182 | + [discover-communities-header |
| 183 | + {:selected-tab selected-tab |
| 184 | + :view-type view-type |
| 185 | + :featured-communities-count featured-communities-count |
| 186 | + :featured-communities featured-communities}] |
| 187 | + [communities-lists selected-tab view-type]]) |
198 | 188 |
|
199 | 189 | (defn render-sticky-header
|
200 | 190 | [{:keys [selected-tab scroll-height]}]
|
201 |
| - (fn [] |
202 |
| - (when (> @scroll-height 360) |
203 |
| - [rn/view |
204 |
| - {:style (style/blur-tabs-header (safe-area/get-top))} |
205 |
| - [discover-communities-segments selected-tab true]]))) |
| 191 | + (when (> @scroll-height 360) |
| 192 | + [rn/view |
| 193 | + {:style (style/blur-tabs-header (safe-area/get-top))} |
| 194 | + [discover-communities-segments selected-tab true]])) |
206 | 195 |
|
207 |
| -(defn discover-screen-content |
208 |
| - [featured-communities theme] |
| 196 | +(defn discover-screen-content [] |
209 | 197 | (let [view-type (reagent/atom :card-view)
|
210 | 198 | selected-tab (reagent/atom :all)
|
211 |
| - scroll-height (reagent/atom 0) |
212 |
| - featured-communities-count (count featured-communities)] |
| 199 | + scroll-height (reagent/atom 0)] |
213 | 200 | (fn []
|
214 |
| - [scroll-page/scroll-page |
215 |
| - {:on-scroll #(reset! scroll-height %) |
216 |
| - :page-nav-props {:background :blur} |
217 |
| - :navigate-back? :true |
218 |
| - :height (if (> @scroll-height 360) |
219 |
| - 208 |
220 |
| - 148) |
221 |
| - :background-color (colors/theme-colors colors/white colors/neutral-95 theme) |
222 |
| - :sticky-header [render-sticky-header |
223 |
| - {:selected-tab selected-tab |
224 |
| - :scroll-height scroll-height}]} |
225 |
| - |
226 |
| - [render-communities |
227 |
| - selected-tab |
228 |
| - featured-communities-count |
229 |
| - featured-communities |
230 |
| - @view-type]]))) |
| 201 | + (let [theme (quo.theme/use-theme) |
| 202 | + featured-communities (rf/sub [:communities/featured-contract-communities]) |
| 203 | + featured-communities-count (count featured-communities)] |
| 204 | + [scroll-page/scroll-page |
| 205 | + {:on-scroll #(reset! scroll-height %) |
| 206 | + :page-nav-props {:background :blur} |
| 207 | + :navigate-back? :true |
| 208 | + :height (if (> @scroll-height 360) |
| 209 | + 208 |
| 210 | + 148) |
| 211 | + :background-color (colors/theme-colors colors/white colors/neutral-95 theme) |
| 212 | + :sticky-header [render-sticky-header |
| 213 | + {:selected-tab selected-tab |
| 214 | + :scroll-height scroll-height}]} |
| 215 | + [render-communities |
| 216 | + {:selected-tab selected-tab |
| 217 | + :featured-communities-count featured-communities-count |
| 218 | + :featured-communities featured-communities |
| 219 | + :view-type @view-type}]])))) |
231 | 220 |
|
232 | 221 | (defn view
|
233 | 222 | []
|
234 |
| - (let [theme (quo.theme/use-theme) |
235 |
| - featured-communities (rf/sub [:communities/featured-contract-communities])] |
| 223 | + (let [theme (quo.theme/use-theme)] |
236 | 224 | (rn/use-mount #(rf/dispatch [:fetch-contract-communities]))
|
237 |
| - [rn/view |
238 |
| - {:style (style/discover-screen-container (colors/theme-colors |
239 |
| - colors/white |
240 |
| - colors/neutral-95 |
241 |
| - theme))} |
242 |
| - [discover-screen-content featured-communities theme]])) |
| 225 | + [rn/view {:style (style/discover-screen-container (colors/theme-colors |
| 226 | + colors/white |
| 227 | + colors/neutral-95 |
| 228 | + theme))} |
| 229 | + [discover-screen-content]])) |
0 commit comments