-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expo Web Support in boilerplate apps when using —expo
- Loading branch information
1 parent
f15299b
commit 67ddcb2
Showing
45 changed files
with
292 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
boilerplate/app/components/auto-image/auto-image.story.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* eslint-disable */ | ||
import * as React from "react" | ||
import { storiesOf } from "@storybook/react-native" | ||
import { StoryScreen, Story, UseCase } from "../../../storybook/views" | ||
import { AutoImage } from "./auto-image" | ||
|
||
declare let module | ||
|
||
const bowser = require("../../screens/welcome/bowser.png") | ||
const morty = { uri: "https://rickandmortyapi.com/api/character/avatar/2.jpeg" } | ||
|
||
storiesOf("AutoImage", module) | ||
.addDecorator((fn) => <StoryScreen>{fn()}</StoryScreen>) | ||
.add("Style Presets", () => ( | ||
<Story> | ||
<UseCase text="With require()"> | ||
<AutoImage source={bowser} /> | ||
<AutoImage source={bowser} style={{ width: 150 }} /> | ||
<AutoImage source={bowser} style={{ width: 150, height: 150 }} /> | ||
<AutoImage source={bowser} style={{ height: 150 }} /> | ||
<AutoImage source={bowser} style={{ height: 150, resizeMode: "contain" }} /> | ||
</UseCase> | ||
<UseCase text="With URL"> | ||
<AutoImage source={morty} /> | ||
<AutoImage source={morty} style={{ width: 150 }} /> | ||
<AutoImage source={morty} style={{ width: 150, height: 150 }} /> | ||
<AutoImage source={morty} style={{ height: 150 }} /> | ||
<AutoImage source={morty} style={{ height: 150, resizeMode: "contain" }} /> | ||
</UseCase> | ||
</Story> | ||
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, { useLayoutEffect, useState } from "react" | ||
import { | ||
Image as RNImage, | ||
ImageProps as DefaultImageProps, | ||
ImageURISource, | ||
Platform, | ||
} from "react-native" | ||
|
||
type ImageProps = DefaultImageProps & { | ||
source: ImageURISource | ||
} | ||
|
||
export function AutoImage(props: ImageProps) { | ||
const [imageSize, setImageSize] = useState({ width: 0, height: 0 }) | ||
|
||
useLayoutEffect(() => { | ||
if (props.source?.uri) { | ||
RNImage.getSize(props.source.uri as any, (width, height) => { | ||
setImageSize({ width, height }) | ||
}) | ||
} else if (Platform.OS === "web") { | ||
// web requires a different method to get it's size | ||
RNImage.getSize(props.source as any, (width, height) => { | ||
setImageSize({ width, height }) | ||
}) | ||
} else { | ||
const { width, height } = RNImage.resolveAssetSource(props.source) | ||
setImageSize({ width, height }) | ||
} | ||
}, []) | ||
|
||
return <RNImage {...props} style={[imageSize, props.style]} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Reactotron from "reactotron-react-native" | ||
export const Tron = Reactotron |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Reactotron from "reactotron-react-js" | ||
export const Tron = Reactotron |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
presets: ["babel-preset-expo"], | ||
env: { | ||
production: {}, | ||
}, | ||
plugins: [ | ||
[ | ||
"@babel/plugin-proposal-decorators", | ||
{ | ||
legacy: true, | ||
}, | ||
], | ||
["@babel/plugin-proposal-optional-catch-binding"], | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// This is the first file that ReactNative will run when it starts up. | ||
import App from "./app/app.tsx" | ||
import { registerRootComponent } from "expo" | ||
|
||
registerRootComponent(App) | ||
export default App |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.