Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
cammellos committed May 16, 2022
1 parent 5a6df09 commit 576f1f9
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 453 deletions.
3 changes: 2 additions & 1 deletion nix/scripts/lib.sh
Expand Up @@ -31,6 +31,7 @@ nix_install_type() {
echo "No Nix installtion detected!" >&2
echo "none"
else
echo "single"
echo "Unknown Nix installtion type!" >&2
exit 1
fi
}
2 changes: 1 addition & 1 deletion src/status_im/chat/models/input.cljs
Expand Up @@ -282,7 +282,7 @@
{:events [:contacts/send-contact-request]}
[{:keys [db] :as cofx} public-key message]
(fx/merge cofx
{::json-rpc/call [{:method (json-rpc/call-ext-method "sendContactRequest")
{::json-rpc/call [{:method "wakuext_sendContactRequest"
:js-response true
:params [{:id public-key :message message}]
:on-error #(log/warn "failed to send a contact request" %)
Expand Down
6 changes: 3 additions & 3 deletions src/status_im/constants.cljs
Expand Up @@ -35,9 +35,9 @@
(def ^:const timeline-chat-type 5)
(def ^:const community-chat-type 6)

(def ^:const contact-request-state-pending 1)
(def ^:const contact-request-state-accepted 2)
(def ^:const contact-request-state-declined 3)
(def ^:const contact-request-message-state-pending 1)
(def ^:const contact-request-message-state-accepted 2)
(def ^:const contact-request-message-state-declined 3)

(def request-to-join-pending-state 1)

Expand Down
7 changes: 7 additions & 0 deletions src/status_im/contact/core.cljs
Expand Up @@ -60,6 +60,13 @@
(when (> (count events) 1)
{:dispatch-n events}))))

(defn- own-info
[db]
(let [{:keys [name preferred-name identicon address]} (:multiaccount db)]
{:name (or preferred-name name)
:profile-image identicon
:address address}))

(fx/defn send-contact-request
{:events [::send-contact-request]}
[{:keys [db] :as cofx} public-key]
Expand Down
24 changes: 12 additions & 12 deletions src/status_im/ui/screens/chat/components/contact_request.cljs
Expand Up @@ -7,7 +7,8 @@
[status-im.ethereum.stateofus :as stateofus]
[status-im.ui.screens.chat.components.style :as styles]
[re-frame.core :as re-frame]
[clojure.string :as string]))
[clojure.string :as string])
(:require-macros [status-im.utils.views :refer [defview letsubs]]))

(def ^:private contact-request-symbol "")

Expand Down Expand Up @@ -49,18 +50,18 @@
(let [{:keys [input-text]} @(re-frame/subscribe [:chats/current-chat-inputs])]
[rn/view {:style {:flex-direction :row}}
[rn/view {:style (styles/contact-request-content)}
[quo/button {:type :secondary
[quo/button {:type :secondary
:weight :medium
:number-of-lines 1
:style {:line-height 18}
:on-press #(re-frame/dispatch [:chat.ui/cancel-contact-request])}
:on-press #(re-frame/dispatch [:chat.ui/cancel-contact-request])}
(i18n/label :t/cancel)]
[quo/button {:type :secondary
:disabled (string/blank? input-text)
:weight :medium
:after :main-icons/send
:after :main-icons/send
:on-press #(re-frame/dispatch [:contacts/send-contact-request their-public-key input-text])
:style {:line-height 18}}
:style {:line-height 18}}
(i18n/label :t/send-request)]]]))

(defn focus-input-on-contact-request [contact-request had-contact-request text-input-ref]
Expand All @@ -77,10 +78,9 @@
:padding-vertical 8}}
[contact-request-message contact-request]])

