aboutsummaryrefslogtreecommitdiffstats
path: root/components/Options.js
blob: fd0c21cb86d388d92f95ded96ef24a2e5ac62a38 (plain) (blame)
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
59
60
61
62
63
64
65
66
67
68
import * as React from 'react';
import { SafeAreaView, TextInput, StyleSheet, Text, TouchableOpacity } from 'react-native';
import * as SecureStore from 'expo-secure-store';

let a = true
export default function CategoryView(props) {
  let [font, setFont] = React.useState(0)

  async function setFontSS(f) {
    setFont(f);
    await SecureStore.setItemAsync('font', f.toString())
  }

  React.useEffect(() => getFont(setFont), [])
  if (a) {
    props.navigation.addListener('focus', () => getFont(setFont))
    a = false
  }

  return (
    <SafeAreaView style={styles.cont}>
      <Text style={styles.txt}>Selected font: {font}</Text>
      <TouchableOpacity onPress={() => setFontSS(12)}><Text style={[styles.txt, styles.btn]}>Font 12</Text></TouchableOpacity>
      <TouchableOpacity onPress={() => setFontSS(19)}><Text style={[styles.txt, styles.btn]}>Font 19</Text></TouchableOpacity >
      <TouchableOpacity onPress={() => setFontSS(26)}><Text style={[styles.txt, styles.btn]}>Font 26</Text></TouchableOpacity >
    </SafeAreaView >
  )
}
export async function getFont(setFont) {
  let font = await SecureStore.getItemAsync('font')
  if (!font) { font = 22; await SecureStore.setItemAsync('font', '22'); } else font = JSON.parse(font);
  setFont(parseInt(font));
}

const styles = StyleSheet.create({
  cont: {
    flex: 1,
    backgroundColor: "black",
    padding: 20,
    alignItems: "center"
  },
  ico: {
    width: 200,
    height: 200,
  },
  txt: {
    fontSize: 30,
    fontWeight: "bold",
    color: "#FFFFFF"
  },
  btn: {
    textAlign: "center",
    borderColor: "pink",
    borderWidth: 5,
    margin: 10,
    padding: 10,
  },
  input: {
    height: 40,
    width: "100%",
    margin: 12,
    borderWidth: 1,
    padding: 10,
    color: "#FFFFFF",
  }
})