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

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

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

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

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

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