├── .DS_Store ├── .gitignore ├── App.tsx ├── ReadMe.md ├── __tests__ └── App-test.tsx ├── android ├── TypeScript.iml ├── app │ ├── BUCK │ ├── app.iml │ ├── build.gradle │ ├── build_defs.bzl │ ├── proguard-rules.pro │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── typescript │ │ │ ├── MainActivity.java │ │ │ └── MainApplication.java │ │ └── res │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── strings.xml │ │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── keystores │ ├── BUCK │ └── debug.keystore.properties ├── local.properties └── settings.gradle ├── app.json ├── babel.config.js ├── index.js ├── ios ├── TypeScript-tvOS │ └── Info.plist ├── TypeScript-tvOSTests │ └── Info.plist ├── TypeScript.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ ├── TypeScript-tvOS.xcscheme │ │ └── TypeScript.xcscheme ├── TypeScript │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ └── LaunchScreen.xib │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ ├── Info.plist │ └── main.m └── TypeScriptTests │ ├── Info.plist │ └── TypeScriptTests.m ├── jest.config.js ├── metro.config.js ├── package-lock.json ├── package.json ├── screenshots ├── .DS_Store └── install.png ├── src ├── CustomTabUI.tsx ├── CustomTabs.tsx ├── Drawer.tsx ├── GIOTestChng.tsx ├── ModalStack.tsx ├── SampleText.tsx ├── SimpleStack.tsx ├── SimpleTabs.tsx ├── StackWithCustomHeaderBackImage.tsx ├── StackWithHeaderPreset.tsx ├── StackWithTranslucentHeader.tsx ├── StacksAndKeys.tsx ├── StacksInTabs.tsx ├── StacksOverTabs.tsx ├── StacksOverTopTabs.tsx ├── SwitchWithStacks.tsx ├── TabsInDrawer.tsx ├── assets │ ├── NavLogo.png │ ├── back.png │ ├── dog-back.png │ ├── icon.png │ └── splash.png └── commonComponents │ ├── Button.tsx │ ├── ButtonWithMargin.tsx │ └── HeaderButtons.tsx ├── tsconfig.json ├── yarn-error.log └── yarn.lock /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/growingio/ReactNativeDemo/e12751f35ca88e34d5bb3c09926b543ecd0419e7/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .idea/ 3 | /build 4 | /captures 5 | .externalNativeBuild 6 | node_modules/ 7 | app/build/ 8 | -------------------------------------------------------------------------------- /App.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | Animated, 4 | Image, 5 | Platform, 6 | StatusBar, 7 | StyleSheet, 8 | Text, 9 | TouchableHighlight, 10 | View, 11 | } from 'react-native'; 12 | import { 13 | createAppContainer, 14 | createStackNavigator, 15 | SafeAreaView, 16 | } from 'react-navigation'; 17 | import CustomTabs from './src/CustomTabs'; 18 | import CustomTabUI from './src/CustomTabUI'; 19 | import Drawer from './src/Drawer'; 20 | import ModalStack from './src/ModalStack'; 21 | import SimpleStack from './src/SimpleStack'; 22 | import SimpleTabs from './src/SimpleTabs'; 23 | import StacksInTabs from './src/StacksInTabs'; 24 | import StacksOverTabs from './src/StacksOverTabs'; 25 | import StacksOverTopTabs from './src/StacksOverTopTabs'; 26 | import StacksAndKeys from './src/StacksAndKeys'; 27 | import StackWithCustomHeaderBackImage from './src/StackWithCustomHeaderBackImage'; 28 | import StackWithHeaderPreset from './src/StackWithHeaderPreset'; 29 | import StackWithTranslucentHeader from './src/StackWithTranslucentHeader'; 30 | import SwitchWithStacks from './src/SwitchWithStacks'; 31 | import TabsInDrawer from './src/TabsInDrawer'; 32 | import PizzaTranslator from './src/GIOTestChng' 33 | 34 | const ExampleInfo: any = { 35 | PizzaTranslator:{ 36 | description: '测试输入框输入事件采集', 37 | name: 'GrowingIO chng 事件' 38 | }, 39 | CustomTabUI: { 40 | description: 'GIO 兼容 ^3.11.0 react-navigation', 41 | name: '点击事件和页面浏览事件,元素展现事件采集测试', 42 | }, 43 | CustomTabs: { 44 | description: 'GIO 测试埋点事件', 45 | name: '演示自定义事件和变量的调用', 46 | }, 47 | CustomTransitioner: { 48 | description: 'Custom transitioner with stack router', 49 | name: 'Custom Transitioner', 50 | }, 51 | Drawer: { 52 | description: 'Android-style drawer navigation', 53 | name: 'Drawer Example', 54 | }, 55 | InactiveStack: { 56 | description: 57 | 'An inactive route in a stack should be given the opportunity to handle actions', 58 | name: 'Navigate idempotently to stacks in inactive routes', 59 | }, 60 | KeyboardHandlingExample: { 61 | description: 62 | 'Demo automatic handling of keyboard showing/hiding inside StackNavigator', 63 | name: 'Keyboard Handling Example', 64 | }, 65 | LinkStack: { 66 | description: 'Deep linking into a route in stack', 67 | name: 'Link in Stack', 68 | }, 69 | LinkTabs: { 70 | description: 'Deep linking into a route in tab', 71 | name: 'Link to Settings Tab', 72 | }, 73 | ModalStack: { 74 | description: 75 | Platform.OS === 'ios' 76 | ? 'Stack navigation with modals' 77 | : 'Dynamically showing and hiding the header', 78 | name: 79 | Platform.OS === 'ios' 80 | ? 'Modal Stack Example' 81 | : 'Stack with Dynamic Header', 82 | }, 83 | SimpleStack: { 84 | description: 'A card stack', 85 | name: 'Stack Example', 86 | }, 87 | SimpleTabs: { 88 | description: 'Tabs following platform conventions', 89 | name: 'Tabs Example', 90 | }, 91 | StackWithCustomHeaderBackImage: { 92 | description: 'Stack with custom header back image', 93 | name: 'Custom header back image', 94 | }, 95 | StackWithHeaderPreset: { 96 | description: 'Masked back button and sliding header items. iOS only.', 97 | name: 'UIKit-style Header Transitions', 98 | }, 99 | StackWithTranslucentHeader: { 100 | description: 'Render arbitrary translucent content in header background.', 101 | name: 'Translucent Header', 102 | }, 103 | StacksInTabs: { 104 | description: 'Nested stack navigation in tabs', 105 | name: 'Stacks in Tabs', 106 | }, 107 | StacksOverTabs: { 108 | description: 'Nested stack navigation that pushes on top of tabs', 109 | name: 'Stacks over Tabs', 110 | }, 111 | StacksOverTopTabs: { 112 | description: 'Tab navigator in stack with custom header heights', 113 | name: 'Stacks with non-standard header height', 114 | }, 115 | StacksAndKeys: { 116 | description: 'Use keys to link between screens', 117 | name: 'Link in Stack with keys', 118 | }, 119 | SwitchWithStacks: { 120 | description: 'Jump between routes', 121 | name: 'Switch between routes', 122 | }, 123 | // MultipleDrawer: { 124 | // description: 'Add any drawer you need', 125 | // name: 'Multiple Drawer Example', 126 | // }, 127 | TabsInDrawer: { 128 | description: 'A drawer combined with tabs', 129 | name: 'Drawer + Tabs Example', 130 | }, 131 | TabsWithNavigationEvents: { 132 | description: 133 | 'Declarative NavigationEvents component to subscribe to navigation events', 134 | name: 'NavigationEvents', 135 | }, 136 | TabsWithNavigationFocus: { 137 | description: 'Receive the focus prop to know when a screen is focused', 138 | name: 'withNavigationFocus', 139 | }, 140 | }; 141 | 142 | const ExampleRoutes: any = { 143 | PizzaTranslator, 144 | CustomTabUI, 145 | CustomTabs, 146 | Drawer, 147 | ModalStack, 148 | SimpleStack, 149 | SimpleTabs, 150 | StackWithCustomHeaderBackImage, 151 | StackWithTranslucentHeader, 152 | StacksAndKeys, 153 | StacksOverTabs, 154 | SwitchWithStacks, 155 | StacksOverTopTabs, 156 | StacksInTabs, 157 | ...Platform.select({ 158 | android: {}, 159 | ios: { 160 | StackWithHeaderPreset, 161 | }, 162 | }), 163 | TabsInDrawer, 164 | LinkStack: { 165 | screen: SimpleStack, 166 | path: 'people/Jordan', 167 | }, 168 | LinkTabs: { 169 | screen: SimpleTabs, 170 | path: 'settings', 171 | }, 172 | }; 173 | 174 | interface State { 175 | scrollY: Animated.Value; 176 | } 177 | 178 | class MainScreen extends React.Component { 179 | state = { 180 | scrollY: new Animated.Value(0), 181 | }; 182 | 183 | render() { 184 | const { navigation } = this.props; 185 | 186 | const scale = this.state.scrollY.interpolate({ 187 | extrapolate: 'clamp', 188 | inputRange: [-450, 0, 100], 189 | outputRange: [2, 1, 0.8], 190 | }); 191 | 192 | const translateY = this.state.scrollY.interpolate({ 193 | inputRange: [-450, 0, 100], 194 | outputRange: [-150, 0, 40], 195 | }); 196 | 197 | const opacity = this.state.scrollY.interpolate({ 198 | extrapolate: 'clamp', 199 | inputRange: [0, 50], 200 | outputRange: [1, 0], 201 | }); 202 | 203 | const underlayOpacity = this.state.scrollY.interpolate({ 204 | extrapolate: 'clamp', 205 | inputRange: [0, 50], 206 | outputRange: [0, 1], 207 | }); 208 | 209 | const backgroundScale = this.state.scrollY.interpolate({ 210 | extrapolate: 'clamp', 211 | inputRange: [-450, 0], 212 | outputRange: [3, 1], 213 | }); 214 | 215 | const backgroundTranslateY = this.state.scrollY.interpolate({ 216 | inputRange: [-450, 0], 217 | outputRange: [0, 0], 218 | }); 219 | 220 | return ( 221 | 222 | 234 | 245 | 248 | 252 | 253 | 257 | 258 | GrowingIO Eamples 259 | 260 | 261 | 262 | 263 | 264 | 268 | 269 | {Object.keys(ExampleRoutes).map((routeName: string) => ( 270 | { 275 | const route = ExampleRoutes[routeName]; 276 | if (route.screen || route.path || route.params) { 277 | const { path, params, screen } = route; 278 | const { router } = screen; 279 | const action = 280 | path && 281 | router.getActionForPathAndParams(path, params); 282 | navigation.navigate(routeName, {}, action); 283 | } else { 284 | navigation.navigate(routeName); 285 | } 286 | }} 287 | > 288 | 289 | 290 | {ExampleInfo[routeName].name} 291 | 292 | 293 | {ExampleInfo[routeName].description} 294 | 295 | 296 | 297 | ))} 298 | 299 | 300 | 301 | 302 | 305 | 306 | ); 307 | } 308 | } 309 | 310 | const AppNavigator = createAppContainer( 311 | createStackNavigator( 312 | { 313 | ...ExampleRoutes, 314 | Index: { 315 | screen: MainScreen, 316 | }, 317 | }, 318 | { 319 | headerMode: 'none', 320 | initialRouteName: 'Index', 321 | 322 | /* 323 | * Use modal on iOS because the card mode comes from the right, 324 | * which conflicts with the drawer example gesture 325 | */ 326 | mode: Platform.OS === 'ios' ? 'modal' : 'card', 327 | } 328 | ) 329 | ); 330 | 331 | class TestScreen extends React.Component{ 332 | render() { 333 | return ; 334 | } 335 | } 336 | 337 | export default class App extends React.Component { 338 | render() { 339 | return ; 340 | } 341 | } 342 | 343 | const styles = StyleSheet.create({ 344 | backgroundUnderlay: { 345 | backgroundColor: '#673ab7', 346 | height: 300, 347 | left: 0, 348 | position: 'absolute', 349 | right: 0, 350 | top: -100, 351 | }, 352 | banner: { 353 | alignItems: 'center', 354 | flexDirection: 'row', 355 | padding: 16, 356 | }, 357 | bannerContainer: { 358 | // backgroundColor: '#673ab7', 359 | alignItems: 'center', 360 | }, 361 | bannerImage: { 362 | height: 36, 363 | margin: 8, 364 | resizeMode: 'contain', 365 | tintColor: '#fff', 366 | width: 36, 367 | }, 368 | bannerTitle: { 369 | color: '#fff', 370 | fontSize: 18, 371 | fontWeight: '200', 372 | marginRight: 5, 373 | marginVertical: 8, 374 | }, 375 | description: { 376 | color: '#999', 377 | fontSize: 13, 378 | }, 379 | image: { 380 | alignSelf: 'center', 381 | height: 120, 382 | marginBottom: 20, 383 | resizeMode: 'contain', 384 | width: 120, 385 | }, 386 | item: { 387 | borderBottomColor: '#ddd', 388 | borderBottomWidth: StyleSheet.hairlineWidth, 389 | paddingHorizontal: 16, 390 | paddingVertical: 12, 391 | }, 392 | statusBarUnderlay: { 393 | backgroundColor: '#673ab7', 394 | height: 20, 395 | left: 0, 396 | position: 'absolute', 397 | right: 0, 398 | top: 0, 399 | }, 400 | title: { 401 | color: '#444', 402 | fontSize: 16, 403 | fontWeight: 'bold', 404 | }, 405 | }); 406 | -------------------------------------------------------------------------------- /ReadMe.md: -------------------------------------------------------------------------------- 1 | # GrowigIO React Native Demo 2 | 3 | 兼容版本,注意中间版本不支持: 4 | > 5 | 兼容 react native 版本:0.46-0.56 , 0.59.9 6 | > 7 | 兼容组件 react-navigation 版本:^2.7.4 , ^3.11.0 8 | > 9 | 兼容组件 react-native-navigation 版本:^1.1.486 10 | 11 | 12 | ### Demo 运行 13 | 14 | ``` 15 | npm install 16 | ``` 17 | 18 | 19 | #### Android端 20 | 21 | ``` 22 | react-native run-andrid 23 | ``` 24 | 25 | #### IOS端 26 | 27 | ``` 28 | $react-native run-ios 29 | ``` 30 | 31 | ### 集成 SDK 32 | 请进入 GrowingIO 官网登录您的账号后选择 -> 新建应用 33 | 34 | 根据步骤可以顺利集成 SDK 。 35 | ![install](https://github.com/growingio/ReactNativeDemo/blob/master/screenshots/install.png) 36 | -------------------------------------------------------------------------------- /__tests__/App-test.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import 'react-native'; 6 | import React from 'react'; 7 | import App from '../App'; 8 | 9 | // Note: test renderer must be required after react-native. 10 | import renderer from 'react-test-renderer'; 11 | 12 | it('renders correctly', () => { 13 | renderer.create(); 14 | }); -------------------------------------------------------------------------------- /android/TypeScript.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") 12 | 13 | lib_deps = [] 14 | 15 | create_aar_targets(glob(["libs/*.aar"])) 16 | 17 | create_jar_targets(glob(["libs/*.jar"])) 18 | 19 | android_library( 20 | name = "all-libs", 21 | exported_deps = lib_deps, 22 | ) 23 | 24 | android_library( 25 | name = "app-code", 26 | srcs = glob([ 27 | "src/main/java/**/*.java", 28 | ]), 29 | deps = [ 30 | ":all-libs", 31 | ":build_config", 32 | ":res", 33 | ], 34 | ) 35 | 36 | android_build_config( 37 | name = "build_config", 38 | package = "com.typescript", 39 | ) 40 | 41 | android_resource( 42 | name = "res", 43 | package = "com.typescript", 44 | res = "src/main/res", 45 | ) 46 | 47 | android_binary( 48 | name = "app", 49 | keystore = "//android/keystores:debug", 50 | manifest = "src/main/AndroidManifest.xml", 51 | package_type = "debug", 52 | deps = [ 53 | ":app-code", 54 | ], 55 | ) 56 | -------------------------------------------------------------------------------- /android/app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | apply plugin: 'com.growingio.android' 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // whether to bundle JS and assets in debug mode 22 | * bundleInDebug: false, 23 | * 24 | * // whether to bundle JS and assets in release mode 25 | * bundleInRelease: true, 26 | * 27 | * // whether to bundle JS and assets in another build variant (if configured). 28 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 29 | * // The configuration property can be in the following formats 30 | * // 'bundleIn${productFlavor}${buildType}' 31 | * // 'bundleIn${buildType}' 32 | * // bundleInFreeDebug: true, 33 | * // bundleInPaidRelease: true, 34 | * // bundleInBeta: true, 35 | * 36 | * // whether to disable dev mode in custom build variants (by default only disabled in release) 37 | * // for example: to disable dev mode in the staging build type (if configured) 38 | * devDisabledInStaging: true, 39 | * // The configuration property can be in the following formats 40 | * // 'devDisabledIn${productFlavor}${buildType}' 41 | * // 'devDisabledIn${buildType}' 42 | * 43 | * // the root of your project, i.e. where "package.json" lives 44 | * root: "../../", 45 | * 46 | * // where to put the JS bundle asset in debug mode 47 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 48 | * 49 | * // where to put the JS bundle asset in release mode 50 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 51 | * 52 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 53 | * // require('./image.png')), in debug mode 54 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 55 | * 56 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 57 | * // require('./image.png')), in release mode 58 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 59 | * 60 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 61 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 62 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 63 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 64 | * // for example, you might want to remove it from here. 65 | * inputExcludes: ["android/**", "ios/**"], 66 | * 67 | * // override which node gets called and with what additional arguments 68 | * nodeExecutableAndArgs: ["node"], 69 | * 70 | * // supply additional arguments to the packager 71 | * extraPackagerArgs: [] 72 | * ] 73 | */ 74 | 75 | project.ext.react = [ 76 | entryFile: "index.js" 77 | ] 78 | 79 | apply from: "../../node_modules/react-native/react.gradle" 80 | 81 | /** 82 | * Set this to true to create two separate APKs instead of one: 83 | * - An APK that only works on ARM devices 84 | * - An APK that only works on x86 devices 85 | * The advantage is the size of the APK is reduced by about 4MB. 86 | * Upload all the APKs to the Play Store and people will download 87 | * the correct one based on the CPU architecture of their device. 88 | */ 89 | def enableSeparateBuildPerCPUArchitecture = false 90 | 91 | /** 92 | * Run Proguard to shrink the Java bytecode in release builds. 93 | */ 94 | def enableProguardInReleaseBuilds = false 95 | 96 | android { 97 | compileSdkVersion rootProject.ext.compileSdkVersion 98 | 99 | compileOptions { 100 | sourceCompatibility JavaVersion.VERSION_1_8 101 | targetCompatibility JavaVersion.VERSION_1_8 102 | } 103 | 104 | defaultConfig { 105 | applicationId "com.typescript" 106 | minSdkVersion rootProject.ext.minSdkVersion 107 | targetSdkVersion rootProject.ext.targetSdkVersion 108 | versionCode 1 109 | versionName "1.0" 110 | 111 | resValue("string", "growingio_project_id", "85864a8537ab43a2a066feb1855c1783") 112 | resValue("string", "growingio_url_scheme", "growing.c63f36fa0584763e") 113 | } 114 | splits { 115 | abi { 116 | reset() 117 | enable enableSeparateBuildPerCPUArchitecture 118 | universalApk false // If true, also generate a universal APK 119 | include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" 120 | } 121 | } 122 | buildTypes { 123 | release { 124 | minifyEnabled enableProguardInReleaseBuilds 125 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 126 | } 127 | } 128 | // applicationVariants are e.g. debug, release 129 | applicationVariants.all { variant -> 130 | variant.outputs.each { output -> 131 | // For each separate APK per architecture, set a unique version code as described here: 132 | // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits 133 | def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4] 134 | def abi = output.getFilter(OutputFile.ABI) 135 | if (abi != null) { // null for the universal-debug, universal-release variants 136 | output.versionCodeOverride = 137 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 138 | } 139 | } 140 | } 141 | } 142 | 143 | dependencies { 144 | implementation project(':react-native-gesture-handler') 145 | implementation fileTree(dir: "libs", include: ["*.jar"]) 146 | implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" 147 | implementation "com.facebook.react:react-native:+" // From node_modules 148 | implementation 'com.growingio.android:vds-android-agent:RN-autotrack-2.8.1@aar' 149 | } 150 | 151 | // Run this once to be able to run the application with BUCK 152 | // puts all compile dependencies into folder libs for BUCK to use 153 | task copyDownloadableDepsToLibs(type: Copy) { 154 | from configurations.compile 155 | into 'libs' 156 | } 157 | -------------------------------------------------------------------------------- /android/app/build_defs.bzl: -------------------------------------------------------------------------------- 1 | """Helper definitions to glob .aar and .jar targets""" 2 | 3 | def create_aar_targets(aarfiles): 4 | for aarfile in aarfiles: 5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] 6 | lib_deps.append(":" + name) 7 | android_prebuilt_aar( 8 | name = name, 9 | aar = aarfile, 10 | ) 11 | 12 | def create_jar_targets(jarfiles): 13 | for jarfile in jarfiles: 14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] 15 | lib_deps.append(":" + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | -------------------------------------------------------------------------------- /android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 17 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/typescript/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.typescript; 2 | 3 | import com.facebook.react.ReactActivity; 4 | import com.facebook.react.ReactActivityDelegate; 5 | import com.facebook.react.ReactRootView; 6 | import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView; 7 | 8 | public class MainActivity extends ReactActivity { 9 | 10 | /** 11 | * Returns the name of the main component registered from JavaScript. 12 | * This is used to schedule rendering of the component. 13 | */ 14 | @Override 15 | protected String getMainComponentName() { 16 | return "TypeScript"; 17 | } 18 | 19 | @Override 20 | protected ReactActivityDelegate createReactActivityDelegate() { 21 | return new ReactActivityDelegate(this, getMainComponentName()){ 22 | @Override 23 | protected ReactRootView createRootView() { 24 | return new RNGestureHandlerEnabledRootView(MainActivity.this); 25 | } 26 | }; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/typescript/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.typescript; 2 | 3 | import android.app.Application; 4 | 5 | import com.facebook.react.ReactApplication; 6 | import com.growingio.android.plugin.rn.GrowingIOPackage; 7 | import com.growingio.android.sdk.collection.Configuration; 8 | import com.growingio.android.sdk.collection.GrowingIO; 9 | import com.swmansion.gesturehandler.react.RNGestureHandlerPackage; 10 | import com.facebook.react.ReactNativeHost; 11 | import com.facebook.react.ReactPackage; 12 | import com.facebook.react.shell.MainReactPackage; 13 | import com.facebook.soloader.SoLoader; 14 | 15 | import java.util.Arrays; 16 | import java.util.List; 17 | 18 | public class MainApplication extends Application implements ReactApplication { 19 | 20 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 21 | @Override 22 | public boolean getUseDeveloperSupport() { 23 | return BuildConfig.DEBUG; 24 | } 25 | 26 | @Override 27 | protected List getPackages() { 28 | return Arrays.asList( 29 | new MainReactPackage(), 30 | new RNGestureHandlerPackage(), 31 | new GrowingIOPackage() 32 | ); 33 | } 34 | 35 | @Override 36 | protected String getJSMainModuleName() { 37 | return "index"; 38 | } 39 | }; 40 | 41 | @Override 42 | public ReactNativeHost getReactNativeHost() { 43 | return mReactNativeHost; 44 | } 45 | 46 | @Override 47 | public void onCreate() { 48 | super.onCreate(); 49 | SoLoader.init(this, /* native exopackage */ false); 50 | GrowingIO.startWithConfiguration(this, new Configuration() 51 | .setDebugMode(true) 52 | .setTestMode(true) 53 | .trackAllFragments() 54 | .setChannel("XXX应用商店") 55 | ); 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/growingio/ReactNativeDemo/e12751f35ca88e34d5bb3c09926b543ecd0419e7/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/growingio/ReactNativeDemo/e12751f35ca88e34d5bb3c09926b543ecd0419e7/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/growingio/ReactNativeDemo/e12751f35ca88e34d5bb3c09926b543ecd0419e7/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/growingio/ReactNativeDemo/e12751f35ca88e34d5bb3c09926b543ecd0419e7/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/growingio/ReactNativeDemo/e12751f35ca88e34d5bb3c09926b543ecd0419e7/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/growingio/ReactNativeDemo/e12751f35ca88e34d5bb3c09926b543ecd0419e7/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/growingio/ReactNativeDemo/e12751f35ca88e34d5bb3c09926b543ecd0419e7/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/growingio/ReactNativeDemo/e12751f35ca88e34d5bb3c09926b543ecd0419e7/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/growingio/ReactNativeDemo/e12751f35ca88e34d5bb3c09926b543ecd0419e7/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/growingio/ReactNativeDemo/e12751f35ca88e34d5bb3c09926b543ecd0419e7/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | TypeScript 3 | 4 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "28.0.3" 6 | minSdkVersion = 16 7 | compileSdkVersion = 28 8 | targetSdkVersion = 28 9 | supportLibVersion = "28.0.0" 10 | } 11 | repositories { 12 | mavenLocal() 13 | google() 14 | jcenter() 15 | } 16 | dependencies { 17 | classpath("com.android.tools.build:gradle:3.4.0") 18 | classpath 'com.growingio.android:vds-gradle-plugin:RN-autotrack-2.8.1' 19 | 20 | // NOTE: Do not place your application dependencies here; they belong 21 | // in the individual module build.gradle files 22 | } 23 | } 24 | 25 | allprojects { 26 | repositories { 27 | mavenLocal() 28 | google() 29 | jcenter() 30 | maven { 31 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 32 | url "$rootDir/../node_modules/react-native/android" 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/growingio/ReactNativeDemo/e12751f35ca88e34d5bb3c09926b543ecd0419e7/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin, switch paths to Windows format before running java 129 | if $cygwin ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=$((i+1)) 158 | done 159 | case $i in 160 | (0) set -- ;; 161 | (1) set -- "$args0" ;; 162 | (2) set -- "$args0" "$args1" ;; 163 | (3) set -- "$args0" "$args1" "$args2" ;; 164 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=$(save "$@") 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 184 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 185 | cd "$(dirname "$0")" 186 | fi 187 | 188 | exec "$JAVACMD" "$@" 189 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem http://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 34 | 35 | @rem Find java.exe 36 | if defined JAVA_HOME goto findJavaFromJavaHome 37 | 38 | set JAVA_EXE=java.exe 39 | %JAVA_EXE% -version >NUL 2>&1 40 | if "%ERRORLEVEL%" == "0" goto init 41 | 42 | echo. 43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 44 | echo. 45 | echo Please set the JAVA_HOME variable in your environment to match the 46 | echo location of your Java installation. 47 | 48 | goto fail 49 | 50 | :findJavaFromJavaHome 51 | set JAVA_HOME=%JAVA_HOME:"=% 52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 53 | 54 | if exist "%JAVA_EXE%" goto init 55 | 56 | echo. 57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 58 | echo. 59 | echo Please set the JAVA_HOME variable in your environment to match the 60 | echo location of your Java installation. 61 | 62 | goto fail 63 | 64 | :init 65 | @rem Get command-line arguments, handling Windows variants 66 | 67 | if not "%OS%" == "Windows_NT" goto win9xME_args 68 | 69 | :win9xME_args 70 | @rem Slurp the command line arguments. 71 | set CMD_LINE_ARGS= 72 | set _SKIP=2 73 | 74 | :win9xME_args_slurp 75 | if "x%~1" == "x" goto execute 76 | 77 | set CMD_LINE_ARGS=%* 78 | 79 | :execute 80 | @rem Setup the command line 81 | 82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 83 | 84 | @rem Execute Gradle 85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 86 | 87 | :end 88 | @rem End local scope for the variables with windows NT shell 89 | if "%ERRORLEVEL%"=="0" goto mainEnd 90 | 91 | :fail 92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 93 | rem the _cmd.exe /c_ return code! 94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 95 | exit /b 1 96 | 97 | :mainEnd 98 | if "%OS%"=="Windows_NT" endlocal 99 | 100 | :omega 101 | -------------------------------------------------------------------------------- /android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = "debug", 3 | properties = "debug.keystore.properties", 4 | store = "debug.keystore", 5 | visibility = [ 6 | "PUBLIC", 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /android/local.properties: -------------------------------------------------------------------------------- 1 | ## This file must *NOT* be checked into Version Control Systems, 2 | # as it contains information specific to your local configuration. 3 | # 4 | # Location of the SDK. This is only used by Gradle. 5 | # For customization when using a Version Control System, please read the 6 | # header note. 7 | #Wed Jun 19 19:30:33 CST 2019 8 | ndk.dir=/Users/liz/Library/Android/sdk/ndk-bundle 9 | sdk.dir=/Users/liz/Library/Android/sdk 10 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'TypeScript' 2 | include ':react-native-gesture-handler' 3 | project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android') 4 | 5 | include ':app' 6 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "TypeScript", 3 | "displayName": "TypeScript" 4 | } -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import {AppRegistry} from 'react-native'; 6 | import App from './App'; 7 | import {name as appName} from './app.json'; 8 | 9 | AppRegistry.registerComponent(appName, () => App); 10 | -------------------------------------------------------------------------------- /ios/TypeScript-tvOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UIViewControllerBasedStatusBarAppearance 38 | 39 | NSLocationWhenInUseUsageDescription 40 | 41 | NSAppTransportSecurity 42 | 43 | 44 | NSExceptionDomains 45 | 46 | localhost 47 | 48 | NSExceptionAllowsInsecureHTTPLoads 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /ios/TypeScript-tvOSTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /ios/TypeScript.xcodeproj/xcshareddata/xcschemes/TypeScript-tvOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 81 | 82 | 92 | 94 | 100 | 101 | 102 | 103 | 104 | 105 | 111 | 113 | 119 | 120 | 121 | 122 | 124 | 125 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /ios/TypeScript.xcodeproj/xcshareddata/xcschemes/TypeScript.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 81 | 82 | 92 | 94 | 100 | 101 | 102 | 103 | 104 | 105 | 111 | 113 | 119 | 120 | 121 | 122 | 124 | 125 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /ios/TypeScript/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (nonatomic, strong) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ios/TypeScript/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import "AppDelegate.h" 9 | 10 | #import 11 | #import 12 | #import 13 | 14 | @implementation AppDelegate 15 | 16 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 17 | { 18 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 19 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge 20 | moduleName:@"TypeScript" 21 | initialProperties:nil]; 22 | 23 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 24 | 25 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 26 | UIViewController *rootViewController = [UIViewController new]; 27 | rootViewController.view = rootView; 28 | self.window.rootViewController = rootViewController; 29 | [self.window makeKeyAndVisible]; 30 | return YES; 31 | } 32 | 33 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 34 | { 35 | #if DEBUG 36 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 37 | #else 38 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 39 | #endif 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /ios/TypeScript/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /ios/TypeScript/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /ios/TypeScript/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /ios/TypeScript/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | TypeScript 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | NSLocationWhenInUseUsageDescription 28 | 29 | UILaunchStoryboardName 30 | LaunchScreen 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | 41 | UIViewControllerBasedStatusBarAppearance 42 | 43 | NSLocationWhenInUseUsageDescription 44 | 45 | NSAppTransportSecurity 46 | 47 | 48 | NSAllowsArbitraryLoads 49 | 50 | NSExceptionDomains 51 | 52 | localhost 53 | 54 | NSExceptionAllowsInsecureHTTPLoads 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /ios/TypeScript/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ios/TypeScriptTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /ios/TypeScriptTests/TypeScriptTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | #import 10 | 11 | #import 12 | #import 13 | 14 | #define TIMEOUT_SECONDS 600 15 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!" 16 | 17 | @interface TypeScriptTests : XCTestCase 18 | 19 | @end 20 | 21 | @implementation TypeScriptTests 22 | 23 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 24 | { 25 | if (test(view)) { 26 | return YES; 27 | } 28 | for (UIView *subview in [view subviews]) { 29 | if ([self findSubviewInView:subview matching:test]) { 30 | return YES; 31 | } 32 | } 33 | return NO; 34 | } 35 | 36 | - (void)testRendersWelcomeScreen 37 | { 38 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController]; 39 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 40 | BOOL foundElement = NO; 41 | 42 | __block NSString *redboxError = nil; 43 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 44 | if (level >= RCTLogLevelError) { 45 | redboxError = message; 46 | } 47 | }); 48 | 49 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 50 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 51 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 52 | 53 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 54 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 55 | return YES; 56 | } 57 | return NO; 58 | }]; 59 | } 60 | 61 | RCTSetLogFunction(RCTDefaultLogFunction); 62 | 63 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 64 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 65 | } 66 | 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'react-native', 3 | moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], 4 | } 5 | -------------------------------------------------------------------------------- /metro.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Metro configuration for React Native 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | 8 | module.exports = { 9 | transformer: { 10 | getTransformOptions: async () => ({ 11 | transform: { 12 | experimentalImportSupport: false, 13 | inlineRequires: false, 14 | }, 15 | }), 16 | }, 17 | }; 18 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "TypeScript", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node node_modules/react-native/local-cli/cli.js start", 7 | "test": "jest", 8 | "postinstall": "node node_modules/react-native-autotrack-growingio/hook.js -run" 9 | }, 10 | "dependencies": { 11 | "react": "16.8.3", 12 | "react-native": "0.59.9", 13 | "react-native-autotrack-growingio": "git+https://github.com/growingio/GIORNHook.git#develop", 14 | "react-native-blur": "^3.2.2", 15 | "react-native-gesture-handler": "^1.3.0", 16 | "react-native-growingio": "git+https://github.com/growingio/react-native-growingio.git#0.0.7", 17 | "react-native-iphone-x-helper": "^1.2.1", 18 | "react-native-reanimated": "^1.0.1", 19 | "react-native-vector-icons": "^6.5.0", 20 | "react-navigation": "^3.11.0", 21 | "react-navigation-header-buttons": "^2.3.1", 22 | "react-navigation-tabs": "^2.1.3" 23 | }, 24 | "devDependencies": { 25 | "@babel/core": "^7.4.5", 26 | "@babel/runtime": "^7.4.5", 27 | "@types/jest": "^24.0.13", 28 | "@types/react": "^16.8.19", 29 | "@types/react-native": "^0.57.60", 30 | "@types/react-native-vector-icons": "^6.4.1", 31 | "@types/react-test-renderer": "^16.8.1", 32 | "babel-jest": "^24.8.0", 33 | "jest": "^24.8.0", 34 | "metro-react-native-babel-preset": "^0.54.1", 35 | "react-test-renderer": "16.8.3", 36 | "typescript": "^3.5.1" 37 | }, 38 | "jest": { 39 | "preset": "react-native" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /screenshots/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/growingio/ReactNativeDemo/e12751f35ca88e34d5bb3c09926b543ecd0419e7/screenshots/.DS_Store -------------------------------------------------------------------------------- /screenshots/install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/growingio/ReactNativeDemo/e12751f35ca88e34d5bb3c09926b543ecd0419e7/screenshots/install.png -------------------------------------------------------------------------------- /src/CustomTabUI.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | LayoutAnimation, 4 | StatusBar, 5 | StyleSheet, 6 | Text, 7 | View, 8 | } from 'react-native'; 9 | import Ionicons from 'react-native-vector-icons/Ionicons'; 10 | import { 11 | createMaterialTopTabNavigator, 12 | NavigationScreenProp, 13 | NavigationState, 14 | SafeAreaView, 15 | } from 'react-navigation'; 16 | import { Button } from './commonComponents/ButtonWithMargin'; 17 | 18 | interface Props { 19 | navigation: NavigationScreenProp; 20 | } 21 | 22 | class MyHomeScreen extends React.Component { 23 | static navigationOptions = { 24 | tabBarLabel: 'Home', 25 | tabBarIcon: ({ 26 | tintColor, 27 | focused, 28 | horizontal, 29 | }: { 30 | tintColor: string; 31 | focused: boolean; 32 | horizontal: boolean; 33 | }) => ( 34 | 39 | ), 40 | }; 41 | render() { 42 | const { navigation } = this.props; 43 | return ( 44 | 45 | Home Screen 46 |