All files / src/app/settings index.tsx

100% Statements 8/8
50% Branches 1/2
100% Functions 4/4
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146                        1x                                                                                           9x 9x   9x                 63x   63x         7x                                                       1x                                                                                
import React from "react";
import { StyleSheet, Text, View, ScrollView, Pressable } from "react-native";
import { Ionicons } from "@expo/vector-icons";
import { useRouter, type Href } from "expo-router";
import type { ComponentProps } from "react";
import { useTheme } from "../../hooks/useTheme";
 
const SETTINGS_ITEMS: Array<{
  id: string;
  label: string;
  icon: ComponentProps<typeof Ionicons>["name"];
  href: Href;
}> = [
  {
    id: "general",
    label: "General",
    icon: "options-outline",
    href: "/settings/general",
  },
  {
    id: "display",
    label: "Display & Brightness",
    icon: "sunny-outline",
    href: "/settings/display",
  },
  {
    id: "location",
    label: "Location & Privacy",
    icon: "location-outline",
    href: "/settings/location-privacy",
  },
  {
    id: "navigation",
    label: "Navigation",
    icon: "navigate-outline",
    href: "/settings/navigation",
  },
  {
    id: "accessibility",
    label: "Accessibility",
    icon: "accessibility-outline",
    href: "/settings/accessibility",
  },
  {
    id: "about",
    label: "About",
    icon: "information-circle-outline",
    href: "/settings/about",
  },
  {
    id: "terms",
    label: "Terms",
    icon: "document-text-outline",
    href: "/settings/terms",
  },
];
 
export default function SettingsIndexPage() {
  const router = useRouter();
  const { colors } = useTheme();
 
  return (
    <View style={[styles.container, { backgroundColor: colors.background }]}>
      <Text style={[styles.title, { color: colors.text }]}>Settings</Text>
      <ScrollView
        style={styles.scroll}
        contentContainerStyle={styles.scrollContent}
        showsVerticalScrollIndicator={false}
      >
        {SETTINGS_ITEMS.map((item) => (
          <Pressable
            key={item.id}
            style={({ pressed }) => [
              styles.card,
              { backgroundColor: colors.card },
              pressed && styles.cardPressed,
            ]}
            onPress={() => router.push(item.href)}
          >
            <View
              style={[
                styles.iconCircle,
                {
                  backgroundColor: colors.primary,
                  borderColor: colors.primaryBorder,
                },
              ]}
            >
              <Ionicons name={item.icon} size={22} color="#fff" />
            </View>
            <Text style={[styles.label, { color: colors.text }]}>
              {item.label}
            </Text>
            <Ionicons
              name="chevron-forward"
              size={20}
              color={colors.textMuted}
            />
          </Pressable>
        ))}
      </ScrollView>
    </View>
  );
}
 
const styles = StyleSheet.create({
  container: { flex: 1 },
  title: {
    fontSize: 24,
    fontWeight: "700",
    textAlign: "center",
    marginTop: 24,
    marginBottom: 20,
  },
  scroll: { flex: 1 },
  scrollContent: { paddingHorizontal: 20, paddingBottom: 100 },
  card: {
    flexDirection: "row",
    alignItems: "center",
    borderRadius: 12,
    paddingVertical: 14,
    paddingHorizontal: 16,
    marginBottom: 12,
    shadowColor: "#000",
    shadowOffset: { width: 0, height: 2 },
    shadowOpacity: 0.06,
    shadowRadius: 8,
    elevation: 3,
  },
  cardPressed: { opacity: 0.85 },
  iconCircle: {
    width: 44,
    height: 44,
    borderRadius: 22,
    borderWidth: 2,
    alignItems: "center",
    justifyContent: "center",
    marginRight: 14,
  },
  label: {
    flex: 1,
    fontSize: 16,
    fontWeight: "500",
  },
});