eletrotupi / tcc/ frontend/components/ui/LinkRow.tsx204e7cf19d87a7f2cc816beab1279ba854cd1127
1.4 KB | 68 lines Raw
1
import React from "react";
2
import { StyleSheet, View, Switch } from "react-native";
3
import { Text } from "@/components/ui/Text";
4
import { Card } from "@/components/ui/Cards";
5
import { Typography, Colors, Spacing } from "@/constants/theme";
6

7
const styles = StyleSheet.create({
8
  linkRowCard: {
9
    padding: Spacing.cardGap,
10
    flex: 1,
11
    flexDirection: "row",
12
    alignItems: "flex-start",
13
    justifyContent: "space-between",
14
    gap: 12,
15
  },
16
  linkRowIcon: {
17
    width: 40,
18
    height: 40,
19
  },
20
  linkRowDescription: {
21
    flexGrow: 1,
22
  },
23
  linkRowLabel: {
24
    ...Typography.bodyLg,
25
  },
26
  linkRowSublabel: {
27
    ...Typography.labelSm,
28
  },
29
});
30

31
type LinkRowProps = {
32
  icon: React.ReactNode;
33
  label: string;
34
  sublabel: string;
35
  disabled?: boolean;
36
  value?: boolean;
37
  onToggle: (value: boolean) => void;
38
};
39

40
export const LinkRow = ({
41
  icon,
42
  label,
43
  sublabel,
44
  disabled,
45
  value,
46
  onToggle,
47
}: LinkRowProps) => {
48
  return (
49
    <Card
50
      style={styles.linkRowCard}
51
      onPress={() => !disabled && onToggle(!value)}
52
    >
53
      {icon}
54

55
      <View style={styles.linkRowDescription}>
56
        <Text style={styles.linkRowLabel}>{label}</Text>
57
        <Text style={styles.linkRowSublabel}>{sublabel}</Text>
58
      </View>
59

60
      <Switch
61
        value={value}
62
        trackColor={{ false: "#767577", true: Colors.light.tint }}
63
        disabled={disabled}
64
        onValueChange={onToggle}
65
      />
66
    </Card>
67
  );
68
};