Skip to content

Colota - Android GPS Location tracker

1.1 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 { ViewStyle, StyleProp, StyleSheet } from "react-native"
import { LocateFixed } from "lucide-react-native"
import { useTheme } from "../../../hooks/useTheme"
import { MapActionButton, mapActionStyles } from "./MapActionButton"
import { size, space } from "../../../constants"
import { useTranslation } from "../../../i18n/useTranslation"

interface Props {
  onPress: () => void
  visible: boolean
  style?: StyleProp<ViewStyle>
}

export const MapCenterButton: React.FC<Props> = ({ onPress, visible, style }) => {
  const { colors } = useTheme()
  const { t } = useTranslation()

  if (!visible) return null

  return (
    <MapActionButton
      onPress={onPress}
      style={[mapActionStyles.right, styles.position, style]}
      accessibilityRole="button"
      accessibilityLabel={t("map.centre")}
    >
      <LocateFixed size={size.icon.md} color={colors.textLight} />
    </MapActionButton>
  )
}

const styles = StyleSheet.create({
  position: { bottom: space.xxl + size.iconColumn + space.lg }
})