ADD: lapp-browser

This commit is contained in:
Overtorment 2019-01-12 00:23:32 +00:00
parent ca1a8873d0
commit d269f4926e
10 changed files with 268 additions and 19 deletions

View file

@ -35,6 +35,7 @@ import Success from './screen/send/success';
import ManageFunds from './screen/lnd/manageFunds';
import ScanLndInvoice from './screen/lnd/scanLndInvoice';
import LappBrowser from './screen/lnd/browser';
import LNDCreateInvoice from './screen/lnd/lndCreateInvoice';
import LNDViewInvoice from './screen/lnd/lndViewInvoice';
import LNDViewAdditionalInvoiceInformation from './screen/lnd/lndViewAdditionalInvoiceInformation';
@ -243,6 +244,10 @@ const MainBottomTabs = createStackNavigator(
ScanQrAddress: {
screen: sendScanQrAddress,
},
LappBrowser: {
screen: LappBrowser,
},
ReorderWallets: {
screen: ReorderWalletsStackNavigator,
navigationOptions: {

View file

@ -147,6 +147,7 @@ android {
}
dependencies {
compile project(':react-native-webview')
compile project(':react-native-camera')
compile project(':react-native-fs')
compile project(':react-native-gesture-handler')

View file

@ -3,6 +3,7 @@ package io.bluewallet.bluewallet;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.reactnativecommunity.webview.RNCWebViewPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.horcrux.svg.SvgPackage;
import io.sentry.RNSentryPackage;
@ -35,6 +36,7 @@ public class MainApplication extends Application implements ReactApplication {
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNCWebViewPackage(),
new RNFSPackage() ,
new VectorIconsPackage(),
new SvgPackage(),

View file

@ -0,0 +1 @@
../../../../../../../.././android/app/src/main/java/com/bluewallet/MainApplication.java

View file

@ -1,4 +1,6 @@
rootProject.name = 'BlueWallet'
include ':react-native-webview'
project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')
include ':react-native-camera'
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android')
include ':react-native-fs'

View file

@ -5,7 +5,6 @@
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
@ -74,6 +73,7 @@
F6AA297664414342AC23B529 /* libRNFS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F9F01E9C22C243A9AB48A90A /* libRNFS.a */; };
F97F051969164CCBA5336FC2 /* libRNRandomBytes.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 907C87020BD04956A5253DEB /* libRNRandomBytes.a */; };
FDE69393B0DE46149DDB7E3C /* FontAwesome5_Solid.ttf in Resources */ = {isa = PBXBuildFile; fileRef = C0708F2D346B415C84383510 /* FontAwesome5_Solid.ttf */; };
A2C00245B747440ABEB7D316 /* libRNCWebView.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 81EDDF247D484BC38EBCE565 /* libRNCWebView.a */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -564,6 +564,8 @@
F9F01E9C22C243A9AB48A90A /* libRNFS.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNFS.a; sourceTree = "<group>"; };
F9FC88F4A85F40E9ABACACB9 /* 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 = "<group>"; };
FDDDD64DF1014CDE82A5D7D9 /* ReactNativePermissions.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = ReactNativePermissions.xcodeproj; path = "../node_modules/react-native-permissions/ios/ReactNativePermissions.xcodeproj"; sourceTree = "<group>"; };
642C144246BF4C3EB350442F /* RNCWebView.xcodeproj */ = {isa = PBXFileReference; name = "RNCWebView.xcodeproj"; path = "../node_modules/react-native-webview/ios/RNCWebView.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
81EDDF247D484BC38EBCE565 /* libRNCWebView.a */ = {isa = PBXFileReference; name = "libRNCWebView.a"; path = "libRNCWebView.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -608,6 +610,7 @@
6FEBC8E7AA7D4744A2EEE87B /* libRNGestureHandler.a in Frameworks */,
F439E4EEAE42446B8AE33E3F /* libRNCamera.a in Frameworks */,
F6AA297664414342AC23B529 /* libRNFS.a in Frameworks */,
A2C00245B747440ABEB7D316 /* libRNCWebView.a in Frameworks */,
228DCD6BAF1B4DF181C5A307 /* libRNRate.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -837,6 +840,7 @@
DAC908621D184867839621FE /* RNGestureHandler.xcodeproj */,
7F7225A9F01C4785B27FF490 /* RNCamera.xcodeproj */,
C0B6F9440F69425886845061 /* RNFS.xcodeproj */,
642C144246BF4C3EB350442F /* RNCWebView.xcodeproj */,
D6051C6440444360BD29AFE4 /* RNRate.xcodeproj */,
);
name = Libraries;
@ -1827,6 +1831,7 @@
"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**",
"$(SRCROOT)/../node_modules/react-native-camera/ios/**",
"$(SRCROOT)/../node_modules/react-native-fs/**",
"$(SRCROOT)/../node_modules/react-native-webview/ios",
"$(SRCROOT)/../node_modules/react-native-rate/ios",
);
INFOPLIST_FILE = BlueWalletTests/Info.plist;
@ -1866,6 +1871,7 @@
"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**",
"$(SRCROOT)/../node_modules/react-native-camera/ios/**",
"$(SRCROOT)/../node_modules/react-native-fs/**",
"$(SRCROOT)/../node_modules/react-native-webview/ios",
"$(SRCROOT)/../node_modules/react-native-rate/ios",
);
INFOPLIST_FILE = BlueWalletTests/Info.plist;
@ -1906,6 +1912,7 @@
"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**",
"$(SRCROOT)/../node_modules/react-native-camera/ios/**",
"$(SRCROOT)/../node_modules/react-native-fs/**",
"$(SRCROOT)/../node_modules/react-native-webview/ios",
"$(SRCROOT)/../node_modules/react-native-rate/ios",
);
INFOPLIST_FILE = BlueWallet/Info.plist;
@ -1944,6 +1951,7 @@
"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**",
"$(SRCROOT)/../node_modules/react-native-camera/ios/**",
"$(SRCROOT)/../node_modules/react-native-fs/**",
"$(SRCROOT)/../node_modules/react-native-webview/ios",
"$(SRCROOT)/../node_modules/react-native-rate/ios",
);
INFOPLIST_FILE = BlueWallet/Info.plist;
@ -1988,6 +1996,7 @@
"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**",
"$(SRCROOT)/../node_modules/react-native-camera/ios/**",
"$(SRCROOT)/../node_modules/react-native-fs/**",
"$(SRCROOT)/../node_modules/react-native-webview/ios",
"$(SRCROOT)/../node_modules/react-native-rate/ios",
);
INFOPLIST_FILE = "BlueWallet-tvOS/Info.plist";
@ -2035,6 +2044,7 @@
"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**",
"$(SRCROOT)/../node_modules/react-native-camera/ios/**",
"$(SRCROOT)/../node_modules/react-native-fs/**",
"$(SRCROOT)/../node_modules/react-native-webview/ios",
"$(SRCROOT)/../node_modules/react-native-rate/ios",
);
INFOPLIST_FILE = "BlueWallet-tvOS/Info.plist";
@ -2081,6 +2091,7 @@
"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**",
"$(SRCROOT)/../node_modules/react-native-camera/ios/**",
"$(SRCROOT)/../node_modules/react-native-fs/**",
"$(SRCROOT)/../node_modules/react-native-webview/ios",
"$(SRCROOT)/../node_modules/react-native-rate/ios",
);
INFOPLIST_FILE = "BlueWallet-tvOSTests/Info.plist";
@ -2127,6 +2138,7 @@
"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**",
"$(SRCROOT)/../node_modules/react-native-camera/ios/**",
"$(SRCROOT)/../node_modules/react-native-fs/**",
"$(SRCROOT)/../node_modules/react-native-webview/ios",
"$(SRCROOT)/../node_modules/react-native-rate/ios",
);
INFOPLIST_FILE = "BlueWallet-tvOSTests/Info.plist";

