-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
191 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
(ns status-im.ui.components.invite.chat | ||
(:require [quo.design-system.colors :as colors] | ||
[quo.design-system.spacing :as spacing] | ||
[quo.react-native :as rn] | ||
[re-frame.core :as re-frame] | ||
[status-im.ethereum.tokens :as tokens] | ||
[status-im.acquisition.core :as acquisition] | ||
[clojure.string :as cstr] | ||
[quo.core :as quo] | ||
[status-im.acquisition.chat :as acquisition.chat] | ||
[status-im.utils.config :as config] | ||
[status-im.ui.components.invite.events :as invite] | ||
[status-im.i18n :as i18n] | ||
[status-im.ui.components.invite.style :as styles])) | ||
|
||
(defn messages-wrapper [] | ||
(:small spacing/padding-vertical)) | ||
|
||
(defn message-wrapper [] | ||
{:padding-right 96 | ||
:padding-left 8 | ||
:flex-direction :row}) | ||
|
||
(defn message-view [] | ||
{:border-top-left-radius 16 | ||
:border-top-right-radius 16 | ||
:border-bottom-right-radius 16 | ||
:border-radius 8 | ||
:border-bottom-left-radius 4 | ||
:border-width 1 | ||
:margin-bottom 4 | ||
:border-color (:border-01 @colors/theme)}) | ||
|
||
(defn message-text [] | ||
(merge (:small spacing/padding-horizontal) | ||
{:padding-vertical 6})) | ||
|
||
(defn author-text [] | ||
(merge (:small spacing/padding-horizontal) | ||
{:padding-top (:tiny spacing/spacing) | ||
:paddingbottom (:x-tiny spacing/spacing)})) | ||
|
||
(defn button-message [] | ||
{:flex-direction :row | ||
:justify-content :center | ||
:align-items :center}) | ||
|
||
(defn starter-pack-style [] | ||
(merge (:small spacing/padding-horizontal) | ||
(:small spacing/padding-vertical) | ||
{:background-color (:interactive-02 @colors/theme) | ||
:flex-direction :row | ||
:border-bottom-width 1 | ||
:border-top-width 1 | ||
:border-color (:border-02 @colors/theme)})) | ||
|
||
(defn starter-pack [] | ||
(let [{:keys [tokens eth-amount tokens-amount]} | ||
@(re-frame/subscribe [::acquisition/starter-pack]) | ||
|
||
all-tokens @(re-frame/subscribe [:wallet/all-tokens]) | ||
chain @(re-frame/subscribe [:ethereum/chain-keyword]) | ||
tokens (->> tokens | ||
(map #(tokens/address->token all-tokens %)) | ||
(into [(get tokens/all-native-currencies chain)]) | ||
(mapv (fn [v i k] [k v i]) | ||
(into [eth-amount] tokens-amount) | ||
(range))) | ||
reward-text (cstr/join ", " (map (comp name :symbol first) tokens))] | ||
[rn/view {:style (starter-pack-style)} | ||
[rn/view {:style {:padding-right 16}} | ||
(doall | ||
(for [[{name :name | ||
{source :source} :icon} _ idx] tokens] | ||
^{:key name} | ||
[rn/view {:style (styles/reward-token-icon idx)} | ||
[rn/image {:source (if (fn? source) (source) source) | ||
:style {:width 40 | ||
:height 40}}]]))] | ||
[rn/view {:style styles/reward-description} | ||
[quo/text {:weight :medium} | ||
"Starter Pack"] | ||
[quo/text {} reward-text]]])) | ||
|
||
(defn render-message [{:keys [content]}] | ||
[rn/view {:style (message-wrapper)} | ||
[rn/view {:style (message-view)} | ||
(for [{:keys [type value]} content] | ||
(case type | ||
:text [rn/view {:style (message-text)} | ||
[quo/text value]] | ||
:pack [starter-pack] | ||
:author [rn/view {:style (author-text)} | ||
[quo/text {:color :secondary} | ||
value]] | ||
:button [rn/view {:style (button-message)} | ||
value] | ||
nil))]]) | ||
|
||
(defn reward-messages [] | ||
(when config/referrals-invite-enabled? | ||
(let [pending-invite @(re-frame/subscribe [::invite/pending-chat-invite]) | ||
messages [{:content [{:type :text | ||
:value "👋"}]} | ||
{:content [{:type :author | ||
:value (i18n/label :t/invite-chat-name)} | ||
{:type :text | ||
:value (i18n/label :t/invite-chat-intro)} | ||
{:type :pack} | ||
{:type :button | ||
:value [quo/button {:type :secondary | ||
:on-press #(re-frame/dispatch [::acquisition.chat/accept-pack])} | ||
(i18n/label :t/invite-chat-accept)]}]} | ||
{:content [{:type :text | ||
:value (i18n/label :t/invite-chat-rule)}]} | ||
{:content [{:type :text | ||
:value [:<> | ||
(i18n/label :t/invite-privacy-policy1) " " | ||
[quo/text {:color :link | ||
:on-press #(re-frame/dispatch [::invite/terms-and-conditions])} | ||
(i18n/label :t/invite-privacy-policy2)]]}]}]] | ||
(when pending-invite | ||
[rn/view {:style (messages-wrapper)} | ||
(for [message messages] | ||
[render-message message])])))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters