Skip to content

Commit

Permalink
Add xml file
Browse files Browse the repository at this point in the history
  • Loading branch information
jasper committed Aug 2, 2018
1 parent e47279a commit b3c8be0
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 0 deletions.
26 changes: 26 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.awesomeproject">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>

</manifest>
3 changes: 3 additions & 0 deletions android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">AwesomeProject</string>
</resources>
8 changes: 8 additions & 0 deletions android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
</style>

</resources>
44 changes: 44 additions & 0 deletions src/Components/WebView/EOSJS.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="./eos.min.js"></script>
<script>
var eos = null;
window.onload = function() {
document.addEventListener('message', function(e) {
var data = JSON.parse(e.data);
var blockHeader = data.blockHeader;
var chainId = data.chainId;
var privateKey = data.PrivateKey;
var actions = data.actions;
getEos(chainId, privateKey, blockHeader, actions);
});
};
function getEos(chainId, privateKey, blockHeader, actions) {
eos = Eos({
httpEndpoint: null,
transactionHeaders: blockHeader,
chainId,
broadcast: false,
keyProvider: privateKey,
mockTransactions: () => 'pass',
});
transaction(actions);
}
function transaction(actions) {
eos.transaction({
actions,
}).then(tr => {
tr.transaction.fee = "0.01 EOS";
window.postMessage(JSON.stringify(tr.transaction));
}).catch(err => {
window.postMessage(JSON.stringify(err));
});
}
</script>
</head>

<body>
</body>
</html>
1 change: 1 addition & 0 deletions src/Components/WebView/eos.min.js

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions src/Components/WebView/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// 引入公共组件
import React, { Component } from "react";
import {View, WebView, StyleSheet, Platform} from "react-native";

export default class WebViewComp extends Component {
constructor (props) {
super(props);
this.state = {};
}

render() {
const WebViewSource = Platform.OS === "ios" ? require("./EOSJS.html") : {uri: "file:///android_asset/eos/EOSJS.html", baseUrl:"file:///android_asset/eos/"};
return (
<View style={styles.mainBox}>
<WebView
ref="WebView"
style={styles.WebViewStyle}
source={WebViewSource}
onMessage={(e)=>{this.props.onMessage(e);}}
javaScriptEnabled={true}
mixedContentMode="always"
originWhitelist={["*"]}
/>
</View>
);
}
}

const styles = StyleSheet.create({
mainBox: {
flex:1,
height:0,
zIndex:-999999,
position:"absolute",
},
WebViewStyle: {
height:0,
width:0,
backgroundColor:"transparent",
},
});

0 comments on commit b3c8be0

Please sign in to comment.