Set up export button to export a simple file
This commit is contained in:
@@ -137,6 +137,7 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':react-native-share')
|
||||
compile project(':realm')
|
||||
compile project(':react-native-svg')
|
||||
compile fileTree(dir: "libs", include: ["*.jar"])
|
||||
|
||||
@@ -21,6 +21,16 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
|
||||
<provider
|
||||
android:name="android.support.v4.content.FileProvider"
|
||||
android:authorities="com.drip.provider"
|
||||
android:grantUriPermissions="true"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/filepaths" />
|
||||
</provider>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.drip;
|
||||
import android.app.Application;
|
||||
|
||||
import com.facebook.react.ReactApplication;
|
||||
import cl.json.RNSharePackage;
|
||||
import cl.json.ShareApplication;
|
||||
import io.realm.react.RealmReactPackage;
|
||||
import com.horcrux.svg.SvgPackage;
|
||||
import com.facebook.react.ReactNativeHost;
|
||||
@@ -13,7 +15,7 @@ import com.facebook.soloader.SoLoader;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MainApplication extends Application implements ReactApplication {
|
||||
public class MainApplication extends Application implements ReactApplication, ShareApplication {
|
||||
|
||||
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
|
||||
@Override
|
||||
@@ -25,6 +27,7 @@ public class MainApplication extends Application implements ReactApplication {
|
||||
protected List<ReactPackage> getPackages() {
|
||||
return Arrays.<ReactPackage>asList(
|
||||
new MainReactPackage(),
|
||||
new RNSharePackage(),
|
||||
new RealmReactPackage(),
|
||||
new SvgPackage()
|
||||
);
|
||||
@@ -46,4 +49,9 @@ public class MainApplication extends Application implements ReactApplication {
|
||||
super.onCreate();
|
||||
SoLoader.init(this, /* native exopackage */ false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFileProviderAuthority() {
|
||||
return "com.drip.provider";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<external-path name="Downloads" path="Download/" />
|
||||
</paths>
|
||||
@@ -1,4 +1,6 @@
|
||||
rootProject.name = 'drip'
|
||||
include ':react-native-share'
|
||||
project(':react-native-share').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-share/android')
|
||||
include ':realm'
|
||||
project(':realm').projectDir = new File(rootProject.projectDir, '../node_modules/realm/android')
|
||||
include ':react-native-svg'
|
||||
|
||||
@@ -4,8 +4,10 @@ import Home from './components/home'
|
||||
import Calendar from './components/calendar'
|
||||
import CycleDay from './components/cycle-day'
|
||||
import Chart from './components/chart/chart'
|
||||
import Settings from './components/settings'
|
||||
|
||||
// this is until react native fixes this bug, see https://github.com/facebook/react-native/issues/18868#issuecomment-382671739
|
||||
// this is until react native fixes this bugg, see
|
||||
// https://github.com/facebook/react-native/issues/18868#issuecomment-382671739
|
||||
import { YellowBox } from 'react-native'
|
||||
YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated'])
|
||||
|
||||
@@ -13,5 +15,6 @@ export default createStackNavigator({
|
||||
home: { screen: Home },
|
||||
calendar: { screen: Calendar },
|
||||
cycleDay: { screen: CycleDay },
|
||||
chart: { screen: Chart }
|
||||
chart: { screen: Chart },
|
||||
settings: { screen: Settings }
|
||||
})
|
||||
|
||||
@@ -68,6 +68,12 @@ export default class Home extends Component {
|
||||
title="Go to chart">
|
||||
</Button>
|
||||
</View>
|
||||
<View style={styles.homeButton}>
|
||||
<Button
|
||||
onPress={() => navigate('settings')}
|
||||
title="Go to settings">
|
||||
</Button>
|
||||
</View>
|
||||
<View style={styles.homeButton}>
|
||||
<Button
|
||||
onPress={() => fillWithDummyData()}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
import React, { Component } from 'react'
|
||||
import {
|
||||
View,
|
||||
Button,
|
||||
Text,
|
||||
ScrollView,
|
||||
Picker
|
||||
} from 'react-native'
|
||||
import Share from 'react-native-share'
|
||||
import { Base64 } from 'js-base64'
|
||||
import styles from '../styles/index'
|
||||
|
||||
export default class Settings extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
this.state = {
|
||||
pickerVisible: false
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<ScrollView>
|
||||
<Text style={styles.welcome}>{this.state.welcomeText}</Text>
|
||||
<View style={styles.homeButtons}>
|
||||
<View style={styles.homeButton}>
|
||||
<Button
|
||||
onPress={() => this.setState({pickerVisible: true})}
|
||||
title="Edit symptoms for today">
|
||||
</Button>
|
||||
</View>
|
||||
</View>
|
||||
{this.state.pickerVisible &&
|
||||
<Picker
|
||||
selectedValue='json'
|
||||
style={{ height: 50, width: 200 }}
|
||||
onValueChange={ async format => {
|
||||
const data = makeDataURI(format)
|
||||
console.log(data)
|
||||
try {
|
||||
await Share.open({
|
||||
title: 'My Drip data export',
|
||||
url: data,
|
||||
subject: 'My Drip data export',
|
||||
type: 'text/csv',
|
||||
showAppsToView: true
|
||||
})
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
}}>
|
||||
<Picker.Item label="JSON" value="json" />
|
||||
<Picker.Item label="CSV" value="csv" />
|
||||
</Picker>
|
||||
}
|
||||
</ScrollView>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function makeDataURI(format) {
|
||||
const data = {hello: "world"}
|
||||
const encoded = Base64.encodeURI(JSON.stringify(data))
|
||||
return `data:text/csv;base64,${encoded}`
|
||||
}
|
||||
@@ -42,6 +42,7 @@
|
||||
089A8A31B3244EB381D3BA67 /* libRealmReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7A5827160B914D2B99C47381 /* libRealmReact.a */; };
|
||||
62F2A4645AC84CDC9506FF27 /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AEBF0735214455AAEDF56D5 /* libc++.tbd */; };
|
||||
D91133DCE120440893E2FD2E /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CD8C8B91E0A747B3883A0D56 /* libz.tbd */; };
|
||||
26DC04B498C64CE5AAA0C4F8 /* libRNShare.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A8B59389C2FC4F19BD30ABC3 /* libRNShare.a */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -354,6 +355,8 @@
|
||||
7A5827160B914D2B99C47381 /* libRealmReact.a */ = {isa = PBXFileReference; name = "libRealmReact.a"; path = "libRealmReact.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
|
||||
9AEBF0735214455AAEDF56D5 /* libc++.tbd */ = {isa = PBXFileReference; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; fileEncoding = undefined; lastKnownFileType = sourcecode.text-based-dylib-definition; explicitFileType = undefined; includeInIndex = 0; };
|
||||
CD8C8B91E0A747B3883A0D56 /* libz.tbd */ = {isa = PBXFileReference; name = "libz.tbd"; path = "usr/lib/libz.tbd"; sourceTree = SDKROOT; fileEncoding = undefined; lastKnownFileType = sourcecode.text-based-dylib-definition; explicitFileType = undefined; includeInIndex = 0; };
|
||||
4E6AB77B55F2491487B6124E /* RNShare.xcodeproj */ = {isa = PBXFileReference; name = "RNShare.xcodeproj"; path = "../node_modules/react-native-share/ios/RNShare.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
|
||||
A8B59389C2FC4F19BD30ABC3 /* libRNShare.a */ = {isa = PBXFileReference; name = "libRNShare.a"; path = "libRNShare.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -386,6 +389,7 @@
|
||||
089A8A31B3244EB381D3BA67 /* libRealmReact.a in Frameworks */,
|
||||
62F2A4645AC84CDC9506FF27 /* libc++.tbd in Frameworks */,
|
||||
D91133DCE120440893E2FD2E /* libz.tbd in Frameworks */,
|
||||
26DC04B498C64CE5AAA0C4F8 /* libRNShare.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -577,6 +581,7 @@
|
||||
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
|
||||
8316A5AD64274E6FBA6C9FFE /* RNSVG.xcodeproj */,
|
||||
7F6C9FA9B66B453CA602B334 /* RealmReact.xcodeproj */,
|
||||
4E6AB77B55F2491487B6124E /* RNShare.xcodeproj */,
|
||||
);
|
||||
name = Libraries;
|
||||
sourceTree = "<group>";
|
||||
@@ -1203,11 +1208,13 @@
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/drip.app/drip";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)/$(TARGET_NAME)\"",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(SRCROOT)/../node_modules/react-native-svg/ios/**",
|
||||
"$(SRCROOT)/../node_modules/realm/src/**",
|
||||
"$(SRCROOT)/../node_modules/react-native-share/ios",
|
||||
);
|
||||
};
|
||||
name = Debug;
|
||||
@@ -1228,11 +1235,13 @@
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/drip.app/drip";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)/$(TARGET_NAME)\"",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(SRCROOT)/../node_modules/react-native-svg/ios/**",
|
||||
"$(SRCROOT)/../node_modules/realm/src/**",
|
||||
"$(SRCROOT)/../node_modules/react-native-share/ios",
|
||||
);
|
||||
};
|
||||
name = Release;
|
||||
@@ -1256,6 +1265,7 @@
|
||||
"$(inherited)",
|
||||
"$(SRCROOT)/../node_modules/react-native-svg/ios/**",
|
||||
"$(SRCROOT)/../node_modules/realm/src/**",
|
||||
"$(SRCROOT)/../node_modules/react-native-share/ios",
|
||||
);
|
||||
};
|
||||
name = Debug;
|
||||
@@ -1278,6 +1288,7 @@
|
||||
"$(inherited)",
|
||||
"$(SRCROOT)/../node_modules/react-native-svg/ios/**",
|
||||
"$(SRCROOT)/../node_modules/realm/src/**",
|
||||
"$(SRCROOT)/../node_modules/react-native-share/ios",
|
||||
);
|
||||
};
|
||||
name = Release;
|
||||
@@ -1307,11 +1318,13 @@
|
||||
TVOS_DEPLOYMENT_TARGET = 9.2;
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)/$(TARGET_NAME)\"",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(SRCROOT)/../node_modules/react-native-svg/ios/**",
|
||||
"$(SRCROOT)/../node_modules/realm/src/**",
|
||||
"$(SRCROOT)/../node_modules/react-native-share/ios",
|
||||
);
|
||||
};
|
||||
name = Debug;
|
||||
@@ -1341,11 +1354,13 @@
|
||||
TVOS_DEPLOYMENT_TARGET = 9.2;
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)/$(TARGET_NAME)\"",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(SRCROOT)/../node_modules/react-native-svg/ios/**",
|
||||
"$(SRCROOT)/../node_modules/realm/src/**",
|
||||
"$(SRCROOT)/../node_modules/react-native-share/ios",
|
||||
);
|
||||
};
|
||||
name = Release;
|
||||
@@ -1374,11 +1389,13 @@
|
||||
TVOS_DEPLOYMENT_TARGET = 10.1;
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)/$(TARGET_NAME)\"",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(SRCROOT)/../node_modules/react-native-svg/ios/**",
|
||||
"$(SRCROOT)/../node_modules/realm/src/**",
|
||||
"$(SRCROOT)/../node_modules/react-native-share/ios",
|
||||
);
|
||||
};
|
||||
name = Debug;
|
||||
@@ -1407,11 +1424,13 @@
|
||||
TVOS_DEPLOYMENT_TARGET = 10.1;
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)/$(TARGET_NAME)\"",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(SRCROOT)/../node_modules/react-native-svg/ios/**",
|
||||
"$(SRCROOT)/../node_modules/realm/src/**",
|
||||
"$(SRCROOT)/../node_modules/react-native-share/ios",
|
||||
);
|
||||
};
|
||||
name = Release;
|
||||
|
||||
Generated
+354
-281
File diff suppressed because it is too large
Load Diff
@@ -17,12 +17,14 @@
|
||||
"dependencies": {
|
||||
"assert": "^1.4.1",
|
||||
"date-range": "0.0.2",
|
||||
"js-base64": "^2.4.8",
|
||||
"js-joda": "^1.8.2",
|
||||
"moment": "^2.22.1",
|
||||
"react": "16.4.1",
|
||||
"react-native": "^0.56.0",
|
||||
"react-native-calendars": "^1.19.3",
|
||||
"react-native-modal-datetime-picker-nevo": "^4.11.0",
|
||||
"react-native-share": "^1.1.0",
|
||||
"react-native-simple-radio-button": "^2.7.1",
|
||||
"react-native-svg": "^6.3.1",
|
||||
"react-navigation": "^2.0.4",
|
||||
|
||||
Reference in New Issue
Block a user