import React from "react"; import { Modal, Pressable, View, TouchableOpacity, ActivityIndicator, StyleSheet, } from "react-native"; import { Ionicons } from "@expo/vector-icons"; import { ThemedText } from "./ThemedText"; import { ThemedView } from "./ThemedView"; import { useColorScheme } from "@/hooks/useColorScheme"; import { Colors } from "@/constants/Colors"; import { BOOK_STATUS_MAP, BOOK_STATUS, type BookStatus } from "@/constants/index"; const STATUS_OPTIONS = [ BOOK_STATUS.FINISHED, BOOK_STATUS.READING, BOOK_STATUS.WANTTOREAD, BOOK_STATUS.ABANDONED, ]; interface StatusSelectionModalProps { visible: boolean; onClose: () => void; currentStatus: BookStatus | null; onStatusSelect: (status: BookStatus) => void; isPending: boolean; } export const StatusSelectionModal: React.FC = ({ visible, onClose, currentStatus, onStatusSelect, isPending, }) => { const colorScheme = useColorScheme(); const colors = Colors[colorScheme ?? "light"]; return ( true} > {isPending ? ( // Loading state - no header, just loading content Updating your reading status... Please wait a moment ) : ( // Normal state with header and options <> Select Reading Status {STATUS_OPTIONS.map((item, index) => ( onStatusSelect(item)} > {BOOK_STATUS_MAP[item]} {currentStatus === item && ( )} {index < STATUS_OPTIONS.length - 1 && ( )} ))} )} ); }; const styles = StyleSheet.create({ modalBackdrop: { flex: 1, justifyContent: "center", alignItems: "center", backgroundColor: "rgba(0, 0, 0, 0.5)", }, modalView: { margin: 20, borderRadius: 16, paddingVertical: 16, alignItems: "stretch", shadowColor: "#000", shadowOffset: { width: 0, height: 4, }, shadowOpacity: 0.3, shadowRadius: 8, elevation: 8, width: "80%", maxHeight: "50%", }, loadingContainer: { paddingVertical: 32, paddingHorizontal: 20, alignItems: "center", justifyContent: "center", }, loadingSpinner: { marginBottom: 16, }, loadingText: { marginBottom: 8, textAlign: "center", }, loadingSubtext: { textAlign: "center", }, modalHeader: { flexDirection: "row", alignItems: "center", justifyContent: "space-between", paddingHorizontal: 20, paddingBottom: 16, borderBottomWidth: 1, }, modalTitle: { flex: 1, }, modalOption: { paddingVertical: 16, paddingHorizontal: 20, flexDirection: "row", alignItems: "center", justifyContent: "space-between", }, modalOptionText: { textAlign: "center", textTransform: "capitalize", }, separator: { height: 1, marginHorizontal: 16, }, });