|
38 | 38 | :state :default
|
39 | 39 | :action :none}])
|
40 | 40 |
|
41 |
| -(defn view |
| 41 | +(defn parse-accounts |
| 42 | + [given-accounts] |
| 43 | + (map (fn [{:keys [colorId emoji name address]}] |
| 44 | + {:account-props {:customization-color (if (not-empty colorId) (keyword colorId) :blue) |
| 45 | + :size 32 |
| 46 | + :emoji emoji |
| 47 | + :type :default |
| 48 | + :name name |
| 49 | + :address address} |
| 50 | + :networks [{:network-name :ethereum :short-name "eth"} |
| 51 | + {:network-name :optimism :short-name "opt"}] |
| 52 | + :state :default |
| 53 | + :action :none}) |
| 54 | + given-accounts)) |
| 55 | + |
| 56 | +(defn keypair |
| 57 | + [item index _ {:keys [profile-picture compressed-key]}] |
| 58 | + (let [main-account (first (:accounts item)) |
| 59 | + color (keyword (:colorId main-account)) |
| 60 | + parsed-accounts (parse-accounts (:accounts item))] |
| 61 | + [quo/keypair |
| 62 | + {:customization-color (if (not-empty (:colorId main-account)) color :blue) |
| 63 | + :profile-picture (when (zero? index) profile-picture) |
| 64 | + :status-indicator false |
| 65 | + :type (if (zero? index) :default-keypair :other) |
| 66 | + :stored :on-device |
| 67 | + :on-options-press #(js/alert "Options pressed") |
| 68 | + :action :selector |
| 69 | + :blur? false |
| 70 | + :details {:full-name (:name item) |
| 71 | + :address (when (zero? index) |
| 72 | + (utils/get-shortened-compressed-key compressed-key))} |
| 73 | + :accounts parsed-accounts |
| 74 | + :default-selected? (zero? index) |
| 75 | + :container-style {:margin-horizontal 20 |
| 76 | + :margin-vertical 8}}])) |
| 77 | +(defn- view-internal |
42 | 78 | []
|
43 |
| - (let [{:keys [public-key compressed-key |
44 |
| - customization-color]} (rf/sub [:profile/profile]) |
45 |
| - [display-name _] (rf/sub [:contacts/contact-two-names-by-identity public-key]) |
46 |
| - profile-with-image (rf/sub [:profile/profile-with-image]) |
47 |
| - profile-picture (profile.utils/photo profile-with-image)] |
| 79 | + (let [{:keys [compressed-key customization-color]} (rf/sub [:profile/profile]) |
| 80 | + profile-with-image (rf/sub [:profile/profile-with-image]) |
| 81 | + keypairs (rf/sub [:wallet/keypairs]) |
| 82 | + profile-picture (profile.utils/photo profile-with-image)] |
| 83 | + (rn/use-effect #(rf/dispatch [:wallet/get-keypairs])) |
48 | 84 | [rn/view {:style {:flex 1}}
|
49 | 85 | [quo/page-nav
|
50 | 86 | {:icon-name :i/close
|
|
60 | 96 | [:show-bottom-sheet {:content keypair-options}])}
|
61 | 97 | :description :text
|
62 | 98 | :description-text (i18n/label :t/keypairs-description)}]
|
63 |
| - [quo/keypair |
64 |
| - {:customization-color customization-color |
65 |
| - :profile-picture profile-picture |
66 |
| - :status-indicator false |
67 |
| - :type :default-keypair |
68 |
| - :stored :on-device |
69 |
| - :on-options-press #(js/alert "Options pressed") |
70 |
| - :action :selector |
71 |
| - :blur? false |
72 |
| - :details {:full-name display-name |
73 |
| - :address (utils/get-shortened-compressed-key compressed-key)} |
74 |
| - :accounts accounts |
75 |
| - :container-style {:margin-horizontal 20 |
76 |
| - :margin-vertical 8}}] |
| 99 | + [rn/flat-list |
| 100 | + {:data keypairs |
| 101 | + :render-fn keypair |
| 102 | + :render-data {:profile-picture profile-picture |
| 103 | + :compressed-key compressed-key}}] |
77 | 104 | [quo/bottom-actions
|
78 | 105 | {:actions :one-action
|
79 | 106 | :button-one-label (i18n/label :t/confirm-account-origin)
|
80 | 107 | :button-one-props {:disabled? true
|
81 | 108 | :customization-color customization-color}
|
82 | 109 | :container-style style/bottom-action-container}]]))
|
| 110 | + |
| 111 | +(defn view |
| 112 | + [] |
| 113 | + [:f> view-internal]) |
0 commit comments