Skip to content

Commit

Permalink
Merge branch 'develop' into jc/organise-add-account
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Son89 authored Apr 9, 2024
2 parents e604392 + 06aa467 commit f424ca7
Show file tree
Hide file tree
Showing 29 changed files with 176 additions and 133 deletions.
1 change: 1 addition & 0 deletions fastlane/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ GEM

PLATFORMS
arm64-darwin-22
x86_64-darwin-22

DEPENDENCIES
activesupport (>= 6.1.7.3, < 7.1.0)
Expand Down
Binary file removed resources/images/icons2/32x32/group@2x.png
Binary file not shown.
Binary file removed resources/images/icons2/32x32/group@3x.png
Binary file not shown.
Binary file modified resources/images/icons2/32x32/members@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/images/icons2/32x32/members@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/legacy/status_im/data_store/chats.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
:profile-public-key (.-profile chat)
:highlight (.-highlight chat)
:active (.-active chat)
:image (.-image chat)
:members (types/js->clj (.-members chat))
:hide-if-permissions-not-met (.-hideIfPermissionsNotMet chat)}
rpc->type
Expand Down
5 changes: 0 additions & 5 deletions src/legacy/status_im/ui/screens/screens.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
[legacy.status-im.ui.screens.sync-settings.views :as sync-settings]
[legacy.status-im.ui.screens.wakuv2-settings.edit-node.views :as edit-wakuv2-node]
[legacy.status-im.ui.screens.wakuv2-settings.views :as wakuv2-settings]
[status-im.contexts.chat.group-details.view :as group-details]
[utils.i18n :as i18n]))

(defn topbar-options
Expand All @@ -69,10 +68,6 @@
:component progress/progress}

;;CHAT
{:name :group-chat-profile
;;TODO animated-header
:options {:insets {:top? true}}
:component group-details/group-details}
{:name :group-chat-invite
;;TODO parameter in the event
:options {:insets {:top? true}}
Expand Down
14 changes: 9 additions & 5 deletions src/quo/components/text_combinations/page_top/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(:require [clojure.string :as string]
[quo.components.avatars.channel-avatar.view :as channel-avatar]
[quo.components.avatars.collection-avatar.view :as collection-avatar]
[quo.components.avatars.group-avatar.view :as group-avatar]
[quo.components.inputs.address-input.view :as address-input]
[quo.components.inputs.recovery-phrase.view :as recovery-phrase]
[quo.components.inputs.search-input.view :as search-input]
Expand Down Expand Up @@ -36,14 +37,17 @@
[{:keys [title title-accessibility-label input counter-top counter-bottom
title-right title-right-props]
avatar-props :avatar}]
(let [title-props (assoc title-right-props
:title title
:right title-right
:accessibility-label title-accessibility-label)]
(let [avatar-props (assoc avatar-props :size :size-32)
title-props (assoc title-right-props
:title title
:right title-right
:accessibility-label title-accessibility-label)]
[rn/view {:style style/header}
[rn/view {:style style/header-title}
(when avatar-props
[channel-avatar/view (assoc avatar-props :size :size-32)])
(if (:group? avatar-props)
[group-avatar/view avatar-props]
[channel-avatar/view avatar-props]))
[standard-title/view title-props]]
(when (= input :recovery-phrase)
[header-counter counter-top counter-bottom])]))
Expand Down
27 changes: 27 additions & 0 deletions src/react_native/image_crop_picker.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
(ns react-native.image-crop-picker
(:require ["react-native-image-crop-picker" :default image-picker]))

(defn show-access-error
[o]
(js/console.log (.-message ^js o)))

(defn show-image-picker
([callback]
(show-image-picker callback nil))
([callback
{:keys [media-type]
:or {media-type "any"}
:as props}]
(-> ^js image-picker
(.openPicker (clj->js (merge {:mediaType media-type} props)))
(.then #(callback (.-path ^js %)))
(.catch show-access-error))))

(defn show-image-picker-camera
([callback]
(show-image-picker-camera callback nil))
([callback props]
(-> ^js image-picker
(.openCamera (clj->js props))
(.then #(callback (.-path ^js %)))
(.catch show-access-error))))
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
(ns status-im.common.profile-picture-picker.view
(ns status-im.common.avatar-picture-picker.view
(:require
["react-native-image-crop-picker" :default image-picker]
[quo.core :as quo]
[react-native.permissions :as permissions]
[react-native.platform :as platform]
Expand All @@ -16,50 +15,13 @@
:width crop-size
:height crop-size})

(defn show-access-error
[o]
(when (= "E_PERMISSION_MISSING" (.-code ^js o))
(js/console.log (i18n/label :t/error))))

(defn show-image-picker
([images-fn]
(show-image-picker images-fn nil))
([images-fn
{:keys [media-type]
:or {media-type "any"}
:as props}]
(-> ^js image-picker
(.openPicker (clj->js (merge {:mediaType media-type}
props)))
(.then images-fn)
(.catch show-access-error))))

(defn show-image-picker-camera
([images-fn]
(show-image-picker-camera images-fn nil))
([images-fn props]

(-> ^js image-picker
(.openCamera (clj->js props))
(.then images-fn)
(.catch show-access-error))))

(defn pick-pic
[update-profile-pic-callback]
(defn hide-sheet-and-dispatch
[event]
(rf/dispatch [:hide-bottom-sheet])
(show-image-picker
#(update-profile-pic-callback (.-path ^js %))
crop-opts))

(defn take-pic
[update-profile-pic-callback]
(rf/dispatch [:hide-bottom-sheet])
(show-image-picker-camera
#(update-profile-pic-callback (.-path ^js %))
crop-opts))
(rf/dispatch event))

(defn view
[{:keys [update-profile-pic-callback has-picture?]}]
[{:keys [on-result has-picture?]}]
[quo/action-drawer
[[{:icon :i/camera
:accessibility-label :take-photo-button
Expand All @@ -70,10 +32,10 @@
:read-external-storage
:read-media-images)
:write-external-storage]
:on-allowed (fn [] (take-pic update-profile-pic-callback))
:on-denied (fn []
(log/info
"user has denied permissions to click picture"))}))}
:on-allowed #(hide-sheet-and-dispatch [:image-crop-picker/show-camera
on-result crop-opts])
:on-denied #(log/info
"user has denied permissions to click picture")}))}
{:icon :i/image
:accessibility-label :select-from-gallery-button
:label (i18n/label :t/profile-pic-pick)
Expand All @@ -83,10 +45,10 @@
:read-external-storage
:read-media-images)
:write-external-storage]
:on-allowed (fn [] (pick-pic update-profile-pic-callback))
:on-denied (fn []
(log/info
"user has denied permissions to select picture"))}))}
:on-allowed #(hide-sheet-and-dispatch [:image-crop-picker/show on-result
crop-opts])
:on-denied #(log/info
"user has denied permissions to select picture")}))}
(when has-picture?
{:accessibility-label :remove-profile-picture
:add-divider? true
Expand All @@ -96,5 +58,4 @@
:label (i18n/label :t/profile-pic-remove)
:on-press (fn []
(rf/dispatch [:hide-bottom-sheet])
(update-profile-pic-callback nil))})]]])

