Skip to content

Colota - Android GPS Location tracker

1.7 KB
Raw Blame
/**
 * Copyright (C) 2026 Max Dietrich
 * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.
 */

import React from "react"
import { View, Text, StyleSheet, type StyleProp, type ViewStyle } from "react-native"
import { fontSizes, fonts, lineHeights } from "../../styles/typography"
import { useTheme } from "../../hooks/useTheme"
import { space, size } from "../../constants"

interface SettingRowProps {
  label: string
  hint?: string
  children: React.ReactNode
  style?: StyleProp<ViewStyle>
  disabled?: boolean
}

export function SettingRow({ label, hint, children, style, disabled = false }: SettingRowProps) {
  const { colors } = useTheme()
  return (
    <View style={[styles.settingRow, style]}>
      <View style={styles.settingContent}>
        <Text style={[styles.settingLabel, { color: disabled ? colors.textDisabled : colors.text }]}>{label}</Text>
        {hint && (
          <Text style={[styles.settingHint, { color: disabled ? colors.textDisabled : colors.textSecondary }]}>
            {hint}
          </Text>
        )}
      </View>
      {children}
    </View>
  )
}

const styles = StyleSheet.create({
  settingRow: {
    flexDirection: "row",
    justifyContent: "space-between",
    alignItems: "center",
    minHeight: size.row,
    paddingVertical: space.lg,
    // See ListItem: the inset is cancelled and reapplied so a press fills the card's width.
    marginHorizontal: -space.lg,
    paddingHorizontal: space.lg
  },
  settingContent: {
    flex: 1,
    marginEnd: space.lg
  },
  settingLabel: {
    fontSize: fontSizes.label,
    ...fonts.semiBold,
    marginBottom: space.xxs
  },
  settingHint: {
    fontSize: fontSizes.description,
    ...fonts.regular,
    lineHeight: lineHeights.description
  }
})