diff --git a/client/react-native/common/components/Library/ContactIdentityActions/ActionButton.js b/client/react-native/common/components/Library/ContactIdentityActions/ActionButton.js index 1e3f31a3b1..a9b54e77d2 100644 --- a/client/react-native/common/components/Library/ContactIdentityActions/ActionButton.js +++ b/client/react-native/common/components/Library/ContactIdentityActions/ActionButton.js @@ -15,7 +15,7 @@ export const ActionButtonLarge = ({ onPress, color, title, icon }) => + openURL(node.attributes.href)}> + {children} + + +const Markdown = ({ children, style, ...props }) => + {children} + +export default Markdown +Markdown.styles = styles diff --git a/client/react-native/common/components/Library/Menu.js b/client/react-native/common/components/Library/Menu.js index 79f763c65a..9da75d32d9 100644 --- a/client/react-native/common/components/Library/Menu.js +++ b/client/react-native/common/components/Library/Menu.js @@ -14,7 +14,7 @@ import { colors } from '../../constants' import { isRTL } from '../../i18n' export default class Menu extends Component { - static Header = ({ icon, title, description }) => ( + static Header = ({ icon, color, descriptionColor, title, description }) => ( {icon && ( @@ -27,11 +27,11 @@ export default class Menu extends Component { justify='between' style={[paddingLeft, { height: 42 }]} > - + {title} {description && ( - + {description} )} diff --git a/client/react-native/common/components/Library/index.js b/client/react-native/common/components/Library/index.js index 6f1f3d7cce..a851eee984 100644 --- a/client/react-native/common/components/Library/index.js +++ b/client/react-native/common/components/Library/index.js @@ -22,3 +22,4 @@ export EmptyList from './EmptyList' export Animation from './Animation' export MovableView from './MovableView' export DebugStateBar from './DebugStateBar' +export Markdown from './Markdown' diff --git a/client/react-native/common/components/Navigator/ContactTopNavigator.js b/client/react-native/common/components/Navigator/ContactTopNavigator.js index 6f14dfe665..748411aa5e 100644 --- a/client/react-native/common/components/Navigator/ContactTopNavigator.js +++ b/client/react-native/common/components/Navigator/ContactTopNavigator.js @@ -34,7 +34,7 @@ export default createMaterialTopTabNavigator( animationEnabled: true, tabBarOptions: { labelStyle: { - color: colors.black, + color: colors.fakeBlack, }, indicatorStyle: { backgroundColor: colors.blue, diff --git a/client/react-native/common/components/Screens/Chats/Detail.js b/client/react-native/common/components/Screens/Chats/Detail.js index 7e17143a46..b7b290cc48 100644 --- a/client/react-native/common/components/Screens/Chats/Detail.js +++ b/client/react-native/common/components/Screens/Chats/Detail.js @@ -1,6 +1,6 @@ import { ActivityIndicator, - Platform, + Platform, StyleSheet, TextInput as RNTextInput, View, } from 'react-native' @@ -8,7 +8,7 @@ import { btoa } from 'b64-lite' import { withNamespaces } from 'react-i18next' import React, { PureComponent } from 'react' -import { Flex, Header, Icon, Screen, Text, Avatar } from '../../Library' +import { Flex, Header, Icon, Screen, Text, Avatar, Markdown } from '../../Library' import { Pagination, QueryReducer, RelayContext } from '../../../relay' import { colors } from '../../../constants' import { fragments } from '../../../graphql' @@ -20,6 +20,24 @@ import * as dateFns from '../../../i18n/dateFns' import withRelayContext from '../../../helpers/withRelayContext' import * as KeyboardContext from '../../../helpers/KeyboardContext' +const textStyles = StyleSheet.flatten([Markdown.styles, { + text: { + color: colors.white, + }, + listUnorderedItemIcon: { + color: colors.white, + }, + listOrderedItemIcon: { + color: colors.white, + }, + blocklink: { + borderColor: colors.white, + }, + u: { + borderColor: colors.white, + }, +}]) + class Message extends React.PureComponent { static contextType = RelayContext @@ -49,7 +67,7 @@ class Message extends React.PureComponent { return ( {!isMyself && !isOneToOne ? ( ) : null} - - {parseEmbedded(data.attributes).message.text} - + {parseEmbedded(data.attributes).message.text} + - + {utils.getTitle(data)} diff --git a/client/react-native/common/components/Screens/Contacts/List/Item.js b/client/react-native/common/components/Screens/Contacts/List/Item.js index a87fe4ffaf..645d816616 100644 --- a/client/react-native/common/components/Screens/Contacts/List/Item.js +++ b/client/react-native/common/components/Screens/Contacts/List/Item.js @@ -67,7 +67,7 @@ const Item = fragments.Contact( - + {overrideDisplayName || displayName} diff --git a/client/react-native/common/helpers/linking.js b/client/react-native/common/helpers/linking.js new file mode 100644 index 0000000000..4f7534eb9e --- /dev/null +++ b/client/react-native/common/helpers/linking.js @@ -0,0 +1,7 @@ +import { Linking } from 'react-native'; + +export const openURL = url => { + if (url) { + Linking.openURL(url) + } +} diff --git a/client/react-native/common/helpers/linking.web.js b/client/react-native/common/helpers/linking.web.js new file mode 100644 index 0000000000..229526b076 --- /dev/null +++ b/client/react-native/common/helpers/linking.web.js @@ -0,0 +1,9 @@ +import { NativeModules } from 'react-native' + +const { CoreModule } = NativeModules + +export const openURL = url => { + if (url) { + CoreModule.openURL(url) + } +} diff --git a/client/react-native/common/helpers/patch-electron.js b/client/react-native/common/helpers/patch-electron.js index 9ace9a1bdc..9ed4d23f4d 100644 --- a/client/react-native/common/helpers/patch-electron.js +++ b/client/react-native/common/helpers/patch-electron.js @@ -45,6 +45,7 @@ if (Platform.OS === 'web' && 'updateNetworkConfig', 'setCurrentRoute', 'getLocalGRPCInfos', + 'openURL', ] for (let op of ops) { diff --git a/client/react-native/common/helpers/patch-web.js b/client/react-native/common/helpers/patch-web.js index 975f6556f8..e50d3dc52a 100644 --- a/client/react-native/common/helpers/patch-web.js +++ b/client/react-native/common/helpers/patch-web.js @@ -22,6 +22,9 @@ if (Platform.OS === 'web') { getNetworkConfig: async () => console.warn('not implemented in web'), updateNetworkConfig: async () => console.warn('not implemented in web'), setCurrentRoute: () => {}, + openURL: (url) => { + window.open(url, '_blank') + }, } NativeModules.CoreModule = CoreModule diff --git a/client/react-native/desktop/coreinterface/core.go b/client/react-native/desktop/coreinterface/core.go index 3a2bd95413..c871d819bb 100644 --- a/client/react-native/desktop/coreinterface/core.go +++ b/client/react-native/desktop/coreinterface/core.go @@ -4,11 +4,14 @@ import ( "errors" "fmt" + "go.uber.org/zap" + "berty.tech/core/pkg/notification" "berty.tech/client/react-native/gomobile/core" "berty.tech/core/pkg/deviceinfo" + "github.com/pkg/browser" "github.com/shibukawa/configdir" ) @@ -80,6 +83,16 @@ func UpdateNetworkConfig(config string) (interface{}, error) { return nil, core.UpdateNetworkConfig(config) } +func OpenURL(url string) (interface{}, error) { + logger().Info(fmt.Sprintf("opening URL %s", url)) + err := browser.OpenURL(url) + if err != nil { + logger().Error(fmt.Sprintf("unable to open URL %s", url), zap.Error(err)) + } + + return nil, err +} + func IsBotRunning() (interface{}, error) { return core.IsBotRunning(), nil } diff --git a/client/react-native/desktop/coreinterface/logger.gen.go b/client/react-native/desktop/coreinterface/logger.gen.go new file mode 100644 index 0000000000..8d766d93a0 --- /dev/null +++ b/client/react-native/desktop/coreinterface/logger.gen.go @@ -0,0 +1,9 @@ +// Code generated by berty.tech/core/.scripts/generate-logger.sh + +package coreinterface + +import "go.uber.org/zap" + +func logger() *zap.Logger { + return zap.L().Named("client.react-native.desktop.coreinterface") +} diff --git a/client/react-native/desktop/go.mod b/client/react-native/desktop/go.mod index 11586974f9..e15d046f90 100644 --- a/client/react-native/desktop/go.mod +++ b/client/react-native/desktop/go.mod @@ -11,6 +11,7 @@ require ( github.com/asticode/go-astilectron-bootstrap v0.0.0-20180616141213-b3211646d205 github.com/asticode/go-astilectron-bundler v0.0.0-20190221164801-6b22eafb3c85 // indirect github.com/asticode/go-bindata v0.0.0-20151023091102-a0ff2567cfb7 // indirect + github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 github.com/pkg/errors v0.8.1 github.com/sam-kamerer/go-plister v0.0.0-20190202124357-57f251aa88ff // indirect github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0 diff --git a/client/react-native/desktop/go.sum b/client/react-native/desktop/go.sum index 7d9b470d55..49bcc835c3 100644 --- a/client/react-native/desktop/go.sum +++ b/client/react-native/desktop/go.sum @@ -640,6 +640,8 @@ github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA= github.com/multiformats/go-multiaddr v0.0.1 h1:/QUV3VBMDI6pi6xfiw7lr6xhDWWvQKn9udPn68kLSdY= github.com/multiformats/go-multiaddr v0.0.1/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44= +github.com/multiformats/go-multiaddr v0.0.2 h1:RBysRCv5rv3FWlhKWKoXv8tnsCUpEpIZpCmqAGZos2s= +github.com/multiformats/go-multiaddr v0.0.2/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44= github.com/multiformats/go-multiaddr v1.4.0 h1:xt9fCCmSyTosXSvEhEqYnC75LiaDSdXycwOLJaDGPic= github.com/multiformats/go-multiaddr v1.4.0/go.mod h1:1JAWc2R8uiQTLrCHI/lmOkXYu5B8025fQbZjq8//YgY= github.com/multiformats/go-multiaddr-dns v0.0.1/go.mod h1:9kWcqw/Pj6FwxAwW38n/9403szc57zJPs45fmnznu3Q= @@ -676,6 +678,8 @@ github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa github.com/opentracing/opentracing-go v1.0.2 h1:3jA2P6O1F9UOrWVpwrIo17pu01KWvNWg4X946/Y5Zwg= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98= +github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= diff --git a/client/react-native/desktop/main.go b/client/react-native/desktop/main.go index e2c1ee899c..36671f3838 100644 --- a/client/react-native/desktop/main.go +++ b/client/react-native/desktop/main.go @@ -64,7 +64,7 @@ func main() { }, }, { - Label: astilectron.PtrStr("Edit"), + Role: astilectron.MenuItemRoleEditMenu, SubMenu: []*astilectron.MenuItemOptions{ {Role: astilectron.MenuItemRoleUndo}, {Role: astilectron.MenuItemRoleRedo}, @@ -72,6 +72,7 @@ func main() { {Role: astilectron.MenuItemRoleCopy}, {Role: astilectron.MenuItemRolePaste}, {Role: astilectron.MenuItemRoleDelete}, + {Role: astilectron.MenuItemRoleSelectAll}, }, }}, Windows: []*bootstrap.Window{{ diff --git a/client/react-native/desktop/message.go b/client/react-native/desktop/message.go index 8af9099367..444f666e36 100644 --- a/client/react-native/desktop/message.go +++ b/client/react-native/desktop/message.go @@ -27,6 +27,7 @@ var ptrErrFunc = map[string]func() (interface{}, error){ var ptrStrErrFunc = map[string]func(string) (interface{}, error){ "start": coreinterface.Start, "updateNetworkConfig": coreinterface.UpdateNetworkConfig, + "openURL": coreinterface.OpenURL, } func stringPayload(message json.RawMessage) (string, error) { diff --git a/client/react-native/package.json b/client/react-native/package.json index f874499810..6af62e0a47 100644 --- a/client/react-native/package.json +++ b/client/react-native/package.json @@ -27,7 +27,9 @@ "i18next": "^13.0.0", "instabug-reactnative": "8.1.0", "isomorphic-fetch": "^2.2.1", + "linkify-it": "^2.1.0", "lottie-react-native": "^2.5.11", + "markdown-it": "^8.4.2", "moment": "^2.22.2", "mousetrap": "^1.6.3", "object-hash": "^1.3.0",