/** * ModeSelector - Modus-Auswahl fuer ARIA * * Zeigt den aktuellen Betriebsmodus an und ermoeglicht das Umschalten * ueber ein Modal-Dropdown. */ import React, { useState } from 'react'; import { View, Text, TouchableOpacity, Modal, FlatList, StyleSheet, } from 'react-native'; import rvs from '../services/rvs'; // --- Typen --- export interface Mode { id: string; label: string; emoji: string; description: string; } interface ModeSelectorProps { currentModeId: string; onModeChange: (modeId: string) => void; } // --- Verfuegbare Modi --- export const MODES: Mode[] = [ { id: 'normal', label: 'Normal', emoji: '\uD83D\uDFE2', description: 'Standardmodus - ARIA reagiert auf alle Eingaben', }, { id: 'nicht_stoeren', label: 'Nicht st\u00F6ren', emoji: '\uD83D\uDD34', description: 'Nur kritische Benachrichtigungen', }, { id: 'fluester', label: 'Fl\u00FCster', emoji: '\uD83D\uDFE1', description: 'Leise Antworten, reduzierte Aktivit\u00E4t', }, { id: 'hangar', label: 'Hangar', emoji: '\u2708\uFE0F', description: 'Flugmodus - minimale Kommunikation', }, { id: 'gaming', label: 'Gaming', emoji: '\uD83C\uDFAE', description: 'Spielmodus - nur dringende Meldungen', }, ]; // --- Komponente --- const ModeSelector: React.FC = ({ currentModeId, onModeChange }) => { const [modalVisible, setModalVisible] = useState(false); const currentMode = MODES.find(m => m.id === currentModeId) || MODES[0]; const handleSelectMode = (mode: Mode) => { setModalVisible(false); onModeChange(mode.id); // Moduswechsel an ARIA senden rvs.send('mode', { mode: mode.id }); }; const renderModeItem = ({ item }: { item: Mode }) => { const isActive = item.id === currentModeId; return ( handleSelectMode(item)} activeOpacity={0.7} > {item.emoji} {item.label} {item.description} {isActive && {'\u2713'}} ); }; return ( {/* Aktueller Modus - Tappen zum Oeffnen */} setModalVisible(true)} activeOpacity={0.7} > {currentMode.emoji} {currentMode.label} {'\u25BC'} {/* Modus-Auswahl Modal */} setModalVisible(false)} > setModalVisible(false)} > Modus w\u00E4hlen item.id} renderItem={renderModeItem} scrollEnabled={false} /> setModalVisible(false)} > Abbrechen ); }; // --- Styles --- const styles = StyleSheet.create({ currentMode: { flexDirection: 'row', alignItems: 'center', backgroundColor: '#1E1E2E', borderRadius: 12, padding: 14, borderWidth: 1, borderColor: '#2A2A3E', }, currentEmoji: { fontSize: 22, marginRight: 10, }, currentLabel: { color: '#FFFFFF', fontSize: 16, fontWeight: '600', flex: 1, }, chevron: { color: '#8888AA', fontSize: 12, }, modalOverlay: { flex: 1, backgroundColor: 'rgba(0, 0, 0, 0.6)', justifyContent: 'flex-end', }, modalContent: { backgroundColor: '#1A1A2E', borderTopLeftRadius: 20, borderTopRightRadius: 20, padding: 20, paddingBottom: 40, }, modalTitle: { color: '#FFFFFF', fontSize: 18, fontWeight: '700', textAlign: 'center', marginBottom: 16, }, modeItem: { flexDirection: 'row', alignItems: 'center', padding: 14, borderRadius: 10, marginBottom: 6, }, modeItemActive: { backgroundColor: 'rgba(0, 150, 255, 0.15)', }, modeEmoji: { fontSize: 26, marginRight: 14, }, modeTextContainer: { flex: 1, }, modeLabel: { color: '#CCCCDD', fontSize: 16, fontWeight: '500', }, modeLabelActive: { color: '#0096FF', fontWeight: '700', }, modeDescription: { color: '#666680', fontSize: 12, marginTop: 2, }, checkmark: { color: '#0096FF', fontSize: 18, fontWeight: '700', marginLeft: 8, }, cancelButton: { marginTop: 12, padding: 14, borderRadius: 10, backgroundColor: '#2A2A3E', alignItems: 'center', }, cancelText: { color: '#8888AA', fontSize: 16, fontWeight: '600', }, }); export default ModeSelector;