[#8516] Cannot delete dapp from "Recent"

This commit is contained in:
Andrey Shovkoplyas 2019-09-23 16:23:21 +02:00
parent e91375a97b
commit 222c6ac20c
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4
5 changed files with 39 additions and 66 deletions

View File

@ -52,6 +52,15 @@
:params [browser-id]
:on-success #()}]})
(fx/defn clear-all-browsers
{:events [:browser.ui/clear-all-browsers-pressed]}
[{:keys [db]}]
{:db (dissoc db :browser/browsers)
::json-rpc/call (for [browser-id (keys (get db :browser/browsers))]
{:method "browsers_deleteBrowser"
:params [browser-id]
:on-success #()})})
(defn update-dapp-name [{:keys [name] :as browser}]
(assoc browser :dapp? false :name (or name (i18n/label :t/browser))))

View File

@ -28,7 +28,6 @@
[status-im.ui.components.list-item.views :as list-item]
[status-im.ui.components.list.styles :as styles]
[status-im.ui.components.react :as react]
[status-im.ui.screens.home.animations.responder :as responder]
[status-im.utils.platform :as platform]
[status-im.ui.components.radio :as radio])
(:require-macros [status-im.utils.views :as views]))
@ -325,18 +324,3 @@
[react/text {:style styles/label}
label]
list])
;;TODO DEPRECATED, use long-press
(views/defview deletable-list-item [{:keys [type id on-delete]} body]
(views/letsubs [swiped? [:delete-swipe-position type id]]
(let [offset-x (animation/create-value (if swiped? styles/delete-button-width 0))
swipe-pan-responder (responder/swipe-pan-responder offset-x styles/delete-button-width id swiped?)
swipe-pan-handler (responder/pan-handlers swipe-pan-responder)]
[react/view swipe-pan-handler
[react/animated-view {:style {:flex 1
:transform [{:translateX offset-x}]}}
body
[react/touchable-highlight {:style styles/delete-icon-highlight
:on-press on-delete}
[react/view {:style styles/delete-icon-container}
[vector-icons/icon :main-icons/delete {:color colors/red}]]]]])))

View File

@ -18,18 +18,35 @@
[reagent.core :as reagent])
(:require-macros [status-im.utils.views :as views]))
(defn hide-sheet-and-dispatch [event]
(re-frame/dispatch [:bottom-sheet/hide-sheet])
(re-frame/dispatch event))
(defn list-item [{:keys [browser-id name url]}]
[list/deletable-list-item {:type :browsers
:id browser-id
:on-delete #(do
(re-frame/dispatch [:set-swipe-position :browsers browser-id false])
(re-frame/dispatch [:browser.ui/remove-browser-pressed browser-id]))}
[list-item/list-item
{:on-press #(re-frame/dispatch [:browser.ui/browser-item-selected browser-id])
:on-long-press (fn []
(re-frame/dispatch
[:bottom-sheet/show-sheet
{:content (fn []
[react/view {:flex 1}
[list-item/list-item
{:theme :action
:title :t/remove
:accessibility-label :remove-dapp-from-list
:icon :main-icons/delete
:on-press #(hide-sheet-and-dispatch [:browser.ui/remove-browser-pressed browser-id])}]
[list-item/list-item
{:theme :action-destructive
:title :t/clear-all
:accessibility-label :clear-all-dapps
:icon :main-icons/delete
:on-press #(hide-sheet-and-dispatch [:browser.ui/clear-all-browsers-pressed])}]])
:content-height 128}]))
:title name
:subtitle (or url :t/dapp)
:icon [react/view styles/browser-icon-container
[vector-icons/icon :main-icons/browser {:color colors/gray}]]}]])
[vector-icons/icon :main-icons/browser {:color colors/gray}]]}])
(def dapp-image-data {:image (resources/get-image :dapp-store) :width 768 :height 333})
(defn dapp-image [] [components.common/image-contain nil dapp-image-data])

View File

@ -1,38 +0,0 @@
(ns status-im.ui.screens.home.animations.responder
(:require [status-im.ui.components.react :as react]
[re-frame.core :as re-frame]
[status-im.ui.components.animation :as animation]))
(defn get-updated-value [gesture end-offset-x swiped?]
(let [base-value (if swiped? end-offset-x 0)]
(- base-value (.-dx gesture))))
(defn on-start [_ gesture]
(> (js/Math.abs (.-dx gesture)) 10))
(defn on-move [animated-offset-x end-offset-x swiped?]
(fn [_ gesture]
(let [to-value (get-updated-value gesture end-offset-x swiped?)]
(animation/start (animation/spring animated-offset-x
{:toValue (- to-value)
:useNativeDriver true})))))
(defn on-release [animated-offset-x end-offset-x chat-id swiped?]
(fn [_ gesture]
(let [updated-value (get-updated-value gesture end-offset-x swiped?)
should-open? (> updated-value (/ end-offset-x 2))
to-value (if should-open? end-offset-x 0)]
(re-frame/dispatch [:set-swipe-position :chats chat-id should-open?])
(animation/start (animation/spring animated-offset-x
{:toValue (- to-value)
:useNativeDriver true})))))
(defn swipe-pan-responder [animated-offset-x end-offset-x chat-id swiped?]
(.create react/pan-responder
(clj->js {:onMoveShouldSetPanResponder on-start
:onPanResponderMove (on-move animated-offset-x end-offset-x swiped?)
:onPanResponderRelease (on-release animated-offset-x end-offset-x chat-id swiped?)
:onPanResponderTerminate (on-release animated-offset-x end-offset-x chat-id swiped?)})))
(defn pan-handlers [pan-responder]
(js->clj (.-panHandlers pan-responder)))

View File

@ -128,6 +128,7 @@
"check-your-recovery-phrase": "Check your seed phrase",
"choose-authentication-method": "Choose an authentication method to protect your multiaccount",
"clear": "Clear",
"clear-all": "Clear all",
"clear-history": "Clear history",
"clear-history-action": "Clear",
"clear-history-confirmation": "Clear history?",