Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should raise an error when call with invalid argument', () => {
// $ExpectError: first argument must be number or array if numbers
Asset.loadAsync('');
Asset.loadAsync([
1,
// $ExpectError: must be number
'',
]);
});
});
it('should raise an error when call with invalid argument', () => {
// $ExpectError: first argument must be number or array if numbers
Asset.loadAsync('');
Asset.loadAsync([
1,
// $ExpectError: must be number
'',
]);
});
});
async _loadAssetsAsync() {
try {
const iconRequires = Object.keys(Icons).map(key => Icons[key]);
const assetPromises: Promise[] = [
Asset.loadAsync(iconRequires),
Asset.loadAsync(StackAssets),
// @ts-ignore
Font.loadAsync(Ionicons.font),
// @ts-ignore
Font.loadAsync(Entypo.font),
// @ts-ignore
Font.loadAsync(MaterialIcons.font),
Font.loadAsync({
'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf'),
}),
];
if (Platform.OS !== 'web')
assetPromises.push(
Font.loadAsync({
Roboto: 'https://github.com/google/fonts/raw/master/apache/roboto/Roboto-Regular.ttf',
})
);
routeName: 'HeaderBackgroundFade',
},
{
component: DragLimitedToModal,
title: 'Drag limited to modal',
routeName: 'DragLimitedToModal',
},
{
component: StackAnimationConsumerStack,
title: 'Stack animation consumer stack',
routeName: 'StackAnimationConsumerStack',
},
];
// Cache images
Asset.loadAsync(StackAssets);
class Home extends React.Component {
static navigationOptions = {
title: 'Examples',
};
_renderItem = ({ item }: { item: Item }) => (
this.props.navigation.navigate(item.routeName)}
/>
);
_keyExtractor = (item: Item) => item.routeName;
render() {
NavigationStackScreenProps,
} from 'react-navigation-stack';
import {
Themed,
createAppContainer,
ThemeColors,
useTheme,
} from 'react-navigation';
import { MaterialCommunityIcons } from '@expo/vector-icons';
import { Asset } from 'expo-asset';
import BottomTabs from './src/BottomTabs';
import MaterialTopTabs from './src/MaterialTopTabs';
// Load the back button etc
Asset.loadAsync(StackAssets);
const Home = (props: NavigationStackScreenProps) => {
const theme = useTheme();
return (
async function loadResourcesAsync() {
await Promise.all([
Asset.loadAsync([
require('./assets/images/robot-dev.png'),
require('./assets/images/robot-prod.png'),
]),
Font.loadAsync({
// This is the font that we are using for our tab bar
...Ionicons.font,
// We include SpaceMono because we use it in HomeScreen.js. Feel free to
// remove this if you are not using it in your app
'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf'),
}),
]);
}
async _loadAssetsAsync() {
try {
const iconRequires = Object.keys(Icons).map(key => Icons[key]);
const assetPromises: Promise[] = [
Asset.loadAsync(iconRequires),
Asset.loadAsync(StackAssets),
// @ts-ignore
Font.loadAsync(Ionicons.font),
// @ts-ignore
Font.loadAsync(Entypo.font),
// @ts-ignore
Font.loadAsync(MaterialIcons.font),
Font.loadAsync({
'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf'),
}),
];
if (Platform.OS !== 'web')
assetPromises.push(
Font.loadAsync({
Roboto: 'https://github.com/google/fonts/raw/master/apache/roboto/Roboto-Regular.ttf',
})
import { ActionSheetProvider } from '@expo/react-native-action-sheet';
import { Ionicons, MaterialIcons } from '@expo/vector-icons';
import url from 'url';
import './menu/MenuView';
import Navigation from './navigation/Navigation';
import HistoryActions from './redux/HistoryActions';
import SessionActions from './redux/SessionActions';
import SettingsActions from './redux/SettingsActions';
import Store from './redux/Store';
import LocalStorage from './storage/LocalStorage';
import addListenerWithNativeCallback from './utils/addListenerWithNativeCallback';
// Download and cache stack assets, don't block loading on this though
Asset.loadAsync(StackAssets);
@connect(data => App.getDataProps(data))
export default class App extends React.Component {
static getDataProps(data) {
let { settings } = data;
return {
preferredAppearance: settings.preferredAppearance,
};
}
state = {
isReady: false,
colorScheme: Appearance.getColorScheme(),
};
loadLocalAsync = async () => {
return await Promise.all([
Asset.loadAsync([
require('../assets/flame.png'),
require('../assets/icon.png')
]),
Font.loadAsync({
...Icon.Ionicons.font
})
])
}
usePromiseAll(assets.map(asset => Asset.loadAsync(asset)), () =>
setReady(true)