/browse links (addition to #638)
This commit is contained in:
parent
c9366892cf
commit
3b80f7d088
|
@ -42,7 +42,7 @@
|
|||
"imageDirs": [
|
||||
"images"
|
||||
],
|
||||
"iosHost": "10.0.1.4",
|
||||
"iosHost": "localhost",
|
||||
"envRoots": {
|
||||
"dev": "env/dev",
|
||||
"prod": "env/prod"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
(re-frame.core/dispatch [:load-commands!]))
|
||||
|
||||
(figwheel/watch-and-reload
|
||||
:websocket-url "ws://10.0.3.2:3449/figwheel-ws"
|
||||
:websocket-url "ws://localhost:3449/figwheel-ws"
|
||||
:heads-up-display false
|
||||
:jsload-callback callback)
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
get-dimensions]]
|
||||
[status-im.components.animation :as anim]
|
||||
[status-im.chat.constants :as chat-consts]
|
||||
[status-im.components.share :refer [share]]
|
||||
[status-im.components.list-selection :refer [share browse]]
|
||||
[status-im.chat.views.request-message :refer [message-content-command-request]]
|
||||
[status-im.chat.styles.message :as st]
|
||||
[status-im.chat.styles.command-pill :as pill-st]
|
||||
|
@ -203,9 +203,10 @@
|
|||
(let [parsed-text (parse-text content)
|
||||
simple-text? (= (count parsed-text) 2)]
|
||||
(if simple-text?
|
||||
[autolink {:style (st/text-message message)
|
||||
:font :default
|
||||
:text (apply str parsed-text)}]
|
||||
[autolink {:style (st/text-message message)
|
||||
:font :default
|
||||
:text (apply str parsed-text)
|
||||
:onPress #(browse %)}]
|
||||
[text {:style (st/text-message message)
|
||||
:font :default}
|
||||
(parse-text content)]))])
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
(ns status-im.components.list-selection
|
||||
(:require [re-frame.core :refer [dispatch]]
|
||||
[status-im.components.react :refer [copy-to-clipboard
|
||||
linking]]
|
||||
[status-im.utils.platform :refer [platform-specific]]
|
||||
[status-im.i18n :refer [label]]))
|
||||
|
||||
(def class (js/require "react-native-share"))
|
||||
|
||||
(defn open [opts]
|
||||
(.open class (clj->js opts)))
|
||||
|
||||
(defn share [text dialog-title]
|
||||
(let [list-selection-fn (:list-selection-fn platform-specific)]
|
||||
(list-selection-fn {:title dialog-title
|
||||
:options [(label :t/sharing-copy-to-clipboard) (label :t/sharing-share)]
|
||||
:callback (fn [index]
|
||||
(case index
|
||||
0 (copy-to-clipboard text)
|
||||
1 (open {:message text})
|
||||
:default))
|
||||
:cancel-text (label :t/sharing-cancel)})))
|
||||
|
||||
(defn browse [link]
|
||||
(let [list-selection-fn (:list-selection-fn platform-specific)]
|
||||
(list-selection-fn {:title (label :t/browsing-title)
|
||||
:options [(label :t/browsing-browse) (label :t/browsing-open-in-web-browser)]
|
||||
:callback (fn [index]
|
||||
(case index
|
||||
0 (do
|
||||
(dispatch [:set-chat-command :browse])
|
||||
(dispatch [:fill-chat-command-content link])
|
||||
(js/setTimeout #(dispatch [:send-command!]) 500))
|
||||
1 (.openURL linking link)
|
||||
:default))
|
||||
:cancel-text (label :t/browsing-cancel)})))
|
||||
|
|
@ -49,6 +49,7 @@
|
|||
|
||||
(def dimensions (.-Dimensions js/ReactNative))
|
||||
(def keyboard (.-Keyboard react-native))
|
||||
(def linking (.-Linking js/ReactNative))
|
||||
|
||||
;; Accessor methods for React Components
|
||||
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
(ns status-im.components.share
|
||||
(:require [re-frame.core :refer [dispatch]]
|
||||
[status-im.utils.platform :refer [platform-specific]]))
|
||||
|
||||
(def class (js/require "react-native-share"))
|
||||
|
||||
(defn open [opts]
|
||||
(.open class (clj->js opts)))
|
||||
|
||||
(defn share [text dialog-title]
|
||||
(let [list-selection-fn (:list-selection-fn platform-specific)]
|
||||
(dispatch [:open-sharing list-selection-fn text dialog-title])))
|
|
@ -6,8 +6,6 @@
|
|||
[taoensso.timbre :as log]
|
||||
[status-im.utils.crypt :refer [gen-random-bytes]]
|
||||
[status-im.components.status :as status]
|
||||
[status-im.components.share :refer [open]]
|
||||
[status-im.components.react :refer [copy-to-clipboard]]
|
||||
[status-im.utils.handlers :refer [register-handler] :as u]
|
||||
status-im.chat.handlers
|
||||
status-im.group-settings.handlers
|
||||
|
@ -46,18 +44,6 @@
|
|||
(fn [db [_ k v]]
|
||||
(assoc-in db [:animations k] v)))
|
||||
|
||||
(register-handler :open-sharing
|
||||
(u/side-effect!
|
||||
(fn [_ [_ list-selection-fn text dialog-title]]
|
||||
(list-selection-fn {:title dialog-title
|
||||
:options [(label :t/sharing-copy-to-clipboard) (label :t/sharing-share)]
|
||||
:callback (fn [index]
|
||||
(case index
|
||||
0 (copy-to-clipboard text)
|
||||
1 (open {:message text})
|
||||
:default))
|
||||
:cancel-text (label :t/sharing-cancel)}))))
|
||||
|
||||
(register-handler :initialize-db
|
||||
(fn [{:keys [status-module-initialized? network-status network]} _]
|
||||
(data-store/init)
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
[status-im.components.text-field.view :refer [text-field]]
|
||||
[status-im.components.selectable-field.view :refer [selectable-field]]
|
||||
[status-im.components.status-view.view :refer [status-view]]
|
||||
[status-im.components.share :refer [share]]
|
||||
[status-im.components.list-selection :refer [share]]
|
||||
[status-im.utils.phone-number :refer [format-phone-number]]
|
||||
[status-im.utils.image-processing :refer [img->base64]]
|
||||
[status-im.utils.platform :refer [platform-specific]]
|
||||
|
|
|
@ -88,6 +88,11 @@
|
|||
:sharing-share "Share..."
|
||||
:sharing-cancel "Cancel"
|
||||
|
||||
:browsing-title "Browse"
|
||||
:browsing-browse "/browse"
|
||||
:browsing-open-in-web-browser "Open in web browser"
|
||||
:browsing-cancel "Cancel"
|
||||
|
||||
;sign-up
|
||||
:contacts-syncronized "Your contacts have been synchronized"
|
||||
:confirmation-code (str "Thanks! We've sent you a text message with a confirmation "
|
||||
|
|
Loading…
Reference in New Issue