(on-result nil))})]]])
8 changes: 6 additions & 2 deletions src/status_im/common/home/actions/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,11 @@
[chat-id]
(entry {:icon :i/members
:label (i18n/label :t/group-details)
:on-press #(hide-sheet-and-dispatch [:navigate-to :group-chat-profile chat-id])
:on-press (fn []
(rf/dispatch [:chats-list/load-chat chat-id])
(rf/dispatch [:pin-message/load-pin-messages chat-id])
(rf/dispatch [:hide-bottom-sheet])
(rf/dispatch [:navigate-to :group-details chat-id]))
:danger? false
:accessibility-label :group-details
:sub-label nil
Expand Down Expand Up @@ -441,7 +445,7 @@
(defn private-group-chat-actions
[item inside-chat?]
[quo/action-drawer
(let [show-group-actions? (:group-chat-member? item)]
(let [show-group-actions? (:group-chat item)]
[(when show-group-actions?
(group-actions item inside-chat?))
(notification-actions item inside-chat? show-group-actions?)
Expand Down
21 changes: 21 additions & 0 deletions src/status_im/common/image_crop_picker/events.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(ns status-im.common.image-crop-picker.events
(:require [react-native.image-crop-picker :as image-crop-picker]
[utils.re-frame :as rf]))

(rf/reg-fx :effect.image-crop-picker/show
(fn [[callback crop-opts]]
(image-crop-picker/show-image-picker callback crop-opts)))

(rf/reg-fx :effect.image-crop-picker/show-camera
(fn [[callback crop-opts]]
(image-crop-picker/show-image-picker-camera callback crop-opts)))

(rf/reg-event-fx
:image-crop-picker/show
(fn [_ [callback crop-opts]]
{:effect.image-crop-picker/show [callback crop-opts]}))

(rf/reg-event-fx
:image-crop-picker/show-camera
(fn [_ [callback crop-opts]]
{:effect.image-crop-picker/show-camera [callback crop-opts]}))
2 changes: 2 additions & 0 deletions src/status_im/constants.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -488,3 +488,5 @@
(def ^:const alert-banner-height 40)

(def ^:const status-hostname "status.app")

(def ^:const community-joined-notification-type "communityJoined")
4 changes: 2 additions & 2 deletions src/status_im/contexts/chat/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@
(let [{:keys [view-id current-chat-id]} db
{:keys [all-chats chats-home-list removed-chats]}
(reduce
(fn [acc {:keys [chat-id profile-public-key timeline? community-id active muted] :as chat}]
(fn [acc {:keys [chat-id community-id active muted] :as chat}]
(if (not (or active muted))
(update acc :removed-chats conj chat-id)
(cond-> acc
(and (not profile-public-key) (not timeline?) (not community-id) active)
(and (not community-id) active)
(update :chats-home-list conj chat-id)
:always
(assoc-in [:all-chats chat-id] chat))))
Expand Down
10 changes: 8 additions & 2 deletions src/status_im/contexts/chat/group_create/events.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
(ns status-im.contexts.chat.group-create.events
(:require [legacy.status-im.data-store.chats :as data-store.chats]
[oops.core :as oops]
[re-frame.core :as rf]))
[re-frame.core :as rf]
[status-im.common.avatar-picture-picker.view :as avatar-picture-picker]))

(rf/reg-event-fx :group-chat/create
(fn [{:keys [db]} [group-name color image]]
Expand All @@ -28,7 +29,12 @@
(rf/reg-event-fx :group-chat/edit
(fn [_ [{:keys [chat-id group-name color image]}]]
{:json-rpc/call [{:method "chat_editChat"
:params ["" chat-id group-name (name color) image]
:params ["" chat-id group-name (name color)
{:imagePath image
:x 0
:y 0
:width avatar-picture-picker/crop-size
:height avatar-picture-picker/crop-size}]
:js-response true
:on-success #(rf/dispatch [:group-chat/edit-success
(data-store.chats/<-rpc-js %)])}]}))
59 changes: 32 additions & 27 deletions src/status_im/contexts/chat/group_create/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[quo.foundations.colors :as colors]
[quo.theme]
[react-native.core :as rn]
[status-im.common.avatar-picture-picker.view :as avatar-picture-picker]
[status-im.common.floating-button-page.view :as floating-button-page]
[status-im.constants :as constants]
[status-im.contexts.chat.group-create.style :as style]
Expand All @@ -15,30 +16,29 @@
[utils.responsiveness :as responsiveness]))

(defn avatar
[{:keys [customization-color]}]
[rn/pressable {:style style/avatar}
;;NOTE with hole-view group-avatar doesn't change it's background color
#_[hole-view/hole-view
{:holes [style/hole]}]
[quo/group-avatar
{:customization-color customization-color
:size :size-80}]
[quo/button
{:on-press (fn []
#_(rf/dispatch
[:show-bottom-sheet
{:content (fn []
[profile-picture-picker/view
{:update-profile-pic-callback on-change-profile-pic
:has-picture? has-picture?}])
:theme :dark
:shell? true}]))
:container-style style/camera
:icon-only? true
:type :grey
:background :photo
:size 32}
:i/camera]])
[{:keys [customization-color group-image set-group-image]}]
(let [on-press (rn/use-callback (fn []
(rf/dispatch
[:show-bottom-sheet
{:content (fn []
[avatar-picture-picker/view
{:on-result set-group-image}])}])))]
[rn/view {:style style/avatar}
;;NOTE with hole-view group-avatar doesn't change it's background color
#_[hole-view/hole-view
{:holes [style/hole]}]
[quo/group-avatar
{:customization-color customization-color
:size :size-80
:picture group-image}]
[quo/button
{:on-press on-press
:container-style style/camera
:icon-only? true
:type :grey
:background :photo
:size 32}
:i/camera]]))

(defn view
[]
Expand All @@ -63,10 +63,12 @@
set-error-message] (rn/use-state nil)
group-name-empty? (not (and (string? group-name) (not-empty group-name)))
[group-color set-group-color] (rn/use-state (rand-nth colors/account-colors))
[group-image set-group-image] (rn/use-state nil)
create-group-on-press (rn/use-callback #(debounce/throttle-and-dispatch
[:group-chat/create group-name group-color]
[:group-chat/create group-name group-color
group-image]
300)
[group-name group-color])
[group-name group-color group-image])
back-on-press (rn/use-callback #(rf/dispatch [:navigate-back]))
on-change-text (rn/use-callback
(fn [text]
Expand All @@ -91,7 +93,10 @@
:on-press create-group-on-press}
(i18n/label :t/create-group-chat)]}
[:<>
[avatar {:customization-color group-color}]
[avatar
{:customization-color group-color
:group-image group-image
:set-group-image set-group-image}]
[quo/title-input
{:on-change-text on-change-text
:default-value default-value
Expand Down
Loading

0 comments on commit f424ca7

Please sign in to comment.