mirror of
https://github.com/status-im/status-mobile.git
synced 2025-03-01 08:40:50 +00:00
Buy assets drawer - one-time & recurrent tabs (#20063)
This commit is contained in:
parent
abc0da1f00
commit
039ad8d162
@ -511,9 +511,11 @@
|
|||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet/get-crypto-on-ramps-success
|
:wallet/get-crypto-on-ramps-success
|
||||||
(fn [{:keys [db]} [data]]
|
(fn [{:keys [db]} [data]]
|
||||||
{:db (assoc-in db
|
(let [crypto-on-ramps (cske/transform-keys transforms/->kebab-case-keyword data)]
|
||||||
[:wallet :crypto-on-ramps]
|
{:db (assoc-in db
|
||||||
(cske/transform-keys transforms/->kebab-case-keyword data))}))
|
[:wallet :crypto-on-ramps]
|
||||||
|
{:one-time (remove #(string/blank? (:site-url %)) crypto-on-ramps)
|
||||||
|
:recurrent (remove #(string/blank? (:recurrent-site-url %)) crypto-on-ramps)})})))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet/get-crypto-on-ramps
|
:wallet/get-crypto-on-ramps
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
(ns status-im.contexts.wallet.sheets.buy-token.style)
|
(ns status-im.contexts.wallet.sheets.buy-token.style)
|
||||||
|
|
||||||
(def list-container
|
(defn list-container
|
||||||
|
[min-height]
|
||||||
{:padding-horizontal 8
|
{:padding-horizontal 8
|
||||||
|
:min-height min-height
|
||||||
:padding-bottom 8})
|
:padding-bottom 8})
|
||||||
|
|
||||||
|
(def tabs
|
||||||
|
{:margin-horizontal 20
|
||||||
|
:margin-top 8
|
||||||
|
:margin-bottom 12})
|
||||||
|
@ -1,34 +1,63 @@
|
|||||||
(ns status-im.contexts.wallet.sheets.buy-token.view
|
(ns status-im.contexts.wallet.sheets.buy-token.view
|
||||||
(:require [quo.core :as quo]
|
(:require [oops.core :as oops]
|
||||||
|
[quo.core :as quo]
|
||||||
[react-native.core :as rn]
|
[react-native.core :as rn]
|
||||||
[status-im.contexts.wallet.sheets.buy-token.style :as style]
|
[status-im.contexts.wallet.sheets.buy-token.style :as style]
|
||||||
|
[status-im.feature-flags :as ff]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
(defn- crypto-on-ramp-item
|
(defn- crypto-on-ramp-item
|
||||||
[{:keys [name description fees logo-url site-url]}]
|
[{:keys [name description fees logo-url site-url recurrent-site-url]} _ _ {:keys [tab]}]
|
||||||
[quo/settings-item
|
(let [open-url (rn/use-callback (fn []
|
||||||
{:title name
|
(rn/open-url (if (= tab :recurrent) recurrent-site-url site-url)))
|
||||||
:description :text
|
[site-url recurrent-site-url tab])]
|
||||||
:description-props {:text description}
|
[quo/settings-item
|
||||||
:tag :context
|
{:title name
|
||||||
:tag-props {:icon :i/fees
|
:description :text
|
||||||
:context fees}
|
:description-props {:text description}
|
||||||
:action :arrow
|
:tag :context
|
||||||
:action-props {:alignment :flex-start
|
:tag-props {:icon :i/fees
|
||||||
:icon :i/external}
|
:context fees}
|
||||||
:image :icon-avatar
|
:action :arrow
|
||||||
:image-props {:icon logo-url}
|
:action-props {:alignment :flex-start
|
||||||
:on-press #(rn/open-url site-url)}])
|
:icon :i/external}
|
||||||
|
:image :icon-avatar
|
||||||
|
:image-props {:icon logo-url}
|
||||||
|
:on-press open-url}]))
|
||||||
|
|
||||||
|
(def ^:private tabs
|
||||||
|
[{:id :one-time
|
||||||
|
:label (i18n/label :t/one-time)}
|
||||||
|
{:id :recurrent
|
||||||
|
:label (i18n/label :t/recurrent)}])
|
||||||
|
|
||||||
|
(def ^:private initial-tab (:id (first tabs)))
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[]
|
[]
|
||||||
(rn/use-mount (fn []
|
(rn/use-mount (fn []
|
||||||
(rf/dispatch [:wallet/get-crypto-on-ramps])))
|
(rf/dispatch [:wallet/get-crypto-on-ramps])))
|
||||||
(let [crypto-on-ramps (rf/sub [:wallet/crypto-on-ramps])]
|
(let [crypto-on-ramps (rf/sub [:wallet/crypto-on-ramps])
|
||||||
|
[selected-tab set-selected-tab] (rn/use-state initial-tab)
|
||||||
|
[min-height set-min-height] (rn/use-state 0)
|
||||||
|
on-layout (rn/use-callback
|
||||||
|
#(set-min-height
|
||||||
|
(oops/oget % :nativeEvent :layout :height)))]
|
||||||
[:<>
|
[:<>
|
||||||
[quo/drawer-top {:title (i18n/label :t/buy-assets)}]
|
[quo/drawer-top {:title (i18n/label :t/buy-assets)}]
|
||||||
|
(when (ff/enabled? ::ff/wallet.buy-recurrent-assets)
|
||||||
|
[quo/segmented-control
|
||||||
|
{:size 32
|
||||||
|
:container-style style/tabs
|
||||||
|
:default-active initial-tab
|
||||||
|
:on-change set-selected-tab
|
||||||
|
:data tabs}])
|
||||||
[rn/flat-list
|
[rn/flat-list
|
||||||
{:data crypto-on-ramps
|
{:data (if (and (ff/enabled? ::ff/wallet.buy-recurrent-assets) (= selected-tab :recurrent))
|
||||||
:style style/list-container
|
(:recurrent crypto-on-ramps)
|
||||||
:render-fn crypto-on-ramp-item}]]))
|
(:one-time crypto-on-ramps))
|
||||||
|
:on-layout on-layout
|
||||||
|
:style (style/list-container min-height)
|
||||||
|
:render-data {:tab selected-tab}
|
||||||
|
:render-fn crypto-on-ramp-item}]]))
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
::wallet.assets-modal-hide (enabled-in-env? :FLAG_ASSETS_MODAL_HIDE)
|
::wallet.assets-modal-hide (enabled-in-env? :FLAG_ASSETS_MODAL_HIDE)
|
||||||
::wallet.assets-modal-manage-tokens (enabled-in-env? :FLAG_ASSETS_MODAL_MANAGE_TOKENS)
|
::wallet.assets-modal-manage-tokens (enabled-in-env? :FLAG_ASSETS_MODAL_MANAGE_TOKENS)
|
||||||
::wallet.bridge-token (enabled-in-env? :FLAG_BRIDGE_TOKEN_ENABLED)
|
::wallet.bridge-token (enabled-in-env? :FLAG_BRIDGE_TOKEN_ENABLED)
|
||||||
|
::wallet.buy-recurrent-assets (enabled-in-env? :FLAG_BUY_RECURRENT_ASSETS)
|
||||||
::wallet.contacts (enabled-in-env? :FLAG_CONTACTS_ENABLED)
|
::wallet.contacts (enabled-in-env? :FLAG_CONTACTS_ENABLED)
|
||||||
::wallet.edit-derivation-path (enabled-in-env? :FLAG_EDIT_DERIVATION_PATH)
|
::wallet.edit-derivation-path (enabled-in-env? :FLAG_EDIT_DERIVATION_PATH)
|
||||||
::wallet.graph (enabled-in-env? :FLAG_GRAPH_ENABLED)
|
::wallet.graph (enabled-in-env? :FLAG_GRAPH_ENABLED)
|
||||||
|
@ -2483,6 +2483,8 @@
|
|||||||
"oops-this-qr-does-not-contain-an-address": "Oops! This QR does not contain an address",
|
"oops-this-qr-does-not-contain-an-address": "Oops! This QR does not contain an address",
|
||||||
"scan-an-account-qr-code": "Scan an account QR code",
|
"scan-an-account-qr-code": "Scan an account QR code",
|
||||||
"buy-assets": "Buy assets",
|
"buy-assets": "Buy assets",
|
||||||
|
"one-time": "One time",
|
||||||
|
"recurrent": "Recurrent",
|
||||||
"account-info": "Account info",
|
"account-info": "Account info",
|
||||||
"network-preferences": "Network preferences",
|
"network-preferences": "Network preferences",
|
||||||
"network-preferences-desc-1": "Select which networks this address is happy to receive funds on",
|
"network-preferences-desc-1": "Select which networks this address is happy to receive funds on",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user