Skip to content

Commit

Permalink
- fixed Modal contain IOSHoldMenu bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
czy0729 committed Dec 31, 2021
1 parent 470f8d4 commit 2467bd8
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 24 deletions.
14 changes: 3 additions & 11 deletions src/components/@/ant-design/action-sheet/AndroidContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,8 @@ class ActionSheetAndroid extends React.PureComponent {
}
render() {
const { config, onAnimationEnd } = this.props
const {
title,
message,
options,
destructiveButtonIndex,
cancelButtonIndex
} = config
const { title, message, options, destructiveButtonIndex, cancelButtonIndex } =
config

return (
<WithTheme themeStyles={ActionSheetStyles} styles={this.props.styles}>
Expand All @@ -58,11 +53,8 @@ class ActionSheetAndroid extends React.PureComponent {
)
const content = options.map((item, index) => (
<View
// eslint-disable-next-line react/no-array-index-key
key={index}
style={[
cancelButtonIndex === index ? styles.cancelBtn : undefined
]}
style={[cancelButtonIndex === index ? styles.cancelBtn : undefined]}
>
<TouchableHighlight
style={[styles.btn]}
Expand Down
2 changes: 1 addition & 1 deletion src/components/popover/index.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2019-12-14 16:28:46
* @Last Modified by: czy0729
* @Last Modified time: 2021-12-28 22:42:12
* @Last Modified time: 2021-12-31 19:21:24
*/
import React from 'react'
import { observer } from 'mobx-react'
Expand Down
10 changes: 5 additions & 5 deletions src/screens/_/base/folder-manage-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2021-05-27 14:20:46
* @Last Modified by: czy0729
* @Last Modified time: 2021-12-30 08:30:49
* @Last Modified time: 2021-12-31 19:31:06
*/
import React from 'react'
import { Alert, BackHandler, ScrollView, View } from 'react-native'
Expand Down Expand Up @@ -794,15 +794,15 @@ export const FolderManageModal = ob(
onPress={() => this.onToggle(item, detail, isIn)}
/>
)}
<Popover
<Popover.Old
style={this.styles.btnPopover}
data={controlDS.root}
onSelect={title => this.onControl(title, item)}
>
<Flex style={this.styles.touch} justify='center'>
<Iconfont name='md-more-vert' size={18} color={_.colorSub} />
</Flex>
</Popover>
</Popover.Old>
</>
)}
{item.id == create && (
Expand Down Expand Up @@ -938,15 +938,15 @@ export const FolderManageModal = ob(
</View>
)}
{!edit && !create && (
<Popover
<Popover.Old
style={this.styles.btnPopover}
data={data}
onSelect={title => this.onSubjectControl(title, i, item)}
>
<Flex style={this.styles.touch} justify='center'>
<Iconfont name='md-more-vert' size={18} color={_.colorSub} />
</Flex>
</Popover>
</Popover.Old>
)}
</Flex>
</Flex>
Expand Down
33 changes: 31 additions & 2 deletions src/screens/_/base/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
* @Author: czy0729
* @Date: 2019-06-01 18:25:07
* @Last Modified by: czy0729
* @Last Modified time: 2021-11-15 20:55:03
* @Last Modified time: 2021-12-31 19:30:22
*/
import React from 'react'
import { Popover as CompPopover, Menu } from '@components'
import { Popover as CompPopoverOld } from '@components/popover/old'
import { ob } from '@utils/decorators'
import { IOS } from '@constants'

export const Popover = ob(
const Popover = ob(
({ data = [], menuStyle, onSelect = Function.prototype, children, ...other }) => {
const popoverProps = IOS
? {
Expand All @@ -25,10 +26,38 @@ export const Popover = ob(
data,
onSelect
}

return (
<CompPopover placement='bottom' {...popoverProps} {...other}>
{children}
</CompPopover>
)
}
)

Popover.Old = ob(
({ data = [], menuStyle, onSelect = Function.prototype, children, ...other }) => {
const popoverProps = IOS
? {
overlay: (
<Menu
style={menuStyle}
data={data}
onSelect={title => setTimeout(() => onSelect(title), 0)}
/>
)
}
: {
data,
onSelect
}

return (
<CompPopoverOld placement='bottom' {...popoverProps} {...other}>
{children}
</CompPopoverOld>
)
}
)

export { Popover }
6 changes: 3 additions & 3 deletions src/screens/tinygrail/_/characters-modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2020-06-28 14:02:31
* @Last Modified by: czy0729
* @Last Modified time: 2021-11-23 04:35:46
* @Last Modified time: 2021-12-31 19:31:44
*/
import React from 'react'
import { BackHandler, View, Alert, StatusBar } from 'react-native'
Expand Down Expand Up @@ -792,7 +792,7 @@ class CharactersModal extends React.Component {

renderFilter(filter, data, map, onSelect) {
return (
<Popover
<Popover.Old
data={data}
hitSlop={hitSlop}
onSelect={title => {
Expand All @@ -811,7 +811,7 @@ class CharactersModal extends React.Component {
{map[filter] ? ` (${map[filter]})` : ''}
</Text>
</Flex>
</Popover>
</Popover.Old>
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/screens/tinygrail/items/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2020-03-05 17:59:15
* @Last Modified by: czy0729
* @Last Modified time: 2021-11-21 02:36:09
* @Last Modified time: 2021-12-31 19:18:04
*/
import React from 'react'
import { ScrollView, View } from 'react-native'
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"@constants": ["src/constants"],
"@constants/*": ["src/constants/*"],
"@styles": ["src/styles"],
"@styles/*": ["src/styles/*"]
"@styles/*": ["src/styles/*"],
"@tinygrail": ["src/screens/tinygrail"],
"@tinygrail/*": ["src/screens/tinygrail/*"]
},
"allowJs": true,
"esModuleInterop": true,
Expand Down

0 comments on commit 2467bd8

Please sign in to comment.