This repository has been archived by the owner on Jun 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c0d0b9
commit 93add38
Showing
3 changed files
with
34 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
import React from 'react' | ||
import { Text, TouchableOpacity } from 'react-native' | ||
import { Text, TouchableOpacity, StyleSheet } from 'react-native' | ||
import { purple } from '../utils/colors' | ||
|
||
export default function TextButton ({ children, onPress }) { | ||
export default function TextButton ({ children, onPress, style = {} }) { | ||
return ( | ||
<TouchableOpacity onPress={onPress}> | ||
<Text>{children}</Text> | ||
<Text style={[styles.reset, style]}>{children}</Text> | ||
</TouchableOpacity> | ||
) | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
reset: { | ||
textAlign: 'center', | ||
color: purple, | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,35 @@ | ||
import React from 'react' | ||
import { View, Slider, StyleSheet, Text } from 'react-native' | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
import { gray } from '../utils/colors' | ||
|
||
export default function UdaciSlider ({ max, unit, step, value, onChange }) { | ||
return ( | ||
<View> | ||
<View style={styles.row}> | ||
<Slider | ||
style={{flex: 1}} | ||
step={step} | ||
value={value} | ||
maximumValue={max} | ||
minimumValue={0} | ||
onValueChange={onChange} | ||
/> | ||
<View> | ||
<Text>{value}</Text> | ||
<Text>{unit}</Text> | ||
<View style={styles.metricCounter}> | ||
<Text style={{fontSize: 24, textAlign: 'center'}}>{value}</Text> | ||
<Text style={{fontSize: 18, color: gray}}>{unit}</Text> | ||
</View> | ||
</View> | ||
) | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
row: { | ||
flexDirection: 'row', | ||
flex: 1, | ||
alignItems: 'center', | ||
}, | ||
metricCounter: { | ||
width: 85, | ||
justifyContent: 'center', | ||
alignItems: 'center' | ||
}, | ||
}) |
instead of deprecated Slider, we can use this:
import Slider from '@react-native-community/slider'