How to use expo-asset - 10 common examples

To help you get started, we’ve selected a few expo-asset examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / expo-asset_v4.x.x / flow_v0.104.x- / test_expo-asset.js View on Github external
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
        '',
      ]);
    });
  });
github flow-typed / flow-typed / definitions / npm / expo-asset_v4.x.x / flow_v0.104.x- / test_expo-asset.js View on Github external
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
        '',
      ]);
    });
  });
github flow-typed / flow-typed / definitions / npm / expo-asset_v4.x.x / flow_v0.104.x- / test_expo-asset.js View on Github external
it('should raise an error when call with invalid argument', () => {
      // $ExpectError: first argument must be a string
      Asset.fromURI(1);
    });
  });
github flow-typed / flow-typed / definitions / npm / expo-asset_v4.x.x / flow_v0.104.x- / test_expo-asset.js View on Github external
it('should raise an error when call with invalid argument', () => {
      // $ExpectError: first argument must be an object
      Asset.fromMetadata(true);
      // $ExpectError: missing required props
      Asset.fromMetadata({});
    });
  });
github flow-typed / flow-typed / definitions / npm / expo-asset_v4.x.x / flow_v0.104.x- / test_expo-asset.js View on Github external
it('should raise an error when call with invalid argument', () => {
      // $ExpectError: first argument must be an object
      Asset.fromMetadata(true);
      // $ExpectError: missing required props
      Asset.fromMetadata({});
    });
  });
github Marwan01 / food-converter / node_modules / expo-font / src / Font.ts View on Github external
function _getAssetForSource(source: FontSource): Asset {
  if (source instanceof Asset) {
    return source;
  }

  if (!isWeb && typeof source === 'string') {
    return Asset.fromURI(source);
  }

  if (isWeb || typeof source === 'number') {
    return Asset.fromModule(source);
  }

  // @ts-ignore Error: Type 'string' is not assignable to type 'Asset'
  // We can't have a string here, we would have thrown an error if !isWeb
  // or returned Asset.fromModule if isWeb.
  return source;
}
github expo / expo / packages / expo-font / src / FontLoader.ts View on Github external
export function getAssetForSource(source: FontSource): Asset | FontResource {
  if (source instanceof Asset) {
    return source;
  }

  if (typeof source === 'string') {
    return Asset.fromURI(source);
  } else if (typeof source === 'number') {
    return Asset.fromModule(source);
  } else if (typeof source === 'object' && typeof source.uri !== 'undefined') {
    return getAssetForSource(source.uri);
  }

  // @ts-ignore Error: Type 'string' is not assignable to type 'Asset'
  // We can't have a string here, we would have thrown an error if !isWeb
  // or returned Asset.fromModule if isWeb.
  return source;
}
github expo / expo / apps / native-component-list / App.tsx View on Github external
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',
          })
        );
github react-navigation / stack / example / App.tsx View on Github external
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() {
github react-navigation / tabs / example / App.tsx View on Github external
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 (

expo-asset

An Expo universal module to download assets and pass them into other APIs

MIT
Latest version published 11 days ago

Package Health Score

89 / 100
Full package analysis