Skip to content

Commit

Permalink
Refactoring the copy-pasted buttons styles. (Path-Check#26)
Browse files Browse the repository at this point in the history
* Refactoring the copy-pasted buttons styles.

* Remove dead NegButton references

This also includes some code reformatting from VS Code, but mainly it
removes dangling references to the NegViews.

Co-authored-by: Steve Penrod <github@gpll.org>
Co-authored-by: Steve Penrod <steve@tripleblind.market>
  • Loading branch information
3 people committed Mar 20, 2020
1 parent 1b404eb commit e621cb4
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 195 deletions.
6 changes: 3 additions & 3 deletions app/components/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import colors from "../constants/colors";

interface Props {
label: string;
bgColor: string;
onPress: () => void;
}

class Button extends React.Component<Props> {
render() {
const { title, onPress } = this.props;
const { title, onPress, bgColor } = this.props;
return (
<TouchableOpacity style={styles.container} onPress={onPress}>
<TouchableOpacity style={[styles.container, {backgroundColor: bgColor || colors.DODGER_BLUE}]} onPress={onPress} >
<Text style={styles.text}>{title}</Text>
</TouchableOpacity>
);
Expand All @@ -23,7 +24,6 @@ const styles = StyleSheet.create({
width: "100%",
alignItems: "center",
justifyContent: "center",
backgroundColor: colors.DODGER_BLUE,
paddingVertical: 12,
borderRadius: 4,
borderWidth: StyleSheet.hairlineWidth,
Expand Down
41 changes: 0 additions & 41 deletions app/components/NegButton.js

This file was deleted.

41 changes: 0 additions & 41 deletions app/components/PosButton.js

This file was deleted.

41 changes: 0 additions & 41 deletions app/components/SensButton.js

This file was deleted.

7 changes: 6 additions & 1 deletion app/constants/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ const colors = {
APP_BACKGROUND: '#FFF8ED',
PRIMARY_TEXT: "#000",
GREEN: "#32A852",
VIOLET: "#6C3794"
VIOLET: "#6C3794",

REG_BUTTON: "#428AF8",
POS_BUTTON: "#32A852",
NEG_BUTTON: "#F8262F",
SENS_BUTTON: "#6C3794"
};

export default colors;
47 changes: 23 additions & 24 deletions app/views/Export.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import React, { Component } from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
Linking,
View,
Text,
Alert,
Image,
Share
SafeAreaView,
StyleSheet,
ScrollView,
Linking,
View,
Text,
Alert,
Image
Share
} from 'react-native';

import colors from "../constants/colors";
import { WebView } from 'react-native-webview';
import WebView from 'react-native-webview';
import Button from "../components/Button";
import NegButton from "../components/NegButton";
import BackgroundGeolocation from '@mauron85/react-native-background-geolocation';
import {GetStoreData} from '../helpers/General';

Expand Down Expand Up @@ -64,7 +63,7 @@ class ExportScreen extends Component {
<>
<View style={styles.main}>
<View style={styles.headerTitle}>
<Text style={styles.sectionDescription, {fontSize: 22, marginTop: 10}}>Export Data</Text>
<Text style={styles.sectionDescription, { fontSize: 22, marginTop: 10 }}>Export Data</Text>
</View>
<View style={styles.block}>
<Button onPress={this.onShare} title="Share" />
Expand Down Expand Up @@ -111,10 +110,10 @@ const styles = StyleSheet.create({
width: "95%"
},
block: {
margin: 20,
width: "75%",
alignItems: 'center',
justifyContent: 'center'
margin: 20,
width: "75%",
alignItems: 'center',
justifyContent: 'center'
},
topView: {
flex: 1,
Expand All @@ -133,13 +132,13 @@ const styles = StyleSheet.create({
alignItems: 'stretch',
},
sectionDescription: {
fontSize: 18,
lineHeight: 24,
fontWeight: '400',
marginTop: 20,
marginLeft: 10,
marginRight: 10
fontSize: 18,
lineHeight: 24,
fontWeight: '400',
marginTop: 20,
marginLeft: 10,
marginRight: 10
}
});
});

export default ExportScreen;
export default ExportScreen;
71 changes: 35 additions & 36 deletions app/views/Import.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import React, { Component } from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
Linking,
View,
Text,
Alert
SafeAreaView,
StyleSheet,
ScrollView,
Linking,
View,
Text,
Alert
} from 'react-native';

import colors from "../constants/colors";
import { WebView } from 'react-native-webview';
import WebView from 'react-native-webview';
import Button from "../components/Button";
import NegButton from "../components/NegButton";
import BackgroundGeolocation from '@mauron85/react-native-background-geolocation';

class ImportScreen extends Component {
Expand Down Expand Up @@ -111,25 +110,25 @@ class ImportScreen extends Component {
render() {
return (
<>
<View style={styles.main}>
<View style={styles.headerTitle}>
<Text style={styles.sectionDescription, {fontSize: 22, marginTop: 8}}>Import Data:</Text>
<View style={styles.main}>
<View style={styles.headerTitle}>
<Text style={styles.sectionDescription, { fontSize: 22, marginTop: 8 }}>Import Data:</Text>
</View>
<View style={styles.subHeaderTitle}>
<Text style={styles.sectionDescription, { fontSize: 18, marginTop: 8 }}>Rolling out soon</Text>
</View>
<View style={styles.web}>
<WebView
source={{ uri: 'http://privatekit.mit.edu' }}
style={{ marginTop: 15, marginLeft: 15 }}
/>
</View>
</View>
<View style={styles.subHeaderTitle}>
<Text style={styles.sectionDescription, {fontSize: 18, marginTop: 8}}>Rolling out soon</Text>
<View style={styles.footer}>
<Text style={styles.sectionDescription, { textAlign: 'center', paddingTop: 15 }}>For more information visit the Private Kit hompage:</Text>
<Text style={styles.sectionDescription, { color: 'blue', textAlign: 'center' }} onPress={() => Linking.openURL('https://privatekit.mit.edu')}>privatekit.mit.edu</Text>
</View>
<View style={styles.web}>
<WebView
source= {{ uri: 'http://privatekit.mit.edu' }}
style= {{ marginTop: 15, marginLeft: 15}}
/>
</View>
</View>
<View style={styles.footer}>
<Text style={styles.sectionDescription, { textAlign: 'center', paddingTop: 15 }}>For more information visit the Private Kit hompage:</Text>
<Text style={styles.sectionDescription, { color: 'blue', textAlign: 'center' }} onPress={() => Linking.openURL('https://privatekit.mit.edu')}>privatekit.mit.edu</Text>
</View>
</>
</>
)
}
}
Expand Down Expand Up @@ -168,8 +167,8 @@ const styles = StyleSheet.create({
width: "95%"
},
block: {
margin: 20,
width: "100%"
margin: 20,
width: "100%"
},
topView: {
flex: 1,
Expand All @@ -188,12 +187,12 @@ const styles = StyleSheet.create({
alignItems: 'stretch',
},
sectionDescription: {
fontSize: 18,
lineHeight: 24,
fontWeight: '400',
marginTop: 20,
marginLeft: 10,
marginRight: 10
fontSize: 18,
lineHeight: 24,
fontWeight: '400',
marginTop: 20,
marginLeft: 10,
marginRight: 10
}
});
export default ImportScreen;
});
export default ImportScreen;
11 changes: 4 additions & 7 deletions app/views/LocationTracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import {
import colors from "../constants/colors";
import { WebView } from 'react-native-webview';
import Button from "../components/Button";
import NegButton from "../components/NegButton";
import PosButton from "../components/PosButton";
import SensButton from "../components/SensButton";
import BackgroundGeolocation from '@mauron85/react-native-background-geolocation';

import {GetStoreData, SetStoreData} from '../helpers/General';
Expand Down Expand Up @@ -201,19 +198,19 @@ class LocationTracking extends Component {
</View>

<View style={styles.block}>
<NegButton title={"Stop Recording Location"} onPress={() => this.optOut()} />
<Button title={"Stop Recording Location"} bgColor={colors.NEG_BUTTON} onPress={() => this.optOut()} />
</View>

<View style={styles.block}>
<PosButton title={"News"} onPress={() => this.news()} />
<Button title={"News"} bgColor={colors.POS_BUTTON} onPress={() => this.news()} />
</View>

<View style={styles.block}>
<SensButton title={"Import"} onPress={() => this.import()} />
<Button title={"Import"} bgColor={colors.SENS_BUTTON} onPress={() => this.import()} />
</View>

<View style={styles.block}>
<SensButton title={"Export"} onPress={() => this.export()} />
<Button title={"Export"} bgColor={colors.SENS_BUTTON} onPress={() => this.export()} />
</View>

</View>
Expand Down
1 change: 0 additions & 1 deletion app/views/News.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
import colors from "../constants/colors";
import { WebView } from 'react-native-webview';
import Button from "../components/Button";
import NegButton from "../components/NegButton";
import BackgroundGeolocation from '@mauron85/react-native-background-geolocation';

class NewsScreen extends Component {
Expand Down

0 comments on commit e621cb4

Please sign in to comment.