|
| 1 | +ImageViewer 图片查看 |
| 2 | +--- |
| 3 | + |
| 4 | +<!--rehype:style=zoom: 33%;float: right; margin-left: 15px;--> |
| 5 | + |
| 6 | +可自定义拖曳抽屉高度。 |
| 7 | + |
| 8 | +### 基础示例 |
| 9 | + |
| 10 | +```jsx |
| 11 | +import React, { Component } from 'react'; |
| 12 | +import { View, Text } from 'react-native'; |
| 13 | +import Layout, { Container } from '../../Layout'; |
| 14 | +import { ImageViewer } from '@uiw/react-native'; |
| 15 | +import { ComProps } from '../../routes'; |
| 16 | + |
| 17 | +const { Header, Body, Card, Footer } = Layout; |
| 18 | + |
| 19 | +export interface IndexProps extends ComProps { } |
| 20 | + |
| 21 | +export default class Index extends Component<IndexProps> { |
| 22 | + render() { |
| 23 | + const { route } = this.props; |
| 24 | + const description = route.params.description; |
| 25 | + const title = route.params.title; |
| 26 | + return ( |
| 27 | + <Container> |
| 28 | + <Layout> |
| 29 | + <Header title={title} description={description} /> |
| 30 | + <Body style={{ backgroundColor: '#fff' }}> |
| 31 | + <Card title="基础使用"> |
| 32 | + <ImageViewer /> |
| 33 | + </Card> |
| 34 | + </Body> |
| 35 | + <Footer /> |
| 36 | + </Layout> |
| 37 | + </Container> |
| 38 | + ); |
| 39 | + } |
| 40 | +} |
| 41 | +``` |
| 42 | + |
| 43 | +### 自定义图片 |
| 44 | + |
| 45 | +```jsx |
| 46 | +import React, { Component } from 'react'; |
| 47 | +import { View, Text } from 'react-native'; |
| 48 | +import Layout, { Container } from '../../Layout'; |
| 49 | +import { ImageViewer } from '@uiw/react-native'; |
| 50 | +import { ComProps } from '../../routes'; |
| 51 | + |
| 52 | +const { Header, Body, Card, Footer } = Layout; |
| 53 | + |
| 54 | +export interface IndexProps extends ComProps { } |
| 55 | + |
| 56 | +export default class Index extends Component<IndexProps> { |
| 57 | + render() { |
| 58 | + const { route } = this.props; |
| 59 | + const description = route.params.description; |
| 60 | + const title = route.params.title; |
| 61 | + return ( |
| 62 | + <Container> |
| 63 | + <Layout> |
| 64 | + <Header title={title} description={description} /> |
| 65 | + <Body style={{ backgroundColor: '#fff' }}> |
| 66 | + <Card title="自定义图片"> |
| 67 | + <ImageViewer |
| 68 | + height={100} |
| 69 | + width={100} |
| 70 | + src="https://img11.51tietu.net/pic/2016-071418/20160714181543xyu10ukncwf221991.jpg" |
| 71 | + /> |
| 72 | + </Card> |
| 73 | + </Body> |
| 74 | + <Footer /> |
| 75 | + </Layout> |
| 76 | + </Container> |
| 77 | + ); |
| 78 | + } |
| 79 | +} |
| 80 | +``` |
| 81 | + |
| 82 | +### props |
| 83 | + |
| 84 | +```ts |
| 85 | +export interface ImageViewerProps extends ViewProps { |
| 86 | + /** 图片宽度 */ |
| 87 | + width?: number, |
| 88 | + /** 图片高度 */ |
| 89 | + height?: number, |
| 90 | + /** 图像源(远程URL或本地文件资源 */ |
| 91 | + src?: string | number; |
| 92 | +} |
| 93 | +``` |
0 commit comments