Skip to content

Commit

Permalink
Basically the remainings
Browse files Browse the repository at this point in the history
  • Loading branch information
alwx committed May 16, 2024
1 parent 25d7419 commit 68aef1a
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(ns status-im.contexts.wallet.connected-dapps.disconnect-dapp.style)

(def content-wrapper
{:padding-vertical 8
:padding-horizontal 20
:gap 12})
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
(ns status-im.contexts.wallet.connected-dapps.disconnect-dapp.view
(:require
[quo.core :as quo]
[react-native.core :as rn]
[status-im.contexts.wallet.connected-dapps.disconnect-dapp.style :as style]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))

(defn view [{:keys [wallet-account dapp on-disconnect]}]
(let [{:keys [avatar name]} dapp
{:keys [color]} wallet-account]
[:<>
[quo/drawer-top
{:type :context-tag
:context-tag-type :default
:full-name name
:profile-picture avatar
:title (i18n/label :t/disconnect-dapp)
:customization-color color}]
[rn/view {:style style/content-wrapper}
[quo/text
{:size :paragraph-1}
(i18n/label :t/disconnect-dapp-confirmation {:dapp name})]]
[quo/bottom-actions
{:actions :two-actions
:button-one-label (i18n/label :t/disconnect)
:button-one-props {:type :danger
:accessibility-label :block-contact
:on-press on-disconnect}
:button-two-label (i18n/label :t/cancel)
:button-two-props {:type :grey
:accessibility-label :cancel
:on-press #(rf/dispatch [:hide-bottom-sheet])}}]]))
57 changes: 39 additions & 18 deletions src/status_im/contexts/wallet/connected_dapps/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,43 @@
[quo.foundations.resources :as quo.resources]
[quo.theme :as quo.theme]
[react-native.core :as rn]
[reagent.core :as r]
[status-im.common.plus-button.view :as plus-button]
[status-im.common.resources :as resources]
[status-im.contexts.wallet.connected-dapps.disconnect-dapp.view :as disconnect-dapp]
[status-im.contexts.wallet.connected-dapps.style :as style]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))

;; TODO(alwx): hardcoded list before the persistance is finalized and implemented
(def dapps-list (r/atom [{:avatar (quo.resources/get-dapp :1inch)
:name "1inch"
:value "1inch.com"}
{:avatar (quo.resources/get-dapp :coingecko)
:name "Coingecko"
:value "coingecko.com"}
{:avatar (quo.resources/get-dapp :uniswap)
:name "Uniswap"
:value "uniswap.com"}]))

(defn- on-disconnect [wallet-account dapp]
(reset! dapps-list (remove (fn [item]
(= (:name item) (:name dapp)))
@dapps-list))
(rf/dispatch [:toasts/upsert
{:id :dapp-disconnected
:type :positive
:text (i18n/label :t/disconnect-dapp-success
{:dapp (:name dapp)
:account (:name wallet-account)})}])
(rf/dispatch [:hide-bottom-sheet]))

(defn- on-dapp-disconnect-press [wallet-account dapp]
(rf/dispatch [:show-bottom-sheet
{:content (fn [] [disconnect-dapp/view {:wallet-account wallet-account
:dapp dapp
:on-disconnect #(on-disconnect wallet-account dapp)}])}]))

(defn- account-details
[{:keys [name emoji color]}]
(let [theme (quo.theme/use-theme)]
Expand Down Expand Up @@ -51,49 +82,39 @@

(defn view
[]
(let [wallet-account (rf/sub [:wallet/current-viewing-account])
theme (quo.theme/use-theme)
dapps-list [{:avatar (quo.resources/get-dapp :1inch)
:name "1inch"
:value "1inch.com"}
{:avatar (quo.resources/get-dapp :coingecko)
:name "Coingecko"
:value "coingecko.com"}
{:avatar (quo.resources/get-dapp :uniswap)
:name "Uniswap"
:value "uniswap.com"}]]
(let [{:keys [color] :as wallet-account} (rf/sub [:wallet/current-viewing-account])
theme (quo.theme/use-theme)]
[rn/view {:flex 1}
[header
{:title (i18n/label :t/connected-dapps)
:wallet-account wallet-account
:on-close #(rf/dispatch [:navigate-back])
:on-add #(js/alert "Feature not implemented.")}]
(if (empty? dapps-list)
(if (empty? @dapps-list)
[quo/empty-state
{:title (i18n/label :t/no-dapps)
:description (i18n/label :t/no-dapps-description)
:image (resources/get-themed-image :no-dapps theme)
:container-style style/empty-container-style}]
[rn/view style/dapps-container
[rn/flat-list
{:data dapps-list
{:data @dapps-list
:style (style/dapps-list theme)
:render-fn (fn [item]
[quo/dapp
{:dapp item
:state :default
:action :icon
:blur? false
:customization-color :blue
:on-press (fn [{:keys [name]}] (js/alert (str name " got pressed")))
:customization-color color
:right-component (fn [dapp]
[rn/pressable
{:on-press (fn [] (js/alert (str (:name dapp) " right got pressed")))}
{:on-press (fn []
(on-dapp-disconnect-press wallet-account dapp))}
[icons/icon :i/disconnect
{:color (colors/theme-colors
colors/neutral-50
colors/neutral-40
theme)
:accessibility-label :icon}]])}])
:separator [rn/view
{:style (style/separator theme)}]}]])]))
:separator [rn/view {:style (style/separator theme)}]}]])]))
4 changes: 3 additions & 1 deletion translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2453,6 +2453,8 @@
"scan-sync-code-placeholder": "cs2:4FH...",
"visit-dapp": "Visit dApp",
"disconnect-dapp": "Disconnect dApp",
"disconnect-dapp-confirmation": "Are you sure you want to disconnect {{dapp}}?",
"disconnect-dapp-success": "{{dapp}} disconnected from {{account}}",
"edit-account": "Edit account",
"share-account": "Share account",
"remove-account": "Remove account",
Expand Down Expand Up @@ -2635,4 +2637,4 @@
"sending-to-networks-the-receiver-does-not-prefer": "Sending to networks the receiver does not prefer may result in recipient having difficulty accessing the sent tokens.",
"proceed-anyway": "Proceed anyway",
"sending-to-unpreferred-networks": "Sending to unpreferred networks"
}
}

0 comments on commit 68aef1a

Please sign in to comment.