/
App.tsx
58 lines (54 loc) · 1.5 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import React from 'react';
import type {PropsWithChildren} from 'react';
import {Alert, Button, StyleSheet, Text, View} from 'react-native';
import Slider from '@react-native-community/slider';
function Page({children}: PropsWithChildren<{}>) {
return (
// eslint-disable-next-line react-native/no-inline-styles
<View style={{flex: 1, alignItems: 'center', marginTop: 100}}>
{children}
</View>
);
}
function Section({title, children}: PropsWithChildren<{title: string}>) {
return (
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>{title}</Text>
{children}
</View>
);
}
export default function App() {
const [value, setValue] = React.useState(0.5);
return (
<Page>
<Section title="Standard">
<Text>Value: {value && +value.toFixed(3)}</Text>
<Slider value={value} onValueChange={setValue} />
</Section>
<Section title="Custom Color">
<Text>Value: {value && +value.toFixed(3)}</Text>
<Slider
value={value}
minimumTrackTintColor="red"
maximumTrackTintColor="green"
onValueChange={setValue}
thumbTintColor="gold"
/>
</Section>
<Section title="Test interaction">
<Button title="Test" onPress={() => Alert.alert('hi')} />
</Section>
</Page>
);
}
const styles = StyleSheet.create({
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
},
});