Reanimate RPC stats screen

This commit is contained in:
Roman Volosovskyi 2024-01-04 16:46:40 +01:00
parent 4eff9cc39c
commit 09408e7811
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
1 changed files with 48 additions and 48 deletions

View File

@ -6,7 +6,6 @@
[legacy.status-im.ui.components.typography :as typography] [legacy.status-im.ui.components.typography :as typography]
[legacy.status-im.utils.utils :as utils] [legacy.status-im.utils.utils :as utils]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[react-native.core :as rn]
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im.common.json-rpc.events :as json-rpc] [status-im.common.json-rpc.events :as json-rpc]
[taoensso.timbre :as log] [taoensso.timbre :as log]
@ -86,29 +85,28 @@
(defn stats-table (defn stats-table
[{:keys [total filtered-total stats]}] [{:keys [total filtered-total stats]}]
rn/scroll-view [react/scroll-view
{:style {:padding-horizontal 8}} {:style {:padding-horizontal 8}}
rn/view [react/view
{:style {:flex-direction :row [react/view
:justify-content :space-between {:style {:flex-direction :row
:margin-bottom 2}} :justify-content :space-between
[legacy.status-im.ui.components.core/text {:style typography/font-semi-bold} :margin-bottom 2}}
(i18n/label :t/rpc-usage-total)] [legacy.status-im.ui.components.core/text {:style typography/font-semi-bold}
[legacy.status-im.ui.components.core/text {:style typography/font-semi-bold} (i18n/label :t/rpc-usage-total)]
(i18n/label :t/rpc-usage-filtered-total {:filtered-total filtered-total :total total})] [legacy.status-im.ui.components.core/text {:style typography/font-semi-bold}
(when (seq stats) (i18n/label :t/rpc-usage-filtered-total {:filtered-total filtered-total :total total})]]
(for [[k v] stats] [react/view
^{:key (str k v)} {:style {:flex-direction :column
[:<> :flex 1}}
rn/view (when (seq stats)
{:style {:flex-direction :row (for [[k v] stats]
:align-items :center ^{:key (str k v)}
:margin-vertical 10}} [react/view
[legacy.status-im.ui.components.core/text {:style {:flex 1}} {:style {:flex-direction :row
k] :align-items :stretch}}
[legacy.status-im.ui.components.core/text {:style {:margin-left 16}} [legacy.status-im.ui.components.core/text {:style {:flex 7}} k]
v] [legacy.status-im.ui.components.core/text {:style {:flex 1}} v]]))]]])
[legacy.status-im.ui.components.core/separator]])))
(defn prepare-stats (defn prepare-stats
[{:keys [stats]}] [{:keys [stats]}]
@ -125,30 +123,32 @@
[react/view [react/view
{:flex 1 {:flex 1
:margin-horizontal 8} :margin-horizontal 8}
rn/view [react/view
{:style {:flex-direction :row {:style {:flex-direction :column
:margin-vertical 8 :justify-content :space-between}}
:justify-content :space-between}} [react/view
[legacy.status-im.ui.components.core/button {:style {:flex-direction :row
{:on-press #(re-frame/dispatch [::reset]) :justify-content :space-between}}
:accessibility-label :rpc-usage-reset} [legacy.status-im.ui.components.core/button
(i18n/label :t/rpc-usage-reset)] {:on-press #(re-frame/dispatch [::reset])
[legacy.status-im.ui.components.core/button :accessibility-label :rpc-usage-reset}
{:on-press (i18n/label :t/rpc-usage-reset)]
#(react/copy-to-clipboard (prepare-stats stats)) [legacy.status-im.ui.components.core/button
:accessibility-label :rpc-usage-copy} {:on-press
(i18n/label :t/rpc-usage-copy)] #(react/copy-to-clipboard (prepare-stats stats))
[legacy.status-im.ui.components.core/text-input :accessibility-label :rpc-usage-copy}
{:on-change-text #(re-frame/dispatch [::set-filter %]) (i18n/label :t/rpc-usage-copy)]]
:label (i18n/label :t/rpc-usage-filter-methods) [legacy.status-im.ui.components.core/text-input
:placeholder (i18n/label :t/rpc-usage-filter) {:on-change-text #(re-frame/dispatch [::set-filter %])
:container-style {:margin-vertical 18} :label (i18n/label :t/rpc-usage-filter-methods)
:before {:icon :main-icons/search :placeholder (i18n/label :t/rpc-usage-filter)
:style {:padding-horizontal 8}} :container-style {:margin-vertical 18}
:default-value methods-filter :before {:icon :main-icons/search
:auto-capitalize :none :style {:padding-horizontal 8}}
:show-cancel false :default-value methods-filter
:auto-focus false}] :auto-capitalize :none
:show-cancel false
:auto-focus false}]]
[stats-table stats]])) [stats-table stats]]))
(defn usage-info (defn usage-info