import React from 'react'; import { ListRenderItemInfo, StyleSheet } from 'react-native'; import { Divider, List, ThemeProvider, Toggle, TopNavigation, TopNavigationAction, } from '@ui-kitten/components'; import { ThemeCard } from './theme-card.component'; import { SafeAreaLayout } from '../../components/safe-area-layout.component'; import { MappingContextValue, ThemeContextValue, Theming } from '../../services/theme.service'; import { ThemesService } from './themes.service'; import { ThemeItem } from './type'; import { appThemes } from '../../app-theming'; import { MenuIcon } from '../../components/icons'; import { RestartAppModal } from './restart-app-modal.component'; export const ThemesScreen = ({ navigation }): React.ReactElement => { const mappingContext: MappingContextValue = React.useContext(Theming.MappingContext); const themeContext: ThemeContextValue = React.useContext(Theming.ThemeContext); const [evaToggleChecked, setEvaToggleChecked] = React.useState(mappingContext.isEva()); const [restartModalVisible, setRestartModalVisible] = React.useState(false); const themes: ThemeItem[] = ThemesService.createThemeListItems( appThemes, mappingContext.currentMapping, ); const onEvaToggleCheckedChange = (checked: boolean): void => { setEvaToggleChecked(checked); setRestartModalVisible(true); mappingContext.setCurrentMapping(checked ? 'eva' : 'material'); }; const onItemPress = (info: ListRenderItemInfo): void => { themeContext.setCurrentTheme(info.item.name); }; const isActiveTheme = (theme: ThemeItem): boolean => { return mappingContext.currentMapping === theme.mapping && themeContext.currentTheme === theme.name; }; const shouldDisableItem = (theme: ThemeItem): boolean => { return themeContext.currentTheme === theme.name; }; const createThemeNameForItem = (theme: ThemeItem): string => { return `${theme.mapping} ${theme.name}`.toUpperCase(); }; const toggleRestartModal = (): void => { setRestartModalVisible(!restartModalVisible); }; const renderDrawerAction = (): React.ReactElement => ( ); const renderItem = (info: ListRenderItemInfo): React.ReactElement => ( onItemPress(info)} /> ); const renderFooter = (): React.ReactElement => ( Eva Design System ); return ( ); }; const styles = StyleSheet.create({ safeArea: { flex: 1, }, container: { padding: 8, }, item: { margin: 8, }, evaToggle: { margin: 8, alignSelf: 'flex-end', flexDirection: 'row-reverse', }, });