Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Phecda
/
NGPlay
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Phecda
2020-03-27 19:18:58 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e356bf61005c42ead5b1407b3360cdeda7a753ce
e356bf61
1 parent
becba0de
refactor: convert to wx example
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
168 additions
and
98 deletions
App.tsx
android/app/build.gradle
android/build.gradle
ios/NGPlay/AppDelegate.m
ios/NGPlay/Info.plist
ios/Podfile.lock
package.json
yarn.lock
App.tsx
View file @
e356bf6
...
...
@@ -8,111 +8,128 @@
* @format
*/
import React from 'react';
import React
, { useState, useEffect }
from 'react';
import {
SafeAreaView,
StyleSheet,
Button,
NativeModules,
Picker,
ScrollView,
View,
Text,
StatusBar,
Platform,
} from 'react-native';
import { Text, ListItem, Card } from 'react-native-elements';
import Wechat, { WXShareType, WXShareScene } from './src';
import {
Header,
LearnMoreLinks,
Colors,
DebugInstructions,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
declare var global: {HermesInternal: null | {}};
const { BCWechat } = NativeModules;
Wechat.registerApp('wx32beae1b4606079a', 'https://pm.yfchangketong.com/');
const App = () => {
const [err, setErr] = useState<Error>();
const [version, setVersion] = useState('');
const [isWXInstalled, setIsWXInstalled] = useState(false);
const [apiLevel, setApiLevel] = useState<number | boolean>();
const [scene, setScene] = useState(WXShareScene.WXSceneSession);
const constants = BCWechat.getConstants();
useEffect(() => {
Wechat.getApiVersion().then(setVersion);
Wechat.isWXAppInstalled().then(setIsWXInstalled);
if (Platform.OS === 'android') {
Wechat.getWXAppSupportAPI().then(setApiLevel);
} else {
Wechat.isWXAppSupportApi().then(setApiLevel);
}
}, []);
return (
<>
<StatusBar barStyle="dark-content" />
<SafeAreaView>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={styles.scrollView}>
<Header />
{global.HermesInternal == null ? null : (
<View style={styles.engine}>
<Text style={styles.footer}>Engine: Hermes</Text>
</View>
)}
<View style={styles.body}>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Step One</Text>
<Text style={styles.sectionDescription}>
Edit <Text style={styles.highlight}>App.tsx</Text> to change
this screen and then come back to see your edits.
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>See Your Changes</Text>
<Text style={styles.sectionDescription}>
<ReloadInstructions />
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Debug</Text>
<Text style={styles.sectionDescription}>
<DebugInstructions />
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Learn More</Text>
<Text style={styles.sectionDescription}>
Read the docs to discover what to do next:
</Text>
</View>
<LearnMoreLinks />
</View>
</ScrollView>
</SafeAreaView>
</>
<SafeAreaView style={{ flex: 1 }}>
<Card>
<Text h4>Error</Text>
<Text>{`${err?.message}`}</Text>
</Card>
<ScrollView
style={{ flex: 1 }}
contentInsetAdjustmentBehavior="automatic"
>
<Text h4>Native</Text>
{Object.keys(BCWechat).map((k, i) => (
<Text key={i}>{k}</Text>
))}
<Text h4>Info</Text>
<ListItem title="version" rightTitle={version} />
<ListItem title="wx installed" rightTitle={`${isWXInstalled}`} />
<ListItem title="api support" rightTitle={`${apiLevel}`} />
<Text h4>Constants</Text>
{Object.keys(constants).map((k, i) => (
<ListItem key={k} title={k} rightTitle={`${constants[k]}`} />
))}
<Button title="open WX" onPress={Wechat.openWXApp} />
<Text h4>分享</Text>
<Picker selectedValue={scene} onValueChange={v => setScene(v)}>
<Picker.Item label="对话" value={WXShareScene.WXSceneSession} />
<Picker.Item label="朋友圈" value={WXShareScene.WXSceneTimeline} />
<Picker.Item label="收藏" value={WXShareScene.WXSceneFavorite} />
</Picker>
<Button
title="分享文字"
onPress={() => {
Wechat.shareMessage({
type: WXShareType.WXShareTypeText,
text: 'Some test text',
scene,
})
.then(resp => {
console.log(resp);
})
.catch(setErr);
}}
/>
<Button
title="分享图片"
onPress={() => {
Wechat.shareMessage({
type: WXShareType.WXShareTypeImage,
title: '标题',
description: '描述',
thumbUrl: '',
scene,
imageUrl:
'https://i0.hdslb.com/bfs/archive/45b8d2f84ec662df05b829bbe866cf620833cce5.jpg@412w_232h_1c_100q.jpg',
});
}}
/>
<Button
title="分享音乐"
onPress={() => {
Wechat.shareMessage({
type: WXShareType.WXShareTypeMusic,
musicUrl: 'https://music.163.com/#/song?id=1410448577',
title: '标题',
description: '描述',
thumbUrl:
'https://i0.hdslb.com/bfs/archive/45b8d2f84ec662df05b829bbe866cf620833cce5.jpg@412w_232h_1c_100q.jpg',
scene,
});
}}
/>
<Button
title="分享视频"
onPress={() => {
Wechat.shareMessage({
type: WXShareType.WXShareTypeVideo,
videoUrl:
'https://www.bilibili.com/video/BV1o7411177j?spm_id_from=333.851.b_7265706f7274466972737431.8',
title: '标题',
description: '描述',
thumbUrl:
'https://i0.hdslb.com/bfs/archive/45b8d2f84ec662df05b829bbe866cf620833cce5.jpg@412w_232h_1c_100q.jpg',
scene,
});
}}
/>
</ScrollView>
</SafeAreaView>
);
};
const styles = StyleSheet.create({
scrollView: {
backgroundColor: Colors.lighter,
},
engine: {
position: 'absolute',
right: 0,
},
body: {
backgroundColor: Colors.white,
},
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
color: Colors.black,
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
color: Colors.dark,
},
highlight: {
fontWeight: '700',
},
footer: {
color: Colors.dark,
fontSize: 12,
fontWeight: '600',
padding: 4,
paddingRight: 12,
textAlign: 'right',
},
});
export default App;
...
...
android/app/build.gradle
View file @
e356bf6
apply
plugin:
"com.android.application"
apply
plugin:
'kotlin-android-extensions'
apply
plugin:
'kotlin-android'
import
com.android.build.OutputFile
...
...
@@ -191,6 +193,8 @@ dependencies {
}
else
{
implementation
jscFlavor
}
implementation
"androidx.core:core-ktx:+"
implementation
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
// Run this once to be able to run the application with BUCK
...
...
@@ -201,3 +205,6 @@ task copyDownloadableDepsToLibs(type: Copy) {
}
apply
from:
file
(
"../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"
);
applyNativeModulesAppBuildGradle
(
project
)
repositories
{
mavenCentral
()
}
...
...
android/build.gradle
View file @
e356bf6
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript
{
ext
.
kotlin_version
=
'1.3.71'
ext
{
buildToolsVersion
=
"28.0.3"
minSdkVersion
=
16
...
...
@@ -13,6 +14,7 @@ buildscript {
}
dependencies
{
classpath
(
"com.android.tools.build:gradle:3.4.2"
)
classpath
"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
...
...
ios/NGPlay/AppDelegate.m
View file @
e356bf6
...
...
@@ -9,6 +9,7 @@
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTLinkingManager.h>
#import <React/RCTRootView.h>
@implementation
AppDelegate
...
...
@@ -39,4 +40,16 @@
#endif
}
// ios 9.0+
-
(
BOOL
)
application
:(
UIApplication
*
)
application
openURL
:(
NSURL
*
)
url
options
:(
NSDictionary
<
NSString
*
,
id
>
*
)
options
{
return
[
RCTLinkingManager
application
:
application
openURL
:
url
options
:
options
];
}
-
(
BOOL
)
application
:(
UIApplication
*
)
application
continueUserActivity
:(
NSUserActivity
*
)
userActivity
restorationHandler
:(
void
(
^
)(
NSArray
<
id
<
UIUserActivityRestoring
>>
*
_Nullable
))
restorationHandler
{
return
[
RCTLinkingManager
application
:
application
continueUserActivity
:
userActivity
restorationHandler
:
restorationHandler
];
}
@end
...
...
ios/NGPlay/Info.plist
View file @
e356bf6
...
...
@@ -20,8 +20,29 @@
<string>
1.0
</string>
<key>
CFBundleSignature
</key>
<string>
????
</string>
<key>
CFBundleURLTypes
</key>
<array>
<dict>
<key>
CFBundleTypeRole
</key>
<string>
Editor
</string>
<key>
CFBundleURLName
</key>
<string>
weixin
</string>
<key>
CFBundleURLSchemes
</key>
<array>
<string>
wx32beae1b4606079a
</string>
</array>
</dict>
</array>
<key>
CFBundleVersion
</key>
<string>
1
</string>
<key>
LSApplicationCategoryType
</key>
<string></string>
<key>
LSApplicationQueriesSchemes
</key>
<array>
<string>
weixin
</string>
<string>
wechat
</string>
<string>
weixinULAPI
</string>
</array>
<key>
LSRequiresIPhoneOS
</key>
<true/>
<key>
NSAppTransportSecurity
</key>
...
...
ios/Podfile.lock
View file @
e356bf6
...
...
@@ -219,6 +219,8 @@ PODS:
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- ReactCommon/jscallinvoker (= 0.61.5)
- rn-wechat (0.0.2):
- React
- RNCMaskedView (0.1.7):
- React
- RNGestureHandler (1.6.0):
...
...
@@ -260,6 +262,7 @@ DEPENDENCIES:
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
- ReactCommon/jscallinvoker (from `../node_modules/react-native/ReactCommon`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- rn-wechat (from `../../rn-wechat`)
- "RNCMaskedView (from `../node_modules/@react-native-community/masked-view`)"
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
- RNReanimated (from `../node_modules/react-native-reanimated`)
...
...
@@ -322,6 +325,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/Libraries/Vibration"
ReactCommon:
:path: "../node_modules/react-native/ReactCommon"
rn-wechat:
:path: "../../rn-wechat"
RNCMaskedView:
:path: "../node_modules/@react-native-community/masked-view"
RNGestureHandler:
...
...
@@ -362,6 +367,7 @@ SPEC CHECKSUMS:
React-RCTText: 9ccc88273e9a3aacff5094d2175a605efa854dbe
React-RCTVibration: a49a1f42bf8f5acf1c3e297097517c6b3af377ad
ReactCommon: 198c7c8d3591f975e5431bec1b0b3b581aa1c5dd
rn-wechat: 8ef41be3d91557dbf900678c1d86beda86e08f00
RNCMaskedView: 76c40a1d41c3e2535df09246a2b5487f04de0814
RNGestureHandler: dde546180bf24af0b5f737c8ad04b6f3fa51609a
RNReanimated: 031fe8d9ea93c2bd689a40f05320ef9d96f74d7f
...
...
@@ -371,4 +377,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: ad4c3998d58868407224af05ed79c54dc0c9aa70
COCOAPODS: 1.
8.3
COCOAPODS: 1.
9.1
...
...
package.json
View file @
e356bf6
...
...
@@ -25,7 +25,8 @@
"react-native-safe-area-context"
:
"^0.7.3"
,
"react-native-screens"
:
"^2.2.0"
,
"react-native-tab-view"
:
"^2.13.0"
,
"react-native-vector-icons"
:
"^6.6.0"
"react-native-vector-icons"
:
"^6.6.0"
,
"rn-wechat"
:
"file:../rn-wechat"
},
"devDependencies"
:
{
"@babel/core"
:
"^7.6.2"
,
...
...
yarn.lock
View file @
e356bf6
...
...
@@ -7177,6 +7177,9 @@ rimraf@~2.2.6:
resolved "https://registry.npm.taobao.org/rimraf/download/rimraf-2.2.8.tgz#e439be2aaee327321952730f99a8929e4fc50582"
integrity sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI=
"rn-wechat@file:../rn-wechat":
version "0.0.2"
rsvp@^4.8.4:
version "4.8.5"
resolved "https://registry.npm.taobao.org/rsvp/download/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734"
...
...
Please
register
or
login
to post a comment