From 4ffbea6a6a55e507ef644e4937116e7c4493093c Mon Sep 17 00:00:00 2001 From: Alexander Pantyukhov Date: Fri, 25 Nov 2016 12:08:17 +0300 Subject: [PATCH] Share Address/Public Key (#485) --- .re-natal | 3 +- android/app/build.gradle | 1 + .../im/status/ethereum/MainApplication.java | 4 +- android/settings.gradle | 3 + env/dev/env/android/main.cljs | 2 +- ios/StatusIm.xcodeproj/project.pbxproj | 178 +++++++----------- ios/StatusIm/Info.plist | 4 + package.json | 1 + src/status_im/components/react.cljs | 5 + .../components/selectable_field/view.cljs | 7 +- src/status_im/components/share.cljs | 7 + src/status_im/profile/handlers.cljs | 16 +- src/status_im/profile/screen.cljs | 22 ++- src/status_im/translations/en.cljs | 5 + src/status_im/translations/es.cljs | 5 + src/status_im/translations/es_ar.cljs | 5 + src/status_im/translations/ru.cljs | 5 + src/status_im/translations/sw.cljs | 5 + src/status_im/translations/uk.cljs | 5 + 19 files changed, 155 insertions(+), 128 deletions(-) create mode 100644 src/status_im/components/share.cljs diff --git a/.re-natal b/.re-natal index 824fe96059..1e46c72dab 100644 --- a/.re-natal +++ b/.re-natal @@ -33,7 +33,8 @@ "web3", "eccjs", "chance", - "react-native-swiper" + "react-native-swiper", + "react-native-share" ], "imageDirs": [ "images" diff --git a/android/app/build.gradle b/android/app/build.gradle index 1e31a7daa9..21d04a5d41 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -152,6 +152,7 @@ dependencies { compile project(':react-native-fs') compile project(':react-native-image-crop-picker') compile project(':react-native-webview-bridge') + compile project(':react-native-share') compile fileTree(dir: "node_modules/realm/android/libs", include: ["*.jar"]) } diff --git a/android/app/src/main/java/im/status/ethereum/MainApplication.java b/android/app/src/main/java/im/status/ethereum/MainApplication.java index 570e57b09f..e4f8f7acbd 100644 --- a/android/app/src/main/java/im/status/ethereum/MainApplication.java +++ b/android/app/src/main/java/im/status/ethereum/MainApplication.java @@ -24,6 +24,7 @@ import com.aakashns.reactnativedialogs.ReactNativeDialogsPackage; import fr.bamlab.rnimageresizer.ImageResizerPackage; import com.reactnative.ivpusic.imagepicker.PickerPackage; import com.github.alinz.reactnativewebviewbridge.WebViewBridgePackage; +import cl.json.RNSharePackage; import java.util.Arrays; import java.util.List; @@ -56,7 +57,8 @@ public class MainApplication extends Application implements ReactApplication { new ReactNativeDialogsPackage(), new ImageResizerPackage(), new PickerPackage(), - new WebViewBridgePackage() + new WebViewBridgePackage(), + new RNSharePackage() ); } }; diff --git a/android/settings.gradle b/android/settings.gradle index 3378056450..e729defd4c 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -37,3 +37,6 @@ project(':react-native-image-crop-picker').projectDir = new File(settingsDir, '. include ':react-native-webview-bridge' project(':react-native-webview-bridge').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview-bridge/android') + +include ':react-native-share' +project(':react-native-share').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-share/android') \ No newline at end of file diff --git a/env/dev/env/android/main.cljs b/env/dev/env/android/main.cljs index 6813b594fe..a26f34785c 100644 --- a/env/dev/env/android/main.cljs +++ b/env/dev/env/android/main.cljs @@ -14,7 +14,7 @@ (re-frame.core/dispatch [:load-commands!])) (figwheel/watch-and-reload - :websocket-url "ws://localhost:3449/figwheel-ws" + :websocket-url "ws://10.0.3.2:3449/figwheel-ws" :heads-up-display false :jsload-callback callback) diff --git a/ios/StatusIm.xcodeproj/project.pbxproj b/ios/StatusIm.xcodeproj/project.pbxproj index 6a5f558706..8bb1b553ef 100644 --- a/ios/StatusIm.xcodeproj/project.pbxproj +++ b/ios/StatusIm.xcodeproj/project.pbxproj @@ -33,7 +33,6 @@ 213311F38CA74CE280FD09AD /* libRNI18n.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 52F6ED6465184513A082652B /* libRNI18n.a */; }; 22118DE1207A419FBFE7B62D /* libRealmReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CD48A32459B64E96843BB238 /* libRealmReact.a */; }; 25DC9C9DC25846BD8D084888 /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 8B9A886A2CB448B1ABA0EB62 /* libc++.tbd */; }; - 3A7EB04F1DD9CAFC00A4FCC8 /* libSplashScreen.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A7EB04E1DD9CABC00A4FCC8 /* libSplashScreen.a */; }; 3E15DFEC1F6F4D7CAE088F49 /* libTcpSockets.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C2A4E93F6B154AEFA3485B45 /* libTcpSockets.a */; }; 4D3D740D5EFA4F8592B048D7 /* libBVLinearGradient.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DF1CD4C3D1254774ACCAE4E8 /* libBVLinearGradient.a */; }; 4FFAE7B0414A463991039A2E /* libRNRandomBytes.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C55F15EB4D4DAF9202A662 /* libRNRandomBytes.a */; }; @@ -54,6 +53,10 @@ A6AF670051B842249D520C7B /* Foundation.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7ED174A34D7D42358313368B /* Foundation.ttf */; }; AD5063BC2B2A4C52ACE0A0B4 /* libUdpSockets.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A96279092BEC4C4B93914F48 /* libUdpSockets.a */; }; AE97D4B08C9F4821B8E9C50B /* Ionicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 359B076A658B4FBAB5128B03 /* Ionicons.ttf */; }; + B24FC7FB1DE7192200D694FF /* libRNShare.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B24FC7FA1DE7190C00D694FF /* libRNShare.a */; }; + B24FC7FD1DE7195700D694FF /* Social.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B24FC7FC1DE7195700D694FF /* Social.framework */; }; + B24FC7FF1DE7195F00D694FF /* MessageUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B24FC7FE1DE7195F00D694FF /* MessageUI.framework */; }; + B24FC8001DE71C0E00D694FF /* libSplashScreen.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B24FC7F21DE718EF00D694FF /* libSplashScreen.a */; }; B2F2D1BC1D9D531B00B7B453 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B2F2D1BB1D9D531B00B7B453 /* Images.xcassets */; }; B45B40B471414274A7A83185 /* libRCTContacts.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3384AFA9609A409B81928AD5 /* libRCTContacts.a */; }; BA68A2377A20496EA737000D /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 4E586E1B0E544F64AA9F5BD1 /* libz.tbd */; }; @@ -227,62 +230,6 @@ remoteGlobalIDString = F60690131CA2766F0003FB26; remoteInfo = RealmReact; }; - 3A7EB01D1DD9C37800A4FCC8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A283A1D9B042B00D4039D; - remoteInfo = "RCTImage-tvOS"; - }; - 3A7EB0221DD9C37800A4FCC8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A28471D9B043800D4039D; - remoteInfo = "RCTLinking-tvOS"; - }; - 3A7EB0261DD9C37800A4FCC8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A28541D9B044C00D4039D; - remoteInfo = "RCTNetwork-tvOS"; - }; - 3A7EB02B1DD9C37800A4FCC8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A28611D9B046600D4039D; - remoteInfo = "RCTSettings-tvOS"; - }; - 3A7EB0301DD9C37800A4FCC8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A287B1D9B048500D4039D; - remoteInfo = "RCTText-tvOS"; - }; - 3A7EB0351DD9C37800A4FCC8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A28881D9B049200D4039D; - remoteInfo = "RCTWebSocket-tvOS"; - }; - 3A7EB03A1DD9C37800A4FCC8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A28131D9B038B00D4039D; - remoteInfo = "React-tvOS"; - }; - 3A7EB04D1DD9CABC00A4FCC8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 3A7EB0491DD9CABC00A4FCC8 /* SplashScreen.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 3D7682761D8E76B80014119E; - remoteInfo = SplashScreen; - }; 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; @@ -360,6 +307,20 @@ remoteGlobalIDString = 24DF11ED1DA3A2B90056F77C; remoteInfo = RNInstabug; }; + B24FC7F11DE718EF00D694FF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 3A7EB0491DD9CABC00A4FCC8 /* SplashScreen.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 3D7682761D8E76B80014119E; + remoteInfo = SplashScreen; + }; + B24FC7F91DE7190C00D694FF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B24FC7F51DE7190C00D694FF /* RNShare.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 134814201AA4EA6300B7C361; + remoteInfo = RNShare; + }; CE4E319D1D8693090033ED64 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 5E5A7625B76441D984EA8C0D /* RCTImageResizer.xcodeproj */; @@ -453,6 +414,9 @@ 9F1854E6D9654226B1FC8308 /* RCTCamera.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RCTCamera.xcodeproj; path = "../node_modules/react-native-camera/ios/RCTCamera.xcodeproj"; sourceTree = ""; }; A96279092BEC4C4B93914F48 /* libUdpSockets.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libUdpSockets.a; sourceTree = ""; }; ACA66A8F16CD2FE21F38738B /* Pods-StatusIm.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-StatusIm.debug.xcconfig"; path = "Pods/Target Support Files/Pods-StatusIm/Pods-StatusIm.debug.xcconfig"; sourceTree = ""; }; + B24FC7F51DE7190C00D694FF /* RNShare.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RNShare.xcodeproj; path = "../node_modules/react-native-share/ios/RNShare.xcodeproj"; sourceTree = ""; }; + B24FC7FC1DE7195700D694FF /* Social.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Social.framework; path = System/Library/Frameworks/Social.framework; sourceTree = SDKROOT; }; + B24FC7FE1DE7195F00D694FF /* MessageUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MessageUI.framework; path = System/Library/Frameworks/MessageUI.framework; sourceTree = SDKROOT; }; B2F2D1BB1D9D531B00B7B453 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = StatusIm/Images.xcassets; sourceTree = ""; }; B3B19223008342D096AA356E /* Octicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Octicons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Octicons.ttf"; sourceTree = ""; }; C2A4E93F6B154AEFA3485B45 /* libTcpSockets.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libTcpSockets.a; sourceTree = ""; }; @@ -479,7 +443,10 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 3A7EB04F1DD9CAFC00A4FCC8 /* libSplashScreen.a in Frameworks */, + B24FC8001DE71C0E00D694FF /* libSplashScreen.a in Frameworks */, + B24FC7FF1DE7195F00D694FF /* MessageUI.framework in Frameworks */, + B24FC7FD1DE7195700D694FF /* Social.framework in Frameworks */, + B24FC7FB1DE7192200D694FF /* libRNShare.a in Frameworks */, 20A5C9711D9283A2002C4965 /* libimageCropPicker.a in Frameworks */, 9E3AB6D01D87DB2B008846B4 /* libReact-Native-Webview-Bridge.a in Frameworks */, 20B6B6841D92C42600CC5C6A /* RSKImageCropper.framework in Frameworks */, @@ -776,6 +743,7 @@ 832341AE1AAA6A7D00B99B32 /* Libraries */ = { isa = PBXGroup; children = ( + B24FC7F51DE7190C00D694FF /* RNShare.xcodeproj */, 3A7EB0491DD9CABC00A4FCC8 /* SplashScreen.xcodeproj */, 20A5C94B1D927137002C4965 /* imageCropPicker.xcodeproj */, 9E3AB6B21D87DA2A008846B4 /* React-Native-Webview-Bridge.xcodeproj */, @@ -861,6 +829,8 @@ A97BA941B2FB44B4B66EE6D3 /* Frameworks */ = { isa = PBXGroup; children = ( + B24FC7FE1DE7195F00D694FF /* MessageUI.framework */, + B24FC7FC1DE7195700D694FF /* Social.framework */, 20A5C96E1D92716C002C4965 /* QBImagePicker.framework */, 20A5C96C1D92715E002C4965 /* RSKImageCropper.framework */, CE4E31B21D8695250033ED64 /* Statusgo.framework */, @@ -872,6 +842,22 @@ name = Frameworks; sourceTree = ""; }; + B24FC7BB1DE718EA00D694FF /* Products */ = { + isa = PBXGroup; + children = ( + B24FC7F21DE718EF00D694FF /* libSplashScreen.a */, + ); + name = Products; + sourceTree = ""; + }; + B24FC7F61DE7190C00D694FF /* Products */ = { + isa = PBXGroup; + children = ( + B24FC7FA1DE7190C00D694FF /* libRNShare.a */, + ); + name = Products; + sourceTree = ""; + }; CE4E31941D8693090033ED64 /* Products */ = { isa = PBXGroup; children = ( @@ -1048,12 +1034,16 @@ ProductGroup = 20B7D0F01D3F74CC00B70F14 /* Products */; ProjectRef = 45FB5F523DE04BDE9877869C /* RNRandomBytes.xcodeproj */; }, + { + ProductGroup = B24FC7F61DE7190C00D694FF /* Products */; + ProjectRef = B24FC7F51DE7190C00D694FF /* RNShare.xcodeproj */; + }, { ProductGroup = 20B7D0FF1D3F74CD00B70F14 /* Products */; ProjectRef = 8AE71EE8751F4652B13BFE83 /* RNVectorIcons.xcodeproj */; }, { - ProductGroup = 3A7EB04A1DD9CABC00A4FCC8 /* Products */; + ProductGroup = B24FC7BB1DE718EA00D694FF /* Products */; ProjectRef = 3A7EB0491DD9CABC00A4FCC8 /* SplashScreen.xcodeproj */; }, { @@ -1228,62 +1218,6 @@ remoteRef = 20B7D1281D3F74CD00B70F14 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 3A7EB01E1DD9C37800A4FCC8 /* libRCTImage-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRCTImage-tvOS.a"; - remoteRef = 3A7EB01D1DD9C37800A4FCC8 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3A7EB0231DD9C37800A4FCC8 /* libRCTLinking-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRCTLinking-tvOS.a"; - remoteRef = 3A7EB0221DD9C37800A4FCC8 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3A7EB0271DD9C37800A4FCC8 /* libRCTNetwork-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRCTNetwork-tvOS.a"; - remoteRef = 3A7EB0261DD9C37800A4FCC8 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3A7EB02C1DD9C37800A4FCC8 /* libRCTSettings-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRCTSettings-tvOS.a"; - remoteRef = 3A7EB02B1DD9C37800A4FCC8 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3A7EB0311DD9C37800A4FCC8 /* libRCTText-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRCTText-tvOS.a"; - remoteRef = 3A7EB0301DD9C37800A4FCC8 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3A7EB0361DD9C37800A4FCC8 /* libRCTWebSocket-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRCTWebSocket-tvOS.a"; - remoteRef = 3A7EB0351DD9C37800A4FCC8 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3A7EB03B1DD9C37800A4FCC8 /* libReact-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libReact-tvOS.a"; - remoteRef = 3A7EB03A1DD9C37800A4FCC8 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3A7EB04E1DD9CABC00A4FCC8 /* libSplashScreen.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libSplashScreen.a; - remoteRef = 3A7EB04D1DD9CABC00A4FCC8 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; 78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; @@ -1361,6 +1295,20 @@ remoteRef = 9E3F1C111DDAE781005E4779 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + B24FC7F21DE718EF00D694FF /* libSplashScreen.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libSplashScreen.a; + remoteRef = B24FC7F11DE718EF00D694FF /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + B24FC7FA1DE7190C00D694FF /* libRNShare.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libRNShare.a; + remoteRef = B24FC7F91DE7190C00D694FF /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; CE4E319E1D8693090033ED64 /* libRCTImageResizer.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; diff --git a/ios/StatusIm/Info.plist b/ios/StatusIm/Info.plist index b3ae496b68..7980c4e7ec 100644 --- a/ios/StatusIm/Info.plist +++ b/ios/StatusIm/Info.plist @@ -77,6 +77,10 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + LSApplicationQueriesSchemes + + whatsapp + UIViewControllerBasedStatusBarAppearance diff --git a/package.json b/package.json index f876980365..9b27859410 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "react-native-orientation": "github:youennPennarun/react-native-orientation", "react-native-qrcode": "^0.2.2", "react-native-randombytes": "^2.1.0", + "react-native-share": "^1.0.17", "react-native-splash-screen": "^1.0.9", "react-native-swiper": "1.5.3", "react-native-tcp": "^2.0.4", diff --git a/src/status_im/components/react.cljs b/src/status_im/components/react.cljs index ac82e60b3e..4eb8a7d3ca 100644 --- a/src/status_im/components/react.cljs +++ b/src/status_im/components/react.cljs @@ -118,3 +118,8 @@ (.then images-fn)))) (def swiper (adapt-class (js/require "react-native-swiper"))) + +;; Clipboard + +(defn copy-to-clipboard [text] + (.setString (.-Clipboard react-native) text)) \ No newline at end of file diff --git a/src/status_im/components/selectable_field/view.cljs b/src/status_im/components/selectable_field/view.cljs index 22048af6c7..64598295dc 100644 --- a/src/status_im/components/selectable_field/view.cljs +++ b/src/status_im/components/selectable_field/view.cljs @@ -8,7 +8,7 @@ [status-im.utils.platform :as p] [taoensso.timbre :as log])) -(defn- on-press +(defn- on-press-default [event component] (log/debug "Pressed " event component) (r/set-state component {:focused? true})) @@ -29,7 +29,7 @@ :measured? true})))) (defn- reagent-render - [{:keys [label value editable? props] :as data}] + [{:keys [label value editable? props on-press] :as data}] (let [component (r/current-component) {:keys [focused? measured? full-height]} (r/state component)] (log/debug "reagent-render: " data focused? measured? full-height) @@ -49,7 +49,8 @@ :on-blur #(r/set-state component {:focused? false}) :value value}] [text (merge {:style st/text - :on-press #(on-press % component) + :on-press (or on-press + #(on-press-default % component)) :onLayout #(on-layout-text % component) :font :default :ellipsizeMode :middle diff --git a/src/status_im/components/share.cljs b/src/status_im/components/share.cljs new file mode 100644 index 0000000000..f10be26ffb --- /dev/null +++ b/src/status_im/components/share.cljs @@ -0,0 +1,7 @@ +(ns status-im.components.share + (:require [status-im.utils.platform :as p])) + +(def class (js/require "react-native-share")) + +(defn open [opts] + (.open class (clj->js opts))) \ No newline at end of file diff --git a/src/status_im/profile/handlers.cljs b/src/status_im/profile/handlers.cljs index fec0730ba6..a52180213d 100644 --- a/src/status_im/profile/handlers.cljs +++ b/src/status_im/profile/handlers.cljs @@ -1,7 +1,9 @@ (ns status-im.profile.handlers (:require [re-frame.core :refer [subscribe dispatch]] [status-im.utils.handlers :refer [register-handler]] - [status-im.components.react :refer [show-image-picker]] + [status-im.components.react :refer [show-image-picker + copy-to-clipboard]] + [status-im.components.share :refer [open]] [status-im.utils.image-processing :refer [img->base64]] [status-im.i18n :refer [label]] [status-im.utils.handlers :as u :refer [get-hashtags]] @@ -38,3 +40,15 @@ 1 (dispatch [:open-image-picker]) :default)) :cancel-text (label :t/image-source-cancel)})))) + +(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)})))) diff --git a/src/status_im/profile/screen.cljs b/src/status_im/profile/screen.cljs index 1fe617d592..f80127f89a 100644 --- a/src/status_im/profile/screen.cljs +++ b/src/status_im/profile/screen.cljs @@ -22,6 +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 :as 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]] @@ -31,7 +32,12 @@ [status-im.utils.random :refer [id]] [status-im.utils.utils :refer [clean-text]] [status-im.components.image-button.view :refer [show-qr-button]] - [status-im.i18n :refer [label]])) + [status-im.i18n :refer [label]] + [taoensso.timbre :as log])) + +(defn share [text dialog-title] + (let [list-selection-fn (:list-selection-fn platform-specific)] + (dispatch [:open-sharing list-selection-fn text dialog-title]))) (defn toolbar [{:keys [account edit?]}] (let [profile-edit-data-valid? (s/valid? ::v/profile account)] @@ -74,7 +80,7 @@ (if edit? [touchable-highlight {:on-press (fn [] - (let [list-selection-fn (get platform-specific :list-selection-fn)] + (let [list-selection-fn (:list-selection-fn platform-specific)] (dispatch [:open-image-source-selector list-selection-fn])))} [view [my-profile-icon {:account {:photo-path photo-path @@ -163,7 +169,8 @@ [view st/profile-property-field [selectable-field {:label (label :t/address) :editable? false - :value address}]] + :value address + :on-press #(share address (label :t/address))}]] [show-qr-button {:handler #(dispatch [:navigate-to-modal :qr-code-view {:contact contact :qr-source :whisper-identity}])}]] [view st/underline-container]]) @@ -173,7 +180,8 @@ [view st/profile-property-field [selectable-field {:label (label :t/public-key) :editable? false - :value whisper-identity}]] + :value whisper-identity + :on-press #(share whisper-identity (label :t/public-key))}]] [show-qr-button {:handler #(dispatch [:navigate-to-modal :qr-code-view {:contact contact :qr-source :public-key}])}]]] @@ -213,7 +221,8 @@ [view st/profile-property-field [selectable-field {:label (label :t/address) :editable? edit? - :value address}]] + :value address + :on-press #(share address (label :t/address))}]] [show-qr-button {:handler #(dispatch [:navigate-to-modal :qr-code-view {:contact account :qr-source :address}])}]] [view st/underline-container]] @@ -223,7 +232,8 @@ [view st/profile-property-field [selectable-field {:label (label :t/public-key) :editable? edit? - :value public-key}]] + :value public-key + :on-press #(share public-key (label :t/public-key))}]] [show-qr-button {:handler #(dispatch [:navigate-to-modal :qr-code-view {:contact account :qr-source :public-key}])}]]] diff --git a/src/status_im/translations/en.cljs b/src/status_im/translations/en.cljs index b3769922f0..991f989556 100644 --- a/src/status_im/translations/en.cljs +++ b/src/status_im/translations/en.cljs @@ -79,6 +79,11 @@ :image-source-gallery "Select from gallery" :image-source-cancel "Cancel" + ;;sharing + :sharing-copy-to-clipboard "Copy to clipboard" + :sharing-share "Share..." + :sharing-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 " diff --git a/src/status_im/translations/es.cljs b/src/status_im/translations/es.cljs index 9bde45be4e..5043beba20 100644 --- a/src/status_im/translations/es.cljs +++ b/src/status_im/translations/es.cljs @@ -78,6 +78,11 @@ :image-source-gallery "Seleccionar de la galería" :image-source-cancel "Cancelar" + ;;sharing + :sharing-copy-to-clipboard "Copiar" + :sharing-share "Compartir..." + :sharing-cancel "Cancelar" + ;sign-up :contacts-syncronized "Se han sincronizado tus contactos" :confirmation-code (str "¡Gracias! Te hemos enviado un mensaje de texto con un código" diff --git a/src/status_im/translations/es_ar.cljs b/src/status_im/translations/es_ar.cljs index d4ab6ad5eb..cc5f76706b 100644 --- a/src/status_im/translations/es_ar.cljs +++ b/src/status_im/translations/es_ar.cljs @@ -78,6 +78,11 @@ :image-source-gallery "Seleccionar de la galería" :image-source-cancel "Cancelar" + ;;sharing + :sharing-copy-to-clipboard "Copiar" + :sharing-share "Compartir..." + :sharing-cancel "Cancelar" + ;sign-up :contacts-syncronized "Tus contactos se han sincronizado" :confirmation-code (str "¡Gracias! Te hemos enviado un código de confirmación por mensaje de texto. " diff --git a/src/status_im/translations/ru.cljs b/src/status_im/translations/ru.cljs index 9dee175e76..0ba4bf7503 100644 --- a/src/status_im/translations/ru.cljs +++ b/src/status_im/translations/ru.cljs @@ -78,6 +78,11 @@ :image-source-gallery "Выбрать из галереи" :image-source-cancel "Отмена" + ;;sharing + :sharing-copy-to-clipboard "Скопировать" + :sharing-share "Поделиться..." + :sharing-cancel "Отмена" + ;sign-up :contacts-syncronized "Ваши контакты синхронизированы" :confirmation-code (str "Спасибо! Мы отправили вам СМС с кодом подтверждения." diff --git a/src/status_im/translations/sw.cljs b/src/status_im/translations/sw.cljs index 231e30eeaa..5a883b3dc0 100644 --- a/src/status_im/translations/sw.cljs +++ b/src/status_im/translations/sw.cljs @@ -78,6 +78,11 @@ :image-source-gallery "Chagua kutoka nyumba ya sanaa" :image-source-cancel "Ghairi" + ;;sharing + :sharing-copy-to-clipboard "Kopiera" + :sharing-share "Dela..." + :sharing-cancel "Ghairi" + ;sign-up :contacts-syncronized "Mawasiliano yako yamelandanishwa" :confirmation-code (str "Asante! Tumekutumia ujumbe mfupi na uthibitisho " diff --git a/src/status_im/translations/uk.cljs b/src/status_im/translations/uk.cljs index 078d8381d7..20f550e3e2 100644 --- a/src/status_im/translations/uk.cljs +++ b/src/status_im/translations/uk.cljs @@ -78,6 +78,11 @@ :image-source-gallery "Вибрати з галереї" :image-source-cancel "Відміна" + ;;sharing + :sharing-copy-to-clipboard "Скопіювати" + :sharing-share "Поділитися..." + :sharing-cancel "Відміна" + ;sign-up :contacts-syncronized "Ваші контактні дані було синхронізовано" :confirmation-code (str "Дякуємо! Ми відправили вам текстове повідомлення з кодом "