diff --git a/apps/mobile/app/(app)/(tabs)/_layout.tsx b/apps/mobile/app/(app)/(tabs)/_layout.tsx
index 6620e89..efee656 100644
--- a/apps/mobile/app/(app)/(tabs)/_layout.tsx
+++ b/apps/mobile/app/(app)/(tabs)/_layout.tsx
@@ -116,17 +116,6 @@ export default function TabsLayout() {
Search
-
-
-
- More
-
)
diff --git a/apps/mobile/app/(app)/(tabs)/home/_layout.tsx b/apps/mobile/app/(app)/(tabs)/home/_layout.tsx
index 438f058..893a6c7 100644
--- a/apps/mobile/app/(app)/(tabs)/home/_layout.tsx
+++ b/apps/mobile/app/(app)/(tabs)/home/_layout.tsx
@@ -1,5 +1,6 @@
import { Stack } from "expo-router"
+import { ProfileHeaderButton } from "@/components/profile-header-button"
import { tabStackScreenTitles, useStackScreenOptions } from "@/lib/navigation"
export const unstable_settings = {
@@ -15,6 +16,17 @@ export default function HomeLayout() {
screenOptions={({ route }) => ({
...baseOptions,
title: tabStackScreenTitles[route.name] ?? "Home",
+ headerRight: route.name === "settings" ? undefined : () => ,
+ unstable_headerRightItems:
+ route.name === "settings"
+ ? undefined
+ : () => [
+ {
+ type: "custom",
+ element: ,
+ hidesSharedBackground: true,
+ },
+ ],
})}
/>
)
diff --git a/apps/mobile/app/(app)/(tabs)/home/settings.tsx b/apps/mobile/app/(app)/(tabs)/home/settings.tsx
index 8063d66..7324595 100644
--- a/apps/mobile/app/(app)/(tabs)/home/settings.tsx
+++ b/apps/mobile/app/(app)/(tabs)/home/settings.tsx
@@ -1,5 +1,8 @@
+import { Ionicons } from "@expo/vector-icons"
import { useAction, useMutation, useQuery } from "convex/react"
+import { Image } from "expo-image"
import * as ImagePicker from "expo-image-picker"
+import { useRouter } from "expo-router"
import { useState } from "react"
import {
Pressable,
@@ -9,17 +12,28 @@ import {
Text,
View,
} from "react-native"
+import type { StyleProp, ViewStyle } from "react-native"
-import { Button, Input, LoadingView } from "@/components/ui/primitives"
import { contentBottomInset } from "@/components/player"
-import { api } from "@otunes/convex/_generated/api"
-import type { Doc, Id } from "@otunes/convex/_generated/dataModel"
+import { Button, Input, LoadingView } from "@/components/ui/primitives"
+import { useInvalidateAuthSession } from "@/contexts/convex-auth-session"
+import { useServerConfig } from "@/contexts/server-config"
import { initialsFromName } from "@/lib/format"
+import { signOutToSignIn } from "@/lib/session"
+import { radius, spacing, useThemeColors } from "@/lib/theme"
import { showError, showSuccess } from "@/lib/toast"
import type { PlaybackQuality } from "@/lib/urls"
-import { radius, spacing, useThemeColors } from "@/lib/theme"
+import { api } from "@otunes/convex/_generated/api"
+import type { Doc, Id } from "@otunes/convex/_generated/dataModel"
-type Section = "profile" | "quality" | "users" | "library"
+type Section = "profile" | "quality" | "library" | "users"
+
+type SectionConfig = {
+ id: Section
+ label: string
+ icon: React.ComponentProps["name"]
+ admin?: boolean
+}
const QUALITY_OPTIONS: {
value: PlaybackQuality
@@ -32,10 +46,20 @@ const QUALITY_OPTIONS: {
{ value: "lossless", label: "Lossless", description: "ALAC or FLAC" },
]
+const SECTIONS: SectionConfig[] = [
+ { id: "profile", label: "Profile", icon: "person-circle-outline" },
+ { id: "quality", label: "Playback", icon: "volume-high-outline" },
+ { id: "library", label: "Library", icon: "library-outline", admin: true },
+ { id: "users", label: "Users", icon: "people-outline", admin: true },
+]
+
export default function SettingsScreen() {
const colors = useThemeColors()
+ const router = useRouter()
const user = useQuery(api.auth.currentUser)
const allUsers = useQuery(api.users.listUsers)
+ const { invalidateSession } = useInvalidateAuthSession()
+ const { clearServer } = useServerConfig()
const [section, setSection] = useState("profile")
if (!user) {
@@ -43,54 +67,65 @@ export default function SettingsScreen() {
}
const isAdmin = user.isAdmin === true
- const sections: { id: Section; label: string; admin?: boolean }[] = [
- { id: "profile", label: "Profile" },
- { id: "quality", label: "Quality" },
- { id: "library", label: "Library", admin: true },
- { id: "users", label: "Users", admin: true },
- ]
+ const visibleSections = SECTIONS.filter((item) => !item.admin || isAdmin)
+
+ async function handleSignOut() {
+ await signOutToSignIn(router, invalidateSession)
+ }
+
+ async function handleChangeServer() {
+ await invalidateSession()
+ await clearServer()
+ router.replace("/server")
+ }
return (
-
- {sections
- .filter((item) => !item.admin || isAdmin)
- .map((item) => (
- setSection(item.id)}
- style={[
- styles.tab,
- {
- backgroundColor:
- section === item.id ? colors.foreground : colors.muted,
- },
- ]}
- >
-
- {item.label}
-
-
- ))}
-
+
+ {visibleSections.map((item) => {
+ const selected = section === item.id
+ return (
+ setSection(item.id)}
+ style={[
+ styles.pill,
+ { backgroundColor: selected ? colors.primary : "transparent" },
+ ]}
+ >
+
+
+ )
+ })}
+
-
- {section === "profile" ? : null}
- {section === "quality" ? : null}
- {section === "library" && isAdmin ? : null}
- {section === "users" && isAdmin && allUsers ? (
-
- ) : null}
-
+ {section === "profile" ? : null}
+ {section === "quality" ? : null}
+ {section === "library" && isAdmin ? : null}
+ {section === "users" && isAdmin && allUsers ? (
+
+ ) : null}
+
+ {section === "profile" ? (
+ void handleChangeServer()}
+ onSignOut={() => void handleSignOut()}
+ />
+ ) : null}
)
}
@@ -114,6 +149,7 @@ function ProfileSection({ user }: { user: Doc<"users"> }) {
base64: true,
})
if (result.canceled || !result.assets[0]?.base64) return
+
const mime = result.assets[0].mimeType ?? "image/jpeg"
try {
await updateImage({ image: `data:${mime};base64,${result.assets[0].base64}` })
@@ -123,11 +159,21 @@ function ProfileSection({ user }: { user: Doc<"users"> }) {
}
}
+ async function removeImage() {
+ try {
+ await updateImage({ image: null })
+ showSuccess("Profile photo removed")
+ } catch (error) {
+ showError(error instanceof Error ? error.message : "Failed to remove photo")
+ }
+ }
+
async function handlePasswordChange() {
if (newPassword !== confirmPassword) {
showError("Passwords do not match")
return
}
+
setChangingPassword(true)
try {
await updatePassword({ newPassword })
@@ -142,53 +188,95 @@ function ProfileSection({ user }: { user: Doc<"users"> }) {
}
return (
-
-
-
- {initialsFromName(user.name)}
-
-
-
+ <>
+
+
+
+
+ void pickImage()}
+ />
+ {user.image ? (
+ void removeImage()}
+ />
+ ) : null}
+
+
+
+
+
+
+
+
+
+ void updateName({ name: name.trim() }).then(
+ () => showSuccess("Name updated"),
+ (error: Error) => showError(error.message)
+ )
+ }
+ />
+
+
+
+
+
+ void updateEmail({ email: email.trim() }).then(
+ () => showSuccess("Email updated"),
+ (error: Error) => showError(error.message)
+ )
+ }
+ />
+
+
+
+
+
+
+
+
+
+ void handlePasswordChange()}
+ />
+
+ >
)
}
@@ -199,32 +287,49 @@ function QualitySection({ user }: { user: Doc<"users"> }) {
const quality = user.playbackQuality ?? "medium"
return (
-
- {QUALITY_OPTIONS.map((option) => (
-
- void updateQuality({ playbackQuality: option.value }).catch((error: Error) =>
- showError(error.message)
- )
- }
- >
- {option.label}
- {option.description}
-
- ))}
-
-
- Prefer Dolby Atmos when available
-
-
+
+ {QUALITY_OPTIONS.map((option) => {
+ const selected = quality === option.value
+ return (
+
+ void updateQuality({ playbackQuality: option.value }).catch((error: Error) =>
+ showError(error.message)
+ )
+ }
+ style={[
+ styles.optionRow,
+ {
+ borderColor: selected ? colors.primary : colors.border,
+ backgroundColor: selected ? colors.muted : colors.card,
+ },
+ ]}
+ >
+
+
+ {option.label}
+
+ {option.description}
+
+ {selected ? (
+
+ ) : null}
+
+ )
+ })}
+
+
+
+
void updateAtmos({ preferAtmos: checked }).catch((error: Error) =>
@@ -232,8 +337,8 @@ function QualitySection({ user }: { user: Doc<"users"> }) {
)
}
/>
-
-
+
+ >
)
}
@@ -244,9 +349,13 @@ function LibrarySection() {
const [cleaningHls, setCleaningHls] = useState(false)
return (
-
+
{
setUpdating(true)
@@ -261,8 +370,9 @@ function LibrarySection() {
}}
/>
{
setCleaningHls(true)
@@ -276,7 +386,7 @@ function LibrarySection() {
}
}}
/>
-
+
)
}
@@ -294,10 +404,11 @@ function UsersSection({
const deleteUserMutation = useMutation(api.users.deleteUser)
return (
-
-
- Disable account creation
-
+
+
void setDisableCreation({ disabled: checked }).catch((error: Error) =>
@@ -305,84 +416,363 @@ function UsersSection({
)
}
/>
-
- {users.map((user) => (
-
-
- {user.name}
- {user.email}
- {user.isAdmin ? (
- Admin
+
+
+
+ {users.map((user, index) => (
+
+ {index > 0 ? (
+
+ ) : null}
+
+
+
+
+
+ {user.name}
+
+ {user.isAdmin ? (
+
+
+ Admin
+
+
+ ) : null}
+
+
+ {user.email}
+
+
+
+ {user._id !== currentUserId ? (
+
+
+ void setAdmin({ userId: user._id, isAdmin: !user.isAdmin }).then(
+ () => showSuccess("Updated permissions"),
+ (error: Error) => showError(error.message)
+ )
+ }
+ style={styles.userActionButton}
+ />
+
+ void deleteUserMutation({ userId: user._id }).then(
+ () => showSuccess("User deleted"),
+ (error: Error) => showError(error.message)
+ )
+ }
+ style={styles.userActionButton}
+ />
+
) : null}
- {user._id !== currentUserId ? (
-
-
- void setAdmin({ userId: user._id, isAdmin: !user.isAdmin }).then(() =>
- showSuccess("Updated permissions")
- )
- }
- />
-
- void deleteUserMutation({ userId: user._id }).then(() =>
- showSuccess("User deleted")
- )
- }
- />
-
- ) : null}
-
- ))}
+ ))}
+
+ >
+ )
+}
+
+function SessionSection({
+ onChangeServer,
+ onSignOut,
+}: {
+ onChangeServer: () => void
+ onSignOut: () => void
+}) {
+ const colors = useThemeColors()
+
+ return (
+
+
+
+
+
+ )
+}
+
+function SettingsCard({
+ title,
+ subtitle,
+ children,
+}: {
+ title: string
+ subtitle?: string
+ children: React.ReactNode
+}) {
+ const colors = useThemeColors()
+
+ return (
+
+
+ {title}
+ {subtitle ? (
+ {subtitle}
+ ) : null}
+
+ {children}
+
+ )
+}
+
+function Field({ label, children }: { label: string; children: React.ReactNode }) {
+ const colors = useThemeColors()
+
+ return (
+
+ {label}
+ {children}
+
+ )
+}
+
+function SwitchRow({
+ title,
+ subtitle,
+ value,
+ onValueChange,
+}: {
+ title: string
+ subtitle?: string
+ value: boolean
+ onValueChange: (checked: boolean) => void
+}) {
+ const colors = useThemeColors()
+
+ return (
+
+
+ {title}
+ {subtitle ? {subtitle} : null}
+
+
+
+ )
+}
+
+function ActionRow({
+ icon,
+ title,
+ subtitle,
+ destructive,
+ onPress,
+}: {
+ icon: React.ComponentProps["name"]
+ title: string
+ subtitle: string
+ destructive?: boolean
+ onPress: () => void
+}) {
+ const colors = useThemeColors()
+ const tint = destructive ? colors.destructive : colors.foreground
+
+ return (
+ [styles.actionRow, { opacity: pressed ? 0.75 : 1 }]}
+ >
+
+
+
+
+ {title}
+ {subtitle}
+
+
+
+ )
+}
+
+function ProfileAvatar({
+ user,
+ size,
+ style,
+}: {
+ user: Pick, "name" | "image">
+ size: number
+ style?: StyleProp
+}) {
+ const colors = useThemeColors()
+ const avatarStyle = [
+ styles.avatar,
+ {
+ width: size,
+ height: size,
+ borderRadius: size / 2,
+ backgroundColor: colors.muted,
+ },
+ style,
+ ]
+
+ if (user.image) {
+ return (
+
+
+
+ )
+ }
+
+ return (
+
+
+ {initialsFromName(user.name)}
+
)
}
const styles = StyleSheet.create({
- tabs: {
+ container: {
+ gap: spacing.lg,
paddingHorizontal: spacing.lg,
- paddingVertical: spacing.md,
+ paddingTop: spacing.md,
},
- tab: {
- paddingHorizontal: spacing.md,
- paddingVertical: spacing.sm,
+ badge: {
+ alignSelf: "flex-start",
borderRadius: radius.full,
- marginRight: spacing.sm,
+ paddingHorizontal: spacing.sm,
+ paddingVertical: 2,
},
- content: { paddingHorizontal: spacing.lg },
- sectionBlock: { gap: spacing.md, paddingBottom: spacing.xl },
- sectionTitle: { fontSize: 16, fontWeight: "700", marginTop: spacing.md },
- avatar: {
- width: 72,
- height: 72,
- borderRadius: 36,
+ badgeText: {
+ fontSize: 12,
+ fontWeight: "700",
+ },
+ pillGroup: {
+ borderRadius: radius.xl,
+ padding: spacing.xs,
+ flexDirection: "row",
+ gap: spacing.xs,
+ },
+ pill: {
+ flex: 1,
+ minHeight: 48,
+ borderRadius: radius.full,
alignItems: "center",
justifyContent: "center",
},
- qualityRow: {
- borderWidth: 1,
- borderRadius: radius.md,
- padding: spacing.md,
- gap: 4,
+ card: {
+ borderRadius: radius.xl,
+ padding: spacing.lg,
+ gap: spacing.md,
},
+ cardHeader: {
+ gap: spacing.xs,
+ },
+ cardTitle: {
+ fontSize: 18,
+ fontWeight: "800",
+ },
+ cardSubtitle: {
+ fontSize: 14,
+ lineHeight: 20,
+ },
+ photoRow: {
+ flexDirection: "row",
+ alignItems: "center",
+ gap: spacing.lg,
+ },
+ photoActions: {
+ flex: 1,
+ gap: spacing.sm,
+ },
+ field: {
+ gap: spacing.sm,
+ },
+ fieldLabel: {
+ fontSize: 13,
+ fontWeight: "700",
+ textTransform: "uppercase",
+ },
+ divider: {
+ height: StyleSheet.hairlineWidth,
+ },
+ optionRow: {
+ borderWidth: 1,
+ borderRadius: radius.lg,
+ padding: spacing.md,
+ flexDirection: "row",
+ alignItems: "center",
+ gap: spacing.md,
+ },
+ optionCopy: {
+ flex: 1,
+ gap: 3,
+ },
+ optionTitle: {
+ fontSize: 16,
+ fontWeight: "700",
+ },
switchRow: {
+ minHeight: 56,
flexDirection: "row",
alignItems: "center",
gap: spacing.md,
- borderWidth: 1,
- borderRadius: radius.md,
- padding: spacing.md,
},
userRow: {
- borderWidth: 1,
- borderRadius: radius.md,
- padding: spacing.md,
+ flexDirection: "row",
+ alignItems: "center",
+ gap: spacing.md,
+ },
+ userCopy: {
+ flex: 1,
+ gap: 3,
+ },
+ userNameRow: {
+ flexDirection: "row",
+ alignItems: "center",
gap: spacing.sm,
},
- userActions: { gap: spacing.sm },
+ userName: {
+ flexShrink: 1,
+ fontSize: 16,
+ fontWeight: "700",
+ },
+ userActions: {
+ flexDirection: "row",
+ gap: spacing.sm,
+ marginTop: spacing.md,
+ },
+ userActionButton: {
+ flex: 1,
+ },
+ actionRow: {
+ flexDirection: "row",
+ alignItems: "center",
+ gap: spacing.md,
+ },
+ actionIcon: {
+ width: 36,
+ height: 36,
+ borderRadius: 18,
+ alignItems: "center",
+ justifyContent: "center",
+ },
+ avatar: {
+ alignItems: "center",
+ justifyContent: "center",
+ overflow: "hidden",
+ },
+ avatarImage: {
+ width: "100%",
+ height: "100%",
+ },
+ avatarInitials: {
+ fontWeight: "800",
+ },
})
diff --git a/apps/mobile/app/(app)/(tabs)/library/_layout.tsx b/apps/mobile/app/(app)/(tabs)/library/_layout.tsx
index ad3b27c..c706300 100644
--- a/apps/mobile/app/(app)/(tabs)/library/_layout.tsx
+++ b/apps/mobile/app/(app)/(tabs)/library/_layout.tsx
@@ -1,5 +1,6 @@
import { Stack } from "expo-router"
+import { ProfileHeaderButton } from "@/components/profile-header-button"
import { tabStackScreenTitles, useStackScreenOptions } from "@/lib/navigation"
export const unstable_settings = {
@@ -15,6 +16,17 @@ export default function LibraryLayout() {
screenOptions={({ route }) => ({
...baseOptions,
title: tabStackScreenTitles[route.name] ?? "Library",
+ headerRight: route.name === "settings" ? undefined : () => ,
+ unstable_headerRightItems:
+ route.name === "settings"
+ ? undefined
+ : () => [
+ {
+ type: "custom",
+ element: ,
+ hidesSharedBackground: true,
+ },
+ ],
})}
/>
)
diff --git a/apps/mobile/app/(app)/(tabs)/more/_layout.tsx b/apps/mobile/app/(app)/(tabs)/more/_layout.tsx
deleted file mode 100644
index 514112a..0000000
--- a/apps/mobile/app/(app)/(tabs)/more/_layout.tsx
+++ /dev/null
@@ -1,7 +0,0 @@
-import { Stack } from "expo-router"
-
-import { useStackScreenOptions } from "@/lib/navigation"
-
-export default function MoreLayout() {
- return
-}
diff --git a/apps/mobile/app/(app)/(tabs)/more/index.tsx b/apps/mobile/app/(app)/(tabs)/more/index.tsx
deleted file mode 100644
index 14b55a0..0000000
--- a/apps/mobile/app/(app)/(tabs)/more/index.tsx
+++ /dev/null
@@ -1,137 +0,0 @@
-import { useQuery } from "convex/react"
-import { useRouter } from "expo-router"
-import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native"
-import { Ionicons } from "@expo/vector-icons"
-
-import { tabContentBottomInset } from "@/components/player"
-import { useInvalidateAuthSession } from "@/contexts/convex-auth-session"
-import { useServerConfig } from "@/contexts/server-config"
-import { useAppNavigation } from "@/lib/app-navigation"
-import { signOutToSignIn } from "@/lib/session"
-import { api } from "@otunes/convex/_generated/api"
-import type { PlaylistSummary } from "@otunes/convex/types"
-import { initialsFromName } from "@/lib/format"
-import { radius, spacing, useThemeColors } from "@/lib/theme"
-
-export default function MoreScreen() {
- const router = useRouter()
- const { push } = useAppNavigation()
- const colors = useThemeColors()
- const { invalidateSession } = useInvalidateAuthSession()
- const { clearServer } = useServerConfig()
- const user = useQuery(api.auth.currentUser)
- const sidebarPlaylists = useQuery(api.playlists.listSidebarPlaylists)
-
- async function handleSignOut() {
- await signOutToSignIn(router, invalidateSession)
- }
-
- async function handleChangeServer() {
- await invalidateSession()
- await clearServer()
- router.replace("/server")
- }
-
- const subscribed = sidebarPlaylists?.subscribed ?? []
- const owned = sidebarPlaylists?.owned ?? []
-
- return (
-
-
-
-
- {initialsFromName(user?.name ?? "NA")}
-
-
-
- {user?.name ?? "..."}
- {user?.email}
-
-
-
- push("/settings")}>
-
- Settings
-
- push("/queue")}>
-
- Queue
-
-
- {owned.length > 0 ? (
- Your playlists
- ) : null}
- {owned.map((playlist: PlaylistSummary) => (
- push(`/playlist/${playlist.id}`)}
- >
-
- {playlist.title}
-
- ))}
-
- {subscribed.length > 0 ? (
- Subscribed
- ) : null}
- {subscribed.map((playlist: PlaylistSummary) => (
- push(`/playlist/${playlist.id}`)}
- >
-
- {playlist.title}
-
- ))}
-
- void handleSignOut()}>
-
- Sign out
-
- void handleChangeServer()}>
-
- Change server
-
-
- )
-}
-
-const styles = StyleSheet.create({
- profileCard: {
- margin: spacing.lg,
- borderRadius: radius.lg,
- padding: spacing.lg,
- flexDirection: "row",
- alignItems: "center",
- gap: spacing.md,
- },
- avatar: {
- width: 48,
- height: 48,
- borderRadius: 24,
- alignItems: "center",
- justifyContent: "center",
- },
- name: { fontSize: 18, fontWeight: "700" },
- row: {
- flexDirection: "row",
- alignItems: "center",
- gap: spacing.md,
- paddingHorizontal: spacing.lg,
- paddingVertical: spacing.md,
- },
- rowText: { fontSize: 16, fontWeight: "500" },
- sectionLabel: {
- paddingHorizontal: spacing.lg,
- paddingTop: spacing.lg,
- fontSize: 12,
- fontWeight: "700",
- textTransform: "uppercase",
- },
-})
diff --git a/apps/mobile/app/(app)/(tabs)/search/_layout.tsx b/apps/mobile/app/(app)/(tabs)/search/_layout.tsx
index 66257ab..a7103d1 100644
--- a/apps/mobile/app/(app)/(tabs)/search/_layout.tsx
+++ b/apps/mobile/app/(app)/(tabs)/search/_layout.tsx
@@ -1,5 +1,6 @@
import { Stack } from "expo-router"
+import { ProfileHeaderButton } from "@/components/profile-header-button"
import { tabStackScreenTitles, useStackScreenOptions } from "@/lib/navigation"
export const unstable_settings = {
@@ -15,6 +16,17 @@ export default function SearchLayout() {
screenOptions={({ route }) => ({
...baseOptions,
title: tabStackScreenTitles[route.name] ?? "Search",
+ headerRight: route.name === "settings" ? undefined : () => ,
+ unstable_headerRightItems:
+ route.name === "settings"
+ ? undefined
+ : () => [
+ {
+ type: "custom",
+ element: ,
+ hidesSharedBackground: true,
+ },
+ ],
})}
/>
)
diff --git a/apps/mobile/app/(app)/_layout.tsx b/apps/mobile/app/(app)/_layout.tsx
index 9091dd0..033e690 100644
--- a/apps/mobile/app/(app)/_layout.tsx
+++ b/apps/mobile/app/(app)/_layout.tsx
@@ -67,6 +67,16 @@ export default function AppLayout() {
+
router.push("/(app)/settings")}
+ style={({ pressed }) => [styles.button, { opacity: pressed ? 0.75 : 1 }]}
+ >
+
+ {user?.image ? (
+
+ ) : (
+
+ {initialsFromName(user?.name ?? "Me")}
+
+ )}
+
+
+ )
+}
+
+const styles = StyleSheet.create({
+ button: {
+ marginRight: 4,
+ },
+ avatar: {
+ width: 42,
+ height: 42,
+ borderRadius: radius.full,
+ borderWidth: 1,
+ alignItems: "center",
+ justifyContent: "center",
+ overflow: "hidden",
+ },
+ image: {
+ width: "100%",
+ height: "100%",
+ },
+ initials: {
+ fontSize: 14,
+ fontWeight: "700",
+ },
+})