Enable stickers on all envs. Use contenthash to identify stickers
Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
parent
433f840f76
commit
28f7ea0408
1
.env
1
.env
|
@ -17,7 +17,6 @@ POW_TARGET=0.002
|
||||||
POW_TIME=1
|
POW_TIME=1
|
||||||
SNOOPY=0
|
SNOOPY=0
|
||||||
RPC_NETWORKS_ONLY=0
|
RPC_NETWORKS_ONLY=0
|
||||||
STICKERS_ENABLED=1
|
|
||||||
PARTITIONED_TOPIC=0
|
PARTITIONED_TOPIC=0
|
||||||
CONTRACT_NODES=1
|
CONTRACT_NODES=1
|
||||||
MOBILE_UI_FOR_DESKTOP=0
|
MOBILE_UI_FOR_DESKTOP=0
|
||||||
|
|
|
@ -17,7 +17,6 @@ POW_TARGET=0.002
|
||||||
POW_TIME=1
|
POW_TIME=1
|
||||||
SNOOPY=0
|
SNOOPY=0
|
||||||
RPC_NETWORKS_ONLY=0
|
RPC_NETWORKS_ONLY=0
|
||||||
STICKERS_ENABLED=1
|
|
||||||
PARTITIONED_TOPIC=0
|
PARTITIONED_TOPIC=0
|
||||||
CONTRACT_NODES=1
|
CONTRACT_NODES=1
|
||||||
MOBILE_UI_FOR_DESKTOP=0
|
MOBILE_UI_FOR_DESKTOP=0
|
||||||
|
|
|
@ -15,7 +15,6 @@ POW_TARGET=0.002
|
||||||
POW_TIME=1
|
POW_TIME=1
|
||||||
SNOOPY=0
|
SNOOPY=0
|
||||||
RPC_NETWORKS_ONLY=0
|
RPC_NETWORKS_ONLY=0
|
||||||
STICKERS_ENABLED=0
|
|
||||||
PARTITIONED_TOPIC=0
|
PARTITIONED_TOPIC=0
|
||||||
CONTRACT_NODES=1
|
CONTRACT_NODES=1
|
||||||
MOBILE_UI_FOR_DESKTOP=0
|
MOBILE_UI_FOR_DESKTOP=0
|
||||||
|
|
|
@ -15,6 +15,5 @@ POW_TARGET=0.002
|
||||||
POW_TIME=1
|
POW_TIME=1
|
||||||
SNOOPY=0
|
SNOOPY=0
|
||||||
RPC_NETWORKS_ONLY=1
|
RPC_NETWORKS_ONLY=1
|
||||||
STICKERS_ENABLED=0
|
|
||||||
PARTITIONED_TOPIC=0
|
PARTITIONED_TOPIC=0
|
||||||
MOBILE_UI_FOR_DESKTOP=0
|
MOBILE_UI_FOR_DESKTOP=0
|
||||||
|
|
|
@ -152,12 +152,12 @@
|
||||||
:text message-text})})))
|
:text message-text})})))
|
||||||
|
|
||||||
(fx/defn send-sticker-fx
|
(fx/defn send-sticker-fx
|
||||||
[{:keys [db] :as cofx} {:keys [uri pack]} current-chat-id]
|
[{:keys [db] :as cofx} {:keys [hash pack]} current-chat-id]
|
||||||
(when-not (string/blank? uri)
|
(when-not (string/blank? hash)
|
||||||
(chat.message/send-message cofx {:chat-id current-chat-id
|
(chat.message/send-message cofx {:chat-id current-chat-id
|
||||||
:content-type constants/content-type-sticker
|
:content-type constants/content-type-sticker
|
||||||
:content (cond-> {:chat-id current-chat-id
|
:content (cond-> {:chat-id current-chat-id
|
||||||
:uri uri
|
:hash hash
|
||||||
:pack pack
|
:pack pack
|
||||||
:text "Update to latest version to see a nice sticker here!"})})))
|
:text "Update to latest version to see a nice sticker here!"})})))
|
||||||
|
|
||||||
|
|
|
@ -824,10 +824,10 @@
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:chat/send-sticker
|
:chat/send-sticker
|
||||||
(fn [{{:keys [current-chat-id] :account/keys [account]} :db :as cofx} [_ {:keys [uri] :as sticker}]]
|
(fn [{{:keys [current-chat-id] :account/keys [account]} :db :as cofx} [_ {:keys [hash] :as sticker}]]
|
||||||
(fx/merge
|
(fx/merge
|
||||||
cofx
|
cofx
|
||||||
(accounts/update-recent-stickers (conj (remove #(= uri %) (:recent-stickers account)) uri))
|
(accounts/update-recent-stickers (conj (remove #(= hash %) (:recent-stickers account)) hash))
|
||||||
(chat.input/send-sticker-fx sticker current-chat-id))))
|
(chat.input/send-sticker-fx sticker current-chat-id))))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
|
|
|
@ -99,12 +99,18 @@
|
||||||
(assoc :stickers/selected-pack id))}
|
(assoc :stickers/selected-pack id))}
|
||||||
(accounts/update-stickers (conj (:stickers account) (pr-str pack))))))
|
(accounts/update-stickers (conj (:stickers account) (pr-str pack))))))
|
||||||
|
|
||||||
|
(defn valid-sticker? [sticker]
|
||||||
|
(contains? sticker :hash))
|
||||||
|
|
||||||
(fx/defn load-sticker-pack-success
|
(fx/defn load-sticker-pack-success
|
||||||
[{:keys [db] :as cofx} edn-string id price open?]
|
[{:keys [db] :as cofx} edn-string id price open?]
|
||||||
(let [pack (assoc (get (edn/read-string edn-string) 'meta)
|
(let [{:keys [stickers] :as pack} (assoc (get (edn/read-string edn-string) 'meta)
|
||||||
:id id :price price)]
|
:id id :price price)]
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:db (assoc-in db [:stickers/packs id] pack)}
|
{:db (cond-> db
|
||||||
|
(and (seq stickers)
|
||||||
|
(every? valid-sticker? stickers))
|
||||||
|
(assoc-in [:stickers/packs id] pack))}
|
||||||
#(when open?
|
#(when open?
|
||||||
(navigation/navigate-to-cofx % :stickers-pack-modal pack)))))
|
(navigation/navigate-to-cofx % :stickers-pack-modal pack)))))
|
||||||
|
|
||||||
|
@ -127,9 +133,7 @@
|
||||||
hash)
|
hash)
|
||||||
:success-event-creator
|
:success-event-creator
|
||||||
(fn [o]
|
(fn [o]
|
||||||
[:stickers/load-sticker-pack-success o id price open?])
|
[:stickers/load-sticker-pack-success o id price open?])}})
|
||||||
:failure-event-creator
|
|
||||||
(constantly nil)}})
|
|
||||||
|
|
||||||
(fx/defn load-packs
|
(fx/defn load-packs
|
||||||
[{:keys [db]}]
|
[{:keys [db]}]
|
||||||
|
|
|
@ -893,9 +893,9 @@
|
||||||
(fn [[{:keys [id]} packs]]
|
(fn [[{:keys [id]} packs]]
|
||||||
(first (filter #(= (:id %) id) packs))))
|
(first (filter #(= (:id %) id) packs))))
|
||||||
|
|
||||||
(defn find-pack-id-for-uri [sticker-uri packs]
|
(defn find-pack-id-for-hash [sticker-uri packs]
|
||||||
(some (fn [{:keys [stickers id]}]
|
(some (fn [{:keys [stickers id]}]
|
||||||
(when (some #(= sticker-uri (:uri %)) stickers)
|
(when (some #(= sticker-uri (:hash %)) stickers)
|
||||||
id))
|
id))
|
||||||
packs))
|
packs))
|
||||||
|
|
||||||
|
@ -904,7 +904,7 @@
|
||||||
:<- [:account/account]
|
:<- [:account/account]
|
||||||
:<- [:stickers/installed-packs-vals]
|
:<- [:stickers/installed-packs-vals]
|
||||||
(fn [[{:keys [recent-stickers]} packs]]
|
(fn [[{:keys [recent-stickers]} packs]]
|
||||||
(map (fn [uri] {:uri uri :pack (find-pack-id-for-uri uri packs)}) recent-stickers)))
|
(map (fn [hash] {:hash hash :pack (find-pack-id-for-hash hash packs)}) recent-stickers)))
|
||||||
|
|
||||||
;;EXTENSIONS ===========================================================================================================
|
;;EXTENSIONS ===========================================================================================================
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@
|
||||||
:req-opt [:message.content/response-to]))
|
:req-opt [:message.content/response-to]))
|
||||||
(spec/def :message.command/content (spec/keys :req-un [:message.content/command-path :message.content/params]))
|
(spec/def :message.command/content (spec/keys :req-un [:message.content/command-path :message.content/params]))
|
||||||
|
|
||||||
(spec/def :message.sticker/content (spec/keys :req-un [:message.content/uri]))
|
(spec/def :message.sticker/content (spec/keys :req-un [:message.content/hash]))
|
||||||
|
|
||||||
(defmulti content-type :content-type)
|
(defmulti content-type :content-type)
|
||||||
|
|
||||||
|
|
|
@ -201,7 +201,7 @@
|
||||||
[reply-message-view]
|
[reply-message-view]
|
||||||
[react/view {:style style/input-container}
|
[react/view {:style style/input-container}
|
||||||
[input-view {:single-line-input? single-line-input? :set-text set-text :state-text state-text}]
|
[input-view {:single-line-input? single-line-input? :set-text set-text :state-text state-text}]
|
||||||
(when (and config/stickers-enabled? input-text-empty?)
|
(when input-text-empty?
|
||||||
[stickers/button show-stickers?])
|
[stickers/button show-stickers?])
|
||||||
(if input-text-empty?
|
(if input-text-empty?
|
||||||
[commands-button]
|
[commands-button]
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
[status-im.ui.screens.chat.photos :as photos]
|
[status-im.ui.screens.chat.photos :as photos]
|
||||||
[status-im.ui.screens.chat.styles.message.message :as style]
|
[status-im.ui.screens.chat.styles.message.message :as style]
|
||||||
[status-im.ui.screens.chat.utils :as chat.utils]
|
[status-im.ui.screens.chat.utils :as chat.utils]
|
||||||
|
[status-im.utils.contenthash :as contenthash]
|
||||||
[status-im.utils.platform :as platform])
|
[status-im.utils.platform :as platform])
|
||||||
(:require-macros [status-im.utils.views :refer [defview letsubs]]))
|
(:require-macros [status-im.utils.views :refer [defview letsubs]]))
|
||||||
|
|
||||||
|
@ -144,7 +145,7 @@
|
||||||
[wrapper {:keys [content] :as message}]
|
[wrapper {:keys [content] :as message}]
|
||||||
[wrapper message
|
[wrapper message
|
||||||
[react/image {:style {:margin 10 :width 140 :height 140}
|
[react/image {:style {:margin 10 :width 140 :height 140}
|
||||||
:source {:uri (:uri content)}}]])
|
:source {:uri (contenthash/url (:hash content))}}]])
|
||||||
|
|
||||||
(defmethod message-content :default
|
(defmethod message-content :default
|
||||||
[wrapper {:keys [content-type] :as message}]
|
[wrapper {:keys [content-type] :as message}]
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
(ns status-im.ui.screens.chat.stickers.views
|
(ns status-im.ui.screens.chat.stickers.views
|
||||||
(:require-macros [status-im.utils.views :refer [defview letsubs]])
|
(:require-macros [status-im.utils.views :refer [defview letsubs]])
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
|
[reagent.core :as reagent]
|
||||||
|
[status-im.stickers.core :as stickers]
|
||||||
[status-im.ui.components.react :as react]
|
[status-im.ui.components.react :as react]
|
||||||
[status-im.ui.components.icons.vector-icons :as vector-icons]
|
[status-im.ui.components.icons.vector-icons :as vector-icons]
|
||||||
[status-im.ui.components.colors :as colors]
|
[status-im.ui.components.colors :as colors]
|
||||||
[status-im.i18n :as i18n]
|
[status-im.i18n :as i18n]
|
||||||
[status-im.ui.screens.chat.stickers.styles :as styles]
|
[status-im.ui.screens.chat.stickers.styles :as styles]
|
||||||
[status-im.ui.components.animation :as anim]
|
[status-im.ui.components.animation :as anim]
|
||||||
[reagent.core :as reagent]
|
[status-im.utils.contenthash :as contenthash]
|
||||||
[status-im.utils.platform :as platform]))
|
[status-im.utils.platform :as platform]))
|
||||||
|
|
||||||
(def icon-size 28)
|
(def icon-size 28)
|
||||||
|
@ -43,13 +45,14 @@
|
||||||
[react/view {:width window-width :flex 1}
|
[react/view {:width window-width :flex 1}
|
||||||
[react/scroll-view
|
[react/scroll-view
|
||||||
[react/view {:style styles/stickers-panel}
|
[react/view {:style styles/stickers-panel}
|
||||||
(for [{:keys [uri] :as sticker} stickers]
|
(for [{:keys [hash pack] :as sticker} stickers]
|
||||||
^{:key uri}
|
^{:key (str hash)}
|
||||||
[react/touchable-highlight {:style {:height 75 :width 75 :margin 5}
|
[react/touchable-highlight {:style {:height 75 :width 75 :margin 5}
|
||||||
:on-press #(re-frame/dispatch [:chat/send-sticker sticker])}
|
:on-press #(re-frame/dispatch [:chat/send-sticker sticker])}
|
||||||
|
[react/view
|
||||||
[react/image {:style {:resize-mode :cover :width "100%" :height "100%"}
|
[react/image {:style {:resize-mode :cover :width "100%" :height "100%"}
|
||||||
:accessibility-label :sticker-icon
|
:accessibility-label :sticker-icon
|
||||||
:source {:uri uri}}]])]]])
|
:source {:uri (contenthash/url (str "0x" hash))}}]]])]]])
|
||||||
|
|
||||||
(defview recent-stickers-panel [window-width]
|
(defview recent-stickers-panel [window-width]
|
||||||
(letsubs [stickers [:stickers/recent]]
|
(letsubs [stickers [:stickers/recent]]
|
||||||
|
@ -83,6 +86,7 @@
|
||||||
{:component-will-update (fn [_ [_ installed-packs selected-pack]]
|
{:component-will-update (fn [_ [_ installed-packs selected-pack]]
|
||||||
(update-scroll-position @ref installed-packs selected-pack window-width))
|
(update-scroll-position @ref installed-packs selected-pack window-width))
|
||||||
:component-did-mount #(update-scroll-position @ref installed-packs selected-pack window-width)}
|
:component-did-mount #(update-scroll-position @ref installed-packs selected-pack window-width)}
|
||||||
|
(let [width @content-width]
|
||||||
[react/scroll-view {:style {:flex 1} :horizontal true :paging-enabled true
|
[react/scroll-view {:style {:flex 1} :horizontal true :paging-enabled true
|
||||||
:ref #(reset! ref %)
|
:ref #(reset! ref %)
|
||||||
:shows-horizontal-scroll-indicator false
|
:shows-horizontal-scroll-indicator false
|
||||||
|
@ -91,10 +95,10 @@
|
||||||
:on-scroll #(reset! scroll-x (.-nativeEvent.contentOffset.x %))
|
:on-scroll #(reset! scroll-x (.-nativeEvent.contentOffset.x %))
|
||||||
:on-layout #(reset! content-width (-> % .-nativeEvent .-layout .-width))}
|
:on-layout #(reset! content-width (-> % .-nativeEvent .-layout .-width))}
|
||||||
^{:key "recent"}
|
^{:key "recent"}
|
||||||
[recent-stickers-panel @content-width]
|
[recent-stickers-panel width]
|
||||||
(for [{:keys [stickers id]} installed-packs]
|
(for [{:keys [stickers id]} installed-packs]
|
||||||
^{:key (str "sticker" id)}
|
^{:key (str "sticker" id)}
|
||||||
[stickers-panel (map #(assoc % :pack id) stickers) @content-width])]))
|
[stickers-panel (map #(assoc % :pack id) (filter stickers/valid-sticker? stickers)) width])])))
|
||||||
|
|
||||||
(defn pack-icon [{:keys [id on-press background-color]
|
(defn pack-icon [{:keys [id on-press background-color]
|
||||||
:or {on-press #(re-frame/dispatch [:stickers/select-pack id])}}
|
:or {on-press #(re-frame/dispatch [:stickers/select-pack id])}}
|
||||||
|
@ -104,10 +108,6 @@
|
||||||
[react/view {:style (styles/pack-icon background-color icon-size icon-horizontal-margin)}
|
[react/view {:style (styles/pack-icon background-color icon-size icon-horizontal-margin)}
|
||||||
icon]]])
|
icon]]])
|
||||||
|
|
||||||
(defn pack-stickers [packs pack-id]
|
|
||||||
(let [{:keys [stickers id]} (some #(when (= pack-id (:id %)) %) packs)]
|
|
||||||
(map #(assoc % :pack id) stickers)))
|
|
||||||
|
|
||||||
(defn show-panel-anim
|
(defn show-panel-anim
|
||||||
[bottom-anim-value alpha-value]
|
[bottom-anim-value alpha-value]
|
||||||
(anim/start
|
(anim/start
|
||||||
|
@ -157,5 +157,5 @@
|
||||||
[pack-icon {:id id
|
[pack-icon {:id id
|
||||||
:background-color colors/white}
|
:background-color colors/white}
|
||||||
[react/image {:style {:width icon-size :height icon-size :border-radius (/ icon-size 2)}
|
[react/image {:style {:width icon-size :height icon-size :border-radius (/ icon-size 2)}
|
||||||
:source {:uri thumbnail}}]])]
|
:source {:uri (contenthash/url thumbnail)}}]])]
|
||||||
[scroll-indicator]]]]]))
|
[scroll-indicator]]]]]))
|
||||||
|
|
|
@ -27,7 +27,8 @@
|
||||||
[status-im.ui.screens.desktop.main.chat.emoji :as emoji]
|
[status-im.ui.screens.desktop.main.chat.emoji :as emoji]
|
||||||
[status-im.ui.components.icons.vector-icons :as icons]
|
[status-im.ui.components.icons.vector-icons :as icons]
|
||||||
[status-im.ui.screens.chat.message.gap :as gap]
|
[status-im.ui.screens.chat.message.gap :as gap]
|
||||||
[status-im.ui.components.animation :as animation])
|
[status-im.ui.components.animation :as animation]
|
||||||
|
[status-im.utils.contenthash :as contenthash])
|
||||||
(:require-macros [status-im.utils.views :as views]))
|
(:require-macros [status-im.utils.views :as views]))
|
||||||
|
|
||||||
(defn toolbar-chat-view
|
(defn toolbar-chat-view
|
||||||
|
@ -175,7 +176,7 @@
|
||||||
[_ _ {:keys [content] :as message}]
|
[_ _ {:keys [content] :as message}]
|
||||||
[message-wrapper message
|
[message-wrapper message
|
||||||
[react/image {:style {:margin 10 :width 140 :height 140}
|
[react/image {:style {:margin 10 :width 140 :height 140}
|
||||||
:source {:uri (:uri content)}}]])
|
:source {:uri (contenthash/url (:hash content))}}]])
|
||||||
|
|
||||||
(views/defview message-content-status [text message]
|
(views/defview message-content-status [text message]
|
||||||
[react/view
|
[react/view
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
[reagent.core :as reagent]
|
[reagent.core :as reagent]
|
||||||
[status-im.ui.components.action-button.styles :as action-button.styles]
|
[status-im.ui.components.action-button.styles :as action-button.styles]
|
||||||
[status-im.ui.components.action-button.action-button :as action-button]
|
[status-im.ui.components.action-button.action-button :as action-button]
|
||||||
[status-im.utils.config :as config]))
|
[status-im.utils.config :as config]
|
||||||
|
[status-im.utils.contenthash :as contenthash]))
|
||||||
|
|
||||||
(views/defview chat-list-item-inner-view
|
(views/defview chat-list-item-inner-view
|
||||||
[{:keys [chat-id name group-chat
|
[{:keys [chat-id name group-chat
|
||||||
|
@ -54,16 +55,17 @@
|
||||||
:number-of-lines 1
|
:number-of-lines 1
|
||||||
:style (styles/chat-name current?)}
|
:style (styles/chat-name current?)}
|
||||||
name]]
|
name]]
|
||||||
(if (and (:uri (:content last-message) (= constants/content-type-sticker (:content-type last-message))))
|
(let [uri (contenthash/url (:content last-message))]
|
||||||
|
(if (and uri (= constants/content-type-sticker (:content-type last-message)))
|
||||||
[react/image {:style {:margin 2 :width 30 :height 30}
|
[react/image {:style {:margin 2 :width 30 :height 30}
|
||||||
:source {:uri (:uri (:content last-message))}}]
|
:source {:uri uri}}]
|
||||||
[react/text {:ellipsize-mode :tail
|
[react/text {:ellipsize-mode :tail
|
||||||
:number-of-lines 1
|
:number-of-lines 1
|
||||||
:style styles/chat-last-message}
|
:style styles/chat-last-message}
|
||||||
(if (= constants/content-type-command (:content-type last-message))
|
(if (= constants/content-type-command (:content-type last-message))
|
||||||
[chat-item/command-short-preview last-message]
|
[chat-item/command-short-preview last-message]
|
||||||
(or (:text last-message-content)
|
(or (:text last-message-content)
|
||||||
(i18n/label :no-messages-yet)))])]
|
(i18n/label :no-messages-yet)))]))]
|
||||||
[react/view {:style styles/timestamp}
|
[react/view {:style styles/timestamp}
|
||||||
[chat-item/message-timestamp (:timestamp last-message)]
|
[chat-item/message-timestamp (:timestamp last-message)]
|
||||||
(when (pos? unviewed-messages-count)
|
(when (pos? unviewed-messages-count)
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
[status-im.ui.components.list.views :as list]
|
[status-im.ui.components.list.views :as list]
|
||||||
[status-im.ui.components.react :as react]
|
[status-im.ui.components.react :as react]
|
||||||
[status-im.ui.screens.home.styles :as styles]
|
[status-im.ui.screens.home.styles :as styles]
|
||||||
|
[status-im.utils.contenthash :as contenthash]
|
||||||
[status-im.utils.core :as utils]
|
[status-im.utils.core :as utils]
|
||||||
[status-im.utils.datetime :as time])
|
[status-im.utils.datetime :as time])
|
||||||
(:require-macros [status-im.utils.views :refer [defview letsubs]]))
|
(:require-macros [status-im.utils.views :refer [defview letsubs]]))
|
||||||
|
@ -36,7 +37,7 @@
|
||||||
|
|
||||||
(= constants/content-type-sticker content-type)
|
(= constants/content-type-sticker content-type)
|
||||||
[react/image {:style {:margin 2 :width 30 :height 30}
|
[react/image {:style {:margin 2 :width 30 :height 30}
|
||||||
:source {:uri (:uri content)}}]
|
:source {:uri (contenthash/url (:hash content))}}]
|
||||||
|
|
||||||
(string/blank? (:text content))
|
(string/blank? (:text content))
|
||||||
[react/text {:style styles/last-message-text}
|
[react/text {:style styles/last-message-text}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
[status-im.ui.components.styles :as components.styles]
|
[status-im.ui.components.styles :as components.styles]
|
||||||
[status-im.ui.components.toolbar.view :as toolbar]
|
[status-im.ui.components.toolbar.view :as toolbar]
|
||||||
[status-im.ui.screens.stickers.styles :as styles]
|
[status-im.ui.screens.stickers.styles :as styles]
|
||||||
|
[status-im.utils.contenthash :as contenthash]
|
||||||
[status-im.utils.money :as money])
|
[status-im.utils.money :as money])
|
||||||
(:require-macros [status-im.utils.views :refer [defview letsubs]]))
|
(:require-macros [status-im.utils.views :refer [defview letsubs]]))
|
||||||
|
|
||||||
|
@ -47,9 +48,9 @@
|
||||||
(defn pack-badge [{:keys [name author price thumbnail preview id installed owned pending] :as pack}]
|
(defn pack-badge [{:keys [name author price thumbnail preview id installed owned pending] :as pack}]
|
||||||
[react/touchable-highlight {:on-press #(re-frame/dispatch [:navigate-to :stickers-pack pack])}
|
[react/touchable-highlight {:on-press #(re-frame/dispatch [:navigate-to :stickers-pack pack])}
|
||||||
[react/view {:margin-bottom 27}
|
[react/view {:margin-bottom 27}
|
||||||
[react/image {:style {:height 200 :border-radius 20} :source {:uri preview}}]
|
[react/image {:style {:height 200 :border-radius 20} :source {:uri (contenthash/url preview)}}]
|
||||||
[react/view {:height 64 :align-items :center :flex-direction :row}
|
[react/view {:height 64 :align-items :center :flex-direction :row}
|
||||||
[thumbnail-icon thumbnail 40]
|
[thumbnail-icon (contenthash/url thumbnail) 40]
|
||||||
[react/view {:padding-horizontal 16 :flex 1}
|
[react/view {:padding-horizontal 16 :flex 1}
|
||||||
[react/text {:accessibility-label :sticker-pack-name} name]
|
[react/text {:accessibility-label :sticker-pack-name} name]
|
||||||
[react/text {:style {:color colors/gray :margin-top 6}
|
[react/text {:style {:color colors/gray :margin-top 6}
|
||||||
|
@ -79,7 +80,7 @@
|
||||||
[react/keyboard-avoiding-view components.styles/flex
|
[react/keyboard-avoiding-view components.styles/flex
|
||||||
[toolbar/simple-toolbar nil modal?]
|
[toolbar/simple-toolbar nil modal?]
|
||||||
[react/view {:height 74 :align-items :center :flex-direction :row :padding-horizontal 16}
|
[react/view {:height 74 :align-items :center :flex-direction :row :padding-horizontal 16}
|
||||||
[thumbnail-icon thumbnail 64]
|
[thumbnail-icon (contenthash/url thumbnail) 64]
|
||||||
[react/view {:padding-horizontal 16 :flex 1}
|
[react/view {:padding-horizontal 16 :flex 1}
|
||||||
[react/text {:style {:typography :header}} name]
|
[react/text {:style {:typography :header}} name]
|
||||||
[react/text {:style {:color colors/gray :margin-top 6}} author]]
|
[react/text {:style {:color colors/gray :margin-top 6}} author]]
|
||||||
|
@ -89,10 +90,10 @@
|
||||||
[react/view {:style {:padding-top 8 :flex 1}}
|
[react/view {:style {:padding-top 8 :flex 1}}
|
||||||
[react/scroll-view {:keyboard-should-persist-taps :handled :style {:flex 1}}
|
[react/scroll-view {:keyboard-should-persist-taps :handled :style {:flex 1}}
|
||||||
[react/view {:flex-direction :row :flex-wrap :wrap}
|
[react/view {:flex-direction :row :flex-wrap :wrap}
|
||||||
(for [{:keys [uri]} stickers]
|
(for [{:keys [hash]} stickers]
|
||||||
^{:key uri}
|
^{:key hash}
|
||||||
[react/image {:style (styles/sticker-image sticker-icon-size)
|
[react/image {:style (styles/sticker-image sticker-icon-size)
|
||||||
:source {:uri uri}}])]]]]]))
|
:source {:uri (contenthash/url hash)}}])]]]]]))
|
||||||
|
|
||||||
(defview pack []
|
(defview pack []
|
||||||
[pack-main false])
|
[pack-main false])
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
(def cached-webviews-enabled? (enabled? (get-config :CACHED_WEBVIEWS_ENABLED 0)))
|
(def cached-webviews-enabled? (enabled? (get-config :CACHED_WEBVIEWS_ENABLED 0)))
|
||||||
(def snoopy-enabled? (enabled? (get-config :SNOOPY 0)))
|
(def snoopy-enabled? (enabled? (get-config :SNOOPY 0)))
|
||||||
(def extensions-enabled? (enabled? (get-config :EXTENSIONS 0)))
|
(def extensions-enabled? (enabled? (get-config :EXTENSIONS 0)))
|
||||||
(def stickers-enabled? (enabled? (get-config :STICKERS_ENABLED 0)))
|
|
||||||
(def hardwallet-enabled? (enabled? (get-config :HARDWALLET_ENABLED 0)))
|
(def hardwallet-enabled? (enabled? (get-config :HARDWALLET_ENABLED 0)))
|
||||||
(def dev-build? (enabled? (get-config :DEV_BUILD 0)))
|
(def dev-build? (enabled? (get-config :DEV_BUILD 0)))
|
||||||
(def erc20-contract-warnings-enabled? (enabled? (get-config :ERC20_CONTRACT_WARNINGS)))
|
(def erc20-contract-warnings-enabled? (enabled? (get-config :ERC20_CONTRACT_WARNINGS)))
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
(:require [alphabase.base58 :as b58]
|
(:require [alphabase.base58 :as b58]
|
||||||
[alphabase.hex :as hex]
|
[alphabase.hex :as hex]
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
|
[status-im.ethereum.core :as ethereum]
|
||||||
[status-im.ipfs.core :as ipfs]
|
[status-im.ipfs.core :as ipfs]
|
||||||
[status-im.utils.fx :as fx]))
|
[status-im.utils.fx :as fx]))
|
||||||
|
|
||||||
|
@ -54,6 +55,12 @@
|
||||||
hex/decode
|
hex/decode
|
||||||
b58/encode))})))
|
b58/encode))})))
|
||||||
|
|
||||||
|
(defn url [hex]
|
||||||
|
(let [{:keys [namespace hash]} (decode (ethereum/normalized-address hex))]
|
||||||
|
(case namespace
|
||||||
|
:ipfs (str "https://ipfs.infura.io/ipfs/" hash)
|
||||||
|
"")))
|
||||||
|
|
||||||
(fx/defn cat
|
(fx/defn cat
|
||||||
[cofx {:keys [contenthash on-success on-failure]}]
|
[cofx {:keys [contenthash on-success on-failure]}]
|
||||||
(let [{:keys [namespace hash]} (decode contenthash)]
|
(let [{:keys [namespace hash]} (decode contenthash)]
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
[status-im.test.pairing.core]
|
[status-im.test.pairing.core]
|
||||||
[status-im.test.search.core]
|
[status-im.test.search.core]
|
||||||
[status-im.test.sign-in.flow]
|
[status-im.test.sign-in.flow]
|
||||||
|
[status-im.test.stickers.core]
|
||||||
[status-im.test.transport.core]
|
[status-im.test.transport.core]
|
||||||
[status-im.test.tribute-to-talk.core]
|
[status-im.test.tribute-to-talk.core]
|
||||||
[status-im.test.tribute-to-talk.db]
|
[status-im.test.tribute-to-talk.db]
|
||||||
|
@ -127,6 +128,7 @@
|
||||||
'status-im.test.pairing.core
|
'status-im.test.pairing.core
|
||||||
'status-im.test.search.core
|
'status-im.test.search.core
|
||||||
'status-im.test.sign-in.flow
|
'status-im.test.sign-in.flow
|
||||||
|
'status-im.test.stickers.core
|
||||||
'status-im.test.signing.core
|
'status-im.test.signing.core
|
||||||
'status-im.test.signing.gas
|
'status-im.test.signing.gas
|
||||||
'status-im.test.transport.core
|
'status-im.test.transport.core
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
(ns status-im.test.stickers.core
|
||||||
|
(:require [cljs.test :refer-macros [deftest is]]
|
||||||
|
[status-im.stickers.core :as stickers]))
|
||||||
|
|
||||||
|
(deftest valid-sticker?
|
||||||
|
(is (true? (stickers/valid-sticker? {:hash ""})))
|
||||||
|
(is (false? (stickers/valid-sticker? {}))))
|
Loading…
Reference in New Issue