Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | 8x 2x 1x 8x 8x 8x 21x 1x 1x 1x | import React from "react";
import {
Modal,
View,
Text,
TextInput,
TouchableOpacity,
ScrollView,
StyleSheet,
} from "react-native";
import { useTheme } from "../hooks/useTheme";
interface RoomListModalProps {
visible: boolean;
selectingFor: "start" | "end" | null;
searchQuery: string;
filteredRooms: string[];
onSearchChange: (query: string) => void;
onSelectRoom: (room: string) => void;
onClose: () => void;
}
function getModalTitle(selectingFor: "start" | "end" | null): string {
if (selectingFor === "start") return "Select Start Room";
if (selectingFor === "end") return "Select End Room";
return "All Rooms";
}
export default function RoomListModal({
visible,
selectingFor,
searchQuery,
filteredRooms,
onSearchChange,
onSelectRoom,
onClose,
}: Readonly<RoomListModalProps>) {
const { colors } = useTheme();
const modalTitle = getModalTitle(selectingFor);
return (
<Modal
visible={visible}
animationType="slide"
transparent={true}
onRequestClose={onClose}
>
<View style={styles.modalContainer}>
<View style={[styles.modalContent, { backgroundColor: colors.card }]}>
<Text style={[styles.modalTitle, { color: colors.text }]}>
{modalTitle}
</Text>
<TextInput
style={[
styles.searchInput,
{
borderColor: colors.border,
backgroundColor: colors.surface,
color: colors.text,
},
]}
placeholder="Search rooms..."
placeholderTextColor={colors.textMuted}
value={searchQuery}
onChangeText={onSearchChange}
autoFocus={true}
/>
<ScrollView style={styles.roomList}>
{filteredRooms.length === 0 ? (
<Text style={[styles.noResults, { color: colors.textMuted }]}>
No rooms found
</Text>
) : (
filteredRooms.map((room) => (
<TouchableOpacity
key={room}
style={[
styles.roomItem,
{ borderBottomColor: colors.border },
]}
onPress={() => {
Eif (selectingFor) {
onSelectRoom(room);
}
}}
disabled={!selectingFor}
>
<Text style={[styles.roomText, { color: colors.text }]}>
{room}
</Text>
</TouchableOpacity>
))
)}
</ScrollView>
<TouchableOpacity
style={[styles.closeButton, { backgroundColor: colors.primary }]}
onPress={onClose}
>
<Text style={styles.closeButtonText}>Close</Text>
</TouchableOpacity>
</View>
</View>
</Modal>
);
}
const styles = StyleSheet.create({
modalContainer: {
flex: 1,
backgroundColor: "rgba(0, 0, 0, 0.5)",
justifyContent: "flex-end",
},
modalContent: {
borderTopLeftRadius: 20,
borderTopRightRadius: 20,
padding: 20,
maxHeight: "80%",
},
modalTitle: {
fontSize: 20,
fontWeight: "bold",
marginBottom: 16,
},
searchInput: {
borderWidth: 1,
borderRadius: 8,
padding: 12,
fontSize: 16,
marginBottom: 16,
},
roomList: {
maxHeight: 400,
},
roomItem: {
padding: 16,
borderBottomWidth: 1,
},
roomText: {
fontSize: 16,
},
noResults: {
textAlign: "center",
padding: 20,
fontSize: 16,
},
closeButton: {
marginTop: 16,
padding: 14,
borderRadius: 8,
alignItems: "center",
},
closeButtonText: {
color: "#FFFFFF",
fontSize: 16,
fontWeight: "600",
},
});
|