mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-12 09:44:13 +00:00
new profile hook and capacities
Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
parent
b721f4810f
commit
0fb9cabcfc
@ -29,7 +29,8 @@
|
|||||||
[status-im.utils.ethereum.core :as ethereum]
|
[status-im.utils.ethereum.core :as ethereum]
|
||||||
[status-im.chat.commands.sending :as commands-sending]
|
[status-im.chat.commands.sending :as commands-sending]
|
||||||
[status-im.browser.core :as browser]
|
[status-im.browser.core :as browser]
|
||||||
[status-im.utils.platform :as platform]))
|
[status-im.utils.platform :as platform]
|
||||||
|
[status-im.utils.datetime :as datetime]))
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
::identity-event
|
::identity-event
|
||||||
@ -128,8 +129,16 @@
|
|||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:store/get
|
:store/get
|
||||||
(fn [db [_ {id :id} {:keys [key]}]]
|
(fn [db [_ {id :id} {:keys [key] :as params}]]
|
||||||
(get-in db [:extensions/store id key])))
|
(let [result (get-in db [:extensions/store id key])]
|
||||||
|
(if (:reverse params)
|
||||||
|
(reverse result)
|
||||||
|
result))))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
:store/get-in
|
||||||
|
(fn [db [_ {id :id} {:keys [keys]}]]
|
||||||
|
(get-in db (into [] (concat [:extensions/store id] keys)))))
|
||||||
|
|
||||||
(defn- ->contact [{:keys [photo-path address name public-key]}]
|
(defn- ->contact [{:keys [photo-path address name public-key]}]
|
||||||
{:photo photo-path
|
{:photo photo-path
|
||||||
@ -158,6 +167,11 @@
|
|||||||
(fn [{:keys [db]} [_ {id :id} {:keys [key value]}]]
|
(fn [{:keys [db]} [_ {id :id} {:keys [key value]}]]
|
||||||
{:db (put-or-dissoc db id key value)}))
|
{:db (put-or-dissoc db id key value)}))
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
:store/put-in
|
||||||
|
(fn [{:keys [db]} [_ {id :id} {:keys [keys value]}]]
|
||||||
|
{:db (assoc-in db (into [] (concat [:extensions/store id] keys)) value)}))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:store/puts
|
:store/puts
|
||||||
(fn [{:keys [db]} [_ {id :id} {:keys [value]}]]
|
(fn [{:keys [db]} [_ {id :id} {:keys [value]}]]
|
||||||
@ -322,12 +336,17 @@
|
|||||||
(js/clearTimeout id))
|
(js/clearTimeout id))
|
||||||
(reset! current (js/setTimeout #(on-input-change-text on-change value) delay)))
|
(reset! current (js/setTimeout #(on-input-change-text on-change value) delay)))
|
||||||
|
|
||||||
(defn input [{:keys [keyboard-type style on-change change-delay placeholder placeholder-text-color selection-color]}]
|
(defn input [{:keys [keyboard-type style on-change change-delay placeholder placeholder-text-color selection-color
|
||||||
|
auto-focus on-submit default-value]}]
|
||||||
[react/text-input (merge {:placeholder placeholder}
|
[react/text-input (merge {:placeholder placeholder}
|
||||||
(when placeholder-text-color {:placeholder-text-color placeholder-text-color})
|
(when placeholder-text-color {:placeholder-text-color placeholder-text-color})
|
||||||
(when selection-color {:selection-color selection-color})
|
(when selection-color {:selection-color selection-color})
|
||||||
(when style {:style style})
|
(when style {:style style})
|
||||||
(when keyboard-type {:keyboard-type keyboard-type})
|
(when keyboard-type {:keyboard-type keyboard-type})
|
||||||
|
(when auto-focus {:auto-focus auto-focus})
|
||||||
|
(when default-value {:default-value default-value})
|
||||||
|
(when on-submit
|
||||||
|
{:on-submit-editing #(on-submit {})})
|
||||||
(when on-change
|
(when on-change
|
||||||
{:on-change-text
|
{:on-change-text
|
||||||
(if change-delay
|
(if change-delay
|
||||||
@ -417,6 +436,16 @@
|
|||||||
(defn icon [{:keys [key] :as o}]
|
(defn icon [{:keys [key] :as o}]
|
||||||
[icons/icon key o])
|
[icons/icon key o])
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
:store/get-vals
|
||||||
|
(fn [db [_ {id :id} {:keys [key]}]]
|
||||||
|
(vals (get-in db [:extensions/store id key]))))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
:extensions.time/now
|
||||||
|
(fn [_ _]
|
||||||
|
(.toLocaleString (js/Date.))))
|
||||||
|
|
||||||
(def capacities
|
(def capacities
|
||||||
{:components {'view {:data view}
|
{:components {'view {:data view}
|
||||||
'scroll-view {:data scroll-view :properties {:keyboard-should-persist-taps :keyword :content-container-style :map}}
|
'scroll-view {:data scroll-view :properties {:keyboard-should-persist-taps :keyword :content-container-style :map}}
|
||||||
@ -425,7 +454,9 @@
|
|||||||
'touchable-opacity {:data touchable-opacity :properties {:on-press :event}}
|
'touchable-opacity {:data touchable-opacity :properties {:on-press :event}}
|
||||||
'icon {:data icon :properties {:key :keyword :color :any}}
|
'icon {:data icon :properties {:key :keyword :color :any}}
|
||||||
'image {:data image :properties {:uri :string :source :string}}
|
'image {:data image :properties {:uri :string :source :string}}
|
||||||
'input {:data input :properties {:on-change :event :placeholder :string :keyboard-type :keyword :change-delay? :number :placeholder-text-color :any :selection-color :any}}
|
'input {:data input :properties {:on-change :event :placeholder :string :keyboard-type :keyword
|
||||||
|
:change-delay? :number :placeholder-text-color :any :selection-color :any
|
||||||
|
:auto-focus? :boolean :on-submit :event :default-value :any}}
|
||||||
'button {:data button :properties {:enabled :boolean :disabled :boolean :on-click :event}}
|
'button {:data button :properties {:enabled :boolean :disabled :boolean :on-click :event}}
|
||||||
'link {:data link :properties {:uri :string :text? :string :open-in? {:one-of #{:device :status}}}}
|
'link {:data link :properties {:uri :string :text? :string :open-in? {:one-of #{:device :status}}}}
|
||||||
'list {:data list :properties {:data :vector :item-view :view :key? :keyword}}
|
'list {:data list :properties {:data :vector :item-view :view :key? :keyword}}
|
||||||
@ -446,7 +477,10 @@
|
|||||||
:on-change :event}}
|
:on-change :event}}
|
||||||
'map-link {:data map-link :properties {:text :string :lng :any :lat :any}}}
|
'map-link {:data map-link :properties {:text :string :lng :any :lat :any}}}
|
||||||
:queries {'identity {:data :extensions/identity :arguments {:value :map}}
|
:queries {'identity {:data :extensions/identity :arguments {:value :map}}
|
||||||
'store/get {:data :store/get :arguments {:key :string}}
|
'store/get {:data :store/get :arguments {:key :string :reverse? :boolean}}
|
||||||
|
'store/get-in {:data :store/get-in :arguments {:key :vector}}
|
||||||
|
'store/get-vals {:data :store/get-vals :arguments {:key :string}}
|
||||||
|
'time/now {:data :extensions.time/now}
|
||||||
'contacts/all {:data :extensions.contacts/all} ;; :photo :name :address :public-key
|
'contacts/all {:data :extensions.contacts/all} ;; :photo :name :address :public-key
|
||||||
'wallet/collectibles {:data :get-collectible-token :arguments {:token :string :symbol :string}}
|
'wallet/collectibles {:data :get-collectible-token :arguments {:token :string :symbol :string}}
|
||||||
'wallet/balance {:data :extensions.wallet/balance :arguments {:token :string}}
|
'wallet/balance {:data :extensions.wallet/balance :arguments {:token :string}}
|
||||||
@ -536,6 +570,10 @@
|
|||||||
{:permissions [:read]
|
{:permissions [:read]
|
||||||
:data :store/put
|
:data :store/put
|
||||||
:arguments {:key :string :value :any}}
|
:arguments {:key :string :value :any}}
|
||||||
|
'store/put-in
|
||||||
|
{:permissions [:read]
|
||||||
|
:data :store/put-in
|
||||||
|
:arguments {:keys :vector :value :any}}
|
||||||
'store/puts
|
'store/puts
|
||||||
{:permissions [:read]
|
{:permissions [:read]
|
||||||
:data :store/puts
|
:data :store/puts
|
||||||
@ -819,7 +857,13 @@
|
|||||||
{:permissions [:read]
|
{:permissions [:read]
|
||||||
:data :extensions/shh-get-messages
|
:data :extensions/shh-get-messages
|
||||||
:arguments {:id :string}}}
|
:arguments {:id :string}}}
|
||||||
:hooks {:wallet.settings
|
:hooks {:profile.settings
|
||||||
|
{:properties
|
||||||
|
{:label :string
|
||||||
|
:view :view
|
||||||
|
:on-open? :event
|
||||||
|
:on-close? :event}}
|
||||||
|
:wallet.settings
|
||||||
{:properties
|
{:properties
|
||||||
{:label :string
|
{:label :string
|
||||||
:view :view
|
:view :view
|
||||||
|
@ -21,9 +21,16 @@
|
|||||||
(defmethod hook-for "wallet.settings" [_]
|
(defmethod hook-for "wallet.settings" [_]
|
||||||
(reify Hook
|
(reify Hook
|
||||||
(hook-in [_ id _ m {:keys [db]}]
|
(hook-in [_ id _ m {:keys [db]}]
|
||||||
{:db (assoc-in db [:wallet :settings id] m)})
|
(fn [{:keys [db]}] {:db (assoc-in db [:wallet :settings id] m)}))
|
||||||
(unhook [_ id _ _ {:keys [db]}]
|
(unhook [_ id _ _ {:keys [db]}]
|
||||||
{:db (update-in db [:wallet :settings] dissoc id)})))
|
(fn [{:keys [db]}] {:db (update-in db [:wallet :settings] dissoc id)}))))
|
||||||
|
|
||||||
|
(defmethod hook-for "profile.settings" [_]
|
||||||
|
(reify Hook
|
||||||
|
(hook-in [_ id _ m {:keys [db]}]
|
||||||
|
(fn [{:keys [db]}] {:db (assoc-in db [:extensions/profile :settings id] m)}))
|
||||||
|
(unhook [_ id _ _ {:keys [db]}]
|
||||||
|
(fn [{:keys [db]}] {:db (update-in db [:extensions/profile :settings] dissoc id)}))))
|
||||||
|
|
||||||
(defmethod hook-for "chat.command" [_]
|
(defmethod hook-for "chat.command" [_]
|
||||||
(reify Hook
|
(reify Hook
|
||||||
@ -56,7 +63,8 @@
|
|||||||
(preview [_ props] (when preview (preview props)))
|
(preview [_ props] (when preview (preview props)))
|
||||||
protocol/Extension
|
protocol/Extension
|
||||||
(extension-id [_] extension-id)))]
|
(extension-id [_] extension-id)))]
|
||||||
(commands/load-commands cofx [new-command])))
|
(fn [cofx]
|
||||||
|
(commands/load-commands cofx [new-command]))))
|
||||||
(unhook [_ id _ {:keys [scope]} {:keys [db] :as cofx}]
|
(unhook [_ id _ {:keys [scope]} {:keys [db] :as cofx}]
|
||||||
(when-let [command (get-in db [:id->command [(name id) scope] :type])]
|
(when-let [command (get-in db [:id->command [(name id) scope] :type])]
|
||||||
(commands/remove-command command cofx)))))
|
(commands/remove-command command cofx)))))
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
:open-dapp {:type :main}
|
:open-dapp {:type :main}
|
||||||
:my-profile {:type :main}
|
:my-profile {:type :main}
|
||||||
:profile-stack {:type :main}
|
:profile-stack {:type :main}
|
||||||
|
:my-profile-ext-settings {:type :main}
|
||||||
:contacts-list {:type :main}
|
:contacts-list {:type :main}
|
||||||
:browser {:type :main}
|
:browser {:type :main}
|
||||||
:mobile-network-settings {:type :main}
|
:mobile-network-settings {:type :main}
|
||||||
|
@ -197,6 +197,7 @@
|
|||||||
(spec/def :stickers/packs-installed (spec/nilable map?))
|
(spec/def :stickers/packs-installed (spec/nilable map?))
|
||||||
(spec/def :stickers/selected-pack (spec/nilable any?))
|
(spec/def :stickers/selected-pack (spec/nilable any?))
|
||||||
(spec/def :stickers/recent (spec/nilable vector?))
|
(spec/def :stickers/recent (spec/nilable vector?))
|
||||||
|
(spec/def :extensions/profile (spec/nilable any?))
|
||||||
|
|
||||||
(spec/def ::db (spec/keys :opt [:contacts/contacts
|
(spec/def ::db (spec/keys :opt [:contacts/contacts
|
||||||
:contacts/dapps
|
:contacts/dapps
|
||||||
@ -272,7 +273,8 @@
|
|||||||
:stickers/packs-owned
|
:stickers/packs-owned
|
||||||
:stickers/packs-pendning
|
:stickers/packs-pendning
|
||||||
:bottom-sheet/show?
|
:bottom-sheet/show?
|
||||||
:bottom-sheet/view]
|
:bottom-sheet/view
|
||||||
|
:extensions/profile]
|
||||||
:opt-un [::modal
|
:opt-un [::modal
|
||||||
::was-modal?
|
::was-modal?
|
||||||
::rpc-url
|
::rpc-url
|
||||||
|
@ -103,8 +103,12 @@
|
|||||||
|
|
||||||
(defn- my-profile-settings [{:keys [seed-backed-up? mnemonic]}
|
(defn- my-profile-settings [{:keys [seed-backed-up? mnemonic]}
|
||||||
{:keys [dev-mode?
|
{:keys [dev-mode?
|
||||||
settings]} currency logged-in?]
|
settings]}
|
||||||
(let [show-backup-seed? (and (not seed-backed-up?) (not (string/blank? mnemonic)))]
|
currency
|
||||||
|
logged-in?
|
||||||
|
extensions]
|
||||||
|
(let [show-backup-seed? (and (not seed-backed-up?) (not (string/blank? mnemonic)))
|
||||||
|
extensions-settings (vals (get extensions :settings))]
|
||||||
[react/view
|
[react/view
|
||||||
[profile.components/settings-title (i18n/label :t/settings)]
|
[profile.components/settings-title (i18n/label :t/settings)]
|
||||||
[profile.components/settings-item {:label-kw :t/ens-names
|
[profile.components/settings-item {:label-kw :t/ens-names
|
||||||
@ -151,6 +155,13 @@
|
|||||||
{:label-kw :t/dapps-permissions
|
{:label-kw :t/dapps-permissions
|
||||||
:accessibility-label :dapps-permissions-button
|
:accessibility-label :dapps-permissions-button
|
||||||
:action-fn #(re-frame/dispatch [:navigate-to :dapps-permissions])}]
|
:action-fn #(re-frame/dispatch [:navigate-to :dapps-permissions])}]
|
||||||
|
(when extensions-settings
|
||||||
|
(for [{:keys [label] :as st} extensions-settings]
|
||||||
|
[react/view
|
||||||
|
[profile.components/settings-item-separator]
|
||||||
|
[profile.components/settings-item
|
||||||
|
{:item-text label
|
||||||
|
:action-fn #(re-frame/dispatch [:navigate-to :my-profile-ext-settings st])}]]))
|
||||||
[profile.components/settings-item-separator]
|
[profile.components/settings-item-separator]
|
||||||
[profile.components/settings-item
|
[profile.components/settings-item
|
||||||
{:label-kw :t/need-help
|
{:label-kw :t/need-help
|
||||||
@ -268,21 +279,29 @@
|
|||||||
|
|
||||||
(defn tribute-to-talk-item [snt-amount seen?]
|
(defn tribute-to-talk-item [snt-amount seen?]
|
||||||
[list.views/big-list-item
|
[list.views/big-list-item
|
||||||
(cond->
|
(cond-> {:text (i18n/label :t/tribute-to-talk)
|
||||||
{:text (i18n/label :t/tribute-to-talk)
|
:icon :main-icons/tribute-to-talk
|
||||||
:icon :main-icons/tribute-to-talk
|
:accessibility-label :notifications-button
|
||||||
:accessibility-label :notifications-button
|
:new? (not seen?)
|
||||||
:new? (not seen?)
|
:action-fn #(re-frame/dispatch
|
||||||
:action-fn #(re-frame/dispatch
|
[:tribute-to-talk.ui/menu-item-pressed])}
|
||||||
[:tribute-to-talk.ui/menu-item-pressed])}
|
|
||||||
snt-amount
|
snt-amount
|
||||||
(assoc :accessory-value (str snt-amount " SNT"))
|
(assoc :accessory-value (str snt-amount " SNT"))
|
||||||
(not (and seen? snt-amount))
|
(not (and seen? snt-amount))
|
||||||
(assoc :subtext (i18n/label :t/tribute-to-talk-desc)))])
|
(assoc :subtext (i18n/label :t/tribute-to-talk-desc)))])
|
||||||
|
|
||||||
|
(defview extensions-settings []
|
||||||
|
(letsubs [{:keys [label view on-close]} [:get-screen-params :my-profile-ext-settings]]
|
||||||
|
[react/keyboard-avoiding-view {:style {:flex 1}}
|
||||||
|
[status-bar/status-bar {:type :main}]
|
||||||
|
[toolbar/simple-toolbar label]
|
||||||
|
[react/scroll-view
|
||||||
|
[view]]]))
|
||||||
|
|
||||||
(defview my-profile []
|
(defview my-profile []
|
||||||
(letsubs [{:keys [public-key photo-path] :as current-account} [:account/account]
|
(letsubs [{:keys [public-key photo-path] :as current-account} [:account/account]
|
||||||
editing? [:get :my-profile/editing?]
|
editing? [:get :my-profile/editing?]
|
||||||
|
extensions [:get :extensions/profile]
|
||||||
changed-account [:get :my-profile/profile]
|
changed-account [:get :my-profile/profile]
|
||||||
currency [:wallet/currency]
|
currency [:wallet/currency]
|
||||||
login-data [:get :accounts/login]
|
login-data [:get :accounts/login]
|
||||||
@ -324,6 +343,6 @@
|
|||||||
[contacts-list-item active-contacts-count]
|
[contacts-list-item active-contacts-count]
|
||||||
(when config/tr-to-talk-enabled?
|
(when config/tr-to-talk-enabled?
|
||||||
[tribute-to-talk-item snt-amount tribute-to-talk-seen?])
|
[tribute-to-talk-item snt-amount tribute-to-talk-seen?])
|
||||||
[my-profile-settings current-account shown-account currency (nil? login-data)]
|
[my-profile-settings current-account shown-account currency (nil? login-data) extensions]
|
||||||
(when (nil? login-data)
|
(when (nil? login-data)
|
||||||
[advanced shown-account on-show-advanced])]]])))
|
[advanced shown-account on-show-advanced])]]])))
|
||||||
|
@ -28,7 +28,8 @@
|
|||||||
:mobile-network-settings
|
:mobile-network-settings
|
||||||
:backup-seed
|
:backup-seed
|
||||||
:tribute-to-talk
|
:tribute-to-talk
|
||||||
:qr-scanner]
|
:qr-scanner
|
||||||
|
:my-profile-ext-settings]
|
||||||
|
|
||||||
config/hardwallet-enabled?
|
config/hardwallet-enabled?
|
||||||
(concat [:hardwallet-authentication-method
|
(concat [:hardwallet-authentication-method
|
||||||
|
@ -117,6 +117,7 @@
|
|||||||
:wallet-settings-assets [:modal wallet-settings/manage-assets]
|
:wallet-settings-assets [:modal wallet-settings/manage-assets]
|
||||||
:wallet-transactions-filter [:modal wallet-transactions/filter-history]
|
:wallet-transactions-filter [:modal wallet-transactions/filter-history]
|
||||||
:my-profile profile.user/my-profile
|
:my-profile profile.user/my-profile
|
||||||
|
:my-profile-ext-settings profile.user/extensions-settings
|
||||||
:contacts-list contacts-list/contacts-list
|
:contacts-list contacts-list/contacts-list
|
||||||
:blocked-users-list contacts-list/blocked-users-list
|
:blocked-users-list contacts-list/blocked-users-list
|
||||||
:profile-photo-capture photo-capture/profile-photo-capture
|
:profile-photo-capture photo-capture/profile-photo-capture
|
||||||
|
Loading…
x
Reference in New Issue
Block a user