Skip to content

Commit

Permalink
feat(deps): update deps and prepare for release (#501)
Browse files Browse the repository at this point in the history
* chore(example): update example

* feat(deps): update deps and prepare for release
  • Loading branch information
jgcmarins committed May 25, 2019
1 parent 2af10b0 commit 05c2b6a
Show file tree
Hide file tree
Showing 16 changed files with 1,592 additions and 1,739 deletions.
18 changes: 11 additions & 7 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

buildscript {
repositories {
google()
maven {
url 'https://maven.google.com'
}
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.3.1'
}
}

apply plugin: 'com.android.library'

def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

android {
compileSdkVersion safeExtGet('compileSdkVersion', 28)

buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')

defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 16)
Expand All @@ -34,6 +37,7 @@ android {

repositories {
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
Expand All @@ -42,7 +46,7 @@ repositories {
}

dependencies {
compileOnly "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
implementation "com.facebook.react:react-native:+"
//noinspection GradleCompatible
implementation "com.android.support:appcompat-v7:${safeExtGet('supportLibVersion', '28.0.0')}"
}
128 changes: 72 additions & 56 deletions example/App.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,49 @@
import React, { Component } from 'react';

import { Alert, Button, Platform, TextInput, StyleSheet, Text, View } from 'react-native';

/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/

import React, {useState} from 'react';

import {
Alert,
Button,
Platform,
TextInput,
StyleSheet,
Text,
View,
} from 'react-native';

// eslint-disable-next-line import/default
import Share from 'react-native-share';

import images from './images/imagesBase64';

export default class App extends Component {
state = {
packageSearch: '',
result: '',
};
const App = () => {
// eslint-disable-next-line no-undef
const [packageSearch, setPackageSearch] = useState<string>('');
// eslint-disable-next-line no-undef
const [result, setResult] = useState<string>('');

/**
* You can use the method isPackageInstalled to find
* if a package is insalled. It returns a { isInstalled, message }
* only works on Android :/
* You can use the method isPackageInstalled to find if a package is installed.
* It returns an object { isInstalled, message }.
* Only works on Android.
*/
checkIfPackageIsInstalled = async () => {
const { packageSearch } = this.state;
const checkIfPackageIsInstalled = async () => {
const {isInstalled} = await Share.isPackageInstalled(packageSearch);

const { isInstalled } = await Share.isPackageInstalled(packageSearch);

Alert.alert(`Package: ${packageSearch}`, `${isInstalled ? 'Installed' : 'Not Installed'}`);
Alert.alert(
`Package: ${packageSearch}`,
`${isInstalled ? 'Installed' : 'Not Installed'}`,
);
};

setPackageSearch = packageSearch => this.setState({ packageSearch });

getErrorString(error, defaultValue) {
function getErrorString(error, defaultValue) {
let e = defaultValue || 'Something went wrong. Please try again';
if (typeof error === 'string') {
e = error;
Expand All @@ -43,7 +59,7 @@ export default class App extends Component {
* This functions share multiple images that
* you send as the urls param
*/
shareMultipleImages = async () => {
const shareMultipleImages = async () => {
const shareOptions = {
title: 'Share file',
failOnCancel: false,
Expand All @@ -54,18 +70,18 @@ export default class App extends Component {
// the share response. If the user cancels, etc.
try {
const ShareResponse = await Share.open(shareOptions);
this.setState({ result: JSON.stringify(ShareResponse, 0, 2) });
setResult(JSON.stringify(ShareResponse, 0, 2));
} catch (error) {
console.log('Error =>', error);
this.setState({ result: 'error: '.concat(this.getErrorString(error)) });
setResult('error: '.concat(getErrorString(error)));
}
};

/**
* This functions share a image passed using the
* url param
*/
shareEmailImage = async () => {
const shareEmailImage = async () => {
const shareOptions = {
title: 'Share file',
social: Share.Social.EMAIL,
Expand All @@ -75,18 +91,18 @@ export default class App extends Component {

try {
const ShareResponse = await Share.open(shareOptions);
this.setState({ result: JSON.stringify(ShareResponse, 0, 2) });
setResult(JSON.stringify(ShareResponse, 0, 2));
} catch (error) {
console.log('Error =>', error);
this.setState({ result: 'error: '.concat(this.getErrorString(error)) });
setResult('error: '.concat(getErrorString(error)));
}
};

/**
* This functions share a image passed using the
* url param
*/
shareSingleImage = async () => {
const shareSingleImage = async () => {
const shareOptions = {
title: 'Share file',
url: images.image1,
Expand All @@ -95,50 +111,48 @@ export default class App extends Component {

try {
const ShareResponse = await Share.open(shareOptions);
this.setState({ result: JSON.stringify(ShareResponse, 0, 2) });
setResult(JSON.stringify(ShareResponse, 0, 2));
} catch (error) {
console.log('Error =>', error);
this.setState({ result: 'error: '.concat(this.getErrorString(error)) });
setResult('error: '.concat(getErrorString(error)));
}
};

render() {
const { packageSearch } = this.state;

return (
<View style={styles.container}>
<Text style={styles.welcome}>Welcome to React Native Share Example!</Text>
<View style={styles.optionsRow}>
<View style={styles.button}>
<Button onPress={this.shareMultipleImages} title="Share Multiple Images" />
</View>
<View style={styles.button}>
<Button onPress={this.shareSingleImage} title="Share Single Image" />
</View>
<View style={styles.button}>
<Button onPress={this.shareEmailImage} title="Share Social: Email" />
</View>
{Platform.OS === 'android' && (
return (
<View style={styles.container}>
<Text style={styles.welcome}>Welcome to React Native Share Example!</Text>
<View style={styles.optionsRow}>
<View style={styles.button}>
<Button onPress={shareMultipleImages} title="Share Multiple Images" />
</View>
<View style={styles.button}>
<Button onPress={shareSingleImage} title="Share Single Image" />
</View>
<View style={styles.button}>
<Button onPress={shareEmailImage} title="Share Social: Email" />
</View>
{Platform.OS === 'android' && (
<View style={styles.searchPackageContainer}>
<TextInput
placeholder="Search for a Package"
onChangeText={this.setPackageSearch}
onChangeText={setPackageSearch}
value={packageSearch}
style={styles.textInput}
/>
<View>
<Button onPress={this.checkIfPackageIsInstalled} title="Check Package" />
<Button
onPress={checkIfPackageIsInstalled}
title="Check Package"
/>
</View>
</View>
)
}
<Text style={{ marginTop: 20, fontSize: 20 }}>Result</Text>
<Text style={styles.result}>{this.state.result}</Text>
</View>
)}
<Text style={{marginTop: 20, fontSize: 20}}>Result</Text>
<Text style={styles.result}>{result}</Text>
</View>
);
}
}
</View>
);
};

const styles = StyleSheet.create({
button: {
Expand Down Expand Up @@ -173,3 +187,5 @@ const styles = StyleSheet.create({
flexDirection: 'row',
},
});

export default App;
15 changes: 4 additions & 11 deletions example/README.MD
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
## Getting started
# Getting started

#Android
# Android

To get this project running on Android just follow these steps

1. `yarn` or `npm i`
2. `yarn start` or `npm start`
3. `react-native run-android`

#IOS
# iOS

Since We are using cocoapods to manage our ios dependencies. After installing it, you will need to reproduce these steps:
To get this project running on iOS just follow these steps

1. `yarn` or `npm i`
2. `yarn start` or `npm start`
3. `cd ios && pod install && cd ..`
4. `react-native run-ios`

You can also run `yarn install-pods` to install the ios dependencies.

If you have any doubt about installing pods, you call check our README.MD on the repo to get through this.


4 changes: 2 additions & 2 deletions example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @format
*/

import { AppRegistry } from 'react-native';
import {AppRegistry} from 'react-native';
import App from './App';
import { name as appName } from './app.json';
import {name as appName} from './app.json';

AppRegistry.registerComponent(appName, () => App);
40 changes: 0 additions & 40 deletions example/ios/Podfile

This file was deleted.

0 comments on commit 05c2b6a

Please sign in to comment.