From 0d15d23aae11a6df1cb7f06f0b22bde4b70059f3 Mon Sep 17 00:00:00 2001 From: Henning Hall Date: Sun, 19 Feb 2023 18:28:41 +0100 Subject: [PATCH] chore: example project improvements (#612) * chore: add dev scripts * chore: improve safe areas in example project --- .npmignore | 1 + examples/Rn069/src/App.js | 14 ++++++++------ package.json | 3 ++- scripts/available-android-emulator.sh | 11 +++++++++++ scripts/start-android-emulator.sh | 4 ++++ 5 files changed, 26 insertions(+), 7 deletions(-) create mode 100755 scripts/available-android-emulator.sh create mode 100755 scripts/start-android-emulator.sh diff --git a/.npmignore b/.npmignore index 916e2c6..c092bc3 100644 --- a/.npmignore +++ b/.npmignore @@ -5,3 +5,4 @@ example-cocoapods examples githubREADME.md .gitignore +scripts diff --git a/examples/Rn069/src/App.js b/examples/Rn069/src/App.js index 4708991..127a506 100644 --- a/examples/Rn069/src/App.js +++ b/examples/Rn069/src/App.js @@ -1,10 +1,10 @@ import React, {Component} from 'react'; import { ScrollView, - AppRegistry, StyleSheet, Text, TouchableOpacity, + SafeAreaView, } from 'react-native'; import examples from './examples'; @@ -22,10 +22,12 @@ export default class App extends Component { ]} contentContainerStyle={styles.content} > - {!this.state.picker && 'Examples'} - {!this.state.picker && this.renderButtons()} - {!!this.state.picker && this.renderBackButton()} - {!!this.state.picker && this.renderPicker()} + + {!this.state.picker && 'Examples'} + {!this.state.picker && this.renderButtons()} + {!!this.state.picker && this.renderBackButton()} + {!!this.state.picker && this.renderPicker()} + ); } @@ -60,7 +62,7 @@ export default class App extends Component { renderBackButton = key => ( this.setState({picker: undefined})} - style={{margin: 10, position: 'absolute', top: 0, left: 10}} + style={{margin: 10, position: 'absolute', top: 30, left: 0}} > Back diff --git a/package.json b/package.json index 13d713e..5c8e7ae 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "scripts": { "prepublishOnly": "mv README.md githubREADME.md && mv npmREADME.md README.md", "postpublish": "mv README.md npmREADME.md && mv githubREADME.md README.md", - "test": "jest src" + "test": "jest src", + "emulator": "bash ./scripts/start-android-emulator.sh" }, "repository": { "type": "git", diff --git a/scripts/available-android-emulator.sh b/scripts/available-android-emulator.sh new file mode 100755 index 0000000..a567747 --- /dev/null +++ b/scripts/available-android-emulator.sh @@ -0,0 +1,11 @@ +emulators=$(emulator -list-avds ) + +for emulator in $emulators +do + # Prefer non TV emulators + if [[ "$emulator" != *"TV"* ]]; then + EMULATOR=$emulator + fi +done + +echo $EMULATOR \ No newline at end of file diff --git a/scripts/start-android-emulator.sh b/scripts/start-android-emulator.sh new file mode 100755 index 0000000..5b4f8f4 --- /dev/null +++ b/scripts/start-android-emulator.sh @@ -0,0 +1,4 @@ +currentDir=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) +emulatorName=$(bash ${currentDir}/available-android-emulator.sh) +echo "Starting $emulatorName ..." +~/Library/Android/sdk/emulator/emulator -avd $emulatorName &