Skip to content

Commit

Permalink
Fixes UI styling and added contact request screen
Browse files Browse the repository at this point in the history
  • Loading branch information
briansztamfater authored and cammellos committed Mar 24, 2022
1 parent e30345e commit d86df4b
Show file tree
Hide file tree
Showing 11 changed files with 418 additions and 23 deletions.
1 change: 1 addition & 0 deletions src/quo/components/text.cljs
Expand Up @@ -28,6 +28,7 @@
:inherit nil)
(case (or size :base)
:tiny typography/tiny
:x-small typography/x-small
:small typography/small
:base typography/base
:large typography/large
Expand Down
3 changes: 3 additions & 0 deletions src/quo/design_system/typography.cljs
Expand Up @@ -3,6 +3,9 @@
(def tiny {:font-size 10
:line-height 14})

(def x-small {:font-size 12
:line-height 16})

(def small {:font-size 13
:line-height 18})

Expand Down
7 changes: 7 additions & 0 deletions src/status_im/chat/models/input.cljs
Expand Up @@ -159,6 +159,13 @@
(update-in [:chat/inputs current-chat-id :metadata]
dissoc :sending-image))})))

(fx/defn cancel-contact-request
"Cancels contact request"
{:events [:chat.ui/cancel-contact-request]}
[{:keys [db]}]
(let [current-chat-id (:current-chat-id db)]
{:db (assoc-in db [:chat/inputs current-chat-id :metadata :sending-contact-request] nil)}))

(fx/defn cancel-message-reply
"Cancels stage message reply"
{:events [:chat.ui/cancel-message-reply]}
Expand Down
9 changes: 5 additions & 4 deletions src/status_im/ui/screens/chat/audio_message/views.cljs
Expand Up @@ -227,13 +227,13 @@
[react/animated-view {:style (styles/rec-outer-circle outer-scale)}]
[react/animated-view {:style (styles/rec-inner-circle inner-scale inner-border-radius)}]]]))

