Skip to content

Commit

Permalink
Merge branch 'ant-design:master' into fix/disable-modal-button-before…
Browse files Browse the repository at this point in the history
…-press-handler-promise-becomes-to-resolve-state
  • Loading branch information
cw1997 authored Aug 27, 2022
2 parents 37b3f3d + 02c3cd0 commit 60b5261
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 12 deletions.
3 changes: 0 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
components/**/*.js
components/**/*.jsx
components/*/__tests__/type.tsx
!.eslintrc.js
!components/*/__tests__/**/*.js
!components/*/demo/*
2 changes: 1 addition & 1 deletion components/modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class AntmModal extends React.Component<ModalProps, any> {
const styleMap: {
[key: string]: object
} = {
cancel: {},
cancel: { color: '#000' },
default: {},
destructive: { color: 'red' },
disabled: { color: 'lightgray' },
Expand Down
4 changes: 2 additions & 2 deletions components/modal/PromptContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export default class PropmptContainer extends React.Component<
onChangeText={(value) => {
this.onChangeText('text', value)
}}
value={this.state.text}
defaultValue={this.state.text}
style={styles.input}
underlineColorAndroid="transparent"
placeholder={placeholders![0]}
Expand All @@ -173,7 +173,7 @@ export default class PropmptContainer extends React.Component<
onChangeText={(value) => {
this.onChangeText('password', value)
}}
value={this.state.password}
defaultValue={this.state.password}
style={styles.input}
underlineColorAndroid="transparent"
placeholder={placeholders![1]}
Expand Down
28 changes: 28 additions & 0 deletions components/modal/demo/basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,30 @@ export default class BasicModalExample extends React.Component<any, any> {
])
}

onButtonClickPromise = () => {
Modal.alert('Title', 'promise button', [
{
text: 'Cancel',
onPress: () => {
Toast.info('onPress promise resolve', 1)
return new Promise((resolve) => {
setTimeout(resolve, 1000)
})
},
style: 'cancel',
},
{
text: 'Hold on',
onPress: () => {
Toast.info('onPress promise reject', 1)
return new Promise((_, reject) => {
setTimeout(reject, 1000)
})
},
},
])
}

onButtonClick2 = () => {
Modal.operation([
{ text: '标为未读', onPress: () => console.log('标为未读被点击了') },
Expand Down Expand Up @@ -112,6 +136,10 @@ export default class BasicModalExample extends React.Component<any, any> {
<WhiteSpace />
<Button onPress={this.onButtonClick}>Modal.alert</Button>
<WhiteSpace />
<Button onPress={this.onButtonClickPromise}>
Modal.alert (promise)
</Button>
<WhiteSpace />
<Button onPress={this.onButtonClick2}>Modal.opertation</Button>
<WhiteSpace />
<Button onPress={this.onButtonClick6}>
Expand Down
4 changes: 3 additions & 1 deletion components/tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ export class Tabs extends React.PureComponent<TabsProps, StateType> {
if (this.carousel) {
this.carousel.goTo(index)
}
this.state.scrollX.setValue(index * this.state.containerWidth)
this.setState({ currentTab: index }, () => {
this.state.scrollX.setValue(index * this.state.containerWidth)
})
}

tabClickGoToTab(index: number) {
Expand Down
2 changes: 1 addition & 1 deletion components/tabs/demo/basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default class BasicTabsExample extends React.Component<any, any> {
}}>
<Text
style={{
color: tabProps.activeTab === i ? 'green' : undefined,
color: tabProps.activeTab === i ? 'green' : '#333333',
}}>
{tab.title}
</Text>
Expand Down
15 changes: 15 additions & 0 deletions example/app.web-build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"expo": {
"name": "@ant-design/react-native",
"slug": "@ant-design/react-native",
"description": "基于蚂蚁金服移动设计规范的 React Native 组件库",
"privacy": "public",
"sdkVersion": "34.0.0",
"platforms": ["web"],
"version": "5.0.1",
"primaryColor": "#cccccc",
"web": {
"publicPath": "."
}
}
}
7 changes: 3 additions & 4 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@
"version": "5.0.0",
"description": "Demo app for ant-design mobile RN UI Library",
"private": true,
"homepage": "https://github.com/ant-design/ant-design-mobile-rn",
"homepage": ".",
"main": "./index.js",
"scripts": {
"start": "EXPO_NO_TYPESCRIPT_SETUP=1 expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject",
"build:web": "expo build:web --config ./app.web-build.json --polyfill",
"deploy": "gh-pages -d web-build",
"build:web": "expo build:web --config ./app.web-build.json",
"publish": "expo publish",
"prettify": "prettier --write . --config ./.prettierrc",
"lint": "eslint --ext js,ts,tsx ."
},
"dependencies": {
"@babel/preset-typescript": "^7.16.7",
"expo": "^44.0.6",
"expo-app-loading": "~1.3.0",
"expo-dev-client": "^0.8.4",
Expand Down

0 comments on commit 60b5261

Please sign in to comment.