Skip to content

Colota - Android GPS Location tracker

Improve touch reliability and reduce unnecessary re-renders

Max Dietrich8ddf94c7cef4
diff --git a/apps/mobile/src/components/features/dashboard/QuickAccess.tsx b/apps/mobile/src/components/features/dashboard/QuickAccess.tsx
index 362af1f4..86524036 100644
--- a/apps/mobile/src/components/features/dashboard/QuickAccess.tsx
+++ b/apps/mobile/src/components/features/dashboard/QuickAccess.tsx
@@ -3,7 +3,7 @@
* Licensed under the GNU AGPLv3. See LICENSE in the project root for details.
*/
import React from "react"
-import { View, StyleSheet, Text, TouchableOpacity, Linking } from "react-native"
+import { View, StyleSheet, Text, Pressable, Linking } from "react-native"
import { Settings, Fence, Search, Download, Info, Heart, LucideIcon } from "lucide-react-native"
import { useTheme } from "../../../hooks/useTheme"
import { fonts } from "../../../styles/typography"
@@ -67,15 +67,15 @@ export function QuickAccess({ navigation }: QuickAccessProps) {
<SectionTitle>QUICK ACCESS</SectionTitle>
<View style={styles.navGrid}>
{navItems.map((item) => (
- <TouchableOpacity
+ <Pressable
key={item.name}
- activeOpacity={0.7}
- style={[
+ style={({ pressed }) => [
styles.navItem,
{
backgroundColor: colors.card,
borderColor: colors.border
- }
+ },
+ pressed && { opacity: 0.7 }
]}
onPress={item.onPress}
>
@@ -94,7 +94,7 @@ export function QuickAccess({ navigation }: QuickAccessProps) {
<Text style={[styles.navLabel, { color: colors.text }]} numberOfLines={1}>
{item.name}
</Text>
- </TouchableOpacity>
+ </Pressable>
))}
</View>
</View>
diff --git a/apps/mobile/src/components/features/dashboard/ServerConnection.tsx b/apps/mobile/src/components/features/dashboard/ServerConnection.tsx
index 955c646a..5efec0a7 100644
--- a/apps/mobile/src/components/features/dashboard/ServerConnection.tsx
+++ b/apps/mobile/src/components/features/dashboard/ServerConnection.tsx
@@ -4,7 +4,7 @@
*/
import React, { useState, useCallback, useMemo, useRef } from "react"
-import { StyleSheet, View, Text, TouchableOpacity } from "react-native"
+import { StyleSheet, View, Text, Pressable } from "react-native"
import { ChevronRight } from "lucide-react-native"
import { useFocusEffect } from "@react-navigation/native"
import { useTheme } from "../../../hooks/useTheme"
@@ -118,10 +118,13 @@ export function ServerConnection({ endpoint, navigation }: ServerConnectionProps
}, [serverStatus, colors, isOffline])
return (
- <TouchableOpacity
- activeOpacity={0.7}
+ <Pressable
onPress={() => navigation.navigate("Settings")}
- style={[styles.container, { backgroundColor: colors.card, borderColor: colors.border }]}
+ style={({ pressed }) => [
+ styles.container,
+ { backgroundColor: colors.card, borderColor: colors.border },
+ pressed && { opacity: 0.7 }
+ ]}
>
<View style={[styles.dot, { backgroundColor: config.color }]} />
<Text style={[styles.host, { color: colors.text }]} numberOfLines={1}>
@@ -129,7 +132,7 @@ export function ServerConnection({ endpoint, navigation }: ServerConnectionProps
</Text>
<Text style={[styles.status, { color: config.color }]}>{config.label}</Text>
<ChevronRight size={16} color={colors.textLight} />
- </TouchableOpacity>
+ </Pressable>
)
}
diff --git a/apps/mobile/src/components/features/dashboard/WelcomeCard.tsx b/apps/mobile/src/components/features/dashboard/WelcomeCard.tsx
index 53d2fc22..0adf4174 100644
--- a/apps/mobile/src/components/features/dashboard/WelcomeCard.tsx
+++ b/apps/mobile/src/components/features/dashboard/WelcomeCard.tsx
@@ -4,7 +4,7 @@
*/
import React from "react"
-import { Text, StyleSheet, View, TouchableOpacity } from "react-native"
+import { Text, StyleSheet, View, Pressable } from "react-native"
import { Check, ChevronRight } from "lucide-react-native"
import { Settings, ThemeColors } from "../../../types/global"
import { fonts } from "../../../styles/typography"
@@ -57,9 +57,9 @@ function ChecklistItem({ label, completed, colors, onPress }: ChecklistItemProps
if (onPress && !completed) {
return (
- <TouchableOpacity onPress={onPress} activeOpacity={0.6}>
+ <Pressable onPress={onPress} style={({ pressed }) => pressed && { opacity: 0.6 }}>
{content}
- </TouchableOpacity>
+ </Pressable>
)
}
@@ -94,21 +94,20 @@ export function WelcomeCard({
</View>
<View style={styles.linkRow}>
- <TouchableOpacity onPress={onNavigateToApiConfig} activeOpacity={0.6}>
+ <Pressable onPress={onNavigateToApiConfig} style={({ pressed }) => pressed && { opacity: 0.6 }}>
<Text style={[styles.link, { color: colors.primaryDark }]}>API field mapping</Text>
- </TouchableOpacity>
- <TouchableOpacity onPress={onNavigateToSettings} activeOpacity={0.6}>
+ </Pressable>
+ <Pressable onPress={onNavigateToSettings} style={({ pressed }) => pressed && { opacity: 0.6 }}>
<Text style={[styles.link, { color: colors.primaryDark }]}>Tracking presets</Text>
- </TouchableOpacity>
+ </Pressable>
</View>
- <TouchableOpacity
- style={[styles.dismissButton, { borderColor: colors.border }]}
+ <Pressable
+ style={({ pressed }) => [styles.dismissButton, { borderColor: colors.border }, pressed && { opacity: 0.6 }]}
onPress={onDismiss}
- activeOpacity={0.6}
>
<Text style={[styles.dismissText, { color: colors.textSecondary }]}>Got it</Text>
- </TouchableOpacity>
+ </Pressable>
</Card>
</View>
)
diff --git a/apps/mobile/src/components/features/inspector/DatePicker.tsx b/apps/mobile/src/components/features/inspector/DatePicker.tsx
index 7fc0a796..65a241cc 100644
--- a/apps/mobile/src/components/features/inspector/DatePicker.tsx
+++ b/apps/mobile/src/components/features/inspector/DatePicker.tsx
@@ -4,7 +4,7 @@
*/
import React from "react"
-import { View, Text, TouchableOpacity, StyleSheet } from "react-native"
+import { View, Text, Pressable, StyleSheet } from "react-native"
import { ChevronLeft, ChevronRight } from "lucide-react-native"
import { ThemeColors } from "../../../types/global"
import { fonts } from "../../../styles/typography"
@@ -51,31 +51,38 @@ export function DatePicker({ date, onDateChange, locationCount, distance, colors
return (
<View style={[styles.container, { borderBottomColor: colors.border }]}>
<View style={styles.row}>
- <TouchableOpacity onPress={goBack} style={styles.navBtn} activeOpacity={0.6}>
+ <Pressable onPress={goBack} style={({ pressed }) => [styles.navBtn, pressed && { opacity: 0.6 }]}>
<ChevronLeft size={22} color={colors.primary} />
- </TouchableOpacity>
+ </Pressable>
- <TouchableOpacity onPress={goToToday} style={styles.dateContainer} activeOpacity={0.7}>
+ <Pressable onPress={goToToday} style={({ pressed }) => [styles.dateContainer, pressed && { opacity: 0.7 }]}>
<Text style={[styles.dateText, { color: colors.text }]}>{formatted}</Text>
<Text style={[styles.countText, { color: colors.textSecondary }]}>
{locationCount} {locationCount === 1 ? "location" : "locations"}
{distance ? ` · ${distance}` : ""}
</Text>
- </TouchableOpacity>
+ </Pressable>
- <TouchableOpacity onPress={goForward} style={styles.navBtn} activeOpacity={0.6} disabled={isToday}>
+ <Pressable
+ onPress={goForward}
+ style={({ pressed }) => [styles.navBtn, pressed && { opacity: 0.6 }]}
+ disabled={isToday}
+ >
<ChevronRight size={22} color={isToday ? colors.textDisabled : colors.primary} />
- </TouchableOpacity>
+ </Pressable>
</View>
{!isToday && (
- <TouchableOpacity
+ <Pressable
onPress={goToToday}
- style={[styles.todayBtn, { backgroundColor: colors.primary + "15" }]}
- activeOpacity={0.7}
+ style={({ pressed }) => [
+ styles.todayBtn,
+ { backgroundColor: colors.primary + "15" },
+ pressed && { opacity: 0.7 }
+ ]}
>
<Text style={[styles.todayText, { color: colors.primary }]}>Today</Text>
- </TouchableOpacity>
+ </Pressable>
)}
</View>
)
diff --git a/apps/mobile/src/components/features/inspector/TrackMap.tsx b/apps/mobile/src/components/features/inspector/TrackMap.tsx
index c6c3f561..d59d2935 100644
--- a/apps/mobile/src/components/features/inspector/TrackMap.tsx
+++ b/apps/mobile/src/components/features/inspector/TrackMap.tsx
@@ -4,7 +4,7 @@
*/
import React, { useRef, useEffect, useMemo, useState, useCallback } from "react"
-import { View, StyleSheet, Text, TouchableOpacity } from "react-native"
+import { View, StyleSheet, Text, Pressable } from "react-native"
import { ShapeSource, LineLayer, CircleLayer } from "@maplibre/maplibre-react-native"
import { MapPinOff, X } from "lucide-react-native"
import { ThemeColors } from "../../../types/global"
@@ -239,9 +239,13 @@ export function TrackMap({ locations, selectedPoint, colors }: Props) {
<Text style={[styles.popupTime, { color: colors.text }]}>
{popup.timestamp ? new Date(popup.timestamp * 1000).toLocaleTimeString() : "—"}
</Text>
- <TouchableOpacity onPress={() => setPopup(null)} hitSlop={{ top: 8, right: 8, bottom: 8, left: 8 }}>
+ <Pressable
+ onPress={() => setPopup(null)}
+ hitSlop={{ top: 8, right: 8, bottom: 8, left: 8 }}
+ style={({ pressed }) => pressed && { opacity: 0.7 }}
+ >
<X size={16} color={colors.textSecondary} />
- </TouchableOpacity>
+ </Pressable>
</View>
<View style={styles.popupRow}>
<Text style={[styles.popupLabel, { color: colors.textSecondary }]}>Speed</Text>
diff --git a/apps/mobile/src/components/features/map/ColotaMapView.tsx b/apps/mobile/src/components/features/map/ColotaMapView.tsx
index 5db2e37e..28db4557 100644
--- a/apps/mobile/src/components/features/map/ColotaMapView.tsx
+++ b/apps/mobile/src/components/features/map/ColotaMapView.tsx
@@ -4,7 +4,7 @@
*/
import React, { useRef, useImperativeHandle, forwardRef, useState, useEffect, useCallback } from "react"
-import { StyleProp, ViewStyle, View, Text, StyleSheet, Linking, TouchableOpacity } from "react-native"
+import { StyleProp, ViewStyle, View, Text, StyleSheet, Linking, Pressable } from "react-native"
import { MapView, Camera } from "@maplibre/maplibre-react-native"
import type { MapViewRef, CameraRef } from "@maplibre/maplibre-react-native"
import type { RegionPayload } from "@maplibre/maplibre-react-native"
@@ -135,29 +135,35 @@ export const ColotaMapView = forwardRef<ColotaMapRef, Props>(function ColotaMapV
{/* Custom compass button */}
{showCompass && (
- <TouchableOpacity
- style={[styles.compassButton, { backgroundColor: colors.card, borderColor: colors.border }]}
+ <Pressable
+ style={({ pressed }) => [
+ styles.compassButton,
+ { backgroundColor: colors.card, borderColor: colors.border },
+ pressed && { opacity: 0.7 }
+ ]}
onPress={handleCompassPress}
- activeOpacity={0.7}
>
<View style={{ transform: [{ rotate: `${-heading}deg` }] }}>
<Compass size={24} color={colors.text} />
</View>
- </TouchableOpacity>
+ </Pressable>
)}
{/* Attribution */}
<View style={[styles.attribution, { backgroundColor: colors.card + "CC" }]}>
- <TouchableOpacity onPress={() => Linking.openURL("https://openfreemap.org")} activeOpacity={0.7}>
+ <Pressable
+ onPress={() => Linking.openURL("https://openfreemap.org")}
+ style={({ pressed }) => pressed && { opacity: 0.7 }}
+ >
<Text style={[styles.attributionText, { color: colors.link }, fonts.regular]}>OpenFreeMap</Text>
- </TouchableOpacity>
+ </Pressable>
<Text style={[styles.attributionSep, { color: colors.textLight }]}>{" | "}</Text>
- <TouchableOpacity
+ <Pressable
onPress={() => Linking.openURL("https://www.openstreetmap.org/copyright")}
- activeOpacity={0.7}
+ style={({ pressed }) => pressed && { opacity: 0.7 }}
>
<Text style={[styles.attributionText, { color: colors.link }, fonts.regular]}>OSM</Text>
- </TouchableOpacity>
+ </Pressable>
</View>
</View>
)
diff --git a/apps/mobile/src/components/features/map/MapCenterButton.tsx b/apps/mobile/src/components/features/map/MapCenterButton.tsx
index f5d83b87..89a40339 100644
--- a/apps/mobile/src/components/features/map/MapCenterButton.tsx
+++ b/apps/mobile/src/components/features/map/MapCenterButton.tsx
@@ -4,7 +4,7 @@
*/
import React from "react"
-import { TouchableOpacity, StyleSheet, ViewStyle, StyleProp } from "react-native"
+import { Pressable, StyleSheet, ViewStyle, StyleProp } from "react-native"
import { LocateFixed } from "lucide-react-native"
import { useTheme } from "../../../hooks/useTheme"
@@ -20,13 +20,17 @@ export const MapCenterButton: React.FC<Props> = ({ onPress, visible, style }) =>
if (!visible) return null
return (
- <TouchableOpacity
- style={[styles.centerButton, { backgroundColor: colors.card, borderColor: colors.border }, style]}
+ <Pressable
+ style={({ pressed }) => [
+ styles.centerButton,
+ { backgroundColor: colors.card, borderColor: colors.border },
+ style,
+ pressed && { opacity: 0.7 }
+ ]}
onPress={onPress}
- activeOpacity={0.7}
>
<LocateFixed size={24} color={colors.text} />
- </TouchableOpacity>
+ </Pressable>
)
}
diff --git a/apps/mobile/src/components/features/settings/ConnectionSettings.tsx b/apps/mobile/src/components/features/settings/ConnectionSettings.tsx
index 84dc2431..5b4996f5 100644
--- a/apps/mobile/src/components/features/settings/ConnectionSettings.tsx
+++ b/apps/mobile/src/components/features/settings/ConnectionSettings.tsx
@@ -4,7 +4,7 @@
*/
import React, { useState, useCallback } from "react"
-import { Text, StyleSheet, TextInput, Switch, View, TouchableOpacity } from "react-native"
+import { Text, StyleSheet, TextInput, Switch, View, Pressable } from "react-native"
import { CheckCircle, ChevronRight } from "lucide-react-native"
import { Settings, ThemeColors } from "../../../types/global"
import NativeLocationService from "../../../services/NativeLocationService"
@@ -236,10 +236,9 @@ export function ConnectionSettings({
<Divider />
- <TouchableOpacity
- style={styles.linkRow}
+ <Pressable
+ style={({ pressed }) => [styles.linkRow, pressed && { opacity: 0.6 }]}
onPress={() => navigation.navigate("Auth Settings")}
- activeOpacity={0.6}
>
<View style={styles.linkContent}>
<Text style={[styles.linkLabel, { color: colors.text }]}>Authentication & Headers</Text>
@@ -248,7 +247,7 @@ export function ConnectionSettings({
</Text>
</View>
<ChevronRight size={20} color={colors.textLight} />
- </TouchableOpacity>
+ </Pressable>
</>
)}
</Card>
diff --git a/apps/mobile/src/components/features/settings/PresetOption.tsx b/apps/mobile/src/components/features/settings/PresetOption.tsx
index 791d1f44..9248fc92 100644
--- a/apps/mobile/src/components/features/settings/PresetOption.tsx
+++ b/apps/mobile/src/components/features/settings/PresetOption.tsx
@@ -3,7 +3,7 @@
* Licensed under the GNU AGPLv3. See LICENSE in the project root for details.
*/
import React from "react"
-import { View, Text, StyleSheet, TouchableOpacity } from "react-native"
+import { View, Text, StyleSheet, Pressable } from "react-native"
import { Zap, Check } from "lucide-react-native"
import { ThemeColors, SelectablePreset, TRACKING_PRESETS } from "../../../types/global"
import { fonts } from "../../../styles/typography"
@@ -32,15 +32,15 @@ export function PresetOption({ preset, isSelected, onSelect, colors }: PresetOpt
const radioBgColor = isSelected ? colors.primary + "20" : "transparent"
return (
- <TouchableOpacity
- style={[
+ <Pressable
+ style={({ pressed }) => [
styles.container,
{
backgroundColor: isSelected ? colors.primary + "12" : colors.background
- }
+ },
+ pressed && { opacity: 0.7 }
]}
onPress={() => onSelect(preset)}
- activeOpacity={0.7}
>
{/* Selection indicator bar */}
{isSelected && <View style={[styles.selectionBar, { backgroundColor: colors.primary }]} />}
@@ -101,7 +101,7 @@ export function PresetOption({ preset, isSelected, onSelect, colors }: PresetOpt
{isSelected && <View style={[styles.radioInner, { backgroundColor: colors.primary }]} />}
</View>
</View>
- </TouchableOpacity>
+ </Pressable>
)
}
diff --git a/apps/mobile/src/components/features/settings/StatsCard.tsx b/apps/mobile/src/components/features/settings/StatsCard.tsx
index 8907c781..23d4d3e9 100644
--- a/apps/mobile/src/components/features/settings/StatsCard.tsx
+++ b/apps/mobile/src/components/features/settings/StatsCard.tsx
@@ -3,7 +3,7 @@
* Licensed under the GNU AGPLv3. See LICENSE in the project root for details.
*/
import React from "react"
-import { View, Text, StyleSheet, TouchableOpacity } from "react-native"
+import { View, Text, StyleSheet, Pressable } from "react-native"
import { AlertTriangle, ChevronRight } from "lucide-react-native"
import { ThemeColors } from "../../../types/global"
import { getQueueColor } from "../../../utils/queueStatus"
@@ -118,16 +118,16 @@ export function StatsCard({ queueCount, sentCount, interval, isOfflineMode, onMa
{/* Warning Banner */}
{showWarning && onManageClick && (
- <TouchableOpacity
- style={[
+ <Pressable
+ style={({ pressed }) => [
styles.warningBanner,
{
backgroundColor: warningLevel === "critical" ? colors.error + "15" : colors.warning + "15",
borderTopColor: colors.border
- }
+ },
+ pressed && { opacity: 0.7 }
]}
onPress={onManageClick}
- activeOpacity={0.7}
>
<View style={styles.warningContent}>
<AlertTriangle size={20} color={warningLevel === "critical" ? colors.error : colors.warning} />
@@ -146,7 +146,7 @@ export function StatsCard({ queueCount, sentCount, interval, isOfflineMode, onMa
</View>
</View>
<ChevronRight size={20} color={warningLevel === "critical" ? colors.error : colors.warning} />
- </TouchableOpacity>
+ </Pressable>
)}
</View>
)
diff --git a/apps/mobile/src/components/features/settings/SyncStrategySettings.tsx b/apps/mobile/src/components/features/settings/SyncStrategySettings.tsx
index 6b0381ee..12389f96 100644
--- a/apps/mobile/src/components/features/settings/SyncStrategySettings.tsx
+++ b/apps/mobile/src/components/features/settings/SyncStrategySettings.tsx
@@ -4,7 +4,7 @@
*/
import React, { useState, useCallback, useEffect } from "react"
-import { Text, StyleSheet, Switch, View, TouchableOpacity } from "react-native"
+import { Text, StyleSheet, Switch, View, Pressable } from "react-native"
import { Lightbulb } from "lucide-react-native"
import { Settings, TRACKING_PRESETS, SyncPreset, SelectablePreset, ThemeColors } from "../../../types/global"
import { fonts, fontSizes } from "../../../styles/typography"
@@ -129,19 +129,19 @@ export function SyncStrategySettings({
))}
</View>
- <TouchableOpacity
- style={[
+ <Pressable
+ style={({ pressed }) => [
styles.advancedToggle,
showAdvanced ? styles.advancedToggleActive : styles.advancedToggleInactive,
- { borderColor: showAdvanced ? colors.primary : colors.border }
+ { borderColor: showAdvanced ? colors.primary : colors.border },
+ pressed && { opacity: 0.7 }
]}
onPress={() => setShowAdvanced(!showAdvanced)}
- activeOpacity={0.7}
>
<Text style={[styles.advancedText, { color: colors.primaryDark }]}>
{showAdvanced ? "− Hide" : "+ Show"} Advanced Settings
</Text>
- </TouchableOpacity>
+ </Pressable>
{showAdvanced && (
<View style={styles.advancedPanel}>
@@ -215,9 +215,9 @@ export function SyncStrategySettings({
const isSelected = settings.syncInterval === sec
return (
- <TouchableOpacity
+ <Pressable
key={sec}
- style={[
+ style={({ pressed }) => [
styles.gridOption,
{
borderColor: colors.border,
@@ -226,15 +226,15 @@ export function SyncStrategySettings({
isSelected && {
borderColor: colors.primary,
backgroundColor: colors.primary + "20"
- }
+ },
+ pressed && { opacity: 0.7 }
]}
onPress={() => handleGridSelect("syncInterval", sec)}
- activeOpacity={0.7}
>
<Text style={[styles.gridLabel, { color: isSelected ? colors.primary : colors.text }]}>
{labels[sec]}
</Text>
- </TouchableOpacity>
+ </Pressable>
)
})}
</View>
diff --git a/apps/mobile/src/components/features/settings/__tests__/SyncStrategySettings.test.tsx b/apps/mobile/src/components/features/settings/__tests__/SyncStrategySettings.test.tsx
index 1563d060..69a4ccc2 100644
--- a/apps/mobile/src/components/features/settings/__tests__/SyncStrategySettings.test.tsx
+++ b/apps/mobile/src/components/features/settings/__tests__/SyncStrategySettings.test.tsx
@@ -31,9 +31,9 @@ jest.mock("../../../index", () => {
jest.mock("../PresetOption", () => ({
PresetOption: ({ preset, isSelected, onSelect }: any) => {
const R = require("react")
- const { TouchableOpacity, Text } = require("react-native")
+ const { Pressable, Text } = require("react-native")
return R.createElement(
- TouchableOpacity,
+ Pressable,
{ testID: `preset-${preset}`, onPress: () => onSelect(preset) },
R.createElement(Text, null, preset, isSelected ? " (selected)" : "")
)
diff --git a/apps/mobile/src/components/ui/AppModal.tsx b/apps/mobile/src/components/ui/AppModal.tsx
index 463eb5ce..ac94e58c 100644
--- a/apps/mobile/src/components/ui/AppModal.tsx
+++ b/apps/mobile/src/components/ui/AppModal.tsx
@@ -4,7 +4,7 @@
*/
import React, { useState, useRef, useEffect, useCallback } from "react"
-import { Modal, View, Text, TouchableOpacity, StyleSheet, BackHandler } from "react-native"
+import { Modal, View, Text, Pressable, StyleSheet, BackHandler } from "react-native"
import { Info, AlertCircle, AlertTriangle, CheckCircle } from "lucide-react-native"
import { useTheme } from "../../hooks/useTheme"
import { fonts } from "../../styles/typography"
@@ -75,14 +75,13 @@ export function AppModal() {
{current.buttons.map((btn, i) => {
const btnStyles = getButtonStyles(btn.style, colors)
return (
- <TouchableOpacity
+ <Pressable
key={i}
- style={[styles.button, btnStyles.container]}
+ style={({ pressed }) => [styles.button, btnStyles.container, pressed && { opacity: 0.7 }]}
onPress={() => handlePress(i)}
- activeOpacity={0.7}
>
<Text style={[styles.buttonText, btnStyles.text]}>{btn.text}</Text>
- </TouchableOpacity>
+ </Pressable>
)
})}
</View>
diff --git a/apps/mobile/src/components/ui/Button.tsx b/apps/mobile/src/components/ui/Button.tsx
index f1b399b8..8db90ce5 100644
--- a/apps/mobile/src/components/ui/Button.tsx
+++ b/apps/mobile/src/components/ui/Button.tsx
@@ -5,7 +5,7 @@
import React, { useRef, useCallback } from "react"
import {
- TouchableOpacity,
+ Pressable,
Text,
View,
Animated,
@@ -102,21 +102,21 @@ export function Button({
return (
<Animated.View style={[{ transform: [{ scale }] }, style]}>
- <TouchableOpacity
- style={[
+ <Pressable
+ style={({ pressed }) => [
styles.button,
{
backgroundColor: v.bg,
borderColor: v.borderColor,
borderWidth: v.borderWidth,
- borderRadius: colors.borderRadius
+ borderRadius: colors.borderRadius,
+ opacity: pressed ? activeOpacity ?? 0.7 : 1
}
]}
onPress={onPress}
onPressIn={handlePressIn}
onPressOut={handlePressOut}
disabled={disabled || loading}
- activeOpacity={activeOpacity ?? 0.7}
>
<View style={styles.content}>
{loading ? (
@@ -126,7 +126,7 @@ export function Button({
) : null}
<Text style={[styles.text, { color: v.text }]}>{title}</Text>
</View>
- </TouchableOpacity>
+ </Pressable>
</Animated.View>
)
}
diff --git a/apps/mobile/src/components/ui/Card.tsx b/apps/mobile/src/components/ui/Card.tsx
index 0ad40902..e1f01b50 100644
--- a/apps/mobile/src/components/ui/Card.tsx
+++ b/apps/mobile/src/components/ui/Card.tsx
@@ -4,7 +4,7 @@
*/
import React from "react"
-import { View, TouchableOpacity, StyleSheet, ViewStyle, StyleProp } from "react-native"
+import { View, Pressable, StyleSheet, ViewStyle, StyleProp } from "react-native"
import { useTheme } from "../../hooks/useTheme"
type CardVariant = "default" | "elevated" | "outlined" | "interactive"
@@ -66,9 +66,9 @@ export function Card({ children, style, danger = false, variant = "default", onP
if (variant === "interactive" && onPress) {
return (
- <TouchableOpacity onPress={onPress} activeOpacity={0.7}>
+ <Pressable onPress={onPress} style={({ pressed }) => ({ opacity: pressed ? 0.7 : 1 })}>
{cardView}
- </TouchableOpacity>
+ </Pressable>
)
}
diff --git a/apps/mobile/src/components/ui/ChipGroup.tsx b/apps/mobile/src/components/ui/ChipGroup.tsx
index 5bf2f0ff..090b363c 100644
--- a/apps/mobile/src/components/ui/ChipGroup.tsx
+++ b/apps/mobile/src/components/ui/ChipGroup.tsx
@@ -4,7 +4,7 @@
*/
import React from "react"
-import { View, TouchableOpacity, Text, StyleSheet } from "react-native"
+import { View, Pressable, Text, StyleSheet } from "react-native"
import { ThemeColors } from "../../types/global"
import { fonts } from "../../styles/typography"
@@ -21,18 +21,18 @@ export function ChipGroup<T extends string>({ options, selected, onSelect, color
{options.map(({ value, label }) => {
const isSelected = selected === value
return (
- <TouchableOpacity
+ <Pressable
key={value}
- style={[
+ style={({ pressed }) => [
styles.chip,
{ borderColor: colors.border, backgroundColor: colors.background },
- isSelected && { borderColor: colors.primary, backgroundColor: colors.primary + "20" }
+ isSelected && { borderColor: colors.primary, backgroundColor: colors.primary + "20" },
+ pressed && { opacity: 0.7 }
]}
onPress={() => onSelect(value)}
- activeOpacity={0.7}
>
<Text style={[styles.label, { color: isSelected ? colors.primary : colors.text }]}>{label}</Text>
- </TouchableOpacity>
+ </Pressable>
)
})}
</View>
diff --git a/apps/mobile/src/components/ui/ErrorBoundary.tsx b/apps/mobile/src/components/ui/ErrorBoundary.tsx
index d73723c9..c802ef39 100644
--- a/apps/mobile/src/components/ui/ErrorBoundary.tsx
+++ b/apps/mobile/src/components/ui/ErrorBoundary.tsx
@@ -3,7 +3,7 @@
* Licensed under the GNU AGPLv3. See LICENSE in the project root for details.
*/
import React, { Component } from "react"
-import { View, Text, StyleSheet, TouchableOpacity } from "react-native"
+import { View, Text, StyleSheet, Pressable } from "react-native"
import { ThemeColors } from "../../types/global"
import { useTheme } from "../../hooks/useTheme"
import { logger } from "../../utils/logger"
@@ -47,12 +47,16 @@ class ErrorBoundaryInternal extends Component<ErrorBoundaryInternalProps, ErrorB
<Text style={[styles.errorMessage, { color: colors.textSecondary }]}>
{this.state.error?.message || "An unexpected error occurred"}
</Text>
- <TouchableOpacity
- style={[styles.errorButton, { backgroundColor: colors.primary }]}
+ <Pressable
+ style={({ pressed }) => [
+ styles.errorButton,
+ { backgroundColor: colors.primary },
+ pressed && { opacity: 0.7 }
+ ]}
onPress={this.handleReset}
>
<Text style={[styles.errorButtonText, { color: colors.textOnPrimary }]}>Try Again</Text>
- </TouchableOpacity>
+ </Pressable>
</View>
)
}
diff --git a/apps/mobile/src/components/ui/LocationDisclosureModal.tsx b/apps/mobile/src/components/ui/LocationDisclosureModal.tsx
index a8057551..1a6184c1 100644
--- a/apps/mobile/src/components/ui/LocationDisclosureModal.tsx
+++ b/apps/mobile/src/components/ui/LocationDisclosureModal.tsx
@@ -4,7 +4,7 @@
*/
import React, { useState, useRef, useEffect, useCallback } from "react"
-import { Modal, View, Text, TouchableOpacity, StyleSheet, BackHandler } from "react-native"
+import { Modal, View, Text, Pressable, StyleSheet, BackHandler } from "react-native"
import { useTheme } from "../../hooks/useTheme"
import { fonts } from "../../styles/typography"
import { fontSizes } from "@colota/shared"
@@ -79,21 +79,29 @@ export function LocationDisclosureModal() {
{/* Buttons */}
<View style={styles.buttons}>
- <TouchableOpacity
- style={[styles.button, styles.secondaryButton, { borderColor: colors.border }]}
+ <Pressable
+ style={({ pressed }) => [
+ styles.button,
+ styles.secondaryButton,
+ { borderColor: colors.border },
+ pressed && { opacity: 0.7 }
+ ]}
onPress={handleNotNow}
- activeOpacity={0.7}
>
<Text style={[styles.buttonText, { color: colors.textSecondary }]}>Not Now</Text>
- </TouchableOpacity>
+ </Pressable>
- <TouchableOpacity
- style={[styles.button, styles.primaryButton, { backgroundColor: colors.primary }]}
+ <Pressable
+ style={({ pressed }) => [
+ styles.button,
+ styles.primaryButton,
+ { backgroundColor: colors.primary },
+ pressed && { opacity: 0.7 }
+ ]}
onPress={handleAgree}
- activeOpacity={0.7}
>
<Text style={[styles.buttonText, { color: colors.textOnPrimary }]}>Agree</Text>
- </TouchableOpacity>
+ </Pressable>
</View>
</View>
</View>
diff --git a/apps/mobile/src/contexts/TrackingProvider.tsx b/apps/mobile/src/contexts/TrackingProvider.tsx
index fae4391d..d6a93222 100644
--- a/apps/mobile/src/contexts/TrackingProvider.tsx
+++ b/apps/mobile/src/contexts/TrackingProvider.tsx
@@ -17,7 +17,6 @@ type TrackingContextType = {
settings: Settings
setSettings: (s: Settings) => Promise<void>
updateSettingsLocal: (s: Settings) => void
- coords: LocationCoords | null
tracking: boolean
isLoading: boolean
error: Error | null
@@ -28,6 +27,7 @@ type TrackingContextType = {
}
const TrackingContext = createContext<TrackingContextType | null>(null)
+const CoordsContext = createContext<LocationCoords | null>(null)
/**
* Parses raw SQLite settings (all strings) into typed Settings object
@@ -278,7 +278,6 @@ export function TrackingProvider({ children }: { children: React.ReactNode }) {
settings,
setSettings,
updateSettingsLocal: setSettingsState,
- coords,
tracking,
isLoading,
error,
@@ -287,25 +286,16 @@ export function TrackingProvider({ children }: { children: React.ReactNode }) {
stopTracking,
restartTracking
}),
- [
- settings,
- coords,
- tracking,
- isLoading,
- error,
- activeProfileName,
- setSettings,
- startTracking,
- stopTracking,
- restartTracking
- ]
+ [settings, tracking, isLoading, error, activeProfileName, setSettings, startTracking, stopTracking, restartTracking]
)
return (
<TrackingContext.Provider value={value}>
- <LocationDisclosureModal />
- <AppModal />
- {children}
+ <CoordsContext.Provider value={coords}>
+ <LocationDisclosureModal />
+ <AppModal />
+ {children}
+ </CoordsContext.Provider>
</TrackingContext.Provider>
)
}
@@ -322,3 +312,7 @@ export function useTracking(): TrackingContextType {
}
return context
}
+
+export function useCoords(): LocationCoords | null {
+ return useContext(CoordsContext)
+}
diff --git a/apps/mobile/src/screens/AboutScreen.tsx b/apps/mobile/src/screens/AboutScreen.tsx
index 8e6a7e59..b1e6921e 100644
--- a/apps/mobile/src/screens/AboutScreen.tsx
+++ b/apps/mobile/src/screens/AboutScreen.tsx
@@ -4,7 +4,7 @@
*/
import React, { useState, useEffect, useCallback } from "react"
-import { Text, StyleSheet, View, ScrollView, Linking, TouchableOpacity, Image } from "react-native"
+import { Text, StyleSheet, View, ScrollView, Linking, Pressable, Image } from "react-native"
import { ScreenProps, ThemeColors } from "../types/global"
import { useTheme } from "../hooks/useTheme"
import { ChevronRight, Bug, FileText, Code, ScrollText, MessageCircle, Copy, Check } from "lucide-react-native"
@@ -63,14 +63,14 @@ const LinkRow = ({
colors: ThemeColors
onOpenURL: (url: string) => void
}) => (
- <TouchableOpacity style={styles.linkRow} onPress={() => onOpenURL(url)} activeOpacity={0.7}>
+ <Pressable style={({ pressed }) => [styles.linkRow, pressed && { opacity: 0.7 }]} onPress={() => onOpenURL(url)}>
<Icon size={20} color={colors.primaryDark} />
<View style={styles.linkTextContainer}>
<Text style={[styles.linkTitle, { color: colors.text }]}>{title}</Text>
<Text style={[styles.linkSubtitle, { color: colors.textLight }]}>{subtitle}</Text>
</View>
<ChevronRight size={18} color={colors.textLight} />
- </TouchableOpacity>
+ </Pressable>
)
const DEBUG_MODE_SETTING_KEY = "debug_mode_enabled"
@@ -219,13 +219,16 @@ export function AboutScreen({}: ScreenProps) {
<ScrollView contentContainerStyle={styles.scrollContent}>
{/* Header */}
<View style={styles.header}>
- <TouchableOpacity style={styles.appIconContainer} onPress={handleVersionTap} activeOpacity={0.8}>
+ <Pressable
+ style={({ pressed }) => [styles.appIconContainer, pressed && { opacity: 0.8 }]}
+ onPress={handleVersionTap}
+ >
<Image source={icon} style={styles.appIcon} resizeMode="contain" />
- </TouchableOpacity>
+ </Pressable>
<Text style={[styles.title, { color: colors.text }]}>Colota</Text>
- <TouchableOpacity onPress={handleVersionTap} activeOpacity={0.8}>
+ <Pressable onPress={handleVersionTap} style={({ pressed }) => pressed && { opacity: 0.8 }}>
<Text style={[styles.version, { color: colors.textSecondary }]}>Version {buildConfig.VERSION_NAME}</Text>
- </TouchableOpacity>
+ </Pressable>
{/* Tap counter hint */}
{tapCount > 0 && tapCount < 7 && (
@@ -235,13 +238,17 @@ export function AboutScreen({}: ScreenProps) {
)}
{showDebugInfo && (
- <TouchableOpacity
+ <Pressable
onPress={() => toggleDebugMode(false)}
- style={[styles.debugBadge, { backgroundColor: colors.warning + "20" }]}
+ style={({ pressed }) => [
+ styles.debugBadge,
+ { backgroundColor: colors.warning + "20" },
+ pressed && { opacity: 0.7 }
+ ]}
>
<Bug size={14} color={colors.warning} />
<Text style={[styles.debugText, { color: colors.warning }]}>Debug Mode (tap to hide)</Text>
- </TouchableOpacity>
+ </Pressable>
)}
</View>
@@ -319,16 +326,15 @@ export function AboutScreen({}: ScreenProps) {
</View>
)}
- <TouchableOpacity
- style={[styles.copyButton, { borderColor: colors.border }]}
+ <Pressable
+ style={({ pressed }) => [styles.copyButton, { borderColor: colors.border }, pressed && { opacity: 0.7 }]}
onPress={handleCopyDebugInfo}
- activeOpacity={0.7}
>
{copied ? <Check size={16} color={colors.success} /> : <Copy size={16} color={colors.primaryDark} />}
<Text style={[styles.copyButtonText, { color: copied ? colors.success : colors.primaryDark }]}>
{copied ? "Copied!" : "Copy Debug Info"}
</Text>
- </TouchableOpacity>
+ </Pressable>
</>
)}
diff --git a/apps/mobile/src/screens/ApiSettingsScreen.tsx b/apps/mobile/src/screens/ApiSettingsScreen.tsx
index da9c3cd4..3ef62872 100644
--- a/apps/mobile/src/screens/ApiSettingsScreen.tsx
+++ b/apps/mobile/src/screens/ApiSettingsScreen.tsx
@@ -4,7 +4,7 @@
*/
import React, { useState, useCallback, useMemo, useRef } from "react"
-import { Text, StyleSheet, TextInput, View, ScrollView, TouchableOpacity } from "react-native"
+import { Text, StyleSheet, TextInput, View, ScrollView, Pressable } from "react-native"
import {
FieldMap,
DEFAULT_FIELD_MAP,
@@ -391,9 +391,12 @@ export function ApiSettingsScreen({}: ScreenProps) {
<View style={styles.sectionHeader}>
<SectionTitle>FIELD MAPPINGS</SectionTitle>
{hasModifications && (
- <TouchableOpacity onPress={handleResetAll} style={styles.resetAllButton}>
+ <Pressable
+ onPress={handleResetAll}
+ style={({ pressed }) => [styles.resetAllButton, pressed && { opacity: 0.7 }]}
+ >
<Text style={[styles.resetAllText, { color: colors.primaryDark }]}>RESET ALL</Text>
- </TouchableOpacity>
+ </Pressable>
)}
</View>
@@ -445,12 +448,16 @@ export function ApiSettingsScreen({}: ScreenProps) {
autoCorrect={false}
/>
{isFieldModified && (
- <TouchableOpacity
+ <Pressable
onPress={() => handleResetField(key)}
- style={[styles.resetButton, { backgroundColor: colors.border }]}
+ style={({ pressed }) => [
+ styles.resetButton,
+ { backgroundColor: colors.border },
+ pressed && { opacity: 0.7 }
+ ]}
>
<Text style={[styles.resetIcon, { color: colors.textSecondary }]}>↺</Text>
- </TouchableOpacity>
+ </Pressable>
)}
</View>
</View>
@@ -512,12 +519,16 @@ export function ApiSettingsScreen({}: ScreenProps) {
autoCapitalize="none"
autoCorrect={false}
/>
- <TouchableOpacity
+ <Pressable
onPress={() => handleRemoveCustomField(field.id)}
- style={[styles.removeButton, { backgroundColor: colors.error + "15" }]}
+ style={({ pressed }) => [
+ styles.removeButton,
+ { backgroundColor: colors.error + "15" },
+ pressed && { opacity: 0.7 }
+ ]}
>
<Text style={[styles.removeButtonText, { color: colors.error }]}>X</Text>
- </TouchableOpacity>
+ </Pressable>
</View>
{index < localCustomFields.length - 1 && <Divider />}
</View>
@@ -525,9 +536,12 @@ export function ApiSettingsScreen({}: ScreenProps) {
})
)}
- <TouchableOpacity onPress={handleAddCustomField} style={[styles.addButton, { borderColor: colors.border }]}>
+ <Pressable
+ onPress={handleAddCustomField}
+ style={({ pressed }) => [styles.addButton, { borderColor: colors.border }, pressed && { opacity: 0.7 }]}
+ >
<Text style={[styles.addButtonText, { color: colors.primaryDark }]}>+ Add Field</Text>
- </TouchableOpacity>
+ </Pressable>
</View>
</View>
@@ -555,11 +569,14 @@ export function ApiSettingsScreen({}: ScreenProps) {
]}
>
<Text style={[styles.exampleCode, { color: colors.textSecondary }]}>{examplePayload}</Text>
- <TouchableOpacity onPress={handleCopyPayload} style={styles.copyButton}>
+ <Pressable
+ onPress={handleCopyPayload}
+ style={({ pressed }) => [styles.copyButton, pressed && { opacity: 0.7 }]}
+ >
<Text style={[styles.copyButtonText, { color: copied ? colors.success : colors.primaryDark }]}>
{copied ? "COPIED!" : "COPY"}
</Text>
- </TouchableOpacity>
+ </Pressable>
</View>
</View>
diff --git a/apps/mobile/src/screens/AuthSettingsScreen.tsx b/apps/mobile/src/screens/AuthSettingsScreen.tsx
index c8d6f8cb..45789e67 100644
--- a/apps/mobile/src/screens/AuthSettingsScreen.tsx
+++ b/apps/mobile/src/screens/AuthSettingsScreen.tsx
@@ -4,7 +4,7 @@
*/
import React, { useState, useCallback, useEffect, useRef, useMemo } from "react"
-import { Text, StyleSheet, TextInput, View, ScrollView, TouchableOpacity } from "react-native"
+import { Text, StyleSheet, TextInput, View, ScrollView, Pressable } from "react-native"
import { AuthConfig, AuthType, DEFAULT_AUTH_CONFIG, ScreenProps } from "../types/global"
import { useTheme } from "../hooks/useTheme"
import { useAutoSave } from "../hooks/useAutoSave"
@@ -291,13 +291,16 @@ export function AuthSettingsScreen({}: ScreenProps) {
autoCorrect={false}
/>
</View>
- <TouchableOpacity
+ <Pressable
onPress={() => removeHeader(header.id)}
- style={[styles.removeButton, { backgroundColor: colors.error + "15" }]}
- activeOpacity={0.7}
+ style={({ pressed }) => [
+ styles.removeButton,
+ { backgroundColor: colors.error + "15" },
+ pressed && { opacity: 0.7 }
+ ]}
>
<Text style={[styles.removeButtonText, { color: colors.error }]}>X</Text>
- </TouchableOpacity>
+ </Pressable>
</View>
</View>
)
@@ -306,13 +309,12 @@ export function AuthSettingsScreen({}: ScreenProps) {
{localHeaders.length > 0 && <Divider />}
- <TouchableOpacity
- style={[styles.addButton, { borderColor: colors.primary }]}
+ <Pressable
+ style={({ pressed }) => [styles.addButton, { borderColor: colors.primary }, pressed && { opacity: 0.7 }]}
onPress={addHeader}
- activeOpacity={0.7}
>
<Text style={[styles.addButtonText, { color: colors.primaryDark }]}>+ Add Header</Text>
- </TouchableOpacity>
+ </Pressable>
<Text style={[styles.hint, { color: colors.textSecondary }]}>
e.g., CF-Access-Client-Id for Cloudflare Access
diff --git a/apps/mobile/src/screens/DashboardScreen.tsx b/apps/mobile/src/screens/DashboardScreen.tsx
index 86e836fe..ca93f444 100644
--- a/apps/mobile/src/screens/DashboardScreen.tsx
+++ b/apps/mobile/src/screens/DashboardScreen.tsx
@@ -8,7 +8,7 @@ import { StyleSheet, View, ScrollView, DeviceEventEmitter, Animated } from "reac
import { ScreenProps, DatabaseStats } from "../types/global"
import { useTheme } from "../hooks/useTheme"
import NativeLocationService from "../services/NativeLocationService"
-import { useTracking } from "../contexts/TrackingProvider"
+import { useTracking, useCoords } from "../contexts/TrackingProvider"
import { useFocusEffect } from "@react-navigation/native"
import {
Button,
@@ -25,7 +25,8 @@ import { Square, Play } from "lucide-react-native"
import { logger } from "../utils/logger"
export function DashboardScreen({ navigation }: ScreenProps) {
- const { coords, settings, tracking, startTracking, stopTracking, setSettings, activeProfileName } = useTracking()
+ const { settings, tracking, startTracking, stopTracking, setSettings, activeProfileName } = useTracking()
+ const coords = useCoords()
const { colors } = useTheme()
const [stats, setStats] = useState<DatabaseStats>({
diff --git a/apps/mobile/src/screens/DataManagementScreen.tsx b/apps/mobile/src/screens/DataManagementScreen.tsx
index f837eff1..e177372e 100644
--- a/apps/mobile/src/screens/DataManagementScreen.tsx
+++ b/apps/mobile/src/screens/DataManagementScreen.tsx
@@ -9,7 +9,7 @@ import {
StyleSheet,
View,
ScrollView,
- TouchableOpacity,
+ Pressable,
TextInput,
KeyboardAvoidingView,
Platform,
@@ -370,7 +370,11 @@ const ActionRow = ({
onPress: () => void
disabled: boolean
}) => (
- <TouchableOpacity style={styles.actionRow} onPress={onPress} disabled={disabled} activeOpacity={0.7}>
+ <Pressable
+ style={({ pressed }) => [styles.actionRow, pressed && { opacity: 0.7 }]}
+ onPress={onPress}
+ disabled={disabled}
+ >
<View style={styles.actionInfo}>
<Text style={[styles.actionLabel, { color }]}>{label}</Text>
<Text style={[styles.actionHint, { color: textColor }]}>{hint}</Text>
@@ -378,7 +382,7 @@ const ActionRow = ({
<View style={[styles.actionBadge, { backgroundColor: color + "20", borderColor: color }]}>
<Text style={[styles.actionBadgeText, { color }]}>{value}</Text>
</View>
- </TouchableOpacity>
+ </Pressable>
)
const styles = StyleSheet.create({
diff --git a/apps/mobile/src/screens/ExportDataScreen.tsx b/apps/mobile/src/screens/ExportDataScreen.tsx
index 96ad1954..6d2620fe 100644
--- a/apps/mobile/src/screens/ExportDataScreen.tsx
+++ b/apps/mobile/src/screens/ExportDataScreen.tsx
@@ -4,7 +4,7 @@
*/
import React, { useState, useEffect, useCallback, useRef } from "react"
-import { Text, StyleSheet, View, ActivityIndicator, ScrollView, TouchableOpacity } from "react-native"
+import { Text, StyleSheet, View, ActivityIndicator, ScrollView, Pressable } from "react-native"
import { fonts } from "../styles/typography"
import { Download, MapPinOff, type LucideIcon } from "lucide-react-native"
import { Container, Card, SectionTitle, Divider, Button } from "../components"
@@ -254,7 +254,10 @@ const FormatOption = ({
const radioBgColor = selected ? colors.primary + "20" : "transparent"
return (
- <TouchableOpacity style={[styles.formatOption, { backgroundColor }]} onPress={onPress} activeOpacity={0.7}>
+ <Pressable
+ style={({ pressed }) => [styles.formatOption, { backgroundColor }, pressed && { opacity: 0.7 }]}
+ onPress={onPress}
+ >
{selected && <View style={[styles.selectionBar, { backgroundColor: colors.primary }]} />}
<View style={styles.formatContent}>
@@ -292,7 +295,7 @@ const FormatOption = ({
{selected && <View style={[styles.radioInner, { backgroundColor: colors.primary }]} />}
</View>
</View>
- </TouchableOpacity>
+ </Pressable>
)
}
diff --git a/apps/mobile/src/screens/GeofenceScreen.tsx b/apps/mobile/src/screens/GeofenceScreen.tsx
index 096c8b88..5e2e3cfd 100644
--- a/apps/mobile/src/screens/GeofenceScreen.tsx
+++ b/apps/mobile/src/screens/GeofenceScreen.tsx
@@ -4,12 +4,12 @@
*/
import React, { useState, useEffect, useRef, useMemo, useCallback } from "react"
-import { View, Text, StyleSheet, TextInput, TouchableOpacity, FlatList, Switch, DeviceEventEmitter } from "react-native"
+import { View, Text, StyleSheet, TextInput, Pressable, FlatList, Switch, DeviceEventEmitter } from "react-native"
import { useTheme } from "../hooks/useTheme"
import NativeLocationService from "../services/NativeLocationService"
import { showAlert, showConfirm } from "../services/modalService"
import { Geofence, ScreenProps } from "../types/global"
-import { useTracking } from "../contexts/TrackingProvider"
+import { useTracking, useCoords } from "../contexts/TrackingProvider"
import { fonts } from "../styles/typography"
import { X, WifiOff } from "lucide-react-native"
import { Container, SectionTitle, Card } from "../components"
@@ -30,7 +30,8 @@ import { UserLocationOverlay } from "../components/features/map/UserLocationOver
import { logger } from "../utils/logger"
export function GeofenceScreen({}: ScreenProps) {
- const { coords, tracking } = useTracking()
+ const { tracking } = useTracking()
+ const coords = useCoords()
const { colors } = useTheme()
const [geofences, setGeofences] = useState<Geofence[]>([])
@@ -249,10 +250,13 @@ export function GeofenceScreen({}: ScreenProps) {
({ item }: { item: Geofence }) => (
<Card style={styles.card}>
<View style={styles.row}>
- <TouchableOpacity style={styles.info} onPress={() => handleZoomToGeofence(item)} activeOpacity={0.7}>
+ <Pressable
+ style={({ pressed }) => [styles.info, pressed && { opacity: 0.7 }]}
+ onPress={() => handleZoomToGeofence(item)}
+ >
<Text style={[styles.name, { color: colors.text }]}>{item.name}</Text>
<Text style={[styles.radius, { color: colors.textSecondary }]}>{item.radius}m radius</Text>
- </TouchableOpacity>
+ </Pressable>
<View style={styles.actions}>
<View style={styles.pauseSwitch}>
@@ -268,13 +272,16 @@ export function GeofenceScreen({}: ScreenProps) {
/>
</View>
- <TouchableOpacity
+ <Pressable
onPress={() => handleDelete(item)}
- style={[styles.deleteBtn, { backgroundColor: colors.error + "15" }]}
- activeOpacity={0.7}
+ style={({ pressed }) => [
+ styles.deleteBtn,
+ { backgroundColor: colors.error + "15" },
+ pressed && { opacity: 0.7 }
+ ]}
>
<X size={16} color={colors.error} />
- </TouchableOpacity>
+ </Pressable>
</View>
</View>
</Card>
@@ -368,16 +375,19 @@ export function GeofenceScreen({}: ScreenProps) {
</View>
</View>
- <TouchableOpacity
- style={[styles.placeBtn, { backgroundColor: colors.primary }]}
+ <Pressable
+ style={({ pressed }) => [
+ styles.placeBtn,
+ { backgroundColor: colors.primary },
+ pressed && { opacity: 0.7 }
+ ]}
onPress={startPlacingGeofence}
disabled={placingGeofence}
- activeOpacity={0.7}
>
<Text style={[styles.placeBtnText, { color: colors.textOnPrimary }]}>
{placingGeofence ? "Tap Map to Place..." : "Place Geofence"}
</Text>
- </TouchableOpacity>
+ </Pressable>
</Card>
</View>
diff --git a/apps/mobile/src/screens/LocationInspectorScreen.tsx b/apps/mobile/src/screens/LocationInspectorScreen.tsx
index aa65cdf5..2eafd459 100644
--- a/apps/mobile/src/screens/LocationInspectorScreen.tsx
+++ b/apps/mobile/src/screens/LocationInspectorScreen.tsx
@@ -4,7 +4,7 @@
*/
import React, { useState, useEffect, useRef, useCallback, useMemo, memo } from "react"
-import { View, Text, FlatList, StyleSheet, TouchableOpacity, Switch } from "react-native"
+import { View, Text, FlatList, StyleSheet, Pressable, Switch } from "react-native"
import { fonts } from "../styles/typography"
import { ChevronLeft, ChevronRight } from "lucide-react-native"
import { Container, Card } from "../components"
@@ -105,9 +105,9 @@ const LocationItem = memo(({ item, colors, onTap }: LocationItemProps) => {
if (onTap) {
return (
- <TouchableOpacity activeOpacity={0.7} onPress={() => onTap(item)}>
+ <Pressable style={({ pressed }) => pressed && { opacity: 0.7 }} onPress={() => onTap(item)}>
{card}
- </TouchableOpacity>
+ </Pressable>
)
}
@@ -265,20 +265,21 @@ export function LocationHistoryScreen() {
/>
</View>
- <TouchableOpacity
+ <Pressable
onPress={fetchData}
disabled={autoRefresh}
- style={[
+ style={({ pressed }) => [
styles.refreshBtn,
{
backgroundColor: colors.card,
borderColor: colors.border
},
- autoRefresh && styles.refreshBtnDisabled
+ autoRefresh && styles.refreshBtnDisabled,
+ pressed && { opacity: 0.7 }
]}
>
<Text style={[styles.btnText, { color: colors.primaryDark }]}>Refresh</Text>
- </TouchableOpacity>
+ </Pressable>
</View>
</View>
@@ -286,41 +287,42 @@ export function LocationHistoryScreen() {
<View style={styles.limitBar}>
<View style={styles.limitOptions}>
{[10, 50, 100].map((v) => (
- <TouchableOpacity
+ <Pressable
key={v}
onPress={() => handleLimitChange(v)}
- style={[
+ style={({ pressed }) => [
styles.limitBtn,
{
backgroundColor: limit === v ? colors.primary : colors.card,
borderColor: colors.border
- }
+ },
+ pressed && { opacity: 0.7 }
]}
>
<Text style={[styles.limitBtnText, { color: limit === v ? colors.textOnPrimary : colors.text }]}>
{v}
</Text>
- </TouchableOpacity>
+ </Pressable>
))}
</View>
{!autoRefresh && (
<View style={styles.paginationRow}>
- <TouchableOpacity
+ <Pressable
onPress={() => setPage((p) => Math.max(0, p - 1))}
disabled={page === 0}
- style={styles.pageBtn}
+ style={({ pressed }) => [styles.pageBtn, pressed && { opacity: 0.7 }]}
>
<ChevronLeft size={20} color={page === 0 ? colors.textDisabled : colors.primary} />
- </TouchableOpacity>
+ </Pressable>
<Text style={[styles.pageIndicator, { color: colors.text }]}>{page + 1}</Text>
- <TouchableOpacity
+ <Pressable
onPress={() => setPage((p) => p + 1)}
disabled={data.length < limit}
- style={styles.pageBtn}
+ style={({ pressed }) => [styles.pageBtn, pressed && { opacity: 0.7 }]}
>
<ChevronRight size={20} color={data.length < limit ? colors.textDisabled : colors.primary} />
- </TouchableOpacity>
+ </Pressable>
</View>
)}
</View>
@@ -355,11 +357,14 @@ const Tab = ({ label, active, onPress, colors }: TabProps) => {
const textColor = active ? colors.primary : colors.textSecondary
return (
- <TouchableOpacity onPress={onPress} style={[styles.tab, { borderBottomColor }]}>
+ <Pressable
+ onPress={onPress}
+ style={({ pressed }) => [styles.tab, { borderBottomColor }, pressed && { opacity: 0.7 }]}
+ >
<Text style={[styles.tabText, active ? styles.tabTextActive : styles.tabTextInactive, { color: textColor }]}>
{label}
</Text>
- </TouchableOpacity>
+ </Pressable>
)
}
diff --git a/apps/mobile/src/screens/ProfileEditorScreen.tsx b/apps/mobile/src/screens/ProfileEditorScreen.tsx
index 621703cb..bf0cba03 100644
--- a/apps/mobile/src/screens/ProfileEditorScreen.tsx
+++ b/apps/mobile/src/screens/ProfileEditorScreen.tsx
@@ -4,7 +4,7 @@
*/
import React, { useState, useEffect, useCallback } from "react"
-import { View, Text, StyleSheet, ScrollView, TextInput, TouchableOpacity } from "react-native"
+import { View, Text, StyleSheet, ScrollView, TextInput, Pressable } from "react-native"
import { useTheme } from "../hooks/useTheme"
import { ProfileService } from "../services/ProfileService"
import { showAlert } from "../services/modalService"
@@ -211,24 +211,24 @@ export function ProfileEditorScreen({ navigation, route }: any) {
const Icon = opt.icon
const selected = profile.condition.type === opt.type
return (
- <TouchableOpacity
+ <Pressable
key={opt.type}
- style={[
+ style={({ pressed }) => [
styles.conditionOption,
{
backgroundColor: selected ? colors.primary + "15" : colors.background,
borderColor: selected ? colors.primary : colors.border
- }
+ },
+ pressed && { opacity: 0.7 }
]}
onPress={() => setConditionType(opt.type)}
- activeOpacity={0.7}
>
<Icon size={20} color={selected ? colors.primary : colors.textSecondary} />
<Text style={[styles.conditionLabel, { color: selected ? colors.primary : colors.text }]}>
{opt.label}
</Text>
<Text style={[styles.conditionDesc, { color: colors.textLight }]}>{opt.description}</Text>
- </TouchableOpacity>
+ </Pressable>
)
})}
</View>
@@ -300,22 +300,22 @@ export function ProfileEditorScreen({ navigation, route }: any) {
{SYNC_OPTIONS.map((opt) => {
const selected = profile.syncInterval === opt.value
return (
- <TouchableOpacity
+ <Pressable
key={opt.value}
- style={[
+ style={({ pressed }) => [
styles.syncOption,
{
backgroundColor: selected ? colors.primary + "15" : colors.background,
borderColor: selected ? colors.primary : colors.border
- }
+ },
+ pressed && { opacity: 0.7 }
]}
onPress={() => setProfile((prev) => ({ ...prev, syncInterval: opt.value }))}
- activeOpacity={0.7}
>
<Text style={[styles.syncLabel, { color: selected ? colors.primary : colors.text }]}>
{opt.label}
</Text>
- </TouchableOpacity>
+ </Pressable>
)
})}
</View>
@@ -346,17 +346,21 @@ export function ProfileEditorScreen({ navigation, route }: any) {
</Card>
{/* Save Button */}
- <TouchableOpacity
- style={[styles.saveBtn, { backgroundColor: colors.primary }, saving && styles.saveBtnDisabled]}
+ <Pressable
+ style={({ pressed }) => [
+ styles.saveBtn,
+ { backgroundColor: colors.primary },
+ saving && styles.saveBtnDisabled,
+ pressed && { opacity: 0.7 }
+ ]}
onPress={handleSave}
disabled={saving}
- activeOpacity={0.7}
>
<Check size={20} color={colors.textOnPrimary} />
<Text style={[styles.saveBtnText, { color: colors.textOnPrimary }]}>
{saving ? "Saving..." : isEditing ? "Save Changes" : "Create Profile"}
</Text>
- </TouchableOpacity>
+ </Pressable>
</ScrollView>
</Container>
)
diff --git a/apps/mobile/src/screens/SettingsScreen.tsx b/apps/mobile/src/screens/SettingsScreen.tsx
index 315bcc56..1693875f 100644
--- a/apps/mobile/src/screens/SettingsScreen.tsx
+++ b/apps/mobile/src/screens/SettingsScreen.tsx
@@ -4,7 +4,7 @@
*/
import React, { useState, useCallback, useEffect } from "react"
-import { Text, StyleSheet, Switch, View, ScrollView, TouchableOpacity } from "react-native"
+import { Text, StyleSheet, Switch, View, ScrollView, Pressable } from "react-native"
import { ScreenProps, Settings } from "../types/global"
import { useTheme } from "../hooks/useTheme"
import { useAutoSave } from "../hooks/useAutoSave"
@@ -147,10 +147,9 @@ export function SettingsScreen({ navigation }: ScreenProps) {
<View style={styles.section}>
<SectionTitle>Advanced</SectionTitle>
<Card>
- <TouchableOpacity
- style={styles.linkRow}
+ <Pressable
+ style={({ pressed }) => [styles.linkRow, pressed && { opacity: 0.6 }]}
onPress={() => navigation.navigate("Tracking Profiles")}
- activeOpacity={0.6}
>
<View style={styles.linkContent}>
<Text style={[styles.linkLabel, { color: colors.text }]}>Tracking Profiles</Text>
@@ -159,35 +158,33 @@ export function SettingsScreen({ navigation }: ScreenProps) {
</Text>
</View>
<ChevronRight size={20} color={colors.textLight} />
- </TouchableOpacity>
+ </Pressable>
<Divider />
- <TouchableOpacity
- style={styles.linkRow}
+ <Pressable
+ style={({ pressed }) => [styles.linkRow, pressed && { opacity: 0.6 }]}
onPress={() => navigation.navigate("Data Management")}
- activeOpacity={0.6}
>
<View style={styles.linkContent}>
<Text style={[styles.linkLabel, { color: colors.text }]}>Data Management</Text>
<Text style={[styles.linkSub, { color: colors.textSecondary }]}>View queue and clear data</Text>
</View>
<ChevronRight size={20} color={colors.textLight} />
- </TouchableOpacity>
+ </Pressable>
<Divider />
- <TouchableOpacity
- style={styles.linkRow}
+ <Pressable
+ style={({ pressed }) => [styles.linkRow, pressed && { opacity: 0.6 }]}
onPress={() => navigation.navigate("API Config")}
- activeOpacity={0.6}
>
<View style={styles.linkContent}>
<Text style={[styles.linkLabel, { color: colors.text }]}>API Field Mapping</Text>
<Text style={[styles.linkSub, { color: colors.textSecondary }]}>Customize JSON payload structure</Text>
</View>
<ChevronRight size={20} color={colors.textLight} />
- </TouchableOpacity>
+ </Pressable>
</Card>
</View>
</ScrollView>
diff --git a/apps/mobile/src/screens/TrackingProfilesScreen.tsx b/apps/mobile/src/screens/TrackingProfilesScreen.tsx
index e7537042..e6604888 100644
--- a/apps/mobile/src/screens/TrackingProfilesScreen.tsx
+++ b/apps/mobile/src/screens/TrackingProfilesScreen.tsx
@@ -4,7 +4,7 @@
*/
import React, { useState, useEffect, useCallback } from "react"
-import { View, Text, StyleSheet, FlatList, Switch, TouchableOpacity } from "react-native"
+import { View, Text, StyleSheet, FlatList, Switch, Pressable } from "react-native"
import { useTheme } from "../hooks/useTheme"
import { useTracking } from "../contexts/TrackingProvider"
import { ProfileService } from "../services/ProfileService"
@@ -100,10 +100,9 @@ export function TrackingProfilesScreen({ navigation }: ScreenProps) {
return (
<Card style={[styles.card, isActive && styles.activeCard, isActive && { borderColor: colors.primary }]}>
- <TouchableOpacity
- style={styles.row}
+ <Pressable
+ style={({ pressed }) => [styles.row, pressed && { opacity: 0.7 }]}
onPress={() => navigation.navigate("Profile Editor", { profileId: item.id })}
- activeOpacity={0.7}
>
<View style={[styles.iconWrap, { backgroundColor: colors.primary + "15" }]}>
<ConditionIcon size={18} color={colors.primary} />
@@ -134,16 +133,19 @@ export function TrackingProfilesScreen({ navigation }: ScreenProps) {
thumbColor={item.enabled ? colors.primary : colors.border}
/>
- <TouchableOpacity
+ <Pressable
testID={`delete-profile-${item.id}`}
onPress={() => handleDelete(item)}
- style={[styles.deleteBtn, { backgroundColor: colors.error + "15" }]}
- activeOpacity={0.7}
+ style={({ pressed }) => [
+ styles.deleteBtn,
+ { backgroundColor: colors.error + "15" },
+ pressed && { opacity: 0.7 }
+ ]}
>
<X size={16} color={colors.error} />
- </TouchableOpacity>
+ </Pressable>
</View>
- </TouchableOpacity>
+ </Pressable>
</Card>
)
},
@@ -166,14 +168,17 @@ export function TrackingProfilesScreen({ navigation }: ScreenProps) {
</Text>
</View>
- <TouchableOpacity
- style={[styles.createBtn, { backgroundColor: colors.primary }]}
+ <Pressable
+ style={({ pressed }) => [
+ styles.createBtn,
+ { backgroundColor: colors.primary },
+ pressed && { opacity: 0.7 }
+ ]}
onPress={() => navigation.navigate("Profile Editor", {})}
- activeOpacity={0.7}
>
<Plus size={20} color={colors.textOnPrimary} />
<Text style={[styles.createBtnText, { color: colors.textOnPrimary }]}>Create Profile</Text>
- </TouchableOpacity>
+ </Pressable>
{profiles.length > 0 && <SectionTitle>Profiles ({profiles.length})</SectionTitle>}
</>
diff --git a/apps/mobile/src/screens/__tests__/ApiSettingsScreen.test.tsx b/apps/mobile/src/screens/__tests__/ApiSettingsScreen.test.tsx
index dddbe01e..4241dc6f 100644
--- a/apps/mobile/src/screens/__tests__/ApiSettingsScreen.test.tsx
+++ b/apps/mobile/src/screens/__tests__/ApiSettingsScreen.test.tsx
@@ -59,7 +59,7 @@ jest.mock("../../services/NativeLocationService", () => ({
// Mock barrel exports to avoid native module imports
jest.mock("../../components", () => {
const R = require("react")
- const { View, Text, TouchableOpacity } = require("react-native")
+ const { View, Text, Pressable } = require("react-native")
return {
SectionTitle: ({ children }: any) => R.createElement(Text, null, children),
FloatingSaveIndicator: () => null,
@@ -71,7 +71,7 @@ jest.mock("../../components", () => {
null,
options.map((opt: any) =>
R.createElement(
- TouchableOpacity,
+ Pressable,
{ key: opt.value, onPress: () => onSelect(opt.value) },
R.createElement(Text, null, opt.label)
)
diff --git a/apps/mobile/src/screens/__tests__/AuthSettingsScreen.test.tsx b/apps/mobile/src/screens/__tests__/AuthSettingsScreen.test.tsx
index ba628cf2..c9b058ad 100644
--- a/apps/mobile/src/screens/__tests__/AuthSettingsScreen.test.tsx
+++ b/apps/mobile/src/screens/__tests__/AuthSettingsScreen.test.tsx
@@ -59,7 +59,7 @@ jest.mock("../../hooks/useAutoSave", () => ({
jest.mock("../../components", () => {
const R = require("react")
- const { View, Text, TouchableOpacity } = require("react-native")
+ const { View, Text, Pressable } = require("react-native")
return {
SectionTitle: ({ children }: any) => R.createElement(Text, null, children),
FloatingSaveIndicator: () => null,
@@ -72,7 +72,7 @@ jest.mock("../../components", () => {
null,
options.map((opt: any) =>
R.createElement(
- TouchableOpacity,
+ Pressable,
{ key: opt.value, onPress: () => onSelect(opt.value) },
R.createElement(Text, null, opt.label)
)
diff --git a/apps/mobile/src/screens/__tests__/SetupImportScreen.test.tsx b/apps/mobile/src/screens/__tests__/SetupImportScreen.test.tsx
index 0a8f5dea..60b90926 100644
--- a/apps/mobile/src/screens/__tests__/SetupImportScreen.test.tsx
+++ b/apps/mobile/src/screens/__tests__/SetupImportScreen.test.tsx
@@ -61,17 +61,13 @@ jest.mock("../../hooks/useTheme", () => ({
jest.mock("../../components", () => {
const R = require("react")
- const { View, Text, TouchableOpacity } = require("react-native")
+ const { View, Text, Pressable } = require("react-native")
return {
Container: ({ children }: any) => R.createElement(View, null, children),
Card: ({ children }: any) => R.createElement(View, null, children),
SectionTitle: ({ children }: any) => R.createElement(Text, null, children),
Button: ({ title, onPress, disabled }: any) =>
- R.createElement(
- TouchableOpacity,
- { onPress, disabled, accessibilityRole: "button" },
- R.createElement(Text, null, title)
- )
+ R.createElement(Pressable, { onPress, disabled, accessibilityRole: "button" }, R.createElement(Text, null, title))
}
})