-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tanstack query, push notification support
- Loading branch information
Showing
23 changed files
with
584 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
import { Stack } from "expo-router" | ||
|
||
export default function SettingsLayout() { | ||
return <Stack screenOptions={{ headerShown: false, title: "Settings" }} /> | ||
return ( | ||
<Stack> | ||
<Stack.Screen name="index" options={{ title: "Settings" }} /> | ||
<Stack.Screen name="debug" options={{ title: "Debug" }} /> | ||
</Stack> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { | ||
CheckIcon, | ||
ChevronRightIcon, | ||
HeartHandshakeIcon, | ||
VibrateIcon | ||
} from "lucide-react-native" | ||
import { ActivityIndicator, Linking, ScrollView } from "react-native" | ||
|
||
import { | ||
SettingsSection, | ||
SettingsSectionContent, | ||
SettingsSectionHeader, | ||
SettingsSectionItem | ||
} from "@/components/settings/settings" | ||
import { Text } from "@/components/text" | ||
import { View } from "@/components/view" | ||
import { usePushNotificationStatus } from "@/hooks/push-notifications/use-push-notification-status" | ||
import { useRegisterForPushNotifications } from "@/hooks/push-notifications/use-register-for-oush-notifications" | ||
import { useTestPushNotification } from "@/hooks/push-notifications/use-test-push-notification" | ||
import { cls } from "@/lib/cls" | ||
|
||
export default function DebugSettingsScreen() { | ||
const { mutate: requestPermissions, isPending } = | ||
useRegisterForPushNotifications() | ||
|
||
const { mutate: sendTestNotification, isPending: isSendingTestNotification } = | ||
useTestPushNotification() | ||
|
||
const { | ||
isPermissionDenied, | ||
isPermissionUndetermined, | ||
isPermissionGranted, | ||
isLoading: isLoadingPermissionStatus | ||
} = usePushNotificationStatus() | ||
|
||
return ( | ||
<View className="flex-1 bg-background"> | ||
<ScrollView contentContainerClassName="py-6 gap-8"> | ||
{/* Section: Push Notifications */} | ||
<SettingsSection> | ||
<SettingsSectionHeader>Push Notifications</SettingsSectionHeader> | ||
<SettingsSectionContent> | ||
<SettingsSectionItem | ||
className={ | ||
isPermissionDenied || isPermissionUndetermined | ||
? "active:opacity-50" | ||
: undefined | ||
} | ||
icon={HeartHandshakeIcon} | ||
label="Permissions" | ||
onPress={() => { | ||
if (isPermissionDenied) { | ||
void Linking.openSettings() | ||
} else if (isPermissionUndetermined) { | ||
requestPermissions() | ||
} | ||
}} | ||
> | ||
{isLoadingPermissionStatus || isPending ? ( | ||
<ActivityIndicator size={20} /> | ||
) : isPermissionDenied ? ( | ||
<View className="flex-row gap-1"> | ||
<Text className="text-muted-foreground">Denied –</Text> | ||
<Text className="text-primary">Fix</Text> | ||
</View> | ||
) : isPermissionGranted ? ( | ||
<CheckIcon className="text-primary" size={20} /> | ||
) : isPermissionUndetermined ? ( | ||
<Text className="font-bold text-primary">Request</Text> | ||
) : ( | ||
<Text className="text-muted-foreground">Unavailable</Text> | ||
)} | ||
</SettingsSectionItem> | ||
|
||
<SettingsSectionItem | ||
className={cls( | ||
"border-t border-border", | ||
isPermissionGranted ? " active:opacity-50" : "opacity-50" | ||
)} | ||
disabled={!isPermissionGranted} | ||
icon={VibrateIcon} | ||
label="Send Test Notification" | ||
onPress={() => { | ||
sendTestNotification() | ||
}} | ||
> | ||
{isSendingTestNotification ? ( | ||
<ActivityIndicator size={20} /> | ||
) : ( | ||
<ChevronRightIcon className="text-muted-foreground" size={20} /> | ||
)} | ||
</SettingsSectionItem> | ||
</SettingsSectionContent> | ||
</SettingsSection> | ||
</ScrollView> | ||
</View> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.