(defn- cancel-button [disabled? on-press]
(defn- cancel-button [disabled? on-press contact-request]
[pressable/pressable {:type :scale
:disabled disabled?
:on-press on-press}
[react/view {:style (input.style/send-message-button)}
[icons/icon :main-icons/close
{:container-style (merge (input.style/send-message-container) {:background-color colors/gray})
{:container-style (merge (input.style/send-message-container contact-request) {:background-color colors/gray})
:accessibility-label :cancel-message-button
:color colors/white-persist}]]])

Expand Down Expand Up @@ -272,13 +272,14 @@
(reset! on-background-cb nil))}
(let [base-params {:rec-button-anim-value rec-button-anim-value
:ctrl-buttons-anim-value ctrl-buttons-anim-value
:timer timer}]
:timer timer}
contact-request @(re-frame/subscribe [:chats/sending-contact-request])]
[react/view {:style styles/container}
[react/text {:style styles/timer
:accessibility-label :audio-message-recorded-time} @timer]
[react/view {:style styles/buttons-container}
[react/animated-view {:style {:opacity ctrl-buttons-anim-value}}
[cancel-button (:cancel-disabled? @state) #(stop-recording base-params)]]
[cancel-button (:cancel-disabled? @state) #(stop-recording base-params) contact-request]]
[rec-button-view (merge base-params {:state state})]
[react/animated-view {:style {:opacity ctrl-buttons-anim-value}}
[input/send-button (fn [] (cond
Expand Down
Expand Up @@ -55,7 +55,8 @@
[quo/button {:type :secondary
:weight :medium
:number-of-lines 1
:style {:line-height 18}}
:style {:line-height 18}
:on-press #(re-frame/dispatch [:chat.ui/cancel-contact-request])}
"Cancel"]
[quo/button {:type :secondary
:weight :medium
Expand Down
22 changes: 12 additions & 10 deletions src/status_im/ui/screens/chat/components/input.cljs
Expand Up @@ -73,13 +73,14 @@
[icons/icon :main-icons/keyboard (styles/icon false)]
[icons/icon :main-icons/speech (styles/icon false)])]])

(defn send-button [on-send]
(defn send-button [on-send contact-request]
[rn/touchable-opacity {:on-press-in on-send}
[rn/view {:style (styles/send-message-button)}
[icons/icon :main-icons/arrow-up
{:container-style (styles/send-message-container)
:accessibility-label :send-message-button
:color (styles/send-icon-color)}]]])
(when-not contact-request
[icons/icon :main-icons/arrow-up
{:container-style (styles/send-message-container contact-request)
:accessibility-label :send-message-button
:color (styles/send-icon-color)}])]])

(defn on-selection-change [timeout-id last-text-change mentionable-users args]
(let [selection (.-selection ^js (.-nativeEvent ^js args))
Expand Down Expand Up @@ -329,7 +330,7 @@
[reply/send-image sending-image])))

(defn actions [extensions image show-send actions-ref active-panel set-active-panel contact-request]
[rn/view {:style (styles/actions-wrapper show-send contact-request)
[rn/view {:style (styles/actions-wrapper (and (not contact-request) show-send))
:ref actions-ref}
(when extensions
[touchable-icon {:panel :extensions
Expand All @@ -346,8 +347,7 @@
(let [actions-ref (quo.react/create-ref)
send-ref (quo.react/create-ref)
sticker-ref (quo.react/create-ref)
toolbar-options (re-frame/subscribe [:chats/chat-toolbar])
contact-request @(re-frame/subscribe [:chats/sending-contact-request])]
toolbar-options (re-frame/subscribe [:chats/chat-toolbar])]
(fn [{:keys [active-panel set-active-panel text-input-ref chat-id]}]
(let [;we want to control components on native level, so instead of RN state we set native props via reference
;we don't react on input text in this view, @input-texts below is a regular atom
Expand All @@ -356,7 +356,8 @@
:sticker-ref sticker-ref
:text-input-ref text-input-ref}
{:keys [send stickers image extensions audio sending-image]} @toolbar-options
show-send (or sending-image (seq (get @input-texts chat-id)))]
show-send (or sending-image (seq (get @input-texts chat-id)))
contact-request @(re-frame/subscribe [:chats/sending-contact-request])]
[rn/view {:style (styles/toolbar)
:on-layout on-chat-toolbar-layout}
;;EXTENSIONS and IMAGE buttons
Expand All @@ -372,7 +373,8 @@
[rn/view {:ref send-ref :style (when-not show-send {:width 0 :right -100})}
(when send
[send-button #(do (clear-input chat-id refs)
(re-frame/dispatch [:chat.ui/send-current-message]))])]
(re-frame/dispatch [:chat.ui/send-current-message]))
contact-request])]

;;STICKERS and AUDIO buttons
(when-not @(re-frame/subscribe [:chats/edit-message])
Expand Down
17 changes: 9 additions & 8 deletions src/status_im/ui/screens/chat/components/style.cljs
Expand Up @@ -14,11 +14,12 @@
(defn input-container [contact-request]
{:background-color (:ui-01 @colors/theme)
:flex 1
: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)
:border-bottom-left-radius (if contact-request 8 16)
:margin-horizontal (when-not contact-request 8)})
:margin-horizontal (when contact-request 8)})

(def input-row
{:flex-direction :row
Expand Down Expand Up @@ -46,15 +47,15 @@
:padding-horizontal 12}
(if platform/android?
{:padding-vertical 2}
{:padding-top 2
:padding-bottom 6})))
{:padding-top (if contact-request 10 2)
:padding-bottom (if contact-request 5 6)})))

(defn actions-wrapper [show-send contact-request]
(defn actions-wrapper [show-send]
(merge
(when show-send
{:width 0 :left -88})
{:flex-direction :row
:padding-left (if contact-request 8 4)
:padding-left 4
:min-height 34}))

(defn touchable-icon []
Expand Down Expand Up @@ -103,11 +104,11 @@
{:margin-vertical 4
:margin-horizontal 5})

(defn send-message-container []
(defn send-message-container [contact-request]
{:background-color (:interactive-01 @colors/theme)
:width 26
:height 44
;; :border-radius 8
:height (if contact-request 44 26)
:border-radius (if contact-request 22 13)
:justify-content :center
:align-items :center})

Expand Down
66 changes: 66 additions & 0 deletions src/status_im/ui/screens/contact_requests/styles.cljs
@@ -0,0 +1,66 @@
(ns status-im.ui.screens.contact-requests.styles
(:require [status-im.ui.components.colors :as colors]
[quo.design-system.colors :as quo-colors]))

(def contact-request-message-text
{:flex 1
:align-self :stretch
:line-height 22
:font-size 15
:color (:text-01 @quo-colors/theme)})

(def mention-text
{:color colors/blue})

(def datetime-text
{:color colors/text-gray
:font-size 10
:text-align :right
:letter-spacing 0.4
:align-items :center
:line-height 12
:position :absolute
:top 17
:right 16})

(def group-info-container
{:height 22
:align-self :baseline
:align-items :center
:justify-content :center
:border-radius 11
:border-color colors/gray-transparent-40
:border-width 1
:margin-top 6
:margin-bottom 10
:padding-left 7
:padding-right 5
:flex-direction :row})

(defn contact-request-container [read]
{:min-height 64
:background-color (when-not read colors/blue-light)})

(def contact-request-content-container
{:flex 1})

(def photo-container
{:position :absolute
:top 12
:left 16})

(def title-text
{:margin-left 72
:margin-top 12
:margin-right 50})

(def contact-request-message-container
{:margin-left 72
:margin-right 16})

(def group-icon
{:margin-right 4})

(def community-info-container
{:flex-direction :row
:align-items :center})
120 changes: 120 additions & 0 deletions src/status_im/ui/screens/contact_requests/views.cljs
@@ -0,0 +1,120 @@
(ns status-im.ui.screens.contact-requests.views
(:require [status-im.ui.components.react :as react]
[status-im.ui.components.topbar :as topbar]
[status-im.i18n.i18n :as i18n]
[status-im.ui.components.list.views :as list]
[re-frame.core :as re-frame]
[quo.core :as quo]
[status-im.ui.components.colors :as colors]
[reagent.core :as reagent]
[status-im.ui.components.toolbar :as toolbar]
[clojure.string :as string]
[status-im.constants :as constants]
[status-im.ui.screens.contact-requests.views.contact-request :as contact-request]))

(def selecting (reagent/atom nil))
(def select-all (reagent/atom nil))
(def selected-items (reagent/atom #{}))

(defn render-fn [{:keys [id type] :as home-item}]
(when id
(let [selected (get @selected-items id)
on-change (fn []
(when-not (= type 1) (swap! selected-items #(if selected (disj % id) (conj % id)))))]
[react/view {:flex-direction :row :flex 1 :align-items :center}
(when (and @selecting (not (= type 2)))
[react/view {:padding-left 16}
[quo/checkbox {:value (or @select-all selected)
:disabled @select-all
:on-change on-change}]])
[react/view {:flex 1}
[contact-request/activity-text-item
home-item
{:on-press (fn []
(if @selecting
(on-change)
(re-frame/dispatch [:accept-activity-center-contact-request-and-open-chat id])))
:on-long-press #(do (reset! selecting true)
(when-not (= type constants/activity-center-contact-request-type-mention) (swap! selected-items conj id)))}]]])))
(defn filter-item []
[react/view {:padding-vertical 8 :border-bottom-width 1 :border-bottom-color colors/gray-lighter}
[react/view {:align-items :center :justify-content :space-between :padding-horizontal 16 :flex-direction :row}
(if @selecting
[react/view {:flex-direction :row}
[quo/checkbox {:value @select-all
:on-change #(do
(reset! selected-items #{})
(swap! select-all not))}]
[react/text {:style {:color colors/gray :margin-left 20}}
(str (if @select-all (i18n/label :t/all) (count @selected-items))
" " (string/lower-case (i18n/label :t/selected)))]]
[quo/button {:type :secondary
:accessibility-label :select-button-activity-center
:on-press #(reset! selecting true)}
(i18n/label :t/select)])
(when @selecting
[quo/button {:type :secondary
:on-press #(do (reset! selecting false)
(reset! select-all false)
(reset! selected-items #{}))}
(i18n/label :t/cancel)])]])

(defn reset-state []
(reset! selecting nil)
(reset! select-all nil)
(reset! selected-items #{}))

(defn toolbar-action [accept]
(if accept
(if @select-all
(re-frame/dispatch [:accept-all-activity-center-contact-requests])
(re-frame/dispatch [:accept-activity-center-contact-requests @selected-items]))
(if @select-all
(re-frame/dispatch [:dismiss-all-activity-center-contact-requests])
(re-frame/dispatch [:dismiss-activity-center-contact-requests @selected-items])))
(reset-state))

(defn center []
(reagent/create-class
{:display-name "activity-center"
:component-did-mount #(re-frame/dispatch [:get-activity-center-contact-requests])
:reagent-render (fn []
(let [contact-requests @(re-frame/subscribe [:activity.center/contact-requests-grouped-by-date])]
[react/keyboard-avoiding-view {:style {:flex 1}
:ignore-offset true}
[topbar/topbar {:navigation {:on-press #(do
(reset-state)
(re-frame/dispatch [:navigate-back]))}
:title (i18n/label :t/activity)}]
(if (= (count contact-requests) 0)
[react/view {:style {:flex 1
:justify-content :center
:align-items :center}}
[quo/text {:color :secondary
:size :large
:align :center}
(i18n/label :t/empty-activity-center)]]
[:<>
[filter-item]
[list/section-list
{:key-fn #(str (:timestamp %) (or (:chat-id %) (:id %)))
:on-end-reached #(re-frame/dispatch [:load-more-activity-center-contact-requests])
:keyboard-should-persist-taps :always
:sections contact-requests
:render-fn render-fn
:stickySectionHeadersEnabled false
:render-section-header-fn
(fn [{:keys [title]}]
[quo/list-header title])}]
(when (or @select-all (> (count @selected-items) 0))
[toolbar/toolbar
{:show-border? true
:left [quo/button {:type :secondary
:theme :negative
:accessibility-label :reject-and-delete-activity-center
:on-press #(toolbar-action false)}
(i18n/label :t/reject-and-delete)]
:right [quo/button {:type :secondary
:accessibility-label :accept-and-add-activity-center
:on-press #(toolbar-action true)}
(i18n/label :t/accept-and-add)]}])])]))}))

0 comments on commit d86df4b

Please sign in to comment.