Skip to content

Commit

Permalink
Merge branch 'develop' into milad/19775-fix-scanned-address
Browse files Browse the repository at this point in the history
  • Loading branch information
mmilad75 committed May 9, 2024
2 parents 6119423 + 3e5d758 commit 31fafa9
Show file tree
Hide file tree
Showing 23 changed files with 297 additions and 271 deletions.
9 changes: 6 additions & 3 deletions src/legacy/status_im/ui/components/chat_icon/screen.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
[re-frame.core :as re-frame.core]
[react-native.core :as rn]
[status-im.contexts.profile.utils :as profile.utils]
[utils.ens.core :as utils.ens]))
[utils.ens.core :as utils.ens]
[utils.image-server :as image-server]))

;;TODO REWORK THIS NAMESPACE

Expand Down Expand Up @@ -156,9 +157,11 @@
(styles/default-chat-icon-text size)
(styles/emoji-chat-icon-text size))}
override-styles)
photo-path (if (:fn photo-path)
img-config (:config photo-path)
photo-path (if img-config
;; temp support new media server avatar for old component
{:uri ((:fn photo-path)
{:uri (image-server/get-image-uri
img-config
{:size size
:full-name name
:font-size (get-in styles [:default-chat-icon-text :font-size])
Expand Down
28 changes: 15 additions & 13 deletions src/quo/components/avatars/user_avatar/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[react-native.core :as rn]
[react-native.fast-image :as fast-image]
[schema.core :as schema]
[utils.image-server :as image-server]
utils.string))

(defn initials-avatar
Expand Down Expand Up @@ -38,32 +39,33 @@
online? true
ring? true}
:as props}]
(let [theme (quo.theme/use-theme)
full-name (or full-name "Your Name")
(let [theme (quo.theme/use-theme)
picture-config (:config profile-picture)
full-name (or full-name "Your Name")
;; image generated with `profile-picture-fn` is round cropped
;; no need to add border-radius for them
outer-styles (style/outer size (not (:fn profile-picture)))
outer-styles (style/outer size (not picture-config))
;; Once image is loaded, fast image re-renders view with the help of reagent atom,
;; But dynamic updates don't work when user-avatar is used inside hole-view
;; https://github.com/status-im/status-mobile/issues/15553
image-view (if static? no-flicker-image/image fast-image/fast-image)
font-size (get-in style/sizes [size :font-size])
amount-initials (if (#{:xs :xxs :xxxs} size) 1 2)
sizes (get style/sizes size)
indicator-color (get (style/indicator-color theme) (if online? :online :offline))
profile-picture-fn (:fn profile-picture)]
image-view (if static? no-flicker-image/image fast-image/fast-image)
font-size (get-in style/sizes [size :font-size])
amount-initials (if (#{:xs :xxs :xxxs} size) 1 2)
sizes (get style/sizes size)
indicator-color (get (style/indicator-color theme) (if online? :online :offline))]

[rn/view {:style outer-styles :accessibility-label :user-avatar}
(if (and full-name (not (or profile-picture-fn profile-picture)))
(if (and full-name (not (or picture-config profile-picture)))
;; this is for things that's not user-avatar but are currently using user-avatar to render
;; the initials e.g. community avatar
[initials-avatar props]
[image-view
{:accessibility-label :profile-picture
:style outer-styles
:source
(cond profile-picture-fn
{:uri (profile-picture-fn
(cond picture-config
{:uri (image-server/get-image-uri
picture-config
{:length amount-initials
:full-name full-name
:font-size (:font-size (text/text-style {:size
Expand All @@ -76,7 +78,7 @@
:indicator-center-to-edge (when status-indicator?
(:status-indicator-center-to-edge sizes))
:indicator-color indicator-color
:override-theme theme
:theme theme
:color (:color style/initials-avatar-text)
:size (:width outer-styles)
:ring? ring?
Expand Down
9 changes: 8 additions & 1 deletion src/quo/components/buttons/wallet_ctas/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}} text]])

(defn view
[{:keys [buy-action send-action receive-action bridge-action container-style]}]
[{:keys [buy-action send-action receive-action bridge-action swap-action container-style]}]
(let [theme (quo.theme/use-theme)]
[rn/view {:style container-style}
[rn/view {:style style/inner-container}
Expand All @@ -46,6 +46,13 @@
:on-press receive-action
:theme theme
:accessibility-label :receive}]
(when swap-action
[action-button
{:icon :i/swap
:text (i18n/label :t/swap)
:on-press swap-action
:theme theme
:accessibility-label :swap}])
[action-button
{:icon :i/bridge
:text (i18n/label :t/bridge)
Expand Down
11 changes: 6 additions & 5 deletions src/quo/components/community/channel_actions/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
[rn/view {:style (assoc container-style :flex-direction :row)}
(map-indexed
(fn [index action]
^{:key index}
[:<>
[channel-action/view action]
(when (not= action (last actions))
[rn/view {:width 16}])])
(when action
^{:key index}
[:<>
[channel-action/view action]
(when (not= action (last actions))
[rn/view {:style {:width 16}}])]))
actions)])
61 changes: 54 additions & 7 deletions src/schema/quo.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,77 @@
[quo.foundations.colors :as colors]
[schema.registry :as registry]))

(def ^:private ?profile-picture-fn-params
(def ^:private ?customization-color (into [:enum :primary] colors/account-colors))

(def ^:private ?profile-picture-options
[:map
[:length :int]
[:full-name :string]
[:font-size :int]
[:indicator-size {:optional true} [:maybe :int]]
[:indicator-color {:optional true} [:maybe :string]]
[:indicator-center-to-edge {:optional true} [:maybe :int]]
[:override-theme :schema.common/theme]
[:background-color :string]
[:theme :schema.common/theme]
[:color :string]
[:size :int]
[:ring? :boolean]
[:ring-width :int]])

(def ^:private ?account-image-uri-options
[:map
[:port :int]
[:ratio :double]
[:key-uid :string]
[:image-name :string]
[:theme :schema.common/theme]
[:override-ring? [:maybe :boolean]]])

(def ^:private ?initials-image-uri-options
[:map
[:port :int]
[:ratio :double]
[:uppercase-ratio :double]
[:font-file :string]
[:theme :schema.common/theme]
[:customization-color ?customization-color]
[:key-uid {:optional true} [:maybe :string]]
[:public-key {:optional true} [:maybe :string]]
[:override-ring? {:optional true} [:maybe :boolean]]])

(def ^:private ?contact-image-uri-options
[:map
[:port :int]
[:clock :int]
[:ratio :double]
[:image-name :string]
[:public-key :string]
[:theme :schema.common/theme]
[:override-ring? [:maybe :boolean]]])

(def ^:private ?image-uri-config
[:multi {:dispatch :type}
[:account
[:map
[:type [:= :account]]
[:options ?account-image-uri-options]]]
[:contact
[:map
[:type [:= :contact]]
[:options ?contact-image-uri-options]]]
[:initials
[:map
[:type [:= :initials]]
[:options ?initials-image-uri-options]]]])

(def ^:private ?profile-picture-source
[:or
:schema.common/image-source
[:map
[:fn [:=> [:cat ?profile-picture-fn-params] :string]]]])

(def ^:private ?customization-color (into [:enum] colors/account-colors))
[:config ?image-uri-config]]])

(defn register-schemas
[]
(registry/register ::customization-color ?customization-color)
(registry/register ::image-uri-config ?image-uri-config)
(registry/register ::profile-picture-source ?profile-picture-source)
(registry/register ::customization-color ?customization-color))
(registry/register ::profile-picture-options ?profile-picture-options))
5 changes: 3 additions & 2 deletions src/status_im/common/controlled_input/utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@

(defn add-character
[state character]
(when (can-add-character? state character)
(if (can-add-character? state character)
(set-input-value state
(normalize-value-as-numeric (input-value state) character))))
(normalize-value-as-numeric (input-value state) character))
state))

(defn delete-last
[state]
Expand Down
17 changes: 6 additions & 11 deletions src/status_im/common/home/actions/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -365,23 +365,21 @@
:sub-label nil
:chevron? false}))

;; TODO(OmarBasem): to be implemented.
(defn add-members-entry
[]
[chat-id]
(entry {:icon :i/add-user
:label (i18n/label :t/add-members)
:on-press #(js/alert "TODO: to be implemented")
:on-press #(rf/dispatch [:open-modal :group-add-manage-members chat-id])
:danger? false
:accessibility-label :add-members
:sub-label nil
:chevron? false}))

;; TODO(OmarBasem): to be implemented.
(defn manage-members-entry
[]
[chat-id]
(entry {:icon :i/add-user
:label (i18n/label :t/manage-members)
:on-press #(js/alert "TODO: to be implemented")
:on-press #(rf/dispatch [:open-modal :group-add-manage-members chat-id])
:danger? false
:accessibility-label :manage-members
:sub-label nil
Expand Down Expand Up @@ -435,11 +433,8 @@
admin? (get admins current-pub-key)]
[(group-details-entry chat-id)
(when inside-chat?
(if admin?
(when config/show-not-implemented-features?
(manage-members-entry))
(when config/show-not-implemented-features?
(add-members-entry))))
(when admin?
(manage-members-entry chat-id)))
(when (and admin? inside-chat?)
(when config/show-not-implemented-features?
(edit-group-entry)))
Expand Down
40 changes: 21 additions & 19 deletions src/status_im/contexts/chat/group_details/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[quo.foundations.colors :as colors]
[quo.theme]
[react-native.core :as rn]
[react-native.gesture :as gesture]
[react-native.safe-area :as safe-area]
[reagent.core :as reagent]
[status-im.common.contact-list-item.view :as contact-list-item]
Expand Down Expand Up @@ -43,12 +44,11 @@

(defn add-manage-members
[]
(let [selected-participants (rf/sub [:group-chat/selected-participants])
deselected-members (rf/sub [:group-chat/deselected-members])
chat-id (rf/sub [:get-screen-params :group-details])
{:keys [admins] :as group} (rf/sub [:chats/chat-by-id chat-id])
theme (quo.theme/use-theme)
admin? (get admins (rf/sub [:multiaccount/public-key]))]
(let [selected-participants (rf/sub [:group-chat/selected-participants])
deselected-members (rf/sub [:group-chat/deselected-members])
chat-id (rf/sub [:get-screen-params :group-add-manage-members])
group (rf/sub [:chats/chat-by-id chat-id])
theme (quo.theme/use-theme)]
[rn/view {:flex 1 :margin-top 20}
[rn/touchable-opacity
{:on-press #(rf/dispatch [:navigate-back])
Expand All @@ -59,8 +59,8 @@
{:size :heading-1
:weight :semi-bold
:style {:margin-left 20}}
(i18n/label (if admin? :t/manage-members :t/add-members))]
[rn/section-list
(i18n/label :t/manage-members)]
[gesture/section-list
{:key-fn :title
:sticky-section-headers-enabled false
:sections (rf/sub [:contacts/grouped-by-first-letter])
Expand Down Expand Up @@ -139,7 +139,8 @@
:customization-color color}}]
[quo/channel-actions
{:container-style style/actions-view
:actions [{:accessibility-label :pinned-messages
:actions [{:big? (not admin?)
:accessibility-label :pinned-messages
:label (i18n/label :t/pinned-messages)
:customization-color color
:icon :i/pin
Expand All @@ -155,16 +156,17 @@
:on-press #(rf/dispatch [:chat.ui/mute chat-id (not muted)
(when-not muted
constants/mute-till-unmuted)])}
{:accessibility-label :manage-members
:customization-color color
:icon :i/add-user
:label (i18n/label (if admin? :t/manage-members :t/add-members))
:counter-value (count contacts)
:on-press (fn []
(rf/dispatch [:group/clear-added-participants])
(rf/dispatch [:group/clear-removed-members])
(rf/dispatch [:open-modal :group-add-manage-members
chat-id]))}]}]
(when admin?
{:accessibility-label :manage-members
:customization-color color
:icon :i/add-user
:label (i18n/label :t/manage-members)
:counter-value (count contacts)
:on-press (fn []
(rf/dispatch [:group/clear-added-participants])
(rf/dispatch [:group/clear-removed-members])
(rf/dispatch [:open-modal :group-add-manage-members
chat-id]))})]}]
[rn/section-list
{:key-fn :title
:sticky-section-headers-enabled false
Expand Down
3 changes: 2 additions & 1 deletion src/status_im/contexts/preview/quo/buttons/wallet_ctas.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
:buy-action #(js/alert "Buy button pressed")
:send-action #(js/alert "Send button pressed")
:receive-action #(js/alert "Receive button pressed")
:bridge-action #(js/alert "Bridge button pressed")}]])
:bridge-action #(js/alert "Bridge button pressed")
:swap-action #(js/alert "Swap button pressed")}]])
15 changes: 10 additions & 5 deletions src/status_im/contexts/wallet/account/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,30 @@
{:type :wallet-networks
:on-press #(rf/dispatch [:wallet/close-account-page])}]
[quo/account-overview
{:container-style style/account-overview
:current-value formatted-balance
{:current-value formatted-balance
:account-name name
:account (if watch-only? :watched-address :default)
:customization-color color}]
(when (ff/enabled? ::ff/wallet.graph) [quo/wallet-graph {:time-frame :empty}])
[quo/wallet-graph {:time-frame :empty}]
(when (not watch-only?)
[quo/wallet-ctas
{:container-style style/cta-buttons
:send-action (fn []
(rf/dispatch [:wallet/clean-send-data])
(rf/dispatch [:wallet/wizard-navigate-forward
{:start-flow? true
:flow-id :wallet-flow}]))
:flow-id :wallet-send-flow}]))
:receive-action #(rf/dispatch [:open-modal :screen/wallet.share-address
{:status :receive}])
:buy-action #(rf/dispatch [:show-bottom-sheet
{:content buy-token/view}])
:bridge-action #(rf/dispatch [:wallet/start-bridge])}])
:bridge-action (fn []
(rf/dispatch [:wallet/clean-send-data])
(rf/dispatch [:wallet/wizard-navigate-forward
{:start-flow? true
:flow-id :wallet-bridge-flow}]))
:swap-action (when (ff/enabled? ::ff/wallet.swap)
#(rf/dispatch [:wallet/start-swap]))}])
[quo/tabs
{:style style/tabs
:size 32
Expand Down
11 changes: 11 additions & 0 deletions src/status_im/contexts/wallet/bridge/flow_config.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(ns status-im.contexts.wallet.bridge.flow-config)

(def steps
[{:screen-id :screen/wallet.bridge-select-asset
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :token])))}
{:screen-id :screen/wallet.bridge-to
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :bridge-to-chain-id])))}
{:screen-id :screen/wallet.bridge-input-amount
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :amount])))}
{:screen-id :screen/wallet.transaction-confirmation}
{:screen-id :screen/wallet.transaction-progress}])

0 comments on commit 31fafa9

Please sign in to comment.