Skip to content

Commit

Permalink
Merge branch 'develop' into 19188
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrkhalil authored Mar 26, 2024
2 parents a5b5476 + 6a88a34 commit b7878a1
Show file tree
Hide file tree
Showing 13 changed files with 209 additions and 181 deletions.
5 changes: 4 additions & 1 deletion src/legacy/status_im/data_store/chats.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@

(defn <-color
[value]
(if (string/starts-with? value "#") value (keyword value)))
(if (and (some? value)
(string/starts-with? value "#"))
value
(keyword value)))

(defn <-rpc
[chat]
Expand Down
25 changes: 14 additions & 11 deletions src/react_native/keychain.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,26 @@
([server username password]
(save-credentials server username password identity))
([server username password callback]
(-> (.setInternetCredentials ^js react-native-keychain
(string/lower-case server)
username
password
keychain-secure-hardware
keychain-restricted-availability)
(.then callback))))
(when-not (empty? server)
(-> (.setInternetCredentials ^js react-native-keychain
(string/lower-case server)
username
password
keychain-secure-hardware
keychain-restricted-availability)
(.then callback)))))

(defn get-credentials
"Gets the credentials for a specified server from the Keychain"
([server]
(get-credentials server identity))
([server callback]
(-> (.getInternetCredentials ^js react-native-keychain (string/lower-case server))
(.then callback))))
(when-not (empty? server)
(-> (.getInternetCredentials ^js react-native-keychain (string/lower-case server))
(.then callback)))))

