From 6ed2c16efa578c1bec0c68c516f644b7fe74ac57 Mon Sep 17 00:00:00 2001 From: Joshua Higgins Date: Fri, 20 Nov 2026 01:36:41 -0500 Subject: [PATCH] feat(mobile): split user swipe actions by direction Swipe right to toggle admin (blue) and left to delete. Actions are icon only. Co-Authored-By: Claude Opus 5.5 --- .../mobile/app/(app)/(tabs)/home/settings.tsx | 95 +++++++++---------- 1 file changed, 47 insertions(+), 48 deletions(-) diff --git a/apps/mobile/app/(app)/(tabs)/home/settings.tsx b/apps/mobile/app/(app)/(tabs)/home/settings.tsx index cf1791d..399ff80 100644 --- a/apps/mobile/app/(app)/(tabs)/home/settings.tsx +++ b/apps/mobile/app/(app)/(tabs)/home/settings.tsx @@ -16,7 +16,9 @@ import { Text, View, } from "react-native" -import ReanimatedSwipeable from "react-native-gesture-handler/ReanimatedSwipeable" +import ReanimatedSwipeable, { + type SwipeableMethods, +} from "react-native-gesture-handler/ReanimatedSwipeable" import { useSafeAreaInsets } from "react-native-safe-area-context" import { AddButton } from "@/components/add-button" @@ -45,7 +47,7 @@ import { useCachedQuery } from "@/hooks/use-cached-query" import { clearCoverPaletteCache } from "@/hooks/use-cover-palette" import { useProfileImageUrl } from "@/hooks/use-profile-image-url" import { changeServer, signOut } from "@/lib/session" -import { appleMusic, radius, spacing, useThemeColors } from "@/lib/theme" +import { radius, spacing, useThemeColors } from "@/lib/theme" import { showError } from "@/lib/toast" import type { PlaybackQuality } from "@otunes/convex/playback-stream" import { api } from "@otunes/convex/_generated/api" @@ -53,6 +55,9 @@ import type { Id } from "@otunes/convex/_generated/dataModel" type IconName = React.ComponentProps["name"] +/** iOS system blue, used for the swipe-to-admin action. */ +const SWIPE_ADMIN_BLUE = "#0A84FF" + type Section = "profile" | "quality" | "downloads" | "admin" type CurrentUser = { @@ -829,8 +834,8 @@ function UsersSection({ } /** - * A person in the admin list. Swiping left reveals admin and delete actions; - * both ask for confirmation through the handlers. + * A person in the admin list. Swiping right reveals the admin toggle and + * swiping left reveals delete; both ask for confirmation through the handlers. */ function UserRow({ user, @@ -876,52 +881,51 @@ function UserRow({ ) if (!swipeable) return row - const actions: { - label: string - icon: IconName - color: string + // Icon-only actions: swipe right to toggle admin, left to delete. + function renderAction( + label: string, + icon: IconName, + color: string, onPress: () => void - }[] = [ - { - label: user.isAdmin ? "Remove Admin" : "Make Admin", - icon: user.isAdmin ? "shield-outline" : "shield-checkmark", - color: appleMusic.tabInactive, - onPress: onToggleAdmin, - }, - { - label: "Delete", - icon: "trash", - color: colors.destructive, - onPress: onDelete, - }, - ] + ) { + return ( + _progress: unknown, + _translation: unknown, + swipeable: SwipeableMethods + ) => ( + { + swipeable.close() + onPress() + }} + style={[styles.swipeAction, { backgroundColor: color }]} + > + + + ) + } return ( ( - - {actions.map((action) => ( - { - swipeable.close() - action.onPress() - }} - style={[styles.swipeAction, { backgroundColor: action.color }]} - > - - - {action.label} - - - ))} - + renderLeftActions={renderAction( + user.isAdmin ? "Remove Admin" : "Make Admin", + user.isAdmin ? "shield-outline" : "shield-checkmark", + SWIPE_ADMIN_BLUE, + onToggleAdmin + )} + renderRightActions={renderAction( + "Delete", + "trash", + colors.destructive, + onDelete )} > {row} @@ -1325,14 +1329,9 @@ const styles = StyleSheet.create({ marginHorizontal: spacing.lg, }, swipeAction: { - width: 96, + width: 72, alignItems: "center", justifyContent: "center", - gap: 4, - }, - swipeActionText: { - fontSize: 13, - fontWeight: "600", }, groupFooter: { fontSize: 13,