|
35 | 35 | :on-press #(rf/dispatch [:show-bottom-sheet {:content new-account}])
|
36 | 36 | :type :add-account})
|
37 | 37 |
|
| 38 | +(def first-tab-id :assets) |
| 39 | + |
38 | 40 | (def tabs-data
|
39 | 41 | [{:id :assets :label (i18n/label :t/assets) :accessibility-label :assets-tab}
|
40 | 42 | {:id :collectibles :label (i18n/label :t/collectibles) :accessibility-label :collectibles-tab}
|
41 | 43 | (when (ff/enabled? ::ff/wallet.home-activity)
|
42 | 44 | {:id :activity :label (i18n/label :t/activity) :accessibility-label :activity-tab})])
|
43 | 45 |
|
| 46 | +(defn- change-tab [id] (rf/dispatch [:wallet/select-home-tab id])) |
| 47 | + |
44 | 48 | (defn- render-cards
|
45 | 49 | [cards ref]
|
46 | 50 | [rn/flat-list
|
|
64 | 68 |
|
65 | 69 | (defn view
|
66 | 70 | []
|
67 |
| - (let [[selected-tab set-selected-tab] (rn/use-state (:id (first tabs-data))) |
68 |
| - account-list-ref (rn/use-ref-atom nil) |
69 |
| - tokens-loading? (rf/sub [:wallet/home-tokens-loading?]) |
70 |
| - networks (rf/sub [:wallet/selected-network-details]) |
71 |
| - account-cards-data (rf/sub [:wallet/account-cards-data]) |
72 |
| - cards (conj account-cards-data (new-account-card-data)) |
73 |
| - [init-loaded? set-init-loaded] (rn/use-state false) |
74 |
| - {:keys [formatted-balance]} (rf/sub [:wallet/aggregated-token-values-and-balance]) |
75 |
| - theme (quo.theme/use-theme)] |
| 71 | + (let [selected-tab (or (rf/sub [:wallet/home-tab]) first-tab-id) |
| 72 | + account-list-ref (rn/use-ref-atom nil) |
| 73 | + tokens-loading? (rf/sub [:wallet/home-tokens-loading?]) |
| 74 | + networks (rf/sub [:wallet/selected-network-details]) |
| 75 | + account-cards-data (rf/sub [:wallet/account-cards-data]) |
| 76 | + cards (conj account-cards-data (new-account-card-data)) |
| 77 | + [init-loaded? set-init-loaded] (rn/use-state false) |
| 78 | + {:keys [formatted-balance]} (rf/sub [:wallet/aggregated-token-values-and-balance]) |
| 79 | + theme (quo.theme/use-theme)] |
76 | 80 | (rn/use-effect (fn []
|
77 | 81 | (when (and @account-list-ref (pos? (count cards)))
|
78 | 82 | (.scrollToOffset ^js @account-list-ref
|
|
104 | 108 | (when (ff/enabled? ::ff/wallet.graph)
|
105 | 109 | [quo/wallet-graph {:time-frame :empty}])
|
106 | 110 | [render-cards cards account-list-ref]
|
107 |
| - [render-tabs tabs-data set-selected-tab selected-tab]] |
| 111 | + [render-tabs tabs-data change-tab selected-tab]] |
108 | 112 | :content-container-style style/list-container
|
109 | 113 | :sticky-header-indices [0]
|
110 | 114 | :data []
|
|
0 commit comments