(defn reset-credentials
[server]
(-> (.resetInternetCredentials ^js react-native-keychain (string/lower-case server))
(.then #(when-not % (log/error (str "Error while clearing saved password."))))))
(when-not (empty? server)
(-> (.resetInternetCredentials ^js react-native-keychain (string/lower-case server))
(.then #(when-not % (log/error (str "Error while clearing saved password.")))))))
32 changes: 22 additions & 10 deletions src/status_im/common/floating_button_page/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
(reset! ratom height))))

(defn- init-keyboard-listeners
[{:keys [on-did-show]}]
[{:keys [on-did-show scroll-view-ref]}]
(let [keyboard-will-show? (reagent/atom false)
keyboard-did-show? (reagent/atom false)
add-listener (fn [listener callback]
Expand All @@ -41,7 +41,10 @@
(reset! keyboard-did-show? true)
(when on-did-show (on-did-show e))))
will-hide-listener (add-listener "keyboardWillHide"
#(reset! keyboard-will-show? false))
(fn []
(reset! keyboard-will-show? false)
(reagent/flush)
(.scrollTo @scroll-view-ref #js {:x 0 :y 0 :animated true})))
did-hide-listener (add-listener "keyboardDidHide"
#(reset! keyboard-did-show? false))
remove-listeners (fn []
Expand All @@ -55,9 +58,11 @@
(defn view
[{:keys [header footer customization-color footer-container-padding header-container-style
gradient-cover?]
:or {footer-container-padding (safe-area/get-top)}} &
children]
(reagent/with-let [window-height (:height (rn/get-window))
:or {footer-container-padding (safe-area/get-top)}}
& children]
(reagent/with-let [scroll-view-ref (atom nil)
set-scroll-ref #(reset! scroll-view-ref %)
window-height (:height (rn/get-window))
footer-container-height (reagent/atom 0)
header-height (reagent/atom 0)
content-container-height (reagent/atom 0)
Expand All @@ -66,7 +71,8 @@
{:keys [keyboard-will-show?
keyboard-did-show?
remove-listeners]} (init-keyboard-listeners
{:on-did-show
{:scroll-view-ref scroll-view-ref
:on-did-show
(fn [e]
(reset! keyboard-height
(oops/oget e "endCoordinates.height")))})
Expand All @@ -85,16 +91,22 @@
:header-height @header-height
:keyboard-shown? keyboard-shown?})]
[:<>
(when gradient-cover? [quo/gradient-cover {:customization-color customization-color}])
(when gradient-cover?
[quo/gradient-cover {:customization-color customization-color}])
[rn/view {:style style/page-container}
[rn/view
{:on-layout set-header-height
:style header-container-style}
header]
[gesture/scroll-view
{:on-scroll set-content-y-scroll
:scroll-event-throttle 64
:content-container-style {:flex-grow 1}}
{:ref set-scroll-ref
:on-scroll set-content-y-scroll
:scroll-event-throttle 64
:content-container-style {:flex-grow 1
:padding-bottom (when @keyboard-did-show?
@footer-container-height)}
:always-bounce-vertical @keyboard-did-show?
:shows-vertical-scroll-indicator false}
(into [rn/view {:on-layout set-content-container-height}]
children)]
[rn/keyboard-avoiding-view
Expand Down
112 changes: 60 additions & 52 deletions src/status_im/contexts/chat/home/add_new_contact/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[quo.core :as quo]
[react-native.clipboard :as clipboard]
[react-native.core :as rn]
[reagent.core :as reagent]
[status-im.contexts.chat.home.add-new-contact.style :as style]
[utils.address :as address]
[utils.debounce :as debounce]
Expand Down Expand Up @@ -51,57 +50,66 @@

(defn- search-input
[]
(reagent/with-let [input-value (reagent/atom nil)
input-ref (atom nil)
clear-input (fn []
(reset! input-value nil)
(rf/dispatch [:contacts/clear-new-identity]))
paste-on-input #(clipboard/get-string
(fn [clipboard-text]
(reset! input-value clipboard-text)
(rf/dispatch [:contacts/set-new-identity
{:input clipboard-text}])))]
(let [{:keys [scanned] contact-public-key :id} (rf/sub [:contacts/new-identity])
contact-public-key-or-scanned (or contact-public-key scanned)
empty-input? (and (string/blank? @input-value)
(string/blank? contact-public-key-or-scanned))]
[rn/view {:style style/input-and-scan-container}
[quo/input
{:accessibility-label :enter-contact-code-input
:ref #(reset! input-ref %)
:container-style {:flex 1}
:auto-capitalize :none
:multiline? true
:blur-on-submit true
:return-key-type :done
:label (i18n/label :t/ens-or-chat-key)
:placeholder (i18n/label :t/type-some-chat-key)
:clearable? (not empty-input?)
:on-clear clear-input
:button (when empty-input?
{:on-press paste-on-input
:text (i18n/label :t/paste)})
;; NOTE: `contact-public-key-or-scanned` has priority over `@input-value`,
;; we clean it when the input is updated so that it's `nil` and
;; `@input-value`is shown. To fastly clean it, we use `dispatch-sync`.
;; This call could be avoided if `::qr-scanner/scan-code` were able to
;; receive a callback function, not only a re-frame event as callback.
:value (or contact-public-key-or-scanned @input-value)
:on-change-text (fn [new-text]
(reset! input-value new-text)
(as-> [:contacts/set-new-identity {:input new-text}] $
(if (string/blank? contact-public-key-or-scanned)
(debounce/debounce-and-dispatch $ 600)
(rf/dispatch-sync $))))}]
[rn/view {:style style/scan-button-container}
[quo/button
{:type :outline
:icon-only? true
:size 40
:on-press #(rf/dispatch [:open-modal :scan-profile-qr-code])}
:i/scan]]])
(finally
(rf/dispatch [:contacts/clear-new-identity]))))
(let [[input-value set-input-value] (rn/use-state nil)
input-ref (rn/use-ref-atom nil)
on-ref (rn/use-callback #(reset! input-ref %))
{:keys [scanned]
contact-public-key :id} (rf/sub [:contacts/new-identity])
contact-public-key-or-scanned (or contact-public-key scanned)
empty-input? (and (string/blank? input-value)
(string/blank? contact-public-key-or-scanned))
clear-input (rn/use-callback
(fn []
(set-input-value nil)
(rf/dispatch [:contacts/clear-new-identity])))
paste-on-input (rn/use-callback
(fn []
(clipboard/get-string
(fn [clipboard-text]
(set-input-value clipboard-text)
(rf/dispatch [:contacts/set-new-identity
{:input clipboard-text}])))))
on-change-text (rn/use-callback
(fn [new-text]
(set-input-value new-text)
(if (string/blank? contact-public-key-or-scanned)
(debounce/debounce-and-dispatch [:contacts/set-new-identity
{:input new-text}]
600)
(rf/dispatch-sync [:contacts/set-new-identity
{:input new-text}])))
[contact-public-key-or-scanned])]
(rn/use-unmount #(rf/dispatch [:contacts/clear-new-identity]))
[rn/view {:style style/input-and-scan-container}
[quo/input
{:accessibility-label :enter-contact-code-input
:ref on-ref
:container-style {:flex 1}
:auto-capitalize :none
:multiline? true
:blur-on-submit true
:return-key-type :done
:label (i18n/label :t/ens-or-chat-key)
:placeholder (i18n/label :t/type-some-chat-key)
:clearable? (not empty-input?)
:on-clear clear-input
:button (when empty-input?
{:on-press paste-on-input
:text (i18n/label :t/paste)})
;; NOTE: `contact-public-key-or-scanned` has priority over `input-value`,
;; we clean it when the input is updated so that it's `nil` and
;; `input-value`is shown. To fastly clean it, we use `dispatch-sync`.
;; This call could be avoided if `::qr-scanner/scan-code` were able to
;; receive a callback function, not only a re-frame event as callback.
:value (or contact-public-key-or-scanned input-value)
:on-change-text on-change-text}]
[rn/view {:style style/scan-button-container}
[quo/button
{:type :outline
:icon-only? true
:size 40
:on-press #(rf/dispatch [:open-modal :scan-profile-qr-code])}
:i/scan]]]))

(defn- invalid-text
[message]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
has-permissions? (rf/sub [:communities/has-permissions? id])
airdrop-account (rf/sub [:communities/airdrop-account id])
revealed-accounts (rf/sub [:communities/accounts-to-reveal id])
revealed-accounts-count (count revealed-accounts)
wallet-accounts-count (count (rf/sub [:wallet/accounts-without-watched-accounts]))
addresses-shared-text (if (= revealed-accounts-count wallet-accounts-count)
(i18n/label :t/all-addresses)
(i18n/label-pluralize
revealed-accounts-count
:t/address-count))
{:keys [highest-permission-role]} (rf/sub [:community/token-gated-overview id])
highest-role-text (i18n/label (communities.utils/role->translation-key
highest-permission-role
Expand Down Expand Up @@ -110,7 +117,7 @@
:label :preview
:label-props {:type :accounts
:data revealed-accounts}
:description-props {:text (i18n/label :t/all-addresses)}}
:description-props {:text addresses-shared-text}}
{:title (i18n/label :t/for-airdrops)
:on-press show-airdrop-addresses
:description :text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,19 @@

(defn view
[]
(let [{:keys [address]} (rf/sub [:get-screen-params])
number-of-accounts (count (rf/sub [:wallet/watch-only-accounts]))
account-name (reagent/atom "")
placeholder (i18n/label :t/default-watched-address-placeholder
{:number (inc number-of-accounts)})
account-color (reagent/atom (rand-nth colors/account-colors))
account-emoji (reagent/atom (emoji-picker.utils/random-emoji))
on-change-name #(reset! account-name %)
on-change-color #(reset! account-color %)
on-change-emoji #(reset! account-emoji %)]
(let [{:keys [address]} (rf/sub [:get-screen-params])
placeholder (i18n/label :t/default-watched-address-placeholder)
account-name (reagent/atom "")
account-color (reagent/atom (rand-nth colors/account-colors))
account-emoji (reagent/atom (emoji-picker.utils/random-emoji))
on-change-name #(reset! account-name %)
on-change-color #(reset! account-color %)
on-change-emoji #(reset! account-emoji %)]
(fn []
[rn/view {:style style/container}
[create-or-edit-account/view
{:page-nav-right-side [{:icon-name :i/info
:on-press
#(js/alert
"Get info (to be
implemented)")}]
:on-press #(js/alert "Get info (to be implemented)")}]
:placeholder placeholder
:account-name @account-name
:account-emoji @account-emoji
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@
on-change-name
on-change-color
on-change-emoji section-label
hide-bottom-action?
bottom-action-label bottom-action-props
custom-bottom-action watch-only?]} & children]
(let [{window-width :width} (rn/get-window)
footer (when-not hide-bottom-action?
(if custom-bottom-action
custom-bottom-action
[quo/button
(merge
{:size 40
:type :primary}
bottom-action-props)
(i18n/label bottom-action-label)]))]
footer (if custom-bottom-action
custom-bottom-action
[quo/button
(merge {:size 40
:type :primary}
bottom-action-props)
(i18n/label bottom-action-label)])]
[floating-button-page/view
{:header [quo/page-nav
{:type :no-title
Expand Down
7 changes: 1 addition & 6 deletions src/status_im/contexts/wallet/create_account/style.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,4 @@
{:margin-top 12
:margin-bottom 8})

(defn slide-button-container
[bottom]
{:position :absolute
:bottom (+ bottom 12)
:left 20
:right 20})
(def slide-button-container {:z-index 1})
Loading

0 comments on commit b7878a1

Please sign in to comment.