|
| 1 | +import React from "react"; |
| 2 | +import { StatusBar, FlatList, Dimensions } from "react-native"; |
| 3 | +import ProgressiveFastImage from "./build/dist/ProgressiveFastImage"; |
| 4 | +const { width: ScreenWidth } = Dimensions.get("window"); |
| 5 | + |
| 6 | +const images = [ |
| 7 | + { |
| 8 | + uri: |
| 9 | + "https://images.unsplash.com/photo-1544627836-e63eb27c6e09?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjQzMzEwfQ&auto=format&fit=crop&w=2100&q=80", |
| 10 | + }, |
| 11 | + { |
| 12 | + uri: |
| 13 | + "https://images.unsplash.com/photo-1544621660-1a179ba542a9?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2100&q=80", |
| 14 | + }, |
| 15 | + { |
| 16 | + uri: |
| 17 | + "https://images.unsplash.com/photo-1544945582-3b466d874eac?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2389&q=80", |
| 18 | + }, |
| 19 | + { |
| 20 | + uri: |
| 21 | + "https://images.unsplash.com/photo-1544979407-1204ff29f490?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2100&q=80", |
| 22 | + }, |
| 23 | + { |
| 24 | + uri: |
| 25 | + "https://images.unsplash.com/photo-1544807459-eb0ae8cda3e0?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2110&q=80", |
| 26 | + }, |
| 27 | + { |
| 28 | + uri: |
| 29 | + "https://images.unsplash.com/photo-1544954617-f5c6b0d16164?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2064&q=80", |
| 30 | + }, |
| 31 | + { |
| 32 | + uri: |
| 33 | + "https://images.unsplash.com/photo-1544914118-b7a55a9ecca6?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2100&q=80", |
| 34 | + }, |
| 35 | + { |
| 36 | + uri: |
| 37 | + "https://images.unsplash.com/photo-1544913776-90c1223073a3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2102&q=80", |
| 38 | + }, |
| 39 | + { |
| 40 | + uri: |
| 41 | + "https://images.unsplash.com/photo-1545128309-686a71a99f76?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2100&q=80", |
| 42 | + }, |
| 43 | + { |
| 44 | + uri: |
| 45 | + "https://images.unsplash.com/photo-1545140976-8c17471ba12d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2340&q=80", |
| 46 | + }, |
| 47 | + { |
| 48 | + uri: |
| 49 | + "https://images.unsplash.com/photo-1545105511-839f4a45a030?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2100&q=80", |
| 50 | + }, |
| 51 | + { |
| 52 | + uri: |
| 53 | + "https://images.unsplash.com/photo-1545079968-1feb95494244?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1867&q=80", |
| 54 | + }, |
| 55 | + { |
| 56 | + uri: |
| 57 | + "https://images.unsplash.com/photo-1545128337-6c5cf2684520?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2100&q=80", |
| 58 | + }, |
| 59 | + { |
| 60 | + uri: |
| 61 | + "https://images.unsplash.com/photo-1544933411-f64b01485fd3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2102&q=80", |
| 62 | + }, |
| 63 | + { |
| 64 | + uri: |
| 65 | + "https://images.unsplash.com/photo-1544177817-454e1238e05f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2100&q=80", |
| 66 | + }, |
| 67 | + { |
| 68 | + uri: |
| 69 | + "https://images.unsplash.com/photo-1544946632-b73cacef16ad?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2389&q=80", |
| 70 | + }, |
| 71 | +]; |
| 72 | + |
| 73 | +const App = () => { |
| 74 | + const renderItem = (data: any) => { |
| 75 | + const { item, index } = data; |
| 76 | + |
| 77 | + return ( |
| 78 | + <ProgressiveFastImage |
| 79 | + style={{ |
| 80 | + width: ScreenWidth / 2, |
| 81 | + height: ScreenWidth / 2, |
| 82 | + }} |
| 83 | + source={item} |
| 84 | + thumbnailSource={item} |
| 85 | + /> |
| 86 | + ); |
| 87 | + }; |
| 88 | + |
| 89 | + return ( |
| 90 | + <> |
| 91 | + <StatusBar barStyle="light-content" /> |
| 92 | + <FlatList numColumns={2} data={images} renderItem={renderItem} /> |
| 93 | + </> |
| 94 | + ); |
| 95 | +}; |
| 96 | + |
| 97 | +export default App; |
0 commit comments