Colota - Android GPS Location tracker
refactor: unify map action buttons via MapActionButton
Max Dietrich543bc78d2687
diff --git a/apps/mobile/src/components/features/map/ColotaMapView.tsx b/apps/mobile/src/components/features/map/ColotaMapView.tsxindex f7821030..657f74b7 100644--- a/apps/mobile/src/components/features/map/ColotaMapView.tsx+++ b/apps/mobile/src/components/features/map/ColotaMapView.tsx@@ -14,6 +14,7 @@ import { useTheme } from "../../../hooks/useTheme"import { DEFAULT_MAP_ZOOM, MAP_STYLE_URL_LIGHT, MAP_STYLE_URL_DARK } from "../../../constants"import { fonts } from "../../../styles/typography"import NativeLocationService from "../../../services/NativeLocationService"+import { MapActionButton, mapActionStyles } from "./MapActionButton"interface AttributionLink {url: string@@ -191,35 +192,24 @@ export const ColotaMapView = forwardRef<ColotaMapRef, Props>(function ColotaMapV{/* Custom compass button */}{showCompass && (- <Pressable- style={({ pressed }) => [- styles.compassButton,- { backgroundColor: colors.card, borderColor: colors.border },- pressed && { opacity: colors.pressedOpacity }- ]}- onPress={handleCompassPress}- >+ <MapActionButton onPress={handleCompassPress} style={[mapActionStyles.right, styles.compassPosition]}><View style={{ transform: [{ rotate: `${-heading}deg` }] }}><Compass size={20} color={colors.textLight} /></View>- </Pressable>+ </MapActionButton>)}{attributionLinks.length > 0 && (<>- <Pressable+ <MapActionButtononPress={() => setAttributionOpen(true)}+ style={mapActionStyles.right}hitSlop={8}- style={({ pressed }) => [- styles.attributionButton,- { backgroundColor: colors.card, borderColor: colors.border },- pressed && { opacity: colors.pressedOpacity }- ]}accessibilityRole="button"accessibilityLabel="Show map attribution"><Info size={20} color={colors.textLight} />- </Pressable>+ </MapActionButton><Modaltransparent@@ -265,40 +255,7 @@ export const ColotaMapView = forwardRef<ColotaMapRef, Props>(function ColotaMapVconst styles = StyleSheet.create({container: { flex: 1 },map: { flex: 1 },- compassButton: {- position: "absolute",- bottom: 126,- right: 16,- width: 40,- height: 40,- borderRadius: 20,- justifyContent: "center",- alignItems: "center",- elevation: 5,- shadowColor: "#000",- shadowOffset: { width: 0, height: 2 },- shadowOpacity: 0.25,- shadowRadius: 3.84,- borderWidth: 1,- zIndex: 10- },- attributionButton: {- position: "absolute",- bottom: 30,- right: 16,- width: 40,- height: 40,- borderRadius: 20,- alignItems: "center",- justifyContent: "center",- borderWidth: 1,- elevation: 5,- shadowColor: "#000",- shadowOffset: { width: 0, height: 2 },- shadowOpacity: 0.25,- shadowRadius: 3.84,- zIndex: 10- },+ compassPosition: { bottom: 126 },attributionBackdrop: {flex: 1,backgroundColor: "rgba(0, 0, 0, 0.4)",diff --git a/apps/mobile/src/components/features/map/MapActionButton.tsx b/apps/mobile/src/components/features/map/MapActionButton.tsxindex b3d182ec..2c7156f2 100644--- a/apps/mobile/src/components/features/map/MapActionButton.tsx+++ b/apps/mobile/src/components/features/map/MapActionButton.tsx@@ -4,27 +4,33 @@*/import React from "react"-import { Pressable, StyleSheet, ViewStyle, StyleProp } from "react-native"+import { Pressable, StyleSheet, ViewStyle, StyleProp, PressableProps } from "react-native"import { useTheme } from "../../../hooks/useTheme"interface Props {onPress: () => voidstyle?: StyleProp<ViewStyle>children: React.ReactNode+ hitSlop?: PressableProps["hitSlop"]+ accessibilityLabel?: string+ accessibilityRole?: PressableProps["accessibilityRole"]}-export function MapActionButton({ onPress, style, children }: Props) {+export function MapActionButton({ onPress, style, children, hitSlop, accessibilityLabel, accessibilityRole }: Props) {const { colors } = useTheme()return (<Pressablestyle={({ pressed }) => [styles.button,- { backgroundColor: colors.card, borderColor: colors.border },+ { backgroundColor: colors.card },style,pressed && { opacity: colors.pressedOpacity }]}onPress={onPress}+ hitSlop={hitSlop}+ accessibilityLabel={accessibilityLabel}+ accessibilityRole={accessibilityRole}>{children}</Pressable>@@ -37,7 +43,7 @@ const styles = StyleSheet.create({bottom: 30,width: 40,height: 40,- borderRadius: 20,+ borderRadius: 12,justifyContent: "center",alignItems: "center",elevation: 5,@@ -45,7 +51,6 @@ const styles = StyleSheet.create({shadowOffset: { width: 0, height: 2 },shadowOpacity: 0.25,shadowRadius: 3.84,- borderWidth: 1,zIndex: 10},right: { right: 16 },