mirror of
https://github.com/status-im/status-react.git
synced 2025-01-25 18:29:37 +00:00
support style in link
and map-link components in extensions Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
parent
a30c379a87
commit
2fd3ff798a
@ -25,7 +25,8 @@
|
|||||||
[status-im.utils.ethereum.tokens :as tokens]
|
[status-im.utils.ethereum.tokens :as tokens]
|
||||||
[status-im.utils.ethereum.core :as ethereum]
|
[status-im.utils.ethereum.core :as ethereum]
|
||||||
[status-im.chat.commands.sending :as commands-sending]
|
[status-im.chat.commands.sending :as commands-sending]
|
||||||
[status-im.browser.core :as browser]))
|
[status-im.browser.core :as browser]
|
||||||
|
[status-im.utils.platform :as platform]))
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
::identity-event
|
::identity-event
|
||||||
@ -365,12 +366,28 @@
|
|||||||
(defn image [{:keys [source uri style]}]
|
(defn image [{:keys [source uri style]}]
|
||||||
[react/image (merge {:style (merge {:width 100 :height 100} style)} {:source (if source source {:uri uri})})])
|
[react/image (merge {:style (merge {:width 100 :height 100} style)} {:source (if source source {:uri uri})})])
|
||||||
|
|
||||||
(defn link [{:keys [uri]}]
|
(defn link [{:keys [uri style open-in text]}]
|
||||||
[react/text
|
[react/text (merge {:style
|
||||||
{:style {:color colors/white
|
{:color colors/white
|
||||||
:text-decoration-line :underline}
|
:text-decoration-line :underline}
|
||||||
:on-press #(re-frame/dispatch [:browser.ui/message-link-pressed uri])}
|
:on-press (case open-in
|
||||||
uri])
|
:device #(.openURL react/linking uri)
|
||||||
|
:status #(re-frame/dispatch [:browser.ui/open-in-status-option-selected uri])
|
||||||
|
#(re-frame/dispatch [:browser.ui/message-link-pressed uri]))}
|
||||||
|
(when style {:style style}))
|
||||||
|
(or text uri)])
|
||||||
|
|
||||||
|
(defn map-link
|
||||||
|
"create a link-view which opens native map/navigation app with marker and label"
|
||||||
|
[{:keys [text lat lng style]}]
|
||||||
|
(let [uri (cond
|
||||||
|
platform/ios? (str "http://maps.apple.com/?q=" (js/encodeURIComponent text) "&ll=" lat "," lng)
|
||||||
|
platform/android? (str "geo:0,0?q=" lat "," lng "(" (js/encodeURIComponent text) ")")
|
||||||
|
:else (str "http://www.openstreetmap.org/?mlat=" lat "&mlon=" lng))]
|
||||||
|
(link {:uri uri
|
||||||
|
:text text
|
||||||
|
:style style
|
||||||
|
:open-in :device})))
|
||||||
|
|
||||||
(defn list [{:keys [key data item-view]}]
|
(defn list [{:keys [key data item-view]}]
|
||||||
[list/flat-list {:data data :key-fn (or key (fn [_ i] (str i))) :render-fn item-view}])
|
[list/flat-list {:data data :key-fn (or key (fn [_ i] (str i))) :render-fn item-view}])
|
||||||
@ -434,7 +451,7 @@
|
|||||||
'image {:value image :properties {:uri :string :source :string}}
|
'image {:value image :properties {:uri :string :source :string}}
|
||||||
'input {:value input :properties {:on-change :event :placeholder :string :keyboard-type :keyword :change-delay? :number :placeholder-text-color :any :selection-color :any}}
|
'input {:value input :properties {:on-change :event :placeholder :string :keyboard-type :keyword :change-delay? :number :placeholder-text-color :any :selection-color :any}}
|
||||||
'button {:value button :properties {:enabled :boolean :disabled :boolean :on-click :event}}
|
'button {:value button :properties {:enabled :boolean :disabled :boolean :on-click :event}}
|
||||||
'link {:value link :properties {:uri :string}}
|
'link {:value link :properties {:uri :string :text? :string :open-in? {:one-of #{:device :status}}}}
|
||||||
'list {:value list :properties {:data :vector :item-view :view :key? :keyword}}
|
'list {:value list :properties {:data :vector :item-view :view :key? :keyword}}
|
||||||
'checkbox {:value checkbox :properties {:on-change :event :checked :boolean}}
|
'checkbox {:value checkbox :properties {:on-change :event :checked :boolean}}
|
||||||
'activity-indicator {:value activity-indicator :properties {:animating :boolean :color :string :size :keyword :hides-when-stopped :boolean}}
|
'activity-indicator {:value activity-indicator :properties {:animating :boolean :color :string :size :keyword :hides-when-stopped :boolean}}
|
||||||
@ -451,7 +468,7 @@
|
|||||||
:fly? :boolean
|
:fly? :boolean
|
||||||
:interactive? :boolean
|
:interactive? :boolean
|
||||||
:on-change :event}}
|
:on-change :event}}
|
||||||
'map-link {:value map/map-link :properties {:text :string :lng :any :lat :any}}}
|
'map-link {:value map-link :properties {:text :string :lng :any :lat :any}}}
|
||||||
:queries {'identity {:value :extensions/identity :arguments {:value :map}}
|
:queries {'identity {:value :extensions/identity :arguments {:value :map}}
|
||||||
'store/get {:value :store/get :arguments {:key :string}}
|
'store/get {:value :store/get :arguments {:key :string}}
|
||||||
'contacts/all {:value :extensions.contacts/all} ;; :photo :name :address :public-key
|
'contacts/all {:value :extensions.contacts/all} ;; :photo :name :address :public-key
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
[status-im.utils.platform :as platform]
|
[status-im.utils.platform :as platform]
|
||||||
[status-im.utils.types :as types]
|
[status-im.utils.types :as types]
|
||||||
[status-im.ui.components.react :as react]
|
[status-im.ui.components.react :as react]
|
||||||
[status-im.ui.components.colors :as colors]
|
|
||||||
[status-im.ui.screens.browser.styles :as styles]
|
[status-im.ui.screens.browser.styles :as styles]
|
||||||
[status-im.react-native.js-dependencies :as js-dependencies]))
|
[status-im.react-native.js-dependencies :as js-dependencies]))
|
||||||
|
|
||||||
@ -79,17 +78,4 @@
|
|||||||
(if (map? marker)
|
(if (map? marker)
|
||||||
(str "update(" (types/clj->json (assoc marker :fly fly? :interactive interactive?)) ");")
|
(str "update(" (types/clj->json (assoc marker :fly fly? :interactive interactive?)) ");")
|
||||||
(str "init(" (types/clj->json {:interactive interactive?}) ");")))}
|
(str "init(" (types/clj->json {:interactive interactive?}) ");")))}
|
||||||
webview]))
|
webview]))
|
||||||
|
|
||||||
(defn map-link
|
|
||||||
"create a link-view which opens native map/navigation app with marker and label"
|
|
||||||
[{:keys [text lat lng]}]
|
|
||||||
(let [uri (cond
|
|
||||||
platform/ios? (str "http://maps.apple.com/?q=" (js/encodeURIComponent text) "&ll=" lat "," lng)
|
|
||||||
platform/android? (str "geo:0,0?q=" lat "," lng "(" (js/encodeURIComponent text) ")")
|
|
||||||
:else (str "http://www.openstreetmap.org/?mlat=" lat "&mlon=" lng))]
|
|
||||||
[react/text
|
|
||||||
{:style {:color colors/white
|
|
||||||
:text-decoration-line :underline}
|
|
||||||
:on-press #(.openURL react/linking uri)}
|
|
||||||
text]))
|
|
Loading…
x
Reference in New Issue
Block a user