-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
209 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React from 'react'; | ||
import Modal from './Modal'; | ||
import modalStyle from './style/index'; | ||
|
||
export type OperationButtonType = { | ||
text: string; | ||
onPress?: () => void; | ||
style?: any; | ||
}; | ||
|
||
export interface OperationContainerProps { | ||
actions: Array<OperationButtonType>; | ||
onAnimationEnd?: (visible: boolean) => void; | ||
}; | ||
|
||
export default class OperationContainer extends React.Component<OperationContainerProps, any> { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
visible: true, | ||
}; | ||
} | ||
|
||
onClose= () => { | ||
this.setState({ | ||
visible: false, | ||
}); | ||
} | ||
|
||
render() { | ||
const { actions, onAnimationEnd } = this.props; | ||
const footer = actions.map((button) => { | ||
const orginPress = button.onPress || function () {}; | ||
button.onPress = () => { | ||
const res = orginPress(); | ||
if (res && (res as any).then) { | ||
(res as any).then(() => { | ||
this.onClose(); | ||
}); | ||
} else { | ||
this.onClose(); | ||
} | ||
}; | ||
return button; | ||
}); | ||
return ( | ||
<Modal | ||
operation | ||
transparent | ||
maskClosable | ||
visible={this.state.visible} | ||
onClose={this.onClose} | ||
onAnimationEnd={onAnimationEnd} | ||
style={modalStyle.operationContainer} | ||
bodyStyle={modalStyle.operationBody} | ||
footer={footer} | ||
/> | ||
); | ||
} | ||
} |
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,29 @@ | ||
--- | ||
order: 3 | ||
title: | ||
zh-CN: 操作 | ||
en-US: operation | ||
--- | ||
|
||
操作对话框 | ||
|
||
````jsx | ||
import { Modal, Button, WhiteSpace, WingBlank } from 'antd-mobile'; | ||
|
||
const operation = Modal.operation; | ||
|
||
const App = () => ( | ||
<WingBlank size="lg"> | ||
<WhiteSpace size="lg" /> | ||
<Button onClick={() => operation([ | ||
{ text: '标为未读', onPress: () => console.log('标为未读被点击了') }, | ||
{ text: '置顶聊天', onPress: () => console.log('置顶聊天被点击了') }, | ||
])} | ||
>操作按钮</Button> | ||
<WhiteSpace size="lg" /> | ||
</WingBlank> | ||
); | ||
|
||
ReactDOM.render(<App />, mountNode); | ||
|
||
```` |
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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import Modal from './Modal'; | ||
import alert from './alert.web'; | ||
import prompt from './prompt.web'; | ||
import operation from './operation.web'; | ||
|
||
(Modal as any).alert = alert; | ||
(Modal as any).prompt = prompt; | ||
(Modal as any).operation = operation; | ||
|
||
export default Modal; |
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,20 @@ | ||
import React from 'react'; | ||
import topView from 'rn-topview'; | ||
import OperationContainer from './OperationContainer'; | ||
|
||
export default function (...args) { | ||
const actions = args[0] || [{ text: '确定' }]; | ||
|
||
const onAnimationEnd = (visible) => { | ||
if (!visible) { | ||
topView.remove(); | ||
} | ||
}; | ||
|
||
topView.set( | ||
<OperationContainer | ||
actions={actions} | ||
onAnimationEnd={onAnimationEnd} | ||
/>, | ||
); | ||
} |
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,49 @@ | ||
/* tslint:disable:no-unused-variable */ | ||
import React from 'react'; | ||
/* tslint:enable:no-unused-variable */ | ||
import ReactDOM from 'react-dom'; | ||
import Modal from './Modal'; | ||
|
||
export default function (...args) { | ||
const actions = args[0] || [{ text: '确定' }]; | ||
|
||
const prefixCls = 'am-modal'; | ||
let div: any = document.createElement('div'); | ||
document.body.appendChild(div); | ||
|
||
function close() { | ||
ReactDOM.unmountComponentAtNode(div); | ||
div.parentNode.removeChild(div); | ||
} | ||
|
||
const footer = actions.map((button) => { | ||
const orginPress = button.onPress || function() {}; | ||
button.onPress = () => { | ||
const res = orginPress(); | ||
if (res && res.then) { | ||
res.then(() => { | ||
close(); | ||
}); | ||
} else { | ||
close(); | ||
} | ||
}; | ||
return button; | ||
}); | ||
|
||
ReactDOM.render( | ||
<Modal | ||
visible | ||
operation | ||
transparent | ||
prefixCls={prefixCls} | ||
transitionName="am-zoom" | ||
closable={false} | ||
maskClosable | ||
onClose={close} | ||
footer={footer} | ||
maskTransitionName="am-fade" | ||
className="am-modal-operation" | ||
/> , div | ||
); | ||
} |
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