fontFamily 'MaterialIcons' 不是系统字体,还没有通过 Font.loadAsync React Native 加载

时间:2021-06-07 08:40:31

标签: react-native fonts expo drawer

我收到此错误:fontFamily 'MaterialIcons' 不是系统字体,并且未在每个视图中通过 Font.loadAsync 加载,我尝试删除 node_modules、package.json、npm 缓存验证、npm 缓存清理 -- force,expo start-c 和 npm install 但问题仍然存在,如果有人能帮我解决这个问题,我会很感激的, 我在我的抽屉上使用了一些 MaterialIcons 这是我的代码:

  import React from 'react';
  import {View,StyleSheet} from 'react-native';
  import {
   DrawerContentScrollView,
   DrawerItem
   }
   from '@react-navigation/drawer'; 
   import {
   Avatar,
   Title,
   Caption,
   Drawer,
   Text,
   TouchableRipple,
   Switch,
   }from 'react-native-paper';
   import { Input } from 'react-native-elements';
   import { MaterialCommunityIcons } from '@expo/vector-icons';


   import * as Font from 'expo-font';

   export function DrawerContent(props){
   const [data, setData] = React.useState([]);


    const [isDarkTheme,setIsDarkTheme]=React.useState(false);
    const toggleTheme=() =>{
    setIsDarkTheme(!isDarkTheme);              
    }

    
     return(
    
     <View style={{flex:1}}>
     <DrawerContentScrollView {...props}>
       <View style={styles.drawerContent}>
        <View style={styles.userInfoSection}>
        <View style={{flexDirection:'row',marginTop:20}}>
            <Avatar.Image
            source={{
               uri:'https://image.flaticon.com/icons/png/512/147/147144.png'
            }}
            size={50}
            />
            <View style={{marginLeft:15,flexDirection:'column'}}>
             

                <Title style={styles.title}>{data.Designation}Firas Baya</Title>
                <Caption style={styles.caption}>Firasbayaa@hotmail.com</Caption>
            </View>
        </View>
        <View style={styles.row}></View>

    </View>
    <Drawer.Section style={styles.bottomDrawerSection}>
       
       <DrawerItem
       icon={({color,size})=> (
           <MaterialCommunityIcons
           name="home-outline"
           color={color}
           size={size}               
           />
       )}
           label='Accueil'
           onPress={()=> {props.navigation.navigate('Home')}}
        />
   

    <DrawerItem
    icon={({color,size})=> (
    <MaterialCommunityIcons 
    name="account-multiple-plus-outline"
    color={color}
    size={size}
    />

     )}
    label="Ajouter un magasinier"
    onPress={()=> {props.navigation.navigate('navMagasinier')}}
    />
    <DrawerItem
    icon={({color,size})=> (
    <MaterialCommunityIcons 
    name="chat-processing-outline"
    color={color}
    size={size}
    />
    )}
    label="ChatBot"
    onPress={()=> {props.navigation.navigate('test')}}
     />
    <DrawerItem
    icon={({color,size})=> (
    <MaterialCommunityIcons 
    name="clipboard-list-outline"
    color={color}
    size={size}
    
    />

   )}
    label="Liste des tâches"
    onPress={()=> {props.navigation.navigate('TodoList')}}
   />
  <DrawerItem
    icon={({color,size})=> (
    <MaterialCommunityIcons
    name="help-circle-outline"
    color={color}
    size={size}
     />)}
     label='A propos de nous'
     onPress={()=> {props.navigation.navigate('aPropos')}}
     />
    </Drawer.Section>
     <Drawer.Section title="Préférences">
     <TouchableRipple onPress={()=> {toggleTheme()}}>
            <View style={styles.preference}>
                <Text>Dark Theme</Text>
                <View pointerEvents="none">
                <Switch value={isDarkTheme}/>
                </View>
            </View>

        </TouchableRipple>
    </Drawer.Section>
   </View>
   </DrawerContentScrollView>
   <Drawer.Section style={StyleSheet.bottomDrawerSection}>
    <DrawerItem
    icon={({color,size})=> (
    <MaterialCommunityIcons
    name="exit-to-app"
    color={color}
    size={size}
    
    />

  )}
    label='Déconnexion'
    onPress={()=> {props.navigation.navigate('LoginScreen')}}
  />

  </Drawer.Section>
    </View>
    );

  }

我在其他一些视图中使用了一些 searchBars 但是搜索图标也没有显示,我已经使用这个 import { SearchBar } from 'react-native-elements' 导入;

0 个答案:

没有答案