fixed share dialog everywhere on iOS

This commit is contained in:
Gustavo Nunes 2017-03-22 01:44:08 -03:00 committed by Roman Volosovskyi
parent 6ca2f61eb3
commit 141246e8d5
4 changed files with 12 additions and 11 deletions

View File

@ -167,7 +167,7 @@
(defn show-dialog [{:keys [title options callback]}] (defn show-dialog [{:keys [title options callback]}]
(let [dialog (new react-native-dialogs)] (let [dialog (new react-native-dialogs)]
(.set dialog (clj->js {:title title (.set dialog (clj->js {:title title
:items options :items (mapv :text options)
:itemsCallback callback})) :itemsCallback callback}))
(.show dialog))) (.show dialog)))

View File

@ -27,13 +27,11 @@
(def list-selection-fn (:list-selection-fn platform-specific)) (def list-selection-fn (:list-selection-fn platform-specific))
(defn open-ios-menu [options] (defn open-ios-menu [options]
(let [cancel-option {:text (label :t/cancel)} (list-selection-fn {:options options
options (conj options cancel-option)] :callback (fn [index]
(list-selection-fn {:options options (when (< index (count options))
:callback (fn [index] (when-let [handler (:value (nth options index))]
(when (< index (count options)) (handler))))})
(when-let [handler (:value (nth options index))]
(handler))))}))
nil) nil)
(defn context-menu [trigger options] (defn context-menu [trigger options]

View File

@ -17,7 +17,7 @@
(defn share [text dialog-title] (defn share [text dialog-title]
(let [list-selection-fn (:list-selection-fn platform-specific)] (let [list-selection-fn (:list-selection-fn platform-specific)]
(list-selection-fn {:title dialog-title (list-selection-fn {:title dialog-title
:options [(label :t/sharing-copy-to-clipboard) (label :t/sharing-share)] :options (share-options text)
:callback (fn [index] :callback (fn [index]
(case index (case index
0 (copy-to-clipboard text) 0 (copy-to-clipboard text)

View File

@ -1,5 +1,6 @@
(ns status-im.ios.platform (ns status-im.ios.platform
(:require [status-im.components.styles :as styles] (:require [status-im.components.styles :as styles]
[status-im.i18n :refer [label]]
[status-im.utils.utils :as utils])) [status-im.utils.utils :as utils]))
(def component-styles (def component-styles
@ -194,9 +195,11 @@
(def react-native (js/require "react-native")) (def react-native (js/require "react-native"))
(defn action-sheet-options [options] (defn action-sheet-options [options]
(let [destructive-opt-index (utils/first-index :destructive? options)] (let [destructive-opt-index (utils/first-index :destructive? options)
cancel-option {:text (label :t/cancel)}
options (conj options cancel-option)]
(clj->js (merge {:options (mapv :text options) (clj->js (merge {:options (mapv :text options)
:cancelButtonIndex (count options)} :cancelButtonIndex (dec (count options))}
(when destructive-opt-index {:destructiveButtonIndex destructive-opt-index}))))) (when destructive-opt-index {:destructiveButtonIndex destructive-opt-index})))))
(defn show-action-sheet [{:keys [options callback]}] (defn show-action-sheet [{:keys [options callback]}]