Merge pull request 'Updated profile, added polished settings page, added restrictions for screenshot and screen recording' (#31) from profile-settings-screenshot into main
Reviewed-on: https://10.10.0.4/AcuPedia/acupedia-mobile-ui/pulls/31 Reviewed-by: Amit Salunke <amit@noreply.localhost>
This commit is contained in:
commit
cdb6665ac7
12
.env
12
.env
|
|
@ -17,11 +17,11 @@
|
|||
# old working .env file
|
||||
|
||||
# Production Dev
|
||||
# EXPO_PUBLIC_API_URL=https://api.acupedia.in/api
|
||||
# EXPO_PUBLIC_STOREFRONT_URL=https://acupedia.in/store
|
||||
# EXPO_PUBLIC_CONTENT_PREVIEW_ENABLED=false
|
||||
EXPO_PUBLIC_API_URL=https://api.acupedia.in/api
|
||||
EXPO_PUBLIC_STOREFRONT_URL=https://acupedia.in/store
|
||||
EXPO_PUBLIC_CONTENT_PREVIEW_ENABLED=true
|
||||
|
||||
# Local Dev
|
||||
EXPO_PUBLIC_API_URL=http://localhost:8000/api
|
||||
EXPO_PUBLIC_STOREFRONT_URL=http://localhost:3000
|
||||
EXPO_PUBLIC_CONTENT_PREVIEW_ENABLED=true
|
||||
# EXPO_PUBLIC_API_URL=http://localhost:8000/api
|
||||
# EXPO_PUBLIC_STOREFRONT_URL=http://localhost:3000
|
||||
# EXPO_PUBLIC_CONTENT_PREVIEW_ENABLED=true
|
||||
|
|
@ -24,6 +24,7 @@
|
|||
"expo-linear-gradient": "~57.0.1",
|
||||
"expo-linking": "~57.0.9",
|
||||
"expo-router": "~57.0.19",
|
||||
"expo-screen-capture": "~57.0.3",
|
||||
"expo-secure-store": "~57.0.2",
|
||||
"expo-splash-screen": "~57.0.8",
|
||||
"expo-status-bar": "~57.0.1",
|
||||
|
|
@ -4114,6 +4115,16 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/expo-screen-capture": {
|
||||
"version": "57.0.3",
|
||||
"resolved": "https://registry.npmjs.org/expo-screen-capture/-/expo-screen-capture-57.0.3.tgz",
|
||||
"integrity": "sha512-EpTd6tBgX2nWKJUvYDIrnsC2xWGJnlOLqN48EzLwPTQlbbwDUeWwt+4RDZOyFkWCa67XiUbrzIEOJApNBVZSow==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"expo": "*",
|
||||
"react": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-secure-store": {
|
||||
"version": "57.0.3",
|
||||
"resolved": "https://registry.npmjs.org/expo-secure-store/-/expo-secure-store-57.0.3.tgz",
|
||||
|
|
|
|||
21
package.json
21
package.json
|
|
@ -3,15 +3,24 @@
|
|||
"main": "expo-router/entry",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@expo-google-fonts/inter": "^0.4.2",
|
||||
"@expo/ui": "~57.0.16",
|
||||
"@expo/vector-icons": "^15.0.2",
|
||||
"@react-native-async-storage/async-storage": "2.2.0",
|
||||
"@react-native-community/netinfo": "12.0.1",
|
||||
"@tanstack/react-query": "^5.101.2",
|
||||
"axios": "^1.18.1",
|
||||
"expo": "~57.0.20",
|
||||
"expo-constants": "~57.0.17",
|
||||
"expo-device": "~57.0.1",
|
||||
"expo-font": "~57.0.3",
|
||||
"expo-glass-effect": "~57.0.1",
|
||||
"expo-image": "~57.0.4",
|
||||
"expo-linear-gradient": "~57.0.1",
|
||||
"expo-linking": "~57.0.9",
|
||||
"expo-router": "~57.0.19",
|
||||
"expo-screen-capture": "~57.0.3",
|
||||
"expo-secure-store": "~57.0.2",
|
||||
"expo-splash-screen": "~57.0.8",
|
||||
"expo-status-bar": "~57.0.1",
|
||||
"expo-symbols": "~57.0.2",
|
||||
|
|
@ -24,18 +33,10 @@
|
|||
"react-native-reanimated": "4.5.1",
|
||||
"react-native-safe-area-context": "~5.7.0",
|
||||
"react-native-screens": "~4.26.0",
|
||||
"react-native-web": "~0.21.0",
|
||||
"react-native-worklets": "0.10.1",
|
||||
"@expo-google-fonts/inter": "^0.4.2",
|
||||
"@expo/vector-icons": "^15.0.2",
|
||||
"@react-native-async-storage/async-storage": "2.2.0",
|
||||
"@react-native-community/netinfo": "12.0.1",
|
||||
"@tanstack/react-query": "^5.101.2",
|
||||
"axios": "^1.18.1",
|
||||
"expo-linear-gradient": "~57.0.1",
|
||||
"expo-secure-store": "~57.0.2",
|
||||
"react-native-size-matters": "^0.4.2",
|
||||
"react-native-toast-message": "^2.3.3",
|
||||
"react-native-web": "~0.21.0",
|
||||
"react-native-worklets": "0.10.1",
|
||||
"zustand": "^4.5.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
|||
|
|
@ -105,7 +105,10 @@ try {
|
|||
// Silently ignore if module exports are immutable in web bundle environment
|
||||
}
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { Alert, Platform } from "react-native";
|
||||
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
||||
import * as ScreenCapture from "expo-screen-capture";
|
||||
|
||||
export default function RootLayout() {
|
||||
const [fontsLoaded] = useFonts({
|
||||
|
|
@ -115,6 +118,26 @@ export default function RootLayout() {
|
|||
"Inter-Bold": Inter_700Bold,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (Platform.OS === "web") return;
|
||||
|
||||
let isMounted = true;
|
||||
void ScreenCapture.preventScreenCaptureAsync();
|
||||
|
||||
const subscription = ScreenCapture.addScreenshotListener(() => {
|
||||
if (!isMounted) return;
|
||||
Alert.alert(
|
||||
"Confidential Clinical Content",
|
||||
"Acupedia clinical reference materials and diagrams are proprietary. Capturing screenshots is restricted to protect clinical data."
|
||||
);
|
||||
});
|
||||
|
||||
return () => {
|
||||
isMounted = false;
|
||||
subscription?.remove();
|
||||
};
|
||||
}, []);
|
||||
|
||||
if (!fontsLoaded) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,186 @@
|
|||
import React, { useState } from "react";
|
||||
import {
|
||||
KeyboardAvoidingView,
|
||||
Platform,
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
View,
|
||||
Alert,
|
||||
} from "react-native";
|
||||
import { SafeAreaView } from "react-native-safe-area-context";
|
||||
import { router } from "expo-router";
|
||||
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||
|
||||
import SettingsHeader from "@/features/settings/components/SettingsHeader";
|
||||
import PasswordInput from "@/components/forms/PasswordInput";
|
||||
import PrimaryButton from "@/components/buttons/PrimaryButton";
|
||||
import FieldLabel from "@/components/forms/FieldLabel";
|
||||
import { Colors } from "@/theme";
|
||||
import { apiClient } from "@/api";
|
||||
|
||||
export default function ChangePasswordScreen() {
|
||||
const [currentPassword, setCurrentPassword] = useState("");
|
||||
const [newPassword, setNewPassword] = useState("");
|
||||
const [confirmPassword, setConfirmPassword] = useState("");
|
||||
|
||||
const [currentError, setCurrentError] = useState("");
|
||||
const [newError, setNewError] = useState("");
|
||||
const [confirmError, setConfirmError] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const handleUpdatePassword = async () => {
|
||||
let hasError = false;
|
||||
setCurrentError("");
|
||||
setNewError("");
|
||||
setConfirmError("");
|
||||
|
||||
if (!currentPassword) {
|
||||
setCurrentError("Current password is required");
|
||||
hasError = true;
|
||||
}
|
||||
|
||||
if (!newPassword) {
|
||||
setNewError("New password is required");
|
||||
hasError = true;
|
||||
} else if (newPassword.length < 8) {
|
||||
setNewError("New password must be at least 8 characters");
|
||||
hasError = true;
|
||||
} else if (!/[A-Z]/.test(newPassword)) {
|
||||
setNewError("Must contain at least one uppercase letter");
|
||||
hasError = true;
|
||||
} else if (!/[0-9]/.test(newPassword)) {
|
||||
setNewError("Must contain at least one number");
|
||||
hasError = true;
|
||||
} else if (!/[^A-Za-z0-9]/.test(newPassword)) {
|
||||
setNewError("Must contain at least one special character");
|
||||
hasError = true;
|
||||
}
|
||||
|
||||
if (!confirmPassword) {
|
||||
setConfirmError("Please confirm your new password");
|
||||
hasError = true;
|
||||
} else if (newPassword !== confirmPassword) {
|
||||
setConfirmError("Passwords do not match");
|
||||
hasError = true;
|
||||
}
|
||||
|
||||
if (hasError) return;
|
||||
|
||||
setIsLoading(true);
|
||||
try {
|
||||
await apiClient.post("/auth/change-password", {
|
||||
old_password: currentPassword,
|
||||
new_password: newPassword,
|
||||
});
|
||||
|
||||
const msg = "Password updated successfully!";
|
||||
if (Platform.OS === "web") {
|
||||
window.alert(msg);
|
||||
router.back();
|
||||
} else {
|
||||
Alert.alert("Success", msg, [
|
||||
{ text: "OK", onPress: () => router.back() },
|
||||
]);
|
||||
}
|
||||
} catch (err: any) {
|
||||
const errMsg =
|
||||
err?.response?.data?.detail ||
|
||||
"Failed to update password. Please check your current password.";
|
||||
setCurrentError(errMsg);
|
||||
if (Platform.OS === "web") {
|
||||
window.alert(errMsg);
|
||||
} else {
|
||||
Alert.alert("Error", errMsg);
|
||||
}
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<SafeAreaView style={styles.safeArea}>
|
||||
<KeyboardAvoidingView
|
||||
style={styles.keyboardContainer}
|
||||
behavior={Platform.OS === "ios" ? "padding" : undefined}
|
||||
>
|
||||
<ScrollView
|
||||
keyboardShouldPersistTaps="handled"
|
||||
showsVerticalScrollIndicator={false}
|
||||
contentContainerStyle={styles.contentContainer}
|
||||
>
|
||||
<View style={styles.container}>
|
||||
<SettingsHeader title="Change Password" />
|
||||
|
||||
<View style={styles.form}>
|
||||
<View style={styles.field}>
|
||||
<FieldLabel label="Current Password" required />
|
||||
<PasswordInput
|
||||
value={currentPassword}
|
||||
onChangeText={setCurrentPassword}
|
||||
placeholder="Enter current password"
|
||||
error={currentError}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View style={styles.field}>
|
||||
<FieldLabel label="New Password" required />
|
||||
<PasswordInput
|
||||
value={newPassword}
|
||||
onChangeText={setNewPassword}
|
||||
placeholder="Min. 8 characters with numbers & symbols"
|
||||
error={newError}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View style={styles.field}>
|
||||
<FieldLabel label="Confirm New Password" required />
|
||||
<PasswordInput
|
||||
value={confirmPassword}
|
||||
onChangeText={setConfirmPassword}
|
||||
placeholder="Re-enter new password"
|
||||
error={confirmError}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View style={styles.buttonSpacing}>
|
||||
<PrimaryButton
|
||||
title="Update Password"
|
||||
loading={isLoading}
|
||||
onPress={handleUpdatePassword}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</KeyboardAvoidingView>
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
safeArea: {
|
||||
flex: 1,
|
||||
backgroundColor: Colors.background,
|
||||
},
|
||||
keyboardContainer: {
|
||||
flex: 1,
|
||||
},
|
||||
contentContainer: {
|
||||
flexGrow: 1,
|
||||
paddingBottom: verticalScale(32),
|
||||
},
|
||||
container: {
|
||||
flex: 1,
|
||||
paddingHorizontal: moderateScale(20),
|
||||
paddingTop: verticalScale(12),
|
||||
},
|
||||
form: {
|
||||
marginTop: verticalScale(8),
|
||||
},
|
||||
field: {
|
||||
marginBottom: verticalScale(16),
|
||||
},
|
||||
buttonSpacing: {
|
||||
marginTop: verticalScale(12),
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
import EditProfileScreen from "@/screens/profile/EditProfileScreen";
|
||||
|
||||
export default function EditProfileRoute() {
|
||||
return <EditProfileScreen />;
|
||||
}
|
||||
|
|
@ -0,0 +1,159 @@
|
|||
import React from "react";
|
||||
import {
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
View,
|
||||
Text,
|
||||
} from "react-native";
|
||||
import { SafeAreaView } from "react-native-safe-area-context";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||
|
||||
import SettingsHeader from "@/features/settings/components/SettingsHeader";
|
||||
import { Colors } from "@/theme";
|
||||
|
||||
export default function AboutScreen() {
|
||||
return (
|
||||
<SafeAreaView style={styles.safeArea}>
|
||||
<ScrollView
|
||||
showsVerticalScrollIndicator={false}
|
||||
contentContainerStyle={styles.contentContainer}
|
||||
>
|
||||
<View style={styles.container}>
|
||||
<SettingsHeader title="About Acupedia" />
|
||||
|
||||
<View style={styles.logoSection}>
|
||||
<View style={styles.logoWrapper}>
|
||||
<Ionicons
|
||||
name="medical"
|
||||
size={moderateScale(42)}
|
||||
color={Colors.primary}
|
||||
/>
|
||||
</View>
|
||||
<Text style={styles.appName}>Acupedia</Text>
|
||||
<Text style={styles.appTagline}>
|
||||
Comprehensive Clinical Acupuncture Encyclopedia
|
||||
</Text>
|
||||
<View style={styles.versionBadge}>
|
||||
<Text style={styles.versionText}>Version 1.0.0 (Build 240)</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View style={styles.card}>
|
||||
<Text style={styles.infoTitle}>About This Platform</Text>
|
||||
<Text style={styles.infoText}>
|
||||
Acupedia is a clinical reference application developed specifically for acupuncture practitioners, researchers, and healthcare professionals. It delivers evidence-based anatomical mappings, point categories, channel pathways, and clinical safety considerations.
|
||||
</Text>
|
||||
|
||||
<View style={styles.separator} />
|
||||
|
||||
<Text style={styles.infoTitle}>Publisher & Organization</Text>
|
||||
<Text style={styles.infoText}>
|
||||
Published by Panacea Clinical Systems Pvt Ltd. All international rights reserved.
|
||||
</Text>
|
||||
|
||||
<View style={styles.separator} />
|
||||
|
||||
<Text style={styles.infoTitle}>Medical & Clinical Disclaimer</Text>
|
||||
<Text style={styles.disclaimerText}>
|
||||
The information provided in Acupedia is designed for accredited healthcare practitioners and educational reference only. It is not intended as a substitute for individualized clinical judgment, diagnosis, or emergency intervention.
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<Text style={styles.copyrightText}>
|
||||
© {new Date().getFullYear()} Panacea Clinical Systems. All Rights Reserved.
|
||||
</Text>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
safeArea: {
|
||||
flex: 1,
|
||||
backgroundColor: Colors.background,
|
||||
},
|
||||
contentContainer: {
|
||||
flexGrow: 1,
|
||||
paddingBottom: verticalScale(32),
|
||||
},
|
||||
container: {
|
||||
flex: 1,
|
||||
paddingHorizontal: moderateScale(20),
|
||||
paddingTop: verticalScale(12),
|
||||
},
|
||||
logoSection: {
|
||||
alignItems: "center",
|
||||
marginVertical: verticalScale(16),
|
||||
},
|
||||
logoWrapper: {
|
||||
width: moderateScale(80),
|
||||
height: moderateScale(80),
|
||||
borderRadius: moderateScale(40),
|
||||
backgroundColor: "#DCFCE7",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
marginBottom: verticalScale(12),
|
||||
borderWidth: 1,
|
||||
borderColor: "#BBF7D0",
|
||||
},
|
||||
appName: {
|
||||
fontSize: moderateScale(22),
|
||||
fontWeight: "800",
|
||||
color: Colors.textPrimary,
|
||||
marginBottom: verticalScale(4),
|
||||
},
|
||||
appTagline: {
|
||||
fontSize: moderateScale(13),
|
||||
color: Colors.textSecondary,
|
||||
textAlign: "center",
|
||||
marginBottom: verticalScale(10),
|
||||
},
|
||||
versionBadge: {
|
||||
backgroundColor: "#F1F5F9",
|
||||
paddingHorizontal: moderateScale(10),
|
||||
paddingVertical: verticalScale(4),
|
||||
borderRadius: moderateScale(12),
|
||||
},
|
||||
versionText: {
|
||||
fontSize: moderateScale(11),
|
||||
fontWeight: "600",
|
||||
color: "#64748B",
|
||||
},
|
||||
card: {
|
||||
backgroundColor: "#FFFFFF",
|
||||
borderRadius: moderateScale(16),
|
||||
borderWidth: 1,
|
||||
borderColor: "#E5E7EB",
|
||||
padding: moderateScale(18),
|
||||
marginBottom: verticalScale(20),
|
||||
},
|
||||
infoTitle: {
|
||||
fontSize: moderateScale(14),
|
||||
fontWeight: "700",
|
||||
color: Colors.textPrimary,
|
||||
marginBottom: verticalScale(6),
|
||||
},
|
||||
infoText: {
|
||||
fontSize: moderateScale(13),
|
||||
color: Colors.textSecondary,
|
||||
lineHeight: moderateScale(19),
|
||||
},
|
||||
disclaimerText: {
|
||||
fontSize: moderateScale(12),
|
||||
color: "#64748B",
|
||||
lineHeight: moderateScale(18),
|
||||
fontStyle: "italic",
|
||||
},
|
||||
separator: {
|
||||
height: 1,
|
||||
backgroundColor: "#F1F5F9",
|
||||
marginVertical: verticalScale(14),
|
||||
},
|
||||
copyrightText: {
|
||||
fontSize: moderateScale(11),
|
||||
color: Colors.textSecondary,
|
||||
textAlign: "center",
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,239 @@
|
|||
import React, { useState } from "react";
|
||||
import {
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
View,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
Alert,
|
||||
Linking,
|
||||
} from "react-native";
|
||||
import { SafeAreaView } from "react-native-safe-area-context";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||
|
||||
import SettingsHeader from "@/features/settings/components/SettingsHeader";
|
||||
import { Colors } from "@/theme";
|
||||
|
||||
interface FAQ {
|
||||
question: string;
|
||||
answer: string;
|
||||
}
|
||||
|
||||
const FAQS: FAQ[] = [
|
||||
{
|
||||
question: "What is Acupedia?",
|
||||
answer:
|
||||
"Acupedia is a comprehensive clinical reference application designed for acupuncture practitioners, researchers, and students. It offers verified anatomical point mappings, therapeutic indications, needling depths, and clinical protocols.",
|
||||
},
|
||||
{
|
||||
question: "How do I unlock additional clinical modules?",
|
||||
answer:
|
||||
"You can unlock full clinical libraries and specialized modules by visiting the Subscription tab or selecting any locked module to view tier plans.",
|
||||
},
|
||||
{
|
||||
question: "How do I edit my profile information?",
|
||||
answer:
|
||||
"Navigate to the Profile tab or Settings > Edit Profile. You can update your Full Name, Phone Number, and Country.",
|
||||
},
|
||||
{
|
||||
question: "Can I use Acupedia without an internet connection?",
|
||||
answer:
|
||||
"Yes. Once clinical modules and point definitions have been loaded, they remain cached on your device for offline reference in clinical settings.",
|
||||
},
|
||||
{
|
||||
question: "How do I report clinical inaccuracies or suggestions?",
|
||||
answer:
|
||||
"We take clinical accuracy seriously. Please reach out to our editorial and clinical review team directly using the Email Support button below.",
|
||||
},
|
||||
];
|
||||
|
||||
export default function HelpSupportScreen() {
|
||||
const [expandedIndex, setExpandedIndex] = useState<number | null>(0);
|
||||
|
||||
const handleContact = () => {
|
||||
Linking.openURL("mailto:support@acupedia.com").catch(() => {
|
||||
Alert.alert(
|
||||
"Contact Support",
|
||||
"Please email our support desk at support@acupedia.com"
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const toggleExpand = (index: number) => {
|
||||
setExpandedIndex(expandedIndex === index ? null : index);
|
||||
};
|
||||
|
||||
return (
|
||||
<SafeAreaView style={styles.safeArea}>
|
||||
<ScrollView
|
||||
showsVerticalScrollIndicator={false}
|
||||
contentContainerStyle={styles.contentContainer}
|
||||
>
|
||||
<View style={styles.container}>
|
||||
<SettingsHeader title="Help & Support" />
|
||||
|
||||
<Text style={styles.sectionSubtitle}>
|
||||
Find quick answers to common clinical questions or contact our support team.
|
||||
</Text>
|
||||
|
||||
<Text style={styles.sectionTitle}>Frequently Asked Questions</Text>
|
||||
|
||||
<View style={styles.faqCard}>
|
||||
{FAQS.map((faq, index) => {
|
||||
const isExpanded = expandedIndex === index;
|
||||
return (
|
||||
<View key={index}>
|
||||
<TouchableOpacity
|
||||
style={styles.faqHeader}
|
||||
onPress={() => toggleExpand(index)}
|
||||
activeOpacity={0.7}
|
||||
>
|
||||
<Text style={styles.questionText}>{faq.question}</Text>
|
||||
<Ionicons
|
||||
name={isExpanded ? "chevron-up" : "chevron-down"}
|
||||
size={moderateScale(18)}
|
||||
color={Colors.textSecondary}
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
|
||||
{isExpanded && (
|
||||
<View style={styles.answerContainer}>
|
||||
<Text style={styles.answerText}>{faq.answer}</Text>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{index < FAQS.length - 1 && <View style={styles.separator} />}
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
|
||||
<Text style={styles.sectionTitle}>Contact Our Team</Text>
|
||||
|
||||
<TouchableOpacity
|
||||
style={styles.contactCard}
|
||||
onPress={handleContact}
|
||||
activeOpacity={0.8}
|
||||
>
|
||||
<View style={styles.contactIconWrapper}>
|
||||
<Ionicons
|
||||
name="mail-outline"
|
||||
size={moderateScale(22)}
|
||||
color={Colors.primary}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.contactTextContainer}>
|
||||
<Text style={styles.contactLabel}>Email Clinical Support</Text>
|
||||
<Text style={styles.contactSubLabel}>
|
||||
Response typically within 24 hours (support@acupedia.com)
|
||||
</Text>
|
||||
</View>
|
||||
<Ionicons
|
||||
name="chevron-forward"
|
||||
size={moderateScale(18)}
|
||||
color={Colors.textSecondary}
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
safeArea: {
|
||||
flex: 1,
|
||||
backgroundColor: Colors.background,
|
||||
},
|
||||
contentContainer: {
|
||||
flexGrow: 1,
|
||||
paddingBottom: verticalScale(32),
|
||||
},
|
||||
container: {
|
||||
flex: 1,
|
||||
paddingHorizontal: moderateScale(20),
|
||||
paddingTop: verticalScale(12),
|
||||
},
|
||||
sectionSubtitle: {
|
||||
fontSize: moderateScale(13),
|
||||
color: Colors.textSecondary,
|
||||
marginBottom: verticalScale(16),
|
||||
lineHeight: moderateScale(18),
|
||||
},
|
||||
sectionTitle: {
|
||||
fontSize: moderateScale(13),
|
||||
fontWeight: "700",
|
||||
color: Colors.textSecondary,
|
||||
textTransform: "uppercase",
|
||||
letterSpacing: 0.5,
|
||||
marginBottom: verticalScale(8),
|
||||
marginLeft: moderateScale(4),
|
||||
},
|
||||
faqCard: {
|
||||
backgroundColor: "#FFFFFF",
|
||||
borderRadius: moderateScale(16),
|
||||
borderWidth: 1,
|
||||
borderColor: "#E5E7EB",
|
||||
paddingHorizontal: moderateScale(16),
|
||||
marginBottom: verticalScale(24),
|
||||
},
|
||||
faqHeader: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
paddingVertical: verticalScale(14),
|
||||
},
|
||||
questionText: {
|
||||
fontSize: moderateScale(14),
|
||||
fontWeight: "600",
|
||||
color: Colors.textPrimary,
|
||||
flex: 1,
|
||||
marginRight: moderateScale(12),
|
||||
lineHeight: moderateScale(19),
|
||||
},
|
||||
answerContainer: {
|
||||
paddingBottom: verticalScale(14),
|
||||
},
|
||||
answerText: {
|
||||
fontSize: moderateScale(13),
|
||||
color: Colors.textSecondary,
|
||||
lineHeight: moderateScale(19),
|
||||
},
|
||||
separator: {
|
||||
height: 1,
|
||||
backgroundColor: "#F1F5F9",
|
||||
},
|
||||
contactCard: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
backgroundColor: "#FFFFFF",
|
||||
borderRadius: moderateScale(16),
|
||||
borderWidth: 1,
|
||||
borderColor: "#E5E7EB",
|
||||
padding: moderateScale(16),
|
||||
},
|
||||
contactIconWrapper: {
|
||||
width: moderateScale(40),
|
||||
height: moderateScale(40),
|
||||
borderRadius: moderateScale(20),
|
||||
backgroundColor: "#DCFCE7",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
},
|
||||
contactTextContainer: {
|
||||
marginLeft: moderateScale(12),
|
||||
flex: 1,
|
||||
},
|
||||
contactLabel: {
|
||||
fontSize: moderateScale(15),
|
||||
fontWeight: "700",
|
||||
color: Colors.textPrimary,
|
||||
marginBottom: verticalScale(2),
|
||||
},
|
||||
contactSubLabel: {
|
||||
fontSize: moderateScale(12),
|
||||
color: Colors.textSecondary,
|
||||
lineHeight: moderateScale(16),
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
import SettingsScreen from "@/screens/settings/SettingsScreen";
|
||||
|
||||
export default function SettingsRoute() {
|
||||
return <SettingsScreen />;
|
||||
}
|
||||
|
|
@ -0,0 +1,232 @@
|
|||
import React from "react";
|
||||
import {
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
View,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
Alert,
|
||||
Platform,
|
||||
} from "react-native";
|
||||
import { SafeAreaView } from "react-native-safe-area-context";
|
||||
import { router } from "expo-router";
|
||||
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||
|
||||
import SettingsHeader from "@/features/settings/components/SettingsHeader";
|
||||
import PrimaryButton from "@/components/buttons/PrimaryButton";
|
||||
import { Colors } from "@/theme";
|
||||
import { useSettingsStore } from "@/store/settings.store";
|
||||
|
||||
interface LanguageItem {
|
||||
code: string;
|
||||
label: string;
|
||||
nativeLabel: string;
|
||||
available: boolean;
|
||||
}
|
||||
|
||||
const LANGUAGES: LanguageItem[] = [
|
||||
{
|
||||
code: "en",
|
||||
label: "English",
|
||||
nativeLabel: "English (US)",
|
||||
available: true,
|
||||
},
|
||||
{
|
||||
code: "hi",
|
||||
label: "Hindi",
|
||||
nativeLabel: "हिन्दी",
|
||||
available: false,
|
||||
},
|
||||
{
|
||||
code: "es",
|
||||
label: "Spanish",
|
||||
nativeLabel: "Español",
|
||||
available: false,
|
||||
},
|
||||
{
|
||||
code: "zh",
|
||||
label: "Chinese",
|
||||
nativeLabel: "中文 (Traditional & Simplified)",
|
||||
available: false,
|
||||
},
|
||||
{
|
||||
code: "fr",
|
||||
label: "French",
|
||||
nativeLabel: "Français",
|
||||
available: false,
|
||||
},
|
||||
];
|
||||
|
||||
export default function LanguageScreen() {
|
||||
const language = useSettingsStore((state) => state.language);
|
||||
const setLanguage = useSettingsStore((state) => state.setLanguage);
|
||||
|
||||
const handleSelect = (lang: LanguageItem) => {
|
||||
if (!lang.available) {
|
||||
const msg = `${lang.label} translation is in progress and will be available in an upcoming clinical taxonomy release.`;
|
||||
if (Platform.OS === "web") {
|
||||
window.alert(msg);
|
||||
} else {
|
||||
Alert.alert("Coming Soon", msg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
setLanguage(lang.code);
|
||||
};
|
||||
|
||||
const handleSave = () => {
|
||||
const selected = LANGUAGES.find((l) => l.code === language);
|
||||
const msg = `Language set to ${selected?.label || "English"}.`;
|
||||
if (Platform.OS === "web") {
|
||||
window.alert(msg);
|
||||
router.back();
|
||||
} else {
|
||||
Alert.alert("Success", msg, [
|
||||
{ text: "OK", onPress: () => router.back() },
|
||||
]);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<SafeAreaView style={styles.safeArea}>
|
||||
<ScrollView
|
||||
showsVerticalScrollIndicator={false}
|
||||
contentContainerStyle={styles.contentContainer}
|
||||
>
|
||||
<View style={styles.container}>
|
||||
<SettingsHeader title="Language" />
|
||||
|
||||
<Text style={styles.sectionSubtitle}>
|
||||
Choose your preferred clinical taxonomy and interface language.
|
||||
</Text>
|
||||
|
||||
<View style={styles.card}>
|
||||
{LANGUAGES.map((lang, index) => {
|
||||
const isSelected = language === lang.code;
|
||||
return (
|
||||
<TouchableOpacity
|
||||
key={lang.code}
|
||||
style={[
|
||||
styles.optionRow,
|
||||
index < LANGUAGES.length - 1 && styles.border,
|
||||
]}
|
||||
onPress={() => handleSelect(lang)}
|
||||
activeOpacity={0.7}
|
||||
>
|
||||
<View style={styles.textContainer}>
|
||||
<Text style={styles.title}>{lang.label}</Text>
|
||||
<Text style={styles.nativeLabel}>{lang.nativeLabel}</Text>
|
||||
</View>
|
||||
|
||||
{!lang.available ? (
|
||||
<View style={styles.comingSoonBadge}>
|
||||
<Text style={styles.comingSoonText}>Coming Soon</Text>
|
||||
</View>
|
||||
) : (
|
||||
<View
|
||||
style={[
|
||||
styles.radio,
|
||||
isSelected && styles.radioSelected,
|
||||
]}
|
||||
>
|
||||
{isSelected && <View style={styles.radioInner} />}
|
||||
</View>
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
|
||||
<View style={styles.buttonWrapper}>
|
||||
<PrimaryButton title="Confirm Language" onPress={handleSave} />
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
safeArea: {
|
||||
flex: 1,
|
||||
backgroundColor: Colors.background,
|
||||
},
|
||||
contentContainer: {
|
||||
flexGrow: 1,
|
||||
paddingBottom: verticalScale(32),
|
||||
},
|
||||
container: {
|
||||
flex: 1,
|
||||
paddingHorizontal: moderateScale(20),
|
||||
paddingTop: verticalScale(12),
|
||||
},
|
||||
sectionSubtitle: {
|
||||
fontSize: moderateScale(13),
|
||||
color: Colors.textSecondary,
|
||||
marginBottom: verticalScale(16),
|
||||
lineHeight: moderateScale(18),
|
||||
},
|
||||
card: {
|
||||
backgroundColor: "#FFFFFF",
|
||||
borderRadius: moderateScale(16),
|
||||
overflow: "hidden",
|
||||
borderWidth: 1,
|
||||
borderColor: "#E5E7EB",
|
||||
},
|
||||
optionRow: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
padding: moderateScale(16),
|
||||
},
|
||||
border: {
|
||||
borderBottomWidth: 1,
|
||||
borderBottomColor: "#F1F5F9",
|
||||
},
|
||||
textContainer: {
|
||||
flex: 1,
|
||||
marginRight: moderateScale(12),
|
||||
},
|
||||
title: {
|
||||
fontSize: moderateScale(14),
|
||||
fontWeight: "600",
|
||||
color: Colors.textPrimary,
|
||||
},
|
||||
nativeLabel: {
|
||||
fontSize: moderateScale(12),
|
||||
color: Colors.textSecondary,
|
||||
marginTop: verticalScale(2),
|
||||
},
|
||||
comingSoonBadge: {
|
||||
backgroundColor: "#F1F5F9",
|
||||
paddingHorizontal: moderateScale(8),
|
||||
paddingVertical: moderateScale(4),
|
||||
borderRadius: moderateScale(6),
|
||||
},
|
||||
comingSoonText: {
|
||||
fontSize: moderateScale(11),
|
||||
fontWeight: "600",
|
||||
color: "#64748B",
|
||||
},
|
||||
radio: {
|
||||
width: moderateScale(20),
|
||||
height: moderateScale(20),
|
||||
borderRadius: moderateScale(10),
|
||||
borderWidth: 2,
|
||||
borderColor: "#CBD5E1",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
},
|
||||
radioSelected: {
|
||||
borderColor: Colors.primary,
|
||||
},
|
||||
radioInner: {
|
||||
width: moderateScale(10),
|
||||
height: moderateScale(10),
|
||||
borderRadius: moderateScale(5),
|
||||
backgroundColor: Colors.primary,
|
||||
},
|
||||
buttonWrapper: {
|
||||
marginTop: verticalScale(24),
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
import React from "react";
|
||||
import {
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
View,
|
||||
Text,
|
||||
Alert,
|
||||
Platform,
|
||||
} from "react-native";
|
||||
import { SafeAreaView } from "react-native-safe-area-context";
|
||||
import { router } from "expo-router";
|
||||
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||
|
||||
import SettingsHeader from "@/features/settings/components/SettingsHeader";
|
||||
import ProfileMenuItem from "@/features/profile/components/ProfileMenuItem";
|
||||
import PrimaryButton from "@/components/buttons/PrimaryButton";
|
||||
import { Colors } from "@/theme";
|
||||
import { useSettingsStore } from "@/store/settings.store";
|
||||
|
||||
export default function NotificationSettingsScreen() {
|
||||
const notifications = useSettingsStore((state) => state.notifications);
|
||||
const setNotificationPreference = useSettingsStore(
|
||||
(state) => state.setNotificationPreference
|
||||
);
|
||||
|
||||
const handleSave = () => {
|
||||
const msg = "Notification preferences saved successfully!";
|
||||
if (Platform.OS === "web") {
|
||||
window.alert(msg);
|
||||
router.back();
|
||||
} else {
|
||||
Alert.alert("Success", msg, [
|
||||
{ text: "OK", onPress: () => router.back() },
|
||||
]);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<SafeAreaView style={styles.safeArea}>
|
||||
<ScrollView
|
||||
showsVerticalScrollIndicator={false}
|
||||
contentContainerStyle={styles.contentContainer}
|
||||
>
|
||||
<View style={styles.container}>
|
||||
<SettingsHeader title="Notification Settings" />
|
||||
|
||||
<Text style={styles.sectionSubtitle}>
|
||||
Configure how and when you want to receive clinical notices and app updates.
|
||||
</Text>
|
||||
|
||||
<View style={styles.card}>
|
||||
<ProfileMenuItem
|
||||
icon="notifications-outline"
|
||||
title="Push Notifications"
|
||||
subtitle="Receive alerts on mobile for key activities"
|
||||
isSwitch
|
||||
switchValue={notifications.push}
|
||||
onSwitchChange={(val) => setNotificationPreference("push", val)}
|
||||
/>
|
||||
|
||||
<ProfileMenuItem
|
||||
icon="medical-outline"
|
||||
title="Clinical Updates"
|
||||
subtitle="Notices about updated acupuncture points & evidence"
|
||||
isSwitch
|
||||
switchValue={notifications.clinicalUpdates}
|
||||
onSwitchChange={(val) =>
|
||||
setNotificationPreference("clinicalUpdates", val)
|
||||
}
|
||||
/>
|
||||
|
||||
<ProfileMenuItem
|
||||
icon="newspaper-outline"
|
||||
title="Weekly Digest"
|
||||
subtitle="Summary of recent clinical articles and cases"
|
||||
isSwitch
|
||||
switchValue={notifications.weeklyDigest}
|
||||
onSwitchChange={(val) =>
|
||||
setNotificationPreference("weeklyDigest", val)
|
||||
}
|
||||
/>
|
||||
|
||||
<ProfileMenuItem
|
||||
icon="volume-high-outline"
|
||||
title="Sound Alerts"
|
||||
subtitle="Play audio chime on arrival"
|
||||
isSwitch
|
||||
switchValue={notifications.sound}
|
||||
onSwitchChange={(val) => setNotificationPreference("sound", val)}
|
||||
/>
|
||||
|
||||
<ProfileMenuItem
|
||||
icon="phone-portrait-outline"
|
||||
title="Vibrate"
|
||||
subtitle="Haptic feedback on alerts"
|
||||
isSwitch
|
||||
isLast
|
||||
switchValue={notifications.vibration}
|
||||
onSwitchChange={(val) =>
|
||||
setNotificationPreference("vibration", val)
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View style={styles.buttonWrapper}>
|
||||
<PrimaryButton title="Save Preferences" onPress={handleSave} />
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
safeArea: {
|
||||
flex: 1,
|
||||
backgroundColor: Colors.background,
|
||||
},
|
||||
contentContainer: {
|
||||
flexGrow: 1,
|
||||
paddingBottom: verticalScale(32),
|
||||
},
|
||||
container: {
|
||||
flex: 1,
|
||||
paddingHorizontal: moderateScale(20),
|
||||
paddingTop: verticalScale(12),
|
||||
},
|
||||
sectionSubtitle: {
|
||||
fontSize: moderateScale(13),
|
||||
color: Colors.textSecondary,
|
||||
marginBottom: verticalScale(16),
|
||||
lineHeight: moderateScale(18),
|
||||
},
|
||||
card: {
|
||||
backgroundColor: "#FFFFFF",
|
||||
borderRadius: moderateScale(16),
|
||||
overflow: "hidden",
|
||||
borderWidth: 1,
|
||||
borderColor: "#E5E7EB",
|
||||
},
|
||||
buttonWrapper: {
|
||||
marginTop: verticalScale(24),
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,171 @@
|
|||
import React, { useState } from "react";
|
||||
import {
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
View,
|
||||
Text,
|
||||
Alert,
|
||||
Platform,
|
||||
} from "react-native";
|
||||
import { SafeAreaView } from "react-native-safe-area-context";
|
||||
import { router } from "expo-router";
|
||||
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||
|
||||
import SettingsHeader from "@/features/settings/components/SettingsHeader";
|
||||
import ProfileMenuItem from "@/features/profile/components/ProfileMenuItem";
|
||||
import PrimaryButton from "@/components/buttons/PrimaryButton";
|
||||
import { Colors } from "@/theme";
|
||||
|
||||
export default function PrivacySettingsScreen() {
|
||||
const [analyticsEnabled, setAnalyticsEnabled] = useState(true);
|
||||
const [offlineCacheEnabled, setOfflineCacheEnabled] = useState(true);
|
||||
|
||||
const handleClearHistory = () => {
|
||||
const doClear = () => {
|
||||
const msg = "Search and navigation history cleared.";
|
||||
if (Platform.OS === "web") {
|
||||
window.alert(msg);
|
||||
} else {
|
||||
Alert.alert("Success", msg);
|
||||
}
|
||||
};
|
||||
|
||||
if (Platform.OS === "web") {
|
||||
if (window.confirm("Clear all local search history? This cannot be undone.")) {
|
||||
doClear();
|
||||
}
|
||||
} else {
|
||||
Alert.alert(
|
||||
"Clear Search History",
|
||||
"Are you sure you want to clear your local search history?",
|
||||
[
|
||||
{ text: "Cancel", style: "cancel" },
|
||||
{ text: "Clear", style: "destructive", onPress: doClear },
|
||||
]
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSave = () => {
|
||||
const msg = "Privacy preferences updated!";
|
||||
if (Platform.OS === "web") {
|
||||
window.alert(msg);
|
||||
router.back();
|
||||
} else {
|
||||
Alert.alert("Success", msg, [
|
||||
{ text: "OK", onPress: () => router.back() },
|
||||
]);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<SafeAreaView style={styles.safeArea}>
|
||||
<ScrollView
|
||||
showsVerticalScrollIndicator={false}
|
||||
contentContainerStyle={styles.contentContainer}
|
||||
>
|
||||
<View style={styles.container}>
|
||||
<SettingsHeader title="Privacy & Data" />
|
||||
|
||||
<Text style={styles.sectionSubtitle}>
|
||||
Manage your personal data storage, local history, and anonymized metrics.
|
||||
</Text>
|
||||
|
||||
<View style={styles.card}>
|
||||
<ProfileMenuItem
|
||||
icon="analytics-outline"
|
||||
title="Share Anonymous Diagnostics"
|
||||
subtitle="Helps Acupedia improve performance & stability"
|
||||
isSwitch
|
||||
switchValue={analyticsEnabled}
|
||||
onSwitchChange={setAnalyticsEnabled}
|
||||
/>
|
||||
|
||||
<ProfileMenuItem
|
||||
icon="server-outline"
|
||||
title="Offline Content Caching"
|
||||
subtitle="Cache accessed modules for offline clinical reading"
|
||||
isSwitch
|
||||
switchValue={offlineCacheEnabled}
|
||||
onSwitchChange={setOfflineCacheEnabled}
|
||||
/>
|
||||
|
||||
<ProfileMenuItem
|
||||
icon="trash-outline"
|
||||
title="Clear Search History"
|
||||
subtitle="Remove cached search queries & recents"
|
||||
showArrow
|
||||
isLast
|
||||
onPress={handleClearHistory}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View style={styles.infoBox}>
|
||||
<Text style={styles.infoTitle}>Clinical Privacy & Content Protection</Text>
|
||||
<Text style={styles.infoText}>
|
||||
Acupedia is strictly compliant with privacy principles. We never sell your clinical search data, bookmarks, or account information to third parties.
|
||||
</Text>
|
||||
<Text style={[styles.infoText, { marginTop: 6 }]}>
|
||||
Proprietary anatomical charts, point coordinates, and clinical needling depths are protected by hardware screen-capture and recording prevention on native mobile devices.
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<View style={styles.buttonWrapper}>
|
||||
<PrimaryButton title="Save Preferences" onPress={handleSave} />
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
safeArea: {
|
||||
flex: 1,
|
||||
backgroundColor: Colors.background,
|
||||
},
|
||||
contentContainer: {
|
||||
flexGrow: 1,
|
||||
paddingBottom: verticalScale(32),
|
||||
},
|
||||
container: {
|
||||
flex: 1,
|
||||
paddingHorizontal: moderateScale(20),
|
||||
paddingTop: verticalScale(12),
|
||||
},
|
||||
sectionSubtitle: {
|
||||
fontSize: moderateScale(13),
|
||||
color: Colors.textSecondary,
|
||||
marginBottom: verticalScale(16),
|
||||
lineHeight: moderateScale(18),
|
||||
},
|
||||
card: {
|
||||
backgroundColor: "#FFFFFF",
|
||||
borderRadius: moderateScale(16),
|
||||
overflow: "hidden",
|
||||
borderWidth: 1,
|
||||
borderColor: "#E5E7EB",
|
||||
marginBottom: verticalScale(20),
|
||||
},
|
||||
infoBox: {
|
||||
backgroundColor: "#F8FAFC",
|
||||
borderRadius: moderateScale(14),
|
||||
padding: moderateScale(16),
|
||||
borderWidth: 1,
|
||||
borderColor: "#E2E8F0",
|
||||
},
|
||||
infoTitle: {
|
||||
fontSize: moderateScale(14),
|
||||
fontWeight: "700",
|
||||
color: Colors.textPrimary,
|
||||
marginBottom: verticalScale(4),
|
||||
},
|
||||
infoText: {
|
||||
fontSize: moderateScale(12),
|
||||
color: Colors.textSecondary,
|
||||
lineHeight: moderateScale(18),
|
||||
},
|
||||
buttonWrapper: {
|
||||
marginTop: verticalScale(24),
|
||||
},
|
||||
});
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import React, { type PropsWithChildren, useMemo, useState } from "react";
|
||||
import React, { type PropsWithChildren, useEffect, useMemo, useState } from "react";
|
||||
import {
|
||||
LayoutAnimation,
|
||||
Platform,
|
||||
|
|
@ -30,6 +30,10 @@ export function AccordionSection({
|
|||
const [expanded, setExpanded] = useState(defaultExpanded);
|
||||
const tone = useMemo(() => readingToneForTitle(title), [title]);
|
||||
|
||||
useEffect(() => {
|
||||
setExpanded(defaultExpanded);
|
||||
}, [defaultExpanded]);
|
||||
|
||||
const toggle = () => {
|
||||
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
||||
setExpanded((value) => !value);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import React, { type PropsWithChildren, isValidElement } from "react";
|
|||
|
||||
import { isEmptyValue } from "../../utils/attribute-presentation";
|
||||
import { AccordionSection } from "./AccordionSection";
|
||||
import { useSettingsStore } from "@/store/settings.store";
|
||||
|
||||
export interface SectionCardProps {
|
||||
title: string;
|
||||
|
|
@ -35,13 +36,20 @@ function hasRenderableContent(node: React.ReactNode): boolean {
|
|||
|
||||
export function SectionCard({
|
||||
title,
|
||||
defaultExpanded = true,
|
||||
defaultExpanded,
|
||||
children,
|
||||
}: PropsWithChildren<SectionCardProps>) {
|
||||
if (!hasRenderableContent(children)) return null;
|
||||
|
||||
const accordionDefaultExpanded = useSettingsStore(
|
||||
(state) => state.accordionDefaultExpanded
|
||||
);
|
||||
|
||||
const isExpanded =
|
||||
defaultExpanded !== undefined ? defaultExpanded : accordionDefaultExpanded;
|
||||
|
||||
return (
|
||||
<AccordionSection title={title} defaultExpanded={defaultExpanded}>
|
||||
<AccordionSection title={title} defaultExpanded={isExpanded}>
|
||||
{children}
|
||||
</AccordionSection>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
import React from "react";
|
||||
import {
|
||||
Pressable,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
import { Image } from "expo-image";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import {
|
||||
moderateScale,
|
||||
scale,
|
||||
|
|
@ -13,46 +11,25 @@ import {
|
|||
} from "react-native-size-matters";
|
||||
|
||||
interface EditProfileAvatarProps {
|
||||
imageUri?: string;
|
||||
onPress?: () => void;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export default function EditProfileAvatar({
|
||||
imageUri,
|
||||
onPress,
|
||||
}: EditProfileAvatarProps) {
|
||||
function getInitials(nameString?: string): string {
|
||||
if (!nameString || !nameString.trim()) return "U";
|
||||
const parts = nameString.trim().split(/\s+/);
|
||||
if (parts.length === 1) {
|
||||
return parts[0].slice(0, 2).toUpperCase();
|
||||
}
|
||||
return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
|
||||
}
|
||||
|
||||
export default function EditProfileAvatar({ name }: EditProfileAvatarProps) {
|
||||
const initials = getInitials(name);
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<View style={styles.avatarWrapper}>
|
||||
{imageUri ? (
|
||||
<Image
|
||||
source={{ uri: imageUri }}
|
||||
style={styles.avatar}
|
||||
contentFit="cover"
|
||||
/>
|
||||
) : (
|
||||
<View style={styles.avatar}>
|
||||
<Ionicons
|
||||
name="person"
|
||||
size={moderateScale(56)}
|
||||
color="#B8B8B8"
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel="Change Profile Picture"
|
||||
hitSlop={10}
|
||||
onPress={onPress}
|
||||
style={styles.cameraButton}
|
||||
>
|
||||
<Ionicons
|
||||
name="camera"
|
||||
size={moderateScale(15)}
|
||||
color="#FFFFFF"
|
||||
/>
|
||||
</Pressable>
|
||||
<View style={styles.initialsContainer}>
|
||||
<Text style={styles.initialsText}>{initials}</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
|
|
@ -61,37 +38,24 @@ export default function EditProfileAvatar({
|
|||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
alignItems: "center",
|
||||
marginBottom: verticalScale(28),
|
||||
marginBottom: verticalScale(16),
|
||||
},
|
||||
|
||||
avatarWrapper: {
|
||||
position: "relative",
|
||||
},
|
||||
|
||||
avatar: {
|
||||
width: scale(108),
|
||||
height: scale(108),
|
||||
borderRadius: scale(54),
|
||||
backgroundColor: "#F2F3F7",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
},
|
||||
|
||||
cameraButton: {
|
||||
position: "absolute",
|
||||
right: scale(0),
|
||||
bottom: scale(2),
|
||||
|
||||
width: scale(32),
|
||||
height: scale(32),
|
||||
borderRadius: scale(16),
|
||||
|
||||
backgroundColor: "#5B3DF5",
|
||||
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
|
||||
initialsContainer: {
|
||||
width: scale(88),
|
||||
height: scale(88),
|
||||
borderRadius: scale(44),
|
||||
backgroundColor: "#DCFCE7",
|
||||
borderWidth: 2,
|
||||
borderColor: "#FFFFFF",
|
||||
borderColor: "#BBF7D0",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
},
|
||||
|
||||
initialsText: {
|
||||
fontSize: moderateScale(28),
|
||||
fontWeight: "800",
|
||||
color: "#15803D",
|
||||
letterSpacing: 1,
|
||||
},
|
||||
});
|
||||
|
|
@ -1,9 +1,16 @@
|
|||
import React, { useState, useEffect } from "react";
|
||||
import {
|
||||
Modal,
|
||||
Pressable,
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import {
|
||||
moderateScale,
|
||||
scale,
|
||||
verticalScale,
|
||||
} from "react-native-size-matters";
|
||||
|
||||
|
|
@ -11,26 +18,48 @@ import BaseTextInput from "@/components/forms/BaseTextInput";
|
|||
import DropdownField from "@/components/forms/DropdownField";
|
||||
import FieldLabel from "@/components/forms/FieldLabel";
|
||||
import PrimaryButton from "@/components/buttons/PrimaryButton";
|
||||
import { Colors } from "@/theme";
|
||||
|
||||
interface EditProfileFormProps {
|
||||
initialName?: string;
|
||||
initialEmail?: string;
|
||||
initialPhone?: string;
|
||||
initialProfession?: string;
|
||||
initialCountry?: string;
|
||||
onSave?: (updatedName: string, updatedPhone: string) => void;
|
||||
onSave?: (updatedName: string, updatedPhone: string, updatedCountry: string) => void;
|
||||
isLoading?: boolean;
|
||||
}
|
||||
|
||||
const COMMON_COUNTRIES = [
|
||||
"India",
|
||||
"United States",
|
||||
"United Kingdom",
|
||||
"Canada",
|
||||
"Australia",
|
||||
"Germany",
|
||||
"Singapore",
|
||||
"Malaysia",
|
||||
"New Zealand",
|
||||
"United Arab Emirates",
|
||||
"South Africa",
|
||||
"Ireland",
|
||||
"Netherlands",
|
||||
"Switzerland",
|
||||
"France",
|
||||
"Spain",
|
||||
];
|
||||
|
||||
export default function EditProfileForm({
|
||||
initialName = "User Name",
|
||||
initialEmail = "user@example.com",
|
||||
initialPhone = "",
|
||||
initialProfession = "Practitioner",
|
||||
initialCountry = "India",
|
||||
onSave,
|
||||
isLoading = false,
|
||||
}: EditProfileFormProps) {
|
||||
const [fullName, setFullName] = useState(initialName);
|
||||
const [phone, setPhone] = useState(initialPhone);
|
||||
const [country, setCountry] = useState(initialCountry);
|
||||
const [showCountryModal, setShowCountryModal] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setFullName(initialName);
|
||||
|
|
@ -40,35 +69,25 @@ export default function EditProfileForm({
|
|||
setPhone(initialPhone);
|
||||
}, [initialPhone]);
|
||||
|
||||
const [profession, setProfession] =
|
||||
useState(initialProfession);
|
||||
|
||||
const [country] =
|
||||
useState(initialCountry);
|
||||
useEffect(() => {
|
||||
setCountry(initialCountry);
|
||||
}, [initialCountry]);
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<View style={styles.field}>
|
||||
<FieldLabel
|
||||
label="Full Name"
|
||||
required
|
||||
/>
|
||||
|
||||
<FieldLabel label="Full Name" required />
|
||||
<BaseTextInput
|
||||
value={fullName}
|
||||
onChangeText={setFullName}
|
||||
placeholder="User Name"
|
||||
placeholder="Your full name"
|
||||
autoCapitalize="words"
|
||||
autoCorrect={false}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View style={styles.field}>
|
||||
<FieldLabel
|
||||
label="Email"
|
||||
required
|
||||
/>
|
||||
|
||||
<FieldLabel label="Email" required />
|
||||
<BaseTextInput
|
||||
value={initialEmail}
|
||||
editable={false}
|
||||
|
|
@ -77,17 +96,17 @@ export default function EditProfileForm({
|
|||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
/>
|
||||
<Text style={styles.helperText}>
|
||||
Email address is tied to your account identity and subscriptions.
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<View style={styles.field}>
|
||||
<FieldLabel
|
||||
label="Phone Number"
|
||||
/>
|
||||
|
||||
<FieldLabel label="Phone Number" />
|
||||
<BaseTextInput
|
||||
value={phone}
|
||||
onChangeText={setPhone}
|
||||
placeholder="Phone Number"
|
||||
placeholder="e.g. +91 9876543210"
|
||||
keyboardType="phone-pad"
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
|
|
@ -95,50 +114,176 @@ export default function EditProfileForm({
|
|||
</View>
|
||||
|
||||
<View style={styles.field}>
|
||||
<FieldLabel
|
||||
label="Profession (Optional)"
|
||||
/>
|
||||
|
||||
<BaseTextInput
|
||||
value={profession}
|
||||
onChangeText={setProfession}
|
||||
placeholder="Practitioner"
|
||||
autoCapitalize="words"
|
||||
autoCorrect={false}
|
||||
<FieldLabel label="Country / Region" required />
|
||||
<DropdownField
|
||||
value={country}
|
||||
placeholder="Select country"
|
||||
onPress={() => setShowCountryModal(true)}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View style={styles.field}>
|
||||
<FieldLabel
|
||||
label="Country / Region"
|
||||
required
|
||||
/>
|
||||
|
||||
<DropdownField
|
||||
value={country}
|
||||
<View style={styles.buttonWrapper}>
|
||||
<PrimaryButton
|
||||
title="Save Changes"
|
||||
loading={isLoading}
|
||||
onPress={() => {
|
||||
// TODO:
|
||||
// Open Country Picker
|
||||
onSave?.(fullName, phone, country);
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<PrimaryButton
|
||||
title="Save Changes"
|
||||
onPress={() => {
|
||||
onSave?.(fullName, phone);
|
||||
}}
|
||||
/>
|
||||
{/* Country Selection Modal */}
|
||||
<Modal
|
||||
visible={showCountryModal}
|
||||
transparent
|
||||
animationType="slide"
|
||||
onRequestClose={() => setShowCountryModal(false)}
|
||||
>
|
||||
<Pressable
|
||||
style={styles.modalOverlay}
|
||||
onPress={() => setShowCountryModal(false)}
|
||||
>
|
||||
<View style={styles.modalSheet}>
|
||||
<View style={styles.modalHeader}>
|
||||
<Text style={styles.modalTitle}>Select Country</Text>
|
||||
<Pressable
|
||||
hitSlop={8}
|
||||
onPress={() => setShowCountryModal(false)}
|
||||
>
|
||||
<Ionicons
|
||||
name="close"
|
||||
size={moderateScale(22)}
|
||||
color={Colors.textSecondary}
|
||||
/>
|
||||
</Pressable>
|
||||
</View>
|
||||
|
||||
<ScrollView
|
||||
showsVerticalScrollIndicator={false}
|
||||
contentContainerStyle={styles.countryList}
|
||||
>
|
||||
{COMMON_COUNTRIES.map((c) => {
|
||||
const isSelected = country === c;
|
||||
return (
|
||||
<Pressable
|
||||
key={c}
|
||||
style={({ pressed }) => [
|
||||
styles.countryItem,
|
||||
isSelected && styles.countryItemSelected,
|
||||
pressed && styles.countryItemPressed,
|
||||
]}
|
||||
onPress={() => {
|
||||
setCountry(c);
|
||||
setShowCountryModal(false);
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={[
|
||||
styles.countryName,
|
||||
isSelected && styles.countryNameSelected,
|
||||
]}
|
||||
>
|
||||
{c}
|
||||
</Text>
|
||||
{isSelected && (
|
||||
<Ionicons
|
||||
name="checkmark"
|
||||
size={moderateScale(18)}
|
||||
color={Colors.primary}
|
||||
/>
|
||||
)}
|
||||
</Pressable>
|
||||
);
|
||||
})}
|
||||
</ScrollView>
|
||||
</View>
|
||||
</Pressable>
|
||||
</Modal>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
marginTop: verticalScale(8),
|
||||
marginTop: verticalScale(4),
|
||||
},
|
||||
|
||||
field: {
|
||||
marginBottom: verticalScale(18),
|
||||
marginBottom: verticalScale(16),
|
||||
},
|
||||
|
||||
helperText: {
|
||||
marginTop: verticalScale(4),
|
||||
fontSize: moderateScale(11),
|
||||
color: Colors.textSecondary,
|
||||
lineHeight: moderateScale(15),
|
||||
},
|
||||
|
||||
buttonWrapper: {
|
||||
marginTop: verticalScale(10),
|
||||
},
|
||||
|
||||
modalOverlay: {
|
||||
flex: 1,
|
||||
backgroundColor: "rgba(0, 0, 0, 0.4)",
|
||||
justifyContent: "flex-end",
|
||||
},
|
||||
|
||||
modalSheet: {
|
||||
backgroundColor: "#FFFFFF",
|
||||
borderTopLeftRadius: moderateScale(20),
|
||||
borderTopRightRadius: moderateScale(20),
|
||||
maxHeight: "70%",
|
||||
paddingTop: verticalScale(16),
|
||||
paddingBottom: verticalScale(32),
|
||||
},
|
||||
|
||||
modalHeader: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
paddingHorizontal: scale(20),
|
||||
paddingBottom: verticalScale(12),
|
||||
borderBottomWidth: 1,
|
||||
borderBottomColor: "#F1F5F9",
|
||||
},
|
||||
|
||||
modalTitle: {
|
||||
fontSize: moderateScale(17),
|
||||
fontWeight: "700",
|
||||
color: Colors.textPrimary,
|
||||
},
|
||||
|
||||
countryList: {
|
||||
paddingHorizontal: scale(16),
|
||||
paddingTop: verticalScale(8),
|
||||
},
|
||||
|
||||
countryItem: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
paddingVertical: verticalScale(12),
|
||||
paddingHorizontal: scale(12),
|
||||
borderRadius: moderateScale(10),
|
||||
},
|
||||
|
||||
countryItemSelected: {
|
||||
backgroundColor: "#DCFCE7",
|
||||
},
|
||||
|
||||
countryItemPressed: {
|
||||
backgroundColor: "#F1F5F9",
|
||||
},
|
||||
|
||||
countryName: {
|
||||
fontSize: moderateScale(14),
|
||||
color: Colors.textPrimary,
|
||||
fontWeight: "500",
|
||||
},
|
||||
|
||||
countryNameSelected: {
|
||||
fontWeight: "700",
|
||||
color: "#15803D",
|
||||
},
|
||||
});
|
||||
|
|
@ -1,13 +1,9 @@
|
|||
import React from "react";
|
||||
import {
|
||||
Pressable,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
import { Image } from "expo-image";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { useRouter } from "expo-router";
|
||||
import {
|
||||
moderateScale,
|
||||
scale,
|
||||
|
|
@ -19,71 +15,31 @@ import { Colors } from "@/theme";
|
|||
interface ProfileAvatarProps {
|
||||
name: string;
|
||||
email: string;
|
||||
imageUri?: string;
|
||||
onEditPress?: () => void;
|
||||
}
|
||||
|
||||
function getInitials(nameString: string): string {
|
||||
if (!nameString || !nameString.trim()) return "U";
|
||||
const parts = nameString.trim().split(/\s+/);
|
||||
if (parts.length === 1) {
|
||||
return parts[0].slice(0, 2).toUpperCase();
|
||||
}
|
||||
return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
|
||||
}
|
||||
|
||||
export default function ProfileAvatar({
|
||||
name,
|
||||
email,
|
||||
imageUri,
|
||||
onEditPress,
|
||||
}: ProfileAvatarProps) {
|
||||
const router = useRouter();
|
||||
|
||||
const handleEditProfile = () => {
|
||||
onEditPress?.();
|
||||
router.push("/profile/edit");
|
||||
};
|
||||
const initials = getInitials(name);
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<View style={styles.avatarWrapper}>
|
||||
{imageUri ? (
|
||||
<Image
|
||||
source={{ uri: imageUri }}
|
||||
style={styles.avatar}
|
||||
contentFit="cover"
|
||||
/>
|
||||
) : (
|
||||
<View style={styles.avatar}>
|
||||
<Ionicons
|
||||
name="person"
|
||||
size={moderateScale(52)}
|
||||
color="#B8B8B8"
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel="Edit Profile Picture"
|
||||
hitSlop={10}
|
||||
onPress={handleEditProfile}
|
||||
style={styles.editButton}
|
||||
>
|
||||
<Ionicons
|
||||
name="camera"
|
||||
size={moderateScale(14)}
|
||||
color="#FFFFFF"
|
||||
/>
|
||||
</Pressable>
|
||||
<View style={styles.initialsContainer}>
|
||||
<Text style={styles.initialsText}>{initials}</Text>
|
||||
</View>
|
||||
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel="Edit Profile"
|
||||
hitSlop={10}
|
||||
onPress={handleEditProfile}
|
||||
>
|
||||
<Text style={styles.name}>
|
||||
{name}
|
||||
</Text>
|
||||
</Pressable>
|
||||
|
||||
<Text style={styles.email}>
|
||||
{email}
|
||||
</Text>
|
||||
<Text style={styles.name}>{name}</Text>
|
||||
<Text style={styles.email}>{email}</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
|
@ -91,51 +47,40 @@ export default function ProfileAvatar({
|
|||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
alignItems: "center",
|
||||
marginTop: verticalScale(10),
|
||||
marginBottom: verticalScale(28),
|
||||
},
|
||||
|
||||
avatarWrapper: {
|
||||
position: "relative",
|
||||
marginTop: verticalScale(4),
|
||||
marginBottom: verticalScale(16),
|
||||
},
|
||||
|
||||
avatar: {
|
||||
width: scale(96),
|
||||
height: scale(96),
|
||||
borderRadius: scale(48),
|
||||
backgroundColor: "#F2F3F7",
|
||||
initialsContainer: {
|
||||
width: scale(88),
|
||||
height: scale(88),
|
||||
borderRadius: scale(44),
|
||||
backgroundColor: "#DCFCE7",
|
||||
borderWidth: 2,
|
||||
borderColor: "#BBF7D0",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
marginBottom: verticalScale(12),
|
||||
},
|
||||
|
||||
editButton: {
|
||||
position: "absolute",
|
||||
right: scale(-2),
|
||||
bottom: scale(-2),
|
||||
|
||||
width: scale(30),
|
||||
height: scale(30),
|
||||
borderRadius: scale(15),
|
||||
|
||||
backgroundColor: "#5B3DF5",
|
||||
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
|
||||
borderWidth: 2,
|
||||
borderColor: "#FFFFFF",
|
||||
initialsText: {
|
||||
fontSize: moderateScale(28),
|
||||
fontWeight: "800",
|
||||
color: "#15803D",
|
||||
letterSpacing: 1,
|
||||
},
|
||||
|
||||
name: {
|
||||
fontSize: moderateScale(18),
|
||||
fontWeight: "700",
|
||||
color: Colors.text,
|
||||
color: Colors.textPrimary,
|
||||
textAlign: "center",
|
||||
},
|
||||
|
||||
email: {
|
||||
marginTop: verticalScale(6),
|
||||
fontSize: moderateScale(14),
|
||||
color: "#7A7A7A",
|
||||
marginTop: verticalScale(3),
|
||||
fontSize: moderateScale(13),
|
||||
color: Colors.textSecondary,
|
||||
textAlign: "center",
|
||||
},
|
||||
});
|
||||
|
|
@ -17,55 +17,64 @@ import { Colors } from "@/theme";
|
|||
|
||||
interface ProfileHeaderProps {
|
||||
title?: string;
|
||||
showBackButton?: boolean;
|
||||
onSettingsPress?: () => void;
|
||||
}
|
||||
|
||||
export default function ProfileHeader({
|
||||
title = "My Profile",
|
||||
showBackButton = false,
|
||||
onSettingsPress,
|
||||
}: ProfileHeaderProps) {
|
||||
const router = useRouter();
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel="Go Back"
|
||||
hitSlop={10}
|
||||
style={styles.iconButton}
|
||||
onPress={() => {
|
||||
if (router.canGoBack()) {
|
||||
router.back();
|
||||
} else {
|
||||
router.replace("/");
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Ionicons
|
||||
name="arrow-back"
|
||||
size={moderateScale(22)}
|
||||
color={Colors.text}
|
||||
/>
|
||||
</Pressable>
|
||||
{showBackButton ? (
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel="Go Back"
|
||||
hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }}
|
||||
style={({ pressed }) => [
|
||||
styles.iconButton,
|
||||
pressed && styles.iconButtonPressed,
|
||||
]}
|
||||
onPress={() => {
|
||||
if (router.canGoBack()) {
|
||||
router.back();
|
||||
} else {
|
||||
router.replace("/");
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Ionicons
|
||||
name="chevron-back"
|
||||
size={moderateScale(24)}
|
||||
color={Colors.textPrimary}
|
||||
/>
|
||||
</Pressable>
|
||||
) : (
|
||||
<View style={styles.placeholder} />
|
||||
)}
|
||||
|
||||
<Text
|
||||
numberOfLines={1}
|
||||
style={styles.title}
|
||||
>
|
||||
<Text numberOfLines={1} style={styles.title}>
|
||||
{title}
|
||||
</Text>
|
||||
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel="Settings"
|
||||
hitSlop={10}
|
||||
style={styles.iconButton}
|
||||
hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }}
|
||||
style={({ pressed }) => [
|
||||
styles.iconButton,
|
||||
pressed && styles.iconButtonPressed,
|
||||
]}
|
||||
onPress={onSettingsPress}
|
||||
>
|
||||
<Ionicons
|
||||
name="settings-outline"
|
||||
size={moderateScale(22)}
|
||||
color={Colors.text}
|
||||
size={moderateScale(21)}
|
||||
color={Colors.textPrimary}
|
||||
/>
|
||||
</Pressable>
|
||||
</View>
|
||||
|
|
@ -74,36 +83,36 @@ export default function ProfileHeader({
|
|||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
height: verticalScale(56),
|
||||
|
||||
height: verticalScale(50),
|
||||
flexDirection: "row",
|
||||
|
||||
alignItems: "center",
|
||||
|
||||
justifyContent: "space-between",
|
||||
|
||||
marginBottom: verticalScale(24),
|
||||
marginBottom: verticalScale(16),
|
||||
},
|
||||
|
||||
iconButton: {
|
||||
width: scale(40),
|
||||
|
||||
height: scale(40),
|
||||
|
||||
width: scale(38),
|
||||
height: scale(38),
|
||||
borderRadius: scale(19),
|
||||
justifyContent: "center",
|
||||
|
||||
alignItems: "center",
|
||||
backgroundColor: "#F1F5F9",
|
||||
},
|
||||
|
||||
iconButtonPressed: {
|
||||
backgroundColor: "#E2E8F0",
|
||||
},
|
||||
|
||||
title: {
|
||||
flex: 1,
|
||||
|
||||
textAlign: "center",
|
||||
|
||||
fontSize: moderateScale(18),
|
||||
|
||||
fontWeight: "700",
|
||||
color: Colors.textPrimary,
|
||||
},
|
||||
|
||||
color: Colors.text,
|
||||
placeholder: {
|
||||
width: scale(38),
|
||||
height: scale(38),
|
||||
},
|
||||
});
|
||||
|
|
@ -96,12 +96,14 @@ export default function ProfileMenuItem({
|
|||
)}
|
||||
|
||||
{isSwitch ? (
|
||||
<Switch
|
||||
value={switchValue}
|
||||
onValueChange={onSwitchChange}
|
||||
trackColor={{ false: "#CBD5E1", true: "#2563EB" }}
|
||||
thumbColor="#FFFFFF"
|
||||
/>
|
||||
<View style={{ pointerEvents: "none" }}>
|
||||
<Switch
|
||||
value={switchValue}
|
||||
onValueChange={onSwitchChange}
|
||||
trackColor={{ false: "#E2E8F0", true: Colors.primary }}
|
||||
thumbColor="#FFFFFF"
|
||||
/>
|
||||
</View>
|
||||
) : showArrow ? (
|
||||
<Ionicons
|
||||
name="chevron-forward"
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import React, { useEffect } from "react";
|
||||
import { StyleSheet, Text, View } from "react-native";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||
import { moderateScale, scale, verticalScale } from "react-native-size-matters";
|
||||
|
||||
import ProfileMenuItem from "./ProfileMenuItem";
|
||||
import { useAuthStore } from "@/store/auth.store";
|
||||
import { Colors } from "@/theme";
|
||||
|
||||
function formatDate(value?: string | null): string {
|
||||
if (!value) return "Lifetime Access";
|
||||
|
|
@ -36,7 +37,9 @@ export default function ProfileOverviewCard() {
|
|||
|
||||
useEffect(() => {
|
||||
if (accessToken) {
|
||||
void refreshAccess().catch((error) => console.warn("Unable to refresh profile access:", error));
|
||||
void refreshAccess().catch((error) =>
|
||||
console.warn("Unable to refresh profile access:", error)
|
||||
);
|
||||
}
|
||||
}, [accessToken, refreshAccess]);
|
||||
|
||||
|
|
@ -81,23 +84,17 @@ export default function ProfileOverviewCard() {
|
|||
icon={item.icon}
|
||||
title={item.title}
|
||||
value={item.value}
|
||||
showArrow={false}
|
||||
isLast={index === accountOverviewItems.length - 1}
|
||||
/>
|
||||
))}
|
||||
</View>
|
||||
|
||||
<View style={styles.section}>
|
||||
<Text style={styles.heading}>Subscriptions</Text>
|
||||
<View style={styles.card}>
|
||||
{activeSubscriptions.length === 0 ? (
|
||||
<View style={styles.emptyRow}>
|
||||
<Text style={styles.emptyTitle}>No active paid subscription</Text>
|
||||
<Text style={styles.emptyText}>
|
||||
Free modules remain available. Paid access will appear here after checkout is verified.
|
||||
</Text>
|
||||
</View>
|
||||
) : (
|
||||
activeSubscriptions.map((subscription, index) => (
|
||||
{activeSubscriptions.length > 0 && (
|
||||
<View style={styles.section}>
|
||||
<Text style={styles.heading}>Active Subscriptions</Text>
|
||||
<View style={styles.card}>
|
||||
{activeSubscriptions.map((subscription, index) => (
|
||||
<View
|
||||
key={subscription.id}
|
||||
style={[
|
||||
|
|
@ -106,7 +103,9 @@ export default function ProfileOverviewCard() {
|
|||
]}
|
||||
>
|
||||
<View style={styles.subLeft}>
|
||||
<Text style={styles.subTitle}>{planLabel(subscription.plan_code)}</Text>
|
||||
<Text style={styles.subTitle}>
|
||||
{planLabel(subscription.plan_code)}
|
||||
</Text>
|
||||
<Text style={styles.subDateText}>
|
||||
Started: {formatDate(subscription.started_at)}
|
||||
</Text>
|
||||
|
|
@ -118,10 +117,10 @@ export default function ProfileOverviewCard() {
|
|||
<Text style={styles.statusText}>{subscription.status}</Text>
|
||||
</View>
|
||||
</View>
|
||||
))
|
||||
)}
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{activeEntitlements.length > 0 ? (
|
||||
<View style={styles.section}>
|
||||
|
|
@ -154,45 +153,68 @@ export default function ProfileOverviewCard() {
|
|||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: { marginTop: verticalScale(8) },
|
||||
section: { marginTop: verticalScale(24) },
|
||||
heading: {
|
||||
fontSize: moderateScale(16),
|
||||
fontWeight: "700",
|
||||
color: "#171717",
|
||||
marginBottom: verticalScale(12),
|
||||
container: { marginTop: verticalScale(4) },
|
||||
section: { marginTop: verticalScale(20) },
|
||||
|
||||
sectionHeaderRow: {
|
||||
flexDirection: "row",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
marginBottom: verticalScale(8),
|
||||
},
|
||||
|
||||
heading: {
|
||||
fontSize: moderateScale(13),
|
||||
fontWeight: "700",
|
||||
color: Colors.textSecondary,
|
||||
textTransform: "uppercase",
|
||||
letterSpacing: 0.5,
|
||||
marginLeft: moderateScale(4),
|
||||
},
|
||||
|
||||
manageText: {
|
||||
fontSize: moderateScale(13),
|
||||
fontWeight: "600",
|
||||
color: Colors.primary,
|
||||
},
|
||||
|
||||
card: {
|
||||
backgroundColor: "#FFFFFF",
|
||||
borderRadius: moderateScale(16),
|
||||
overflow: "hidden",
|
||||
borderWidth: 1,
|
||||
borderColor: "#ECECEC",
|
||||
borderColor: "#E5E7EB",
|
||||
},
|
||||
|
||||
subRow: {
|
||||
padding: moderateScale(16),
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
},
|
||||
|
||||
entitlementRow: {
|
||||
padding: moderateScale(16),
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
},
|
||||
|
||||
entitlementIcon: { marginRight: moderateScale(10) },
|
||||
subLeft: { flex: 1 },
|
||||
|
||||
subTitle: {
|
||||
fontSize: moderateScale(14),
|
||||
fontWeight: "600",
|
||||
color: "#171717",
|
||||
marginBottom: verticalScale(4),
|
||||
color: Colors.textPrimary,
|
||||
marginBottom: verticalScale(2),
|
||||
},
|
||||
|
||||
subDateText: {
|
||||
fontSize: moderateScale(12),
|
||||
color: "#737373",
|
||||
color: Colors.textSecondary,
|
||||
marginTop: verticalScale(2),
|
||||
},
|
||||
|
||||
statusBadge: {
|
||||
backgroundColor: "#DCFCE7",
|
||||
paddingHorizontal: moderateScale(10),
|
||||
|
|
@ -200,23 +222,13 @@ const styles = StyleSheet.create({
|
|||
borderRadius: moderateScale(12),
|
||||
marginLeft: moderateScale(12),
|
||||
},
|
||||
|
||||
statusText: {
|
||||
fontSize: moderateScale(11),
|
||||
fontWeight: "600",
|
||||
fontWeight: "700",
|
||||
color: "#15803D",
|
||||
textTransform: "capitalize",
|
||||
},
|
||||
separator: { borderBottomWidth: 1, borderBottomColor: "#ECECEC" },
|
||||
emptyRow: { padding: moderateScale(16) },
|
||||
emptyTitle: {
|
||||
fontSize: moderateScale(14),
|
||||
fontWeight: "600",
|
||||
color: "#171717",
|
||||
},
|
||||
emptyText: {
|
||||
marginTop: verticalScale(5),
|
||||
fontSize: moderateScale(12),
|
||||
color: "#737373",
|
||||
lineHeight: moderateScale(18),
|
||||
},
|
||||
|
||||
separator: { borderBottomWidth: 1, borderBottomColor: "#F1F5F9" },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
import React from "react";
|
||||
import {
|
||||
Pressable,
|
||||
StyleSheet,
|
||||
Text,
|
||||
} from "react-native";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import {
|
||||
moderateScale,
|
||||
scale,
|
||||
verticalScale,
|
||||
} from "react-native-size-matters";
|
||||
|
||||
interface LogoutButtonProps {
|
||||
onPress: () => void;
|
||||
}
|
||||
|
||||
export default function LogoutButton({ onPress }: LogoutButtonProps) {
|
||||
return (
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel="Log Out"
|
||||
onPress={onPress}
|
||||
style={({ pressed }) => [
|
||||
styles.container,
|
||||
pressed && styles.pressed,
|
||||
]}
|
||||
>
|
||||
<Ionicons
|
||||
name="log-out-outline"
|
||||
size={moderateScale(20)}
|
||||
color="#DC2626"
|
||||
/>
|
||||
<Text style={styles.text}>Log Out</Text>
|
||||
</Pressable>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
height: verticalScale(50),
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
marginTop: verticalScale(8),
|
||||
marginBottom: verticalScale(24),
|
||||
borderRadius: moderateScale(14),
|
||||
borderWidth: 1,
|
||||
borderColor: "#FECACA",
|
||||
backgroundColor: "#FEF2F2",
|
||||
},
|
||||
text: {
|
||||
marginLeft: scale(8),
|
||||
fontSize: moderateScale(15),
|
||||
fontWeight: "700",
|
||||
color: "#DC2626",
|
||||
},
|
||||
pressed: {
|
||||
opacity: 0.8,
|
||||
backgroundColor: "#FEE2E2",
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
import React from "react";
|
||||
import {
|
||||
Pressable,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { useRouter } from "expo-router";
|
||||
import {
|
||||
moderateScale,
|
||||
scale,
|
||||
verticalScale,
|
||||
} from "react-native-size-matters";
|
||||
|
||||
import { Colors } from "@/theme";
|
||||
|
||||
interface SettingsHeaderProps {
|
||||
title?: string;
|
||||
onBackPress?: () => void;
|
||||
rightAction?: React.ReactNode;
|
||||
}
|
||||
|
||||
export default function SettingsHeader({
|
||||
title = "Settings",
|
||||
onBackPress,
|
||||
rightAction,
|
||||
}: SettingsHeaderProps) {
|
||||
const router = useRouter();
|
||||
|
||||
const handleBack = () => {
|
||||
if (onBackPress) {
|
||||
onBackPress();
|
||||
return;
|
||||
}
|
||||
|
||||
if (router.canGoBack()) {
|
||||
router.back();
|
||||
} else {
|
||||
router.replace("/(tabs)/profile");
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel="Go Back"
|
||||
hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }}
|
||||
style={({ pressed }) => [
|
||||
styles.backButton,
|
||||
pressed && styles.backButtonPressed,
|
||||
]}
|
||||
onPress={handleBack}
|
||||
>
|
||||
<Ionicons
|
||||
name="chevron-back"
|
||||
size={moderateScale(24)}
|
||||
color={Colors.textPrimary}
|
||||
/>
|
||||
</Pressable>
|
||||
|
||||
<Text numberOfLines={1} style={styles.title}>
|
||||
{title}
|
||||
</Text>
|
||||
|
||||
{rightAction ? (
|
||||
<View style={styles.rightActionContainer}>{rightAction}</View>
|
||||
) : (
|
||||
<View style={styles.placeholder} />
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
height: verticalScale(50),
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
marginBottom: verticalScale(16),
|
||||
},
|
||||
|
||||
backButton: {
|
||||
width: scale(38),
|
||||
height: scale(38),
|
||||
borderRadius: scale(19),
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
backgroundColor: "#F1F5F9",
|
||||
},
|
||||
|
||||
backButtonPressed: {
|
||||
backgroundColor: "#E2E8F0",
|
||||
},
|
||||
|
||||
title: {
|
||||
flex: 1,
|
||||
textAlign: "center",
|
||||
fontSize: moderateScale(17),
|
||||
fontWeight: "700",
|
||||
color: Colors.textPrimary,
|
||||
marginHorizontal: scale(8),
|
||||
},
|
||||
|
||||
placeholder: {
|
||||
width: scale(38),
|
||||
height: scale(38),
|
||||
},
|
||||
|
||||
rightActionContainer: {
|
||||
width: scale(38),
|
||||
height: scale(38),
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
import React from "react";
|
||||
import { StyleSheet, Text, View } from "react-native";
|
||||
import { useRouter } from "expo-router";
|
||||
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||
|
||||
import ProfileMenuItem from "@/features/profile/components/ProfileMenuItem";
|
||||
import { Colors } from "@/theme";
|
||||
import { SettingsSectionProps, SettingsItem } from "../types";
|
||||
|
||||
export default function SettingsSection({
|
||||
title,
|
||||
items,
|
||||
}: SettingsSectionProps) {
|
||||
const router = useRouter();
|
||||
|
||||
const handlePress = (item: SettingsItem) => {
|
||||
if (item.onPress) {
|
||||
item.onPress();
|
||||
return;
|
||||
}
|
||||
if (item.route) {
|
||||
router.push(item.route as never);
|
||||
}
|
||||
};
|
||||
|
||||
if (!items || items.length === 0) return null;
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.sectionTitle}>{title}</Text>
|
||||
|
||||
<View style={styles.card}>
|
||||
{items.map((item, index) => (
|
||||
<ProfileMenuItem
|
||||
key={item.id}
|
||||
icon={item.icon}
|
||||
title={item.title}
|
||||
subtitle={item.subtitle}
|
||||
value={item.value}
|
||||
showArrow={!item.isSwitch}
|
||||
isLast={index === items.length - 1}
|
||||
isSwitch={item.isSwitch}
|
||||
switchValue={item.switchValue}
|
||||
onSwitchChange={item.onSwitchChange}
|
||||
onPress={() => handlePress(item)}
|
||||
/>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
marginBottom: verticalScale(20),
|
||||
},
|
||||
|
||||
sectionTitle: {
|
||||
fontSize: moderateScale(13),
|
||||
fontWeight: "700",
|
||||
color: Colors.textSecondary,
|
||||
textTransform: "uppercase",
|
||||
letterSpacing: 0.5,
|
||||
marginBottom: verticalScale(8),
|
||||
marginLeft: moderateScale(4),
|
||||
},
|
||||
|
||||
card: {
|
||||
backgroundColor: "#FFFFFF",
|
||||
borderRadius: moderateScale(16),
|
||||
overflow: "hidden",
|
||||
borderWidth: 1,
|
||||
borderColor: "#E5E7EB",
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { SettingsItem } from "../types";
|
||||
|
||||
export const ACCOUNT_SETTINGS: SettingsItem[] = [
|
||||
{
|
||||
id: "edit-profile",
|
||||
title: "Edit Profile",
|
||||
subtitle: "Update name, phone number & country",
|
||||
icon: "person-outline" as keyof typeof Ionicons.glyphMap,
|
||||
route: "/profile/edit",
|
||||
},
|
||||
{
|
||||
id: "change-password",
|
||||
title: "Change Password",
|
||||
subtitle: "Manage login credentials & security",
|
||||
icon: "lock-closed-outline" as keyof typeof Ionicons.glyphMap,
|
||||
route: "/profile/change-password",
|
||||
},
|
||||
{
|
||||
id: "notification-settings",
|
||||
title: "Notification Settings",
|
||||
subtitle: "Clinical updates & reminder alerts",
|
||||
icon: "notifications-outline" as keyof typeof Ionicons.glyphMap,
|
||||
route: "/settings/notifications",
|
||||
},
|
||||
{
|
||||
id: "privacy-settings",
|
||||
title: "Privacy & Data",
|
||||
subtitle: "Search cache & data governance",
|
||||
icon: "shield-checkmark-outline" as keyof typeof Ionicons.glyphMap,
|
||||
route: "/settings/privacy",
|
||||
},
|
||||
];
|
||||
|
||||
export const PREFERENCE_SETTINGS: SettingsItem[] = [
|
||||
{
|
||||
id: "language",
|
||||
title: "Language",
|
||||
subtitle: "Interface localized language",
|
||||
icon: "language-outline" as keyof typeof Ionicons.glyphMap,
|
||||
value: "English",
|
||||
route: "/settings/language",
|
||||
},
|
||||
];
|
||||
|
||||
export const SUPPORT_SETTINGS: SettingsItem[] = [
|
||||
{
|
||||
id: "help-support",
|
||||
title: "Help & Support",
|
||||
subtitle: "FAQs, user guide & clinical inquiries",
|
||||
icon: "help-circle-outline" as keyof typeof Ionicons.glyphMap,
|
||||
route: "/settings/help-support",
|
||||
},
|
||||
{
|
||||
id: "about-acupedia",
|
||||
title: "About Acupedia",
|
||||
subtitle: "Version, disclaimer & publisher info",
|
||||
icon: "information-circle-outline" as keyof typeof Ionicons.glyphMap,
|
||||
route: "/settings/about",
|
||||
},
|
||||
];
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
import { Ionicons } from "@expo/vector-icons";
|
||||
|
||||
export interface SettingsItem {
|
||||
id: string;
|
||||
title: string;
|
||||
subtitle?: string;
|
||||
icon: keyof typeof Ionicons.glyphMap;
|
||||
route?: string;
|
||||
value?: string;
|
||||
isSwitch?: boolean;
|
||||
switchValue?: boolean;
|
||||
onSwitchChange?: (val: boolean) => void;
|
||||
onPress?: () => void;
|
||||
}
|
||||
|
||||
export interface SettingsSectionProps {
|
||||
title: string;
|
||||
items: SettingsItem[];
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import React from "react";
|
||||
import React, { useState } from "react";
|
||||
import {
|
||||
Alert,
|
||||
KeyboardAvoidingView,
|
||||
Platform,
|
||||
ScrollView,
|
||||
|
|
@ -12,7 +13,8 @@ import {
|
|||
verticalScale,
|
||||
} from "react-native-size-matters";
|
||||
import { router } from "expo-router";
|
||||
import EditProfileHeader from "@/features/profile/components/EditProfileHeader";
|
||||
|
||||
import SettingsHeader from "@/features/settings/components/SettingsHeader";
|
||||
import { Colors } from "@/theme";
|
||||
import EditProfileForm from "@/features/profile/components/EditProfileForm";
|
||||
import EditProfileAvatar from "@/features/profile/components/EditProfileAvatar";
|
||||
|
|
@ -22,22 +24,51 @@ import { apiClient } from "@/api";
|
|||
export default function EditProfileScreen() {
|
||||
const user = useAuthStore((state) => state.user);
|
||||
const refreshIdentity = useAuthStore((state) => state.refreshIdentity);
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
const handleSave = async (updatedName: string, updatedPhone: string) => {
|
||||
if (user) {
|
||||
try {
|
||||
await apiClient.put("/auth/profile", {
|
||||
full_name: updatedName,
|
||||
phone_number: updatedPhone,
|
||||
});
|
||||
|
||||
await refreshIdentity();
|
||||
} catch (err: any) {
|
||||
console.warn("Failed to update profile:", err);
|
||||
alert("Failed to save changes. Please try again.");
|
||||
}
|
||||
const handleSave = async (
|
||||
updatedName: string,
|
||||
updatedPhone: string,
|
||||
updatedCountry: string
|
||||
) => {
|
||||
if (!user) {
|
||||
router.back();
|
||||
return;
|
||||
}
|
||||
|
||||
setSaving(true);
|
||||
try {
|
||||
await apiClient.put("/auth/profile", {
|
||||
full_name: updatedName.trim(),
|
||||
phone_number: updatedPhone.trim() || null,
|
||||
country: updatedCountry.trim() || null,
|
||||
});
|
||||
|
||||
await refreshIdentity();
|
||||
|
||||
const successMsg = "Profile updated successfully!";
|
||||
if (Platform.OS === "web") {
|
||||
window.alert(successMsg);
|
||||
router.back();
|
||||
} else {
|
||||
Alert.alert("Success", successMsg, [
|
||||
{ text: "OK", onPress: () => router.back() },
|
||||
]);
|
||||
}
|
||||
} catch (err: any) {
|
||||
const errMsg =
|
||||
err?.response?.data?.detail ||
|
||||
err?.message ||
|
||||
"Failed to save profile changes. Please try again.";
|
||||
console.warn("Failed to update profile:", err);
|
||||
if (Platform.OS === "web") {
|
||||
window.alert(errMsg);
|
||||
} else {
|
||||
Alert.alert("Error", errMsg);
|
||||
}
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
router.back();
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
@ -52,27 +83,18 @@ export default function EditProfileScreen() {
|
|||
contentContainerStyle={styles.contentContainer}
|
||||
>
|
||||
<View style={styles.container}>
|
||||
|
||||
<EditProfileHeader />
|
||||
<SettingsHeader title="Edit Profile" />
|
||||
|
||||
<EditProfileAvatar name={user?.name || "User Name"} />
|
||||
|
||||
<EditProfileAvatar
|
||||
onPress={() => {
|
||||
// TODO: Open image picker
|
||||
}}
|
||||
/>
|
||||
|
||||
<EditProfileForm
|
||||
initialName={user?.name || "User Name"}
|
||||
initialEmail={user?.email || "user@example.com"}
|
||||
initialName={user?.name || ""}
|
||||
initialEmail={user?.email || ""}
|
||||
initialPhone={user?.phone_number || ""}
|
||||
initialCountry={user?.country || "India"}
|
||||
onSave={handleSave}
|
||||
isLoading={saving}
|
||||
/>
|
||||
|
||||
{/* Step 4 */}
|
||||
{/* EditProfileForm */}
|
||||
|
||||
{/* Step 5 */}
|
||||
{/* Save Button */}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</KeyboardAvoidingView>
|
||||
|
|
@ -92,12 +114,12 @@ const styles = StyleSheet.create({
|
|||
|
||||
contentContainer: {
|
||||
flexGrow: 1,
|
||||
paddingBottom: verticalScale(24),
|
||||
paddingBottom: verticalScale(32),
|
||||
},
|
||||
|
||||
container: {
|
||||
flex: 1,
|
||||
paddingHorizontal: moderateScale(24),
|
||||
paddingTop: verticalScale(20),
|
||||
paddingHorizontal: moderateScale(20),
|
||||
paddingTop: verticalScale(12),
|
||||
},
|
||||
});
|
||||
|
|
@ -17,10 +17,10 @@ import { router } from "expo-router";
|
|||
import { Ionicons } from "@expo/vector-icons";
|
||||
|
||||
import { Colors } from "@/theme";
|
||||
|
||||
import ProfileHeader from "@/features/profile/components/ProfileHeader";
|
||||
import ProfileAvatar from "@/features/profile/components/ProfileAvatar";
|
||||
import ProfileOverviewCard from "@/features/profile/components/ProfileOverviewCard";
|
||||
import LogoutButton from "@/features/settings/components/LogoutButton";
|
||||
import { useAuthStore } from "@/store/auth.store";
|
||||
|
||||
export default function ProfileOverviewScreen() {
|
||||
|
|
@ -45,7 +45,7 @@ export default function ProfileOverviewScreen() {
|
|||
} else {
|
||||
Alert.alert(
|
||||
"Log Out",
|
||||
"Are you sure you want to log out?",
|
||||
"Are you sure you want to log out of Acupedia?",
|
||||
[
|
||||
{ text: "Cancel", style: "cancel" },
|
||||
{
|
||||
|
|
@ -54,7 +54,7 @@ export default function ProfileOverviewScreen() {
|
|||
onPress: doLogout,
|
||||
},
|
||||
],
|
||||
{ cancelable: true },
|
||||
{ cancelable: true }
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
@ -68,23 +68,29 @@ export default function ProfileOverviewScreen() {
|
|||
>
|
||||
<View style={styles.guestCard}>
|
||||
<View style={styles.guestIconWrapper}>
|
||||
<Ionicons name="person-circle-outline" size={80} color={Colors.primary} />
|
||||
<Ionicons
|
||||
name="person-circle-outline"
|
||||
size={80}
|
||||
color={Colors.primary}
|
||||
/>
|
||||
</View>
|
||||
<Text style={styles.guestTitle}>Join AcuPedia</Text>
|
||||
<Text style={styles.guestTitle}>Join Acupedia</Text>
|
||||
<Text style={styles.guestSubtitle}>
|
||||
Sign in or create an account to unlock premium clinical modules, track your learning progress, and customize your profile references.
|
||||
Sign in or create an account to unlock clinical point pathways, track your learning progress, and customize your clinical references.
|
||||
</Text>
|
||||
|
||||
<TouchableOpacity
|
||||
style={styles.guestLoginButton}
|
||||
|
||||
<TouchableOpacity
|
||||
style={styles.guestLoginButton}
|
||||
onPress={() => router.push("/login")}
|
||||
activeOpacity={0.85}
|
||||
>
|
||||
<Text style={styles.guestLoginButtonText}>Log In</Text>
|
||||
</TouchableOpacity>
|
||||
|
||||
<TouchableOpacity
|
||||
style={styles.guestSignupButton}
|
||||
<TouchableOpacity
|
||||
style={styles.guestSignupButton}
|
||||
onPress={() => router.push("/register")}
|
||||
activeOpacity={0.85}
|
||||
>
|
||||
<Text style={styles.guestSignupButtonText}>Create Account</Text>
|
||||
</TouchableOpacity>
|
||||
|
|
@ -102,6 +108,8 @@ export default function ProfileOverviewScreen() {
|
|||
>
|
||||
<View style={styles.container}>
|
||||
<ProfileHeader
|
||||
title="My Profile"
|
||||
showBackButton={false}
|
||||
onSettingsPress={() => {
|
||||
router.push("/settings");
|
||||
}}
|
||||
|
|
@ -110,21 +118,11 @@ export default function ProfileOverviewScreen() {
|
|||
<ProfileAvatar
|
||||
name={displayName}
|
||||
email={displayEmail}
|
||||
onEditPress={() => {
|
||||
router.push("/profile/edit");
|
||||
}}
|
||||
/>
|
||||
|
||||
<ProfileOverviewCard />
|
||||
|
||||
<TouchableOpacity
|
||||
style={styles.logoutButton}
|
||||
onPress={handleLogout}
|
||||
activeOpacity={0.8}
|
||||
>
|
||||
<Ionicons name="log-out-outline" size={20} color="#DC2626" />
|
||||
<Text style={styles.logoutButtonText}>Log Out</Text>
|
||||
</TouchableOpacity>
|
||||
<LogoutButton onPress={handleLogout} />
|
||||
</View>
|
||||
</ScrollView>
|
||||
</SafeAreaView>
|
||||
|
|
@ -142,40 +140,25 @@ const styles = StyleSheet.create({
|
|||
paddingBottom: verticalScale(24),
|
||||
},
|
||||
|
||||
logoutButton: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
gap: moderateScale(8),
|
||||
backgroundColor: "#FEE2E2",
|
||||
borderRadius: moderateScale(14),
|
||||
paddingVertical: verticalScale(14),
|
||||
marginTop: verticalScale(24),
|
||||
},
|
||||
logoutButtonText: {
|
||||
fontSize: moderateScale(15),
|
||||
fontWeight: "700",
|
||||
color: "#DC2626",
|
||||
},
|
||||
|
||||
container: {
|
||||
flex: 1,
|
||||
paddingHorizontal: moderateScale(24),
|
||||
paddingTop: verticalScale(20),
|
||||
paddingHorizontal: moderateScale(20),
|
||||
paddingTop: verticalScale(12),
|
||||
},
|
||||
|
||||
guestContentContainer: {
|
||||
flexGrow: 1,
|
||||
justifyContent: "center",
|
||||
paddingHorizontal: moderateScale(24),
|
||||
paddingHorizontal: moderateScale(20),
|
||||
paddingBottom: verticalScale(40),
|
||||
},
|
||||
|
||||
guestCard: {
|
||||
backgroundColor: "#FFFFFF",
|
||||
borderRadius: moderateScale(24),
|
||||
borderRadius: moderateScale(20),
|
||||
borderWidth: 1,
|
||||
borderColor: "#E5E7EB",
|
||||
padding: moderateScale(28),
|
||||
padding: moderateScale(26),
|
||||
alignItems: "center",
|
||||
shadowColor: "#000000",
|
||||
shadowOffset: { width: 0, height: 4 },
|
||||
|
|
@ -183,44 +166,51 @@ const styles = StyleSheet.create({
|
|||
shadowRadius: 10,
|
||||
elevation: 2,
|
||||
},
|
||||
|
||||
guestIconWrapper: {
|
||||
marginBottom: verticalScale(16),
|
||||
marginBottom: verticalScale(14),
|
||||
},
|
||||
|
||||
guestTitle: {
|
||||
fontSize: moderateScale(22),
|
||||
fontWeight: "800",
|
||||
color: Colors.textPrimary,
|
||||
marginBottom: verticalScale(8),
|
||||
marginBottom: verticalScale(6),
|
||||
},
|
||||
|
||||
guestSubtitle: {
|
||||
fontSize: moderateScale(14),
|
||||
fontSize: moderateScale(13),
|
||||
color: Colors.textSecondary,
|
||||
textAlign: "center",
|
||||
lineHeight: 20,
|
||||
marginBottom: verticalScale(28),
|
||||
lineHeight: 19,
|
||||
marginBottom: verticalScale(24),
|
||||
},
|
||||
|
||||
guestLoginButton: {
|
||||
width: "100%",
|
||||
backgroundColor: Colors.primary,
|
||||
borderRadius: moderateScale(14),
|
||||
borderRadius: moderateScale(12),
|
||||
paddingVertical: verticalScale(13),
|
||||
alignItems: "center",
|
||||
marginBottom: verticalScale(12),
|
||||
marginBottom: verticalScale(10),
|
||||
},
|
||||
|
||||
guestLoginButtonText: {
|
||||
fontSize: moderateScale(15),
|
||||
fontWeight: "700",
|
||||
color: "#FFFFFF",
|
||||
},
|
||||
|
||||
guestSignupButton: {
|
||||
width: "100%",
|
||||
backgroundColor: "#FFFFFF",
|
||||
borderWidth: 2,
|
||||
borderWidth: 1.5,
|
||||
borderColor: Colors.primary,
|
||||
borderRadius: moderateScale(14),
|
||||
borderRadius: moderateScale(12),
|
||||
paddingVertical: verticalScale(12),
|
||||
alignItems: "center",
|
||||
},
|
||||
|
||||
guestSignupButtonText: {
|
||||
fontSize: moderateScale(15),
|
||||
fontWeight: "700",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,150 @@
|
|||
import React from "react";
|
||||
import {
|
||||
Alert,
|
||||
Platform,
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
View,
|
||||
} from "react-native";
|
||||
import { SafeAreaView } from "react-native-safe-area-context";
|
||||
import { router } from "expo-router";
|
||||
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||
|
||||
import { Colors } from "@/theme";
|
||||
import SettingsHeader from "@/features/settings/components/SettingsHeader";
|
||||
import SettingsSection from "@/features/settings/components/SettingsSection";
|
||||
import LogoutButton from "@/features/settings/components/LogoutButton";
|
||||
import {
|
||||
ACCOUNT_SETTINGS,
|
||||
PREFERENCE_SETTINGS,
|
||||
SUPPORT_SETTINGS,
|
||||
} from "@/features/settings/constants/settingsData";
|
||||
import { SettingsItem } from "@/features/settings/types";
|
||||
import { useAuthStore } from "@/store/auth.store";
|
||||
import { useSettingsStore } from "@/store/settings.store";
|
||||
|
||||
export default function SettingsScreen() {
|
||||
const user = useAuthStore((state) => state.user);
|
||||
const logout = useAuthStore((state) => state.logout);
|
||||
|
||||
const accordionDefaultExpanded = useSettingsStore(
|
||||
(state) => state.accordionDefaultExpanded
|
||||
);
|
||||
const setAccordionDefaultExpanded = useSettingsStore(
|
||||
(state) => state.setAccordionDefaultExpanded
|
||||
);
|
||||
|
||||
const contentPreviewEnabled = useSettingsStore(
|
||||
(state) => state.contentPreviewEnabled
|
||||
);
|
||||
const setContentPreviewEnabled = useSettingsStore(
|
||||
(state) => state.setContentPreviewEnabled
|
||||
);
|
||||
|
||||
// Clinical Preview Mode is strictly gated to admin role
|
||||
const isAdmin = user?.roles?.includes("admin") ?? false;
|
||||
|
||||
const appPreferenceItems: SettingsItem[] = [
|
||||
{
|
||||
id: "expand-accordions",
|
||||
title: "Expand Sections by Default",
|
||||
subtitle: "Keep all detail accordions open while reading",
|
||||
icon: "list-outline",
|
||||
isSwitch: true,
|
||||
switchValue: accordionDefaultExpanded,
|
||||
onSwitchChange: (val) => setAccordionDefaultExpanded(val),
|
||||
},
|
||||
...(isAdmin
|
||||
? [
|
||||
{
|
||||
id: "clinical-preview",
|
||||
title: "Clinical Draft / Preview Mode",
|
||||
subtitle: "View unpublished modules & draft revisions",
|
||||
icon: "flask-outline" as const,
|
||||
isSwitch: true,
|
||||
switchValue: contentPreviewEnabled,
|
||||
onSwitchChange: (val: boolean) => setContentPreviewEnabled(val),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...PREFERENCE_SETTINGS,
|
||||
];
|
||||
|
||||
const handleLogout = () => {
|
||||
const doLogout = () => {
|
||||
logout();
|
||||
router.replace("/login");
|
||||
};
|
||||
|
||||
if (Platform.OS === "web") {
|
||||
const confirmed =
|
||||
typeof window !== "undefined"
|
||||
? window.confirm("Are you sure you want to log out?")
|
||||
: true;
|
||||
if (confirmed) {
|
||||
doLogout();
|
||||
}
|
||||
} else {
|
||||
Alert.alert(
|
||||
"Log Out",
|
||||
"Are you sure you want to log out of Acupedia?",
|
||||
[
|
||||
{ text: "Cancel", style: "cancel" },
|
||||
{
|
||||
text: "Log Out",
|
||||
style: "destructive",
|
||||
onPress: doLogout,
|
||||
},
|
||||
],
|
||||
{ cancelable: true }
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<SafeAreaView style={styles.safeArea}>
|
||||
<ScrollView
|
||||
showsVerticalScrollIndicator={false}
|
||||
contentContainerStyle={styles.contentContainer}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
>
|
||||
<View style={styles.container}>
|
||||
<SettingsHeader title="Settings" />
|
||||
|
||||
<SettingsSection
|
||||
title="Account Settings"
|
||||
items={ACCOUNT_SETTINGS}
|
||||
/>
|
||||
|
||||
<SettingsSection
|
||||
title="App Preferences"
|
||||
items={appPreferenceItems}
|
||||
/>
|
||||
|
||||
<SettingsSection
|
||||
title="Support & Info"
|
||||
items={SUPPORT_SETTINGS}
|
||||
/>
|
||||
|
||||
<LogoutButton onPress={handleLogout} />
|
||||
</View>
|
||||
</ScrollView>
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
safeArea: {
|
||||
flex: 1,
|
||||
backgroundColor: Colors.background,
|
||||
},
|
||||
contentContainer: {
|
||||
flexGrow: 1,
|
||||
paddingBottom: verticalScale(32),
|
||||
},
|
||||
container: {
|
||||
flex: 1,
|
||||
paddingHorizontal: moderateScale(20),
|
||||
paddingTop: verticalScale(12),
|
||||
},
|
||||
});
|
||||
|
|
@ -7,7 +7,7 @@ import {
|
|||
setApiAccessToken,
|
||||
} from "@/api/access-token";
|
||||
import { getAccessMe } from "@/features/access/api/access.api";
|
||||
import { isUnauthorizedApiError } from "@/api/error-utils";
|
||||
import { getApiErrorStatus, isUnauthorizedApiError } from "@/api/error-utils";
|
||||
import { setUnauthorizedHandler } from "@/api/session-events";
|
||||
import { getMe } from "@/features/auth/api/auth.api";
|
||||
|
||||
|
|
@ -167,8 +167,11 @@ export const useAuthStore = create<AuthStore>()(
|
|||
get().refreshAccess(),
|
||||
]);
|
||||
|
||||
const isSessionInvalid = (reason: unknown) =>
|
||||
isUnauthorizedApiError(reason) || getApiErrorStatus(reason) === 404;
|
||||
|
||||
const unauthorized =
|
||||
(identityResult.status === "rejected" && isUnauthorizedApiError(identityResult.reason)) ||
|
||||
(identityResult.status === "rejected" && isSessionInvalid(identityResult.reason)) ||
|
||||
(accessResult.status === "rejected" && isUnauthorizedApiError(accessResult.reason));
|
||||
|
||||
if (unauthorized) {
|
||||
|
|
@ -223,10 +226,14 @@ export const useAuthStore = create<AuthStore>()(
|
|||
get().refreshAccess(),
|
||||
]);
|
||||
|
||||
// Identity 401/invalid-token is handled conservatively by clearing the
|
||||
// Identity 401/404/invalid-token is handled conservatively by clearing the
|
||||
// local session. Access failures are non-fatal and leave prior access
|
||||
// state intact for transient-network resilience.
|
||||
if (identityResult.status === "rejected" && isUnauthorizedApiError(identityResult.reason)) {
|
||||
if (
|
||||
identityResult.status === "rejected" &&
|
||||
(isUnauthorizedApiError(identityResult.reason) ||
|
||||
getApiErrorStatus(identityResult.reason) === 404)
|
||||
) {
|
||||
get().logout();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,71 @@
|
|||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||
import { create } from "zustand";
|
||||
import { createJSONStorage, persist } from "zustand/middleware";
|
||||
|
||||
import { SettingsState } from "./types";
|
||||
import { NotificationPreferences, SettingsState } from "./types";
|
||||
|
||||
interface SettingsStore extends SettingsState {
|
||||
setTheme: (theme: "light" | "dark") => void;
|
||||
setTheme: (theme: "light" | "dark" | "system") => void;
|
||||
setContentPreviewEnabled: (enabled: boolean) => void;
|
||||
setAccordionDefaultExpanded: (expanded: boolean) => void;
|
||||
toggleAccordionDefaultExpanded: () => void;
|
||||
setNotificationPreference: (
|
||||
key: keyof NotificationPreferences,
|
||||
value: boolean
|
||||
) => void;
|
||||
setLanguage: (language: string) => void;
|
||||
resetSettings: () => void;
|
||||
}
|
||||
|
||||
export const useSettingsStore = create<SettingsStore>((set) => ({
|
||||
const DEFAULT_NOTIFICATIONS: NotificationPreferences = {
|
||||
push: true,
|
||||
clinicalUpdates: true,
|
||||
weeklyDigest: false,
|
||||
sound: true,
|
||||
vibration: true,
|
||||
};
|
||||
|
||||
const DEFAULT_SETTINGS: SettingsState = {
|
||||
theme: "light",
|
||||
contentPreviewEnabled: false,
|
||||
accordionDefaultExpanded: false,
|
||||
notifications: DEFAULT_NOTIFICATIONS,
|
||||
language: "en",
|
||||
};
|
||||
|
||||
setTheme: (theme) =>
|
||||
set({
|
||||
theme,
|
||||
export const useSettingsStore = create<SettingsStore>()(
|
||||
persist(
|
||||
(set) => ({
|
||||
...DEFAULT_SETTINGS,
|
||||
|
||||
setTheme: (theme) => set({ theme }),
|
||||
|
||||
setContentPreviewEnabled: (contentPreviewEnabled) =>
|
||||
set({ contentPreviewEnabled }),
|
||||
|
||||
setAccordionDefaultExpanded: (accordionDefaultExpanded) =>
|
||||
set({ accordionDefaultExpanded }),
|
||||
|
||||
toggleAccordionDefaultExpanded: () =>
|
||||
set((state) => ({
|
||||
accordionDefaultExpanded: !state.accordionDefaultExpanded,
|
||||
})),
|
||||
|
||||
setNotificationPreference: (key, value) =>
|
||||
set((state) => ({
|
||||
notifications: {
|
||||
...state.notifications,
|
||||
[key]: value,
|
||||
},
|
||||
})),
|
||||
|
||||
setLanguage: (language) => set({ language }),
|
||||
|
||||
resetSettings: () => set(DEFAULT_SETTINGS),
|
||||
}),
|
||||
|
||||
setContentPreviewEnabled: (contentPreviewEnabled) =>
|
||||
set({ contentPreviewEnabled }),
|
||||
}));
|
||||
{
|
||||
name: "acupedia-settings-storage",
|
||||
storage: createJSONStorage(() => AsyncStorage),
|
||||
}
|
||||
)
|
||||
);
|
||||
|
|
@ -108,7 +108,18 @@ export interface AppState {
|
|||
isLoading: boolean;
|
||||
}
|
||||
|
||||
export interface SettingsState {
|
||||
theme: "light" | "dark";
|
||||
contentPreviewEnabled: boolean;
|
||||
export interface NotificationPreferences {
|
||||
push: boolean;
|
||||
clinicalUpdates: boolean;
|
||||
weeklyDigest: boolean;
|
||||
sound: boolean;
|
||||
vibration: boolean;
|
||||
}
|
||||
|
||||
export interface SettingsState {
|
||||
theme: "light" | "dark" | "system";
|
||||
contentPreviewEnabled: boolean;
|
||||
accordionDefaultExpanded: boolean;
|
||||
notifications: NotificationPreferences;
|
||||
language: string;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue