diff --git a/resources/icons/lock.svg b/resources/icons/lock.svg new file mode 100644 index 0000000000..e679bea758 --- /dev/null +++ b/resources/icons/lock.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/status_im/chat/screen.cljs b/src/status_im/chat/screen.cljs index 516a3d364d..09ed3b74ab 100644 --- a/src/status_im/chat/screen.cljs +++ b/src/status_im/chat/screen.cljs @@ -4,6 +4,7 @@ [re-frame.core :as re-frame] [status-im.constants :as constants] [status-im.i18n :as i18n] + [status-im.chat.models :as models.chat] [status-im.chat.styles.screen :as style] [status-im.utils.platform :as platform] [status-im.chat.views.toolbar-content :as toolbar-content] @@ -38,7 +39,7 @@ (defview add-contact-bar [contact-identity] (letsubs [{:keys [pending?] :as contact} [:get-contact-by-identity contact-identity]] - (when (or pending? (not contact)) ;; contact is pending or not in contact list at all + (when (or pending? (nil? pending?)) ;; contact is pending or not in contact list at all [react/touchable-highlight {:on-press #(re-frame/dispatch [:add-contact contact-identity]) :accessibility-label :add-to-contacts-button} @@ -99,18 +100,34 @@ [react/animated-view {:style (style/message-view-animated opacity)} message-view]]])) +(defview empty-chat-container [{:keys [group-chat chat-id]}] + (letsubs [contact [:get-contact-by-identity chat-id]] + (let [one-to-one (and (not group-chat) + (not (:dapp? contact)))] + [react/view style/empty-chat-container + (when one-to-one + [vector-icons/icon :icons/lock]) + [react/text {:style style/empty-chat-text} + (cond + (= chat-id constants/console-chat-id) + (i18n/label :t/empty-chat-description-console) + + one-to-one + [react/text style/empty-chat-container-one-to-one + (i18n/label :t/empty-chat-description-one-to-one) + [react/text {:style style/empty-chat-text-name} (:name contact)]] + + :else + (i18n/label :t/empty-chat-description))]]))) + (defview messages-view [group-chat] (letsubs [messages [:get-current-chat-messages-stream] - chat-id [:get-current-chat-id] + chat [:get-current-chat] current-public-key [:get-current-public-key]] {:component-did-mount #(re-frame/dispatch [:set-chat-ui-props {:messages-focused? true :input-focused? false}])} (if (empty? messages) - [react/view style/empty-chat-container - [react/text {:style style/empty-chat-text} - (if (= chat-id constants/console-chat-id) - (i18n/label :t/empty-chat-description-console) - (i18n/label :t/empty-chat-description))]] + [empty-chat-container chat] [list/flat-list {:data messages :key-fn #(or (:message-id %) (:value %)) :render-fn (fn [message] diff --git a/src/status_im/chat/styles/screen.cljs b/src/status_im/chat/styles/screen.cljs index 7597d6be9d..9bccdbabed 100644 --- a/src/status_im/chat/styles/screen.cljs +++ b/src/status_im/chat/styles/screen.cljs @@ -209,9 +209,12 @@ {:opacity opacity :flex 1}) +(def empty-chat-container-one-to-one + {:margin-top 10}) + (def empty-chat-container {:flex 1 - :flex-direction :row + :flex-direction :column :justify-content :center :align-items :center :padding-vertical 50 @@ -219,7 +222,11 @@ (def empty-chat-text {:color colors/gray - :font-size 14 - :line-height 20 + :width 280 + :font-size 15 + :line-height 22 :letter-spacing -0.2 :text-align :center}) + +(def empty-chat-text-name + {:color colors/black}) diff --git a/src/status_im/translations/en.cljs b/src/status_im/translations/en.cljs index c3f86a5f63..8d5c709028 100644 --- a/src/status_im/translations/en.cljs +++ b/src/status_im/translations/en.cljs @@ -242,6 +242,7 @@ :set-a-topic "Set a topic" :empty-chat-description "There are no messages \nin this chat yet" :empty-chat-description-console "Look under the hood! Console is a javascript runtime environment that exposes the whole web3 API. Type \"web3.\" to get started." + :empty-chat-description-one-to-one "Any messages you send here are encrypted and can only be read by you and " :counter-99-plus "99+" :show-more "Show more" :show-less "Show less" diff --git a/src/status_im/ui/components/icons/vector_icons.cljs b/src/status_im/ui/components/icons/vector_icons.cljs index 5dae7c455c..87c8f8a907 100644 --- a/src/status_im/ui/components/icons/vector_icons.cljs +++ b/src/status_im/ui/components/icons/vector_icons.cljs @@ -61,6 +61,7 @@ :icons/hamburger (components.svg/slurp-svg "./resources/icons/hamburger.svg") :icons/hidden (components.svg/slurp-svg "./resources/icons/hidden.svg") :icons/in-contacts (components.svg/slurp-svg "./resources/icons/in_contacts.svg") + :icons/lock (components.svg/slurp-svg "./resources/icons/lock.svg") :icons/mic (components.svg/slurp-svg "./resources/icons/mic.svg") :icons/ok (components.svg/slurp-svg "./resources/icons/ok.svg") :icons/public (components.svg/slurp-svg "./resources/icons/public.svg") diff --git a/src/status_im/ui/screens/contacts/subs.cljs b/src/status_im/ui/screens/contacts/subs.cljs index 12a247bac3..f276f578f8 100644 --- a/src/status_im/ui/screens/contacts/subs.cljs +++ b/src/status_im/ui/screens/contacts/subs.cljs @@ -64,7 +64,9 @@ (reg-sub :get-contact-by-identity :<- [:get-contacts] (fn [contacts [_ identity]] - (get contacts identity))) + (or + (get contacts identity) + (utils.contacts/whisper-id->new-contact identity)))) (reg-sub :get-dapp-by-name :<- [:get-dapps]