From 9e77635c320471cbd9b0d8a827686a450747b931 Mon Sep 17 00:00:00 2001 From: Alexander Pantyuhov Date: Tue, 18 Oct 2016 17:27:01 +0300 Subject: [PATCH 1/3] Dapp icon on non-dapp contact icon (#362) Former-commit-id: 4b348a7631a0fea6ccb0750e32d57124b8fc2c73 --- src/status_im/chat/views/message.cljs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/status_im/chat/views/message.cljs b/src/status_im/chat/views/message.cljs index 3edc391e9a..95bffe7e6b 100644 --- a/src/status_im/chat/views/message.cljs +++ b/src/status_im/chat/views/message.cljs @@ -37,14 +37,6 @@ {:uri photo-path}) :style st/contact-photo}]]) -(defn contact-online [online?] - (when online? - [view st/online-container - [view st/online-dot-left] - [view st/online-dot-right]])) - -;;[photo-path (subscribe [:chat-photo from]) - (defn message-content-status [{:keys [from]}] (let [chat-photo-path (subscribe [:chat-photo from]) {:keys [group-chat name]} (subscribe [:chat-properties [:group-chat :name]]) @@ -61,8 +53,7 @@ (< (* 60 1000)))] [view st/status-container [view st/status-image-view - [contact-photo (or photo-path @chat-photo-path)] - [contact-online online?]] + [contact-photo (or photo-path @chat-photo-path)]] [text {:style st/status-from :font :default :number-of-lines 1} From f7d78cd35813606bf38239180d01d937fa8965f4 Mon Sep 17 00:00:00 2001 From: Alexander Pantyuhov Date: Tue, 18 Oct 2016 17:51:07 +0300 Subject: [PATCH 2/3] Group chat initial message (#364) Former-commit-id: e239363c1e98975772674ecaa4fbdd525edbf0d8 --- src/status_im/chat/styles/message.cljs | 46 ------------------- src/status_im/chat/views/message.cljs | 20 ++------ .../components/chat_icon/screen.cljs | 10 ++++ .../components/chat_icon/styles.cljs | 19 ++++++++ 4 files changed, 34 insertions(+), 61 deletions(-) diff --git a/src/status_im/chat/styles/message.cljs b/src/status_im/chat/styles/message.cljs index 6dd375acbd..120ed222c9 100644 --- a/src/status_im/chat/styles/message.cljs +++ b/src/status_im/chat/styles/message.cljs @@ -261,52 +261,6 @@ :textAlign :center :color text2-color}) -(def online-container - {:position :absolute - :top 44 - :left 44 - :width 24 - :height 24 - :borderRadius 12 - :backgroundColor online-color - :borderWidth 2 - :borderColor color-white}) - -(def online-dot - {:position :absolute - :top 8 - :width 4 - :height 4 - :borderRadius 2 - :backgroundColor color-white}) - -(def online-dot-left - (assoc online-dot :left 5)) - -(def online-dot-right - (assoc online-dot :left 11)) - -(def contact-photo-container - {:borderRadius 32}) - -(def contact-photo - {:border-radius 32 - :width 64 - :height 64}) - -(def message-date-container - {:backgroundColor color-light-blue-transparent - :height 24 - :borderRadius 12 - :alignSelf :center - :marginTop 20 - :marginBottom 20 - :paddingTop 5 - :paddingHorizontal 12}) - -(def message-date-text - (assoc style-sub-text :textAlign :center)) - (defn message-container [height] {:height height}) diff --git a/src/status_im/chat/views/message.cljs b/src/status_im/chat/views/message.cljs index 95bffe7e6b..9798a47305 100644 --- a/src/status_im/chat/views/message.cljs +++ b/src/status_im/chat/views/message.cljs @@ -24,22 +24,15 @@ content-type-status content-type-command content-type-command-request]] + [status-im.components.chat-icon.screen :refer [chat-icon-message-status]] [status-im.utils.identicon :refer [identicon]] [status-im.utils.gfycat.core :refer [generate-gfy]] [status-im.i18n :refer [label]] [status-im.chat.utils :as cu] [clojure.string :as str])) -(defn contact-photo [photo-path] - [view st/contact-photo-container - [image {:source (if (s/blank? photo-path) - res/user-no-photo - {:uri photo-path}) - :style st/contact-photo}]]) - -(defn message-content-status [{:keys [from]}] - (let [chat-photo-path (subscribe [:chat-photo from]) - {:keys [group-chat name]} (subscribe [:chat-properties [:group-chat :name]]) +(defn message-content-status [_] + (let [{:keys [chat-id group-chat name color]} (subscribe [:chat-properties [:chat-id :group-chat :name :color]]) members (subscribe [:current-chat-contacts])] (fn [{:keys [messages-count content datemark]}] (let [{:keys [photo-path @@ -48,12 +41,9 @@ {:photo-path nil :status nil :last-online 0} - (first @members)) - online? (-> (- (time/now-ms) last-online) - (< (* 60 1000)))] + (first @members))] [view st/status-container - [view st/status-image-view - [contact-photo (or photo-path @chat-photo-path)]] + [chat-icon-message-status @chat-id @group-chat @name @color false] [text {:style st/status-from :font :default :number-of-lines 1} diff --git a/src/status_im/components/chat_icon/screen.cljs b/src/status_im/components/chat_icon/screen.cljs index 7353dcf7b0..2dc5e314c4 100644 --- a/src/status_im/components/chat_icon/screen.cljs +++ b/src/status_im/components/chat_icon/screen.cljs @@ -78,6 +78,16 @@ :default-chat-icon (st/default-chat-icon-menu-item color) :default-chat-icon-text st/default-chat-icon-text}]) +(defn chat-icon-message-status [chat-id group-chat name color online] + [chat-icon-view chat-id group-chat name online + {:container st/container-message-status + :online-view st/online-view + :online-dot-left st/online-dot-left + :online-dot-right st/online-dot-right + :chat-icon st/chat-icon-message-status + :default-chat-icon (st/default-chat-icon-message-status color) + :default-chat-icon-text st/message-status-icon-text}]) + (defn contact-icon-view [contact styles] (let [photo-path (:photo-path contact) ;; TODO: stub diff --git a/src/status_im/components/chat_icon/styles.cljs b/src/status_im/components/chat_icon/styles.cljs index d94cc11f18..3695e75d7d 100644 --- a/src/status_im/components/chat_icon/styles.cljs +++ b/src/status_im/components/chat_icon/styles.cljs @@ -35,12 +35,23 @@ :height 36 :border-radius 18})) +(defn default-chat-icon-message-status [color] + (merge (default-chat-icon color) + {:width 64 + :height 64 + :border-radius 32})) + (def default-chat-icon-text {:marginTop -2 :color color-white :fontSize 16 :lineHeight 20}) +(def message-status-icon-text + {:marginTop -2 + :color color-white + :fontSize 24}) + (def chat-icon {:margin 4 :border-radius 20 @@ -70,6 +81,11 @@ :height 36 :border-radius 18})) +(def chat-icon-message-status + {:border-radius 32 + :width 64 + :height 64}) + (def online-view-wrapper {:position :absolute :bottom -1 @@ -152,3 +168,6 @@ (def container-profile {:width 72 :height 72}) + +(def container-message-status + {:margin-top 20}) From 9993ebd074bdc3ea4a764c5bd4168590ce697a8b Mon Sep 17 00:00:00 2001 From: Alexander Pantyuhov Date: Wed, 19 Oct 2016 00:45:09 +0300 Subject: [PATCH 3/3] Command as the last message (#367) Former-commit-id: dc3d9f8931c879062fc4e57ba1511fad78f3c7c5 --- .../chats_list/views/chat_list_item.cljs | 9 ++--- .../chats_list/views/inner_item.cljs | 35 ++++++++++++++----- src/status_im/data_store/messages.cljs | 4 ++- src/status_im/data_store/realm/messages.cljs | 3 +- src/status_im/translations/en.cljs | 3 ++ 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/status_im/chats_list/views/chat_list_item.cljs b/src/status_im/chats_list/views/chat_list_item.cljs index ddd650816f..d2a5fff6e8 100644 --- a/src/status_im/chats_list/views/chat_list_item.cljs +++ b/src/status_im/chats_list/views/chat_list_item.cljs @@ -4,13 +4,10 @@ text image touchable-highlight]] - [status-im.chats-list.views.inner-item :refer [chat-list-item-inner-view]])) + [status-im.chats-list.views.inner-item :refer [chat-list-item-inner-view]] + [taoensso.timbre :as log])) (defn chat-list-item [[chat-id chat]] [touchable-highlight {:on-press #(dispatch [:navigate-to :chat chat-id])} [view - [chat-list-item-inner-view (merge chat - ;; TODO stub data - {:chat-id chat-id - :new-messages-count 3 - :online true})]]]) + [chat-list-item-inner-view (assoc chat :chat-id chat-id)]]]) diff --git a/src/status_im/chats_list/views/inner_item.cljs b/src/status_im/chats_list/views/inner_item.cljs index e87e37c7aa..89387de3f7 100644 --- a/src/status_im/chats_list/views/inner_item.cljs +++ b/src/status_im/chats_list/views/inner_item.cljs @@ -1,20 +1,37 @@ (ns status-im.chats-list.views.inner-item (:require-macros [status-im.utils.views :refer [defview]]) - (:require [status-im.components.react :refer [view image icon text]] + (:require [re-frame.core :refer [subscribe dispatch]] + [clojure.string :as str] + [status-im.components.react :refer [view image icon text]] [status-im.components.chat-icon.screen :refer [chat-icon-view-chat-list]] + [status-im.models.commands :refer [parse-command-message-content]] [status-im.chats-list.styles :as st] [status-im.utils.utils :refer [truncate-str]] [status-im.i18n :refer [label label-pluralize]] [status-im.utils.datetime :as time] [status-im.utils.gfycat.core :refer [generate-gfy]] - [status-im.constants :refer [console-chat-id]] - [clojure.string :as str])) + [status-im.constants :refer [console-chat-id + content-type-command + content-type-command-request]] + [taoensso.timbre :as log])) -(defn message-content [{:keys [content] :as message}] - (let [content (if message - (if (string? content) - content - (:content content)))] +(defmulti message-content (fn [{:keys [content-type] :as message}] content-type)) + +(defmethod message-content content-type-command + [{{:keys [command params]} :content}] + (let [kw (keyword (str "t/command-text-" (name command)))] + (label kw params))) + +(defmethod message-content content-type-command-request + [{{:keys [content]} :content}] + content) + +(defmethod message-content :default + [{:keys [content]}] + content) + +(defn message-content-text [message] + (let [content (message-content message)] (if (str/blank? content) [text {:style st/last-message-text-no-messages} (label :t/no-messages)] @@ -71,7 +88,7 @@ (when group-chat [text {:style st/memebers-text} (label-pluralize (inc (count contacts)) :t/members)])] - [message-content last-message]] + [message-content-text last-message]] [view (when last-message [view st/status-container diff --git a/src/status_im/data_store/messages.cljs b/src/status_im/data_store/messages.cljs index 6dbc9ffbfd..210dc929b8 100644 --- a/src/status_im/data_store/messages.cljs +++ b/src/status_im/data_store/messages.cljs @@ -65,7 +65,9 @@ (defn get-last-message [chat-id] - (data-store/get-last-message chat-id)) + (let [{:keys [content-type] :as message} (data-store/get-last-message chat-id)] + (when (and message (command-type? content-type)) + (clojure.core/update message :content str-to-map)))) (defn get-unviewed [] diff --git a/src/status_im/data_store/realm/messages.cljs b/src/status_im/data_store/realm/messages.cljs index c818d49c65..787885ff02 100644 --- a/src/status_im/data_store/realm/messages.cljs +++ b/src/status_im/data_store/realm/messages.cljs @@ -31,8 +31,7 @@ [chat-id] (-> (realm/get-by-field @realm/account-realm :message :chat-id chat-id) (realm/sorted :timestamp :desc) - (realm/single) - (js->clj :keywordize-keys true))) + (realm/single-cljs))) (defn get-unviewed [] diff --git a/src/status_im/translations/en.cljs b/src/status_im/translations/en.cljs index 101de3602c..e502cbc852 100644 --- a/src/status_im/translations/en.cljs +++ b/src/status_im/translations/en.cljs @@ -139,6 +139,9 @@ :keypair-password-command-description "" :help-command-description "Help" :request "Request" + :command-text-location "Location: {{address}}" + :command-text-browse "Browsing webpage: {{webpage}}" + :command-text-send "Transaction: {{amount}} ETH" ;new-group :group-chat-name "Chat name"