30
package-lock.json generated
View file

@ -9546,6 +9546,36 @@
}
}
},
"react-native-webview": {
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/react-native-webview/-/react-native-webview-2.8.0.tgz",
"integrity": "sha512-JNpAm4vOJ17xBWeZdNTlFdmDHz3E0n8VILahISSyN6Flzlv1Cmw/i/H/no7HWE990ipZNTuG4VaDxCPeJ5vJlg==",
"requires": {
"escape-string-regexp": "^1.0.5",
"fbjs": "^0.8.17"
},
"dependencies": {
"core-js": {
"version": "1.2.7",
"resolved": "http://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz",
"integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY="
},
"fbjs": {
"version": "0.8.17",
"resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.17.tgz",
"integrity": "sha1-xNWY6taUkRJlPWWIsBpc3Nn5D90=",
"requires": {
"core-js": "^1.0.0",
"isomorphic-fetch": "^2.1.1",
"loose-envify": "^1.0.0",
"object-assign": "^4.1.0",
"promise": "^7.1.1",
"setimmediate": "^1.0.5",
"ua-parser-js": "^0.7.18"
}
}
}
},
"react-navigation": {
"version": "3.0.9",
"resolved": "https://registry.npmjs.org/react-navigation/-/react-navigation-3.0.9.tgz",

View file

@ -1,6 +1,6 @@
{
"name": "BlueWallet",
"version": "3.5.6",
"version": "3.6.0",
"devDependencies": {
"babel-eslint": "^8.2.6",
"babel-jest": "23.6.0",
@ -82,6 +82,7 @@
"react-native-sortable-list": "0.0.22",
"react-native-svg": "^8.0.10",
"react-native-vector-icons": "^6.0.2",
"react-native-webview": "2.8.0",
"react-navigation": "^3.0.9",
"react-test-render": "^1.1.1",
"readable-stream": "^1.1.14",

175
screen/lnd/browser.js Normal file
View file

@ -0,0 +1,175 @@
import React, { Component } from 'react';
import { View, Alert } from 'react-native';
import { WebView } from 'react-native-webview';
import { BlueNavigationStyle } from '../../BlueComponents';
import { FormInput } from 'react-native-elements';
import Ionicons from 'react-native-vector-icons/Ionicons';
import PropTypes from 'prop-types';
export default class Browser extends Component {
static navigationOptions = ({ navigation }) => ({
...BlueNavigationStyle(navigation, true),
title: 'Lapp Browser',
headerLeft: null,
});
constructor(props) {
super(props);
this.state = { url: '' };
}
render() {
return (
<React.Fragment>
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
<Ionicons
onPress={() => {
this.webview.goBack();
}}
name={'ios-arrow-round-back'}
size={26}
style={{
color: 'red',
backgroundColor: 'transparent',
minWidth:36,
paddingLeft:10,
left: 8,
top: 1,
}}
/>
<FormInput
inputStyle={{ color: '#0c2550', maxWidth: 300, fontSize: 16 }}
containerStyle={{
borderColor: '#d2d2d2',
borderWidth: 0.5,
backgroundColor: '#f5f5f5',
}}
value={this.state.url}
/>
<Ionicons
onPress={() => {
this.webview.reload();
}}
name={'ios-sync'}
size={26}
style={{
color: 'red',
backgroundColor: 'transparent',
left: 8,
top: 1,
}}
/>
</View>
<WebView
ref={ref => (this.webview = ref)}
source={{ uri: 'https://bluewallet.io/marketplace/' }}
onMessage={e => {
// this is a handler which receives messages sent from within the browser
let json = false;
try {
json = JSON.parse(e.nativeEvent.data);
} catch (_) {}
// message from browser has ln invoice
if (json && json.pay) {
Alert.alert(
'Page',
'This page asks for permission to pay this invoice',
[
{ text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel' },
{
text: 'Pay',
onPress: () => {
console.log('OK Pressed');
this.props.navigation.navigate({
routeName: 'ScanLndInvoice',
params: {
uri: json.pay,
},
});
},
},
],
{ cancelable: false },
);
}
}}
onLoadEnd={e => {
this.setState({ url: e.nativeEvent.url });
this.webview.injectJavaScript(`
lastTimeTriedToPay = 0;
function tryToPay(invoice) {
if (+new Date() - lastTimeTriedToPay >= 3000) {
window.postMessage(JSON.stringify({pay:invoice}));
lastTimeTriedToPay = +new Date();
}
}
setInterval(function(){
var searchText = "lnbc";
var aTags = document.getElementsByTagName("span");
for (var i = 0; i < aTags.length; i++) {
if (aTags[i].textContent.indexOf(searchText) === 0) {
tryToPay(aTags[i].textContent);
aTags[i].replaceWith('Invoice intercepted by BlueWallet');
break;
}
}
//////////////////////////////////
//////////////////////////////////
//////////////////////////////////
var aTags = document.getElementsByTagName("input");
for (var i = 0; i < aTags.length; i++) {
if (aTags[i].value.indexOf(searchText) === 0) {
tryToPay(aTags[i].value);
aTags[i].replaceWith('Invoice intercepted by BlueWallet');
break;
}
}
//////////////////////////////////
//////////////////////////////////
//////////////////////////////////
var aTags = document.getElementsByTagName("a");
var searchText = "lightning:lnbc";
for (var i = 0; i < aTags.length; i++) {
let href = aTags[i].getAttribute('href') + '';
if (href.indexOf(searchText) === 0) {
tryToPay(href.replace('lightning:', ''));
aTags[i].replaceWith('Invoice intercepted by BlueWallet');
break;
}
}
}, 1000);
`);
}}
/>
</React.Fragment>
);
}
}
Browser.propTypes = {
navigation: PropTypes.shape({
navigate: PropTypes.func,
}),
};

View file

@ -367,23 +367,43 @@ export default class WalletTransactions extends Component {
{(() => {
if (this.state.showManageFundsSmallButton) {
return (
<TouchableOpacity
style={{ alignSelf: 'flex-end', right: 10, flexDirection: 'row' }}
onPress={() => {
console.log('navigating to', this.state.wallet.getLabel());
navigate('ManageFunds', { fromWallet: this.state.wallet });
}}
>
<BlueText style={{ fontWeight: '600', fontSize: 16 }}>{loc.lnd.title}</BlueText>
<Icon
style={{ position: 'relative' }}
name="link"
type="font-awesome"
size={14}
color={BlueApp.settings.foregroundColor}
iconStyle={{ left: 5, transform: [{ rotate: '90deg' }] }}
/>
</TouchableOpacity>
<React.Fragment>
<TouchableOpacity
style={{ alignSelf: 'flex-start', left: 10, top: 15, flexDirection: 'row' }}
onPress={() => {
console.log('navigating to LappBrowser');
navigate('LappBrowser', { fromSecret: this.state.wallet.getSecret() });
}}
>
<BlueText style={{ fontWeight: '600', fontSize: 16 }}>{'marketplace'}</BlueText>
<Icon
style={{ position: 'relative' }}
name="shopping-cart"
type="font-awesome"
size={14}
color={BlueApp.settings.foregroundColor}
iconStyle={{ left: 5 }}
/>
</TouchableOpacity>
<TouchableOpacity
style={{ alignSelf: 'flex-end', right: 10, top: -5, flexDirection: 'row' }}
onPress={() => {
console.log('navigating to', this.state.wallet.getLabel());
navigate('ManageFunds', { fromSecret: this.state.wallet.getSecret() });
}}
>
<BlueText style={{ fontWeight: '600', fontSize: 16 }}>{loc.lnd.title}</BlueText>
<Icon
style={{ position: 'relative' }}
name="link"
type="font-awesome"
size={14}
color={BlueApp.settings.foregroundColor}
iconStyle={{ left: 5, transform: [{ rotate: '90deg' }] }}
/>
</TouchableOpacity>
</React.Fragment>
);
}
})()}