Browse Source

chore: example project improvements (#612)

* chore: add dev scripts

* chore: improve safe areas in example project
master
Henning Hall 2 years ago
committed by GitHub
parent
commit
0d15d23aae
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 7 deletions
  1. +1
    -0
      .npmignore
  2. +8
    -6
      examples/Rn069/src/App.js
  3. +2
    -1
      package.json
  4. +11
    -0
      scripts/available-android-emulator.sh
  5. +4
    -0
      scripts/start-android-emulator.sh

+ 1
- 0
.npmignore View File

@ -5,3 +5,4 @@ example-cocoapods
examples
githubREADME.md
.gitignore
scripts

+ 8
- 6
examples/Rn069/src/App.js View File

@ -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}
>
<Text style={styles.header}>{!this.state.picker && 'Examples'}</Text>
{!this.state.picker && this.renderButtons()}
{!!this.state.picker && this.renderBackButton()}
{!!this.state.picker && this.renderPicker()}
<SafeAreaView>
<Text style={styles.header}>{!this.state.picker && 'Examples'}</Text>
{!this.state.picker && this.renderButtons()}
{!!this.state.picker && this.renderBackButton()}
{!!this.state.picker && this.renderPicker()}
</SafeAreaView>
</ScrollView>
);
}
@ -60,7 +62,7 @@ export default class App extends Component {
renderBackButton = key => (
<TouchableOpacity
onPress={() => this.setState({picker: undefined})}
style={{margin: 10, position: 'absolute', top: 0, left: 10}}
style={{margin: 10, position: 'absolute', top: 30, left: 0}}
>
<Text style={styles.text}>Back</Text>
</TouchableOpacity>

+ 2
- 1
package.json View File

@ -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",

+ 11
- 0
scripts/available-android-emulator.sh View File

@ -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

+ 4
- 0
scripts/start-android-emulator.sh View File

@ -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 &

Loading…
Cancel
Save