|
| 1 | +SpeedDial 悬浮标记 |
| 2 | +--- |
| 3 | + |
| 4 | +SpeedDial 悬浮标记组件按下时,浮动动作按钮可以以快速显示标记的形式显示指定相关动作。 |
| 5 | + |
| 6 | +## 基础示例 |
| 7 | + |
| 8 | +```jsx |
| 9 | +import { Fragment } from 'react'; |
| 10 | +import { SpeedDial } from '@uiw/react-native'; |
| 11 | + |
| 12 | +function Demo() { |
| 13 | + return ( |
| 14 | + <Fragment> |
| 15 | + <SpeedDial |
| 16 | + children={[ |
| 17 | + { |
| 18 | + icon: 'plus', |
| 19 | + title: <Text>'Add'</Text>, |
| 20 | + onPress:()=>console.log('Add') |
| 21 | + }, |
| 22 | + { |
| 23 | + icon: <Icon name='star-on' color="#fff" size={18} />, |
| 24 | + title: 'Star' |
| 25 | + }, |
| 26 | + { |
| 27 | + icon: <Icon name='mail' color="#fff" size={18} />, |
| 28 | + title: 'Mail' |
| 29 | + }, |
| 30 | + { |
| 31 | + icon: <Icon name='share' color="#fff" size={18} />, |
| 32 | + title: 'Share' |
| 33 | + } |
| 34 | + ]} |
| 35 | + /> |
| 36 | + </Fragment> |
| 37 | + ); |
| 38 | +} |
| 39 | +``` |
| 40 | + |
| 41 | +## 使用 Icon |
| 42 | + |
| 43 | +```jsx |
| 44 | +import { Fragment } from 'react'; |
| 45 | +import { Rating, Icon } from '@uiw/react-native'; |
| 46 | +function Demo() { |
| 47 | + return ( |
| 48 | + <Fragment> |
| 49 | + <SpeedDial |
| 50 | + icon={['star-on','star-off']} |
| 51 | + children={[ |
| 52 | + { |
| 53 | + icon: <Icon name='plus' color="#fff" size={18} />, |
| 54 | + title: <Text>'Add'</Text>, |
| 55 | + onPress:()=>console.log('Add') |
| 56 | + }, |
| 57 | + { |
| 58 | + icon: <Icon name='star-on' color="#fff" size={18} />, |
| 59 | + title: 'Star' |
| 60 | + }, |
| 61 | + { |
| 62 | + icon: <Icon name='mail' color="#fff" size={18} />, |
| 63 | + title: 'Mail' |
| 64 | + }, |
| 65 | + { |
| 66 | + icon: <Icon name='share' color="#fff" size={18} />, |
| 67 | + title: 'Share' |
| 68 | + } |
| 69 | + ]} |
| 70 | + /> |
| 71 | + </Fragment> |
| 72 | + ); |
| 73 | +} |
| 74 | +``` |
| 75 | + |
| 76 | +## SpeedDial Props |
| 77 | + |
| 78 | +```ts |
| 79 | +import { ViewStyle,ViewProps } from 'react-native'; |
| 80 | +import { icoType,SpeedDialItemProps } from '@uiw/react-native'; |
| 81 | + |
| 82 | + |
| 83 | +export interface SpeedDialProps extends ViewProps { |
| 84 | + /** 显示的图标 [默认显示, 展开显示] */ |
| 85 | + icon?: icoType, |
| 86 | + /** 盒子样式 */ |
| 87 | + style?: ViewStyle, |
| 88 | + /** 初始距离下边位置 */ |
| 89 | + bottom?: number, // |
| 90 | + /** 初始距离右边位置 */ |
| 91 | + right?: number, // |
| 92 | + /** 展开显示的标记 */ |
| 93 | + children?: Array<SpeedDialItemProps>, |
| 94 | + /** 是否支持拖拽 */ |
| 95 | + isDrag?: boolean, |
| 96 | + /** 动画时间 */ |
| 97 | + transitionDuration?: number, |
| 98 | + /** |
| 99 | + * 打开时触发 |
| 100 | + */ |
| 101 | + onOpen?: Function, |
| 102 | + /** |
| 103 | + * 关闭时触发 |
| 104 | + */ |
| 105 | + onClose?: Function, |
| 106 | +} |
| 107 | +``` |
| 108 | + |
| 109 | + |
| 110 | +## SpeedDialItem Props |
| 111 | + |
| 112 | +```ts |
| 113 | +import { TabsItemIconTypes,IconsName } from '@uiw/react-native'; |
| 114 | + |
| 115 | +export interface SpeedDialItemProps { |
| 116 | + /** 右边 显示的图标 */ |
| 117 | + icon: TabsItemIconTypes, |
| 118 | + /** 左边文字 */ |
| 119 | + title: JSX.Element | string | number, |
| 120 | + /** 左边文字盒子样式 */ |
| 121 | + titleStyle?: ViewStyle, |
| 122 | + /** 右边图标盒子样式 */ |
| 123 | + iconStyle?: ViewStyle, |
| 124 | + /** |
| 125 | + * 点击右边时触发 |
| 126 | + */ |
| 127 | + onPress?: Function, |
| 128 | +} |
| 129 | +``` |
0 commit comments