Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 0044dd1

Browse files
committed
Export logs in store using share functionality.
1 parent f029af5 commit 0044dd1

File tree

4 files changed

+63
-12
lines changed

4 files changed

+63
-12
lines changed

src/asset/icon/share.js

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/asset/icon/share.svg

Lines changed: 6 additions & 0 deletions
Loading

src/component/button.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import BackIcon from '../asset/icon/back';
1313
import CancelIcon from '../asset/icon/cancel';
1414
import PlusIcon from '../asset/icon/plus';
1515
import QrIcon from '../asset/icon/qr';
16+
import ShareIcon from '../asset/icon/share';
1617
import { color, font } from './style';
1718

1819
//
@@ -558,4 +559,20 @@ MaxButton.propTypes = {
558559
style: ViewPropTypes.style,
559560
};
560561

562+
//
563+
// Share Button
564+
//
565+
566+
export const ShareButton = ({ onPress, disabled, style }) => (
567+
<Button onPress={onPress} disabled={disabled} style={style}>
568+
<ShareIcon height={22} width={16} />
569+
</Button>
570+
);
571+
572+
ShareButton.propTypes = {
573+
onPress: PropTypes.func,
574+
disabled: PropTypes.bool,
575+
style: ViewPropTypes.style,
576+
};
577+
561578
export default Button;

src/view/cli.js

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React, { Component } from 'react';
2-
import { ScrollView, StyleSheet } from 'react-native';
2+
import { ScrollView, StyleSheet, Share } from 'react-native';
33
import { observer } from 'mobx-react';
44
import PropTypes from 'prop-types';
55
import { SplitBackground } from '../component/background';
66
import { Header, Title } from '../component/header';
77
import Text from '../component/text';
8-
import { Button, BackButton } from '../component/button';
8+
import { BackButton, ShareButton } from '../component/button';
99
import { createStyles, maxWidth } from '../component/media-query';
1010
import { color, font, breakWidth } from '../component/style';
1111

@@ -19,16 +19,31 @@ const styles = StyleSheet.create({
1919
},
2020
});
2121

22-
const CLIView = ({ store, nav }) => (
23-
<SplitBackground color={color.blackDark} bottom={color.cliBackground}>
24-
<Header separator style={styles.header}>
25-
<BackButton onPress={() => nav.goSettings()} />
26-
<Title title="Logs" />
27-
<Button disabled onPress={() => {}} />
28-
</Header>
29-
<LogOutput logs={store.logs} />
30-
</SplitBackground>
31-
);
22+
class CLIView extends Component {
23+
render() {
24+
const { store, nav } = this.props;
25+
return (
26+
<SplitBackground color={color.blackDark} bottom={color.cliBackground}>
27+
<Header separator style={styles.header}>
28+
<BackButton onPress={() => nav.goSettings()} />
29+
<Title title="Logs" />
30+
<ShareButton onPress={() => this.shareLogs()} />
31+
</Header>
32+
<LogOutput logs={store.logs} />
33+
</SplitBackground>
34+
);
35+
}
36+
37+
shareLogs() {
38+
try {
39+
Share.share({
40+
message: this.props.store.logs,
41+
});
42+
} catch (err) {
43+
console.error(err);
44+
}
45+
}
46+
}
3247

3348
CLIView.propTypes = {
3449
store: PropTypes.object.isRequired,

0 commit comments

Comments
 (0)