(defn contact-request-message-auto-focus-wrapper [text-input-ref]
(let [had-reply (atom nil)]
(fn []
(let [contact-request @(re-frame/subscribe [:chats/sending-contact-request])]
(focus-input-on-contact-request contact-request had-reply text-input-ref)
(when contact-request
[contact-request-message-wrapper contact-request])))))
(defview contact-request-message-auto-focus-wrapper [text-input-ref]
(views/letsubs [had-reply (atom nil)
contact-request @(re-frame/subscribe [:chats/sending-contact-request])]
{:component-did-mount #(focus-input-on-contact-request contact-request had-reply text-input-ref)}
(when contact-request
[contact-request-message-wrapper contact-request])))
2 changes: 1 addition & 1 deletion src/status_im/ui/screens/chat/components/style.cljs
Expand Up @@ -14,7 +14,7 @@
(defn input-container [contact-request]
{:background-color (:ui-01 @colors/theme)
:flex 1
:height (when contact-request 44)
:height (when contact-request 44)
:border-top-left-radius (if contact-request 8 16)
:border-top-right-radius (if contact-request 8 16)
:border-bottom-right-radius (if contact-request 8 4)
Expand Down
132 changes: 54 additions & 78 deletions src/status_im/ui/screens/chat/message/message.cljs
Expand Up @@ -47,7 +47,7 @@

(defview mention-element [from]
(letsubs [contact-name [:contacts/contact-name-by-identity from]]
contact-name))
contact-name))

(def edited-at-text (str "" (i18n/label :t/edited)))

Expand Down Expand Up @@ -87,25 +87,25 @@
(defview quoted-message
[_ {:keys [from parsed-text image]} outgoing current-public-key public? pinned]
(letsubs [contact-name [:contacts/contact-name-by-identity from]]
[react/view {:style (style/quoted-message-container (and outgoing (not pinned)))}
[react/view {:style style/quoted-message-author-container}
[chat.utils/format-reply-author
from
contact-name
current-public-key
(partial style/quoted-message-author (and outgoing (not pinned)))
(and outgoing (not pinned))]]
(if (and image
[react/view {:style (style/quoted-message-container (and outgoing (not pinned)))}
[react/view {:style style/quoted-message-author-container}
[chat.utils/format-reply-author
from
contact-name
current-public-key
(partial style/quoted-message-author (and outgoing (not pinned)))
(and outgoing (not pinned))]]
(if (and image
;; Disabling images for public-chats
(not public?))
[react/fast-image {:style {:width 56
:height 56
:background-color :black
:border-radius 4}
:source {:uri image}}]
[react/text {:style (style/quoted-message-text (and outgoing (not pinned)))
:number-of-lines 5}
(components.reply/get-quoted-text-with-mentions parsed-text)])]))
(not public?))
[react/fast-image {:style {:width 56
:height 56
:background-color :black
:border-radius 4}
:source {:uri image}}]
[react/text {:style (style/quoted-message-text (and outgoing (not pinned)))
:number-of-lines 5}
(components.reply/get-quoted-text-with-mentions parsed-text)])]))

(defn render-inline [message-text outgoing pinned content-type acc {:keys [type literal destination]}]
(case type
Expand Down Expand Up @@ -268,42 +268,42 @@

(defview message-author-name [from opts]
(letsubs [contact-with-names [:contacts/contact-by-identity from]]
(chat.utils/format-author contact-with-names opts)))
(chat.utils/format-author contact-with-names opts)))

(defview message-my-name [opts]
(letsubs [contact-with-names [:multiaccount/contact]]
(chat.utils/format-author contact-with-names opts)))
(chat.utils/format-author contact-with-names opts)))

(defview community-content [{:keys [community-id] :as message}]
(letsubs [{:keys [name description verified] :as community} [:communities/community community-id]
communities-enabled? [:communities/enabled?]]
(when (and communities-enabled? community)
[react/view {:style (assoc (style/message-wrapper message)
:margin-vertical 10
:margin-left 8
:width 271)}
(when verified
[react/view (style/community-verified)
[react/text {:style {:font-size 13
:color colors/blue}} (i18n/label :t/communities-verified)]])
[react/view (style/community-message verified)
[react/view {:width 62
:padding-left 14}
(if (= community-id constants/status-community-id)
[react/image {:source (resources/get-image :status-logo)
:style {:width 40
:height 40}}]
[communities.icon/community-icon community])]
[react/view {:padding-right 14 :flex 1}
[react/text {:style {:font-weight "700" :font-size 17}}
name]
[react/text description]]]
[react/view (style/community-view-button)
[react/touchable-highlight {:on-press #(re-frame/dispatch [:navigate-to
:community
{:community-id (:id community)}])}
[react/text {:style {:text-align :center
:color colors/blue}} (i18n/label :t/view)]]]])))
(when (and communities-enabled? community)
[react/view {:style (assoc (style/message-wrapper message)
:margin-vertical 10
:margin-left 8
:width 271)}
(when verified
[react/view (style/community-verified)
[react/text {:style {:font-size 13
:color colors/blue}} (i18n/label :t/communities-verified)]])
[react/view (style/community-message verified)
[react/view {:width 62
:padding-left 14}
(if (= community-id constants/status-community-id)
[react/image {:source (resources/get-image :status-logo)
:style {:width 40
:height 40}}]
[communities.icon/community-icon community])]
[react/view {:padding-right 14 :flex 1}
[react/text {:style {:font-weight "700" :font-size 17}}
name]
[react/text description]]]
[react/view (style/community-view-button)
[react/touchable-highlight {:on-press #(re-frame/dispatch [:navigate-to
:community
{:community-id (:id community)}])}
[react/text {:style {:text-align :center
:color colors/blue}} (i18n/label :t/view)]]]])))

(defn message-content-wrapper
"Author, userpic and delivery wrapper"
Expand Down Expand Up @@ -637,42 +637,18 @@
(i18n/label :t/contact-request-declined)])

(defn contact-request-status-label [state]
[react/view {:style {:width 136
:border-radius 8
:flex 1
:justify-content :center
:align-items :center
:background-color (when (= :retry state)
colors/blue-light)
:border-width 1
:border-color (case state
constants/contact-request-state-accepted colors/green-transparent-10
constants/contact-request-state-declined colors/red-light
constants/contact-request-state-pending colors/gray-lighter)
:padding-vertical 10
:padding-horizontal 16}}

[react/view {:style (style/contact-request-status-label state)}
(case state
constants/contact-request-state-pending [contact-request-status-pending]
constants/contact-request-state-accepted [contact-request-status-accepted]
constants/contact-request-state-declined [contact-request-status-declined])])
constants/contact-request-message-state-pending [contact-request-status-pending]
constants/contact-request-message-state-accepted [contact-request-status-accepted]
constants/contact-request-message-state-declined [contact-request-status-declined])])

(defmethod ->message constants/content-type-contact-request
[{:keys [outgoing] :as message} _]
[react/view {:style {:width 168
:min-height 224.71
:border-radius 8
:border-width 1
:border-color colors/gray-lighter
:align-items :center
:padding-bottom 10
:margin-vertical 4
:align-self (if outgoing :flex-end :flex-start)
:margin-right (if outgoing 8 0)
:margin-left (if outgoing 0 8)}}
[react/view {:style (style/content-type-contact-request outgoing)}
[react/image {:source (resources/get-image :hand-wave)
:style {:width 112
:height 96.71}}]
:height 97}}]
[quo/text {:style {:margin-top 6}
:weight :bold
:size :large}
Expand Down
7 changes: 7 additions & 0 deletions src/status_im/ui/screens/chat/styles/main.cljs
Expand Up @@ -147,3 +147,10 @@
{:font-size 13
:line-height 18
:text-align :center})

(def contact-request
{:width "100%"
:justify-content :center
:align-items :center
:border-top-width 1
:border-color colors/gray-transparent-10})
29 changes: 29 additions & 0 deletions src/status_im/ui/screens/chat/styles/message/message.cljs
Expand Up @@ -435,3 +435,32 @@
:border-bottom-left-radius 10
:border-bottom-right-radius 10
:border-color colors/gray-lighter})

(defn contact-request-status-label [state]
{:width 136
:border-radius 8
:flex 1
:justify-content :center
:align-items :center
:background-color (when (= :retry state)
colors/blue-light)
:border-width 1
:border-color (case state
constants/contact-request-message-state-accepted colors/green-transparent-10
constants/contact-request-message-state-declined colors/red-light
constants/contact-request-message-state-pending colors/gray-lighter)
:padding-vertical 10
:padding-horizontal 16})

(defn content-type-contact-request [outgoing]
{:width 168
:min-height 224.71
:border-radius 8
:border-width 1
:border-color colors/gray-lighter
:align-items :center
:padding-bottom 10
:margin-vertical 4
:align-self (if outgoing :flex-end :flex-start)
:margin-right (if outgoing 8 0)
:margin-left (if outgoing 0 8)})
6 changes: 1 addition & 5 deletions src/status_im/ui/screens/chat/views.cljs
Expand Up @@ -64,11 +64,7 @@

(defn contact-request []
(let [contact-request @(re-frame/subscribe [:chats/sending-contact-request])]
[react/view {:style {:width "100%"
:justify-content :center
:align-items :center
:border-top-width 1
:border-color colors/gray-transparent-10}}
[react/view {:style style/contact-request}
[react/image {:source (resources/get-image :hand-wave)
:style {:width 112
:height 96.71
Expand Down

0 comments on commit 576f1f9

Please sign in to comment.