ipanel-rnapp-ajb-base 1.0.13 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/app/App.js +3 -0
  2. package/app/components/common/PickerV1/index.js +93 -0
  3. package/app/components/common/PickerV2/index.js +96 -0
  4. package/app/components/common/PickerV2Base/_util/devWarning.tsx +5 -0
  5. package/app/components/common/PickerV2Base/_util/getLocale.tsx +42 -0
  6. package/app/components/common/PickerV2Base/_util/hooks/useAnimations.tsx +57 -0
  7. package/app/components/common/PickerV2Base/_util/hooks/useClickAway.ts +30 -0
  8. package/app/components/common/PickerV2Base/_util/isPromise.ts +5 -0
  9. package/app/components/common/PickerV2Base/_util/reactNode.ts +27 -0
  10. package/app/components/common/PickerV2Base/_util/version.json +1 -0
  11. package/app/components/common/PickerV2Base/_util/with-default-props.tsx +15 -0
  12. package/app/components/common/PickerV2Base/config-provider/DisabledContext.tsx +24 -0
  13. package/app/components/common/PickerV2Base/config-provider/index.tsx +7 -0
  14. package/app/components/common/PickerV2Base/locale-provider/en_US.tsx +22 -0
  15. package/app/components/common/PickerV2Base/locale-provider/es_ES.tsx +22 -0
  16. package/app/components/common/PickerV2Base/locale-provider/fa_IR.tsx +22 -0
  17. package/app/components/common/PickerV2Base/locale-provider/index.en-US.md +37 -0
  18. package/app/components/common/PickerV2Base/locale-provider/index.tsx +126 -0
  19. package/app/components/common/PickerV2Base/locale-provider/index.zh-CN.md +38 -0
  20. package/app/components/common/PickerV2Base/locale-provider/ko_KR.tsx +22 -0
  21. package/app/components/common/PickerV2Base/locale-provider/pt_BR.tsx +22 -0
  22. package/app/components/common/PickerV2Base/locale-provider/ru_RU.tsx +22 -0
  23. package/app/components/common/PickerV2Base/locale-provider/sv_SE.tsx +22 -0
  24. package/app/components/common/PickerV2Base/locale-provider/useLocale.tsx +36 -0
  25. package/app/components/common/PickerV2Base/locale-provider/zh_CN.tsx +22 -0
  26. package/app/components/common/PickerV2Base/picker/Picker.tsx +216 -0
  27. package/app/components/common/PickerV2Base/picker/Popup.tsx +77 -0
  28. package/app/components/common/PickerV2Base/picker/PopupPickerTypes.tsx +16 -0
  29. package/app/components/common/PickerV2Base/picker/PropsType.tsx +26 -0
  30. package/app/components/common/PickerV2Base/picker/index.en-US.md +98 -0
  31. package/app/components/common/PickerV2Base/picker/index.tsx +85 -0
  32. package/app/components/common/PickerV2Base/picker/index.zh-CN.md +97 -0
  33. package/app/components/common/PickerV2Base/picker/locale/en_US.tsx +5 -0
  34. package/app/components/common/PickerV2Base/picker/locale/es_ES.tsx +5 -0
  35. package/app/components/common/PickerV2Base/picker/locale/fa_IR.tsx +5 -0
  36. package/app/components/common/PickerV2Base/picker/locale/id_ID.tsx +5 -0
  37. package/app/components/common/PickerV2Base/picker/locale/ko_KR.tsx +5 -0
  38. package/app/components/common/PickerV2Base/picker/locale/pt_BR.tsx +5 -0
  39. package/app/components/common/PickerV2Base/picker/locale/ru_RU.tsx +5 -0
  40. package/app/components/common/PickerV2Base/picker/locale/sv_SE.tsx +5 -0
  41. package/app/components/common/PickerV2Base/picker/locale/zh_CN.tsx +5 -0
  42. package/app/components/common/PickerV2Base/picker/style/index.tsx +57 -0
  43. package/app/components/common/PickerV2Base/picker-view/PropsType.tsx +37 -0
  44. package/app/components/common/PickerV2Base/picker-view/Wheel.tsx +200 -0
  45. package/app/components/common/PickerV2Base/picker-view/columns-extend.tsx +86 -0
  46. package/app/components/common/PickerV2Base/picker-view/index.en-US.md +71 -0
  47. package/app/components/common/PickerV2Base/picker-view/index.tsx +69 -0
  48. package/app/components/common/PickerV2Base/picker-view/index.zh-CN.md +72 -0
  49. package/app/components/common/PickerV2Base/picker-view/picker-view.tsx +166 -0
  50. package/app/components/common/PickerV2Base/picker-view/style/index.tsx +51 -0
  51. package/app/components/common/PickerV2Base/style/index.tsx +96 -0
  52. package/app/components/common/PickerV2Base/style/themes/default.tsx +203 -0
  53. package/app/components/index.js +2 -0
  54. package/app/eventBus/index.js +1 -0
  55. package/app/hooks/shopMessageManager.js +5 -3
  56. package/app/screens/LoginScreen/OpenLogSheet.js +6 -1
  57. package/app/utils/common.js +0 -1
  58. package/package.json +19 -19
package/app/App.js CHANGED
@@ -19,6 +19,7 @@ import DeviceInfo from 'react-native-device-info';
19
19
  import {SafeAreaProvider, SafeAreaView} from 'react-native-safe-area-context';
20
20
  import VersionUpdateConfirm from './components/VersionUpdateConfirm';
21
21
  // import NetInfo from '@react-native-community/netinfo';
22
+ import { Provider } from '@ant-design/react-native';
22
23
 
23
24
  // 重要:base.js需放在一切自定义代码之前初始化
24
25
  import './base.js';
@@ -396,6 +397,7 @@ const App = () => {
396
397
  const renderContent = () => {
397
398
  return (
398
399
  <>
400
+ <Provider>
399
401
  <SheetProvider>
400
402
  <NavigationContainer
401
403
  ref={navigationRef}
@@ -449,6 +451,7 @@ const App = () => {
449
451
  <View style={styles.touchableContainer} />
450
452
  </TouchableWithoutFeedback>
451
453
  )}
454
+ </Provider>
452
455
  </>
453
456
  );
454
457
  };
@@ -0,0 +1,93 @@
1
+ import React,{useState} from 'react';
2
+ import {View, Text, StyleSheet} from 'react-native';
3
+ import {Picker} from '@ant-design/react-native';
4
+ import px from '../../../utils/scaleSize';
5
+ const pickerStyles = {
6
+ okText: {color: '#E86003',borderLeftColor:'#F0F0F0',borderLeftWidth:1,width:px(500)},
7
+ dismissText: {color: '#666',width:px(500),},
8
+ container:{borderTopLeftRadius:px(20),borderTopRightRadius:px(20)},
9
+ wrappper:{borderTopLeftRadius:px(20),borderTopRightRadius:px(20)},
10
+ headerItem:{flex:0},
11
+ header:{
12
+ borderBottomWidth:px(0),
13
+ borderTopWidth:1,
14
+ borderTopColor:'#F0F0F0'
15
+ },
16
+ maskMiddle:{borderColor:'transparent'},
17
+ }
18
+ const pickerStyle = {height:px(700)}
19
+
20
+ const PickerV1 = ({
21
+ renderMaskTop=()=>{return <View></View>},
22
+ renderMaskBottom=()=>{return <View></View>},
23
+ styles={},
24
+ style={},
25
+ itemHeight=px(140),
26
+ visible=false,
27
+ pickerData = [],
28
+ dealPickerCommit=()=>{},
29
+ dealPickerCancel = () => {},
30
+ renderItem,
31
+ defaultValue = [],
32
+ pickedIndex=0,
33
+ changePickedIndex=()=>{}
34
+ }) => {
35
+ const handlePickerChange=(item)=>{
36
+ // console.log(item)
37
+ const index = pickerData.findIndex(item_=>{
38
+ return item[0] === item_.value
39
+ })
40
+ // console.log(index)
41
+ changePickedIndex(index)
42
+ }
43
+ const handlePikerCommit = (item) => {
44
+ dealPickerCommit(item)
45
+ }
46
+ const handlePickerCancel = () => {
47
+ dealPickerCancel()
48
+ }
49
+ const renderLabel = (item, index) => {
50
+ return (
51
+ <Text
52
+ key={index}
53
+ style={[styless.pickerItemCom,
54
+ index===pickedIndex?styless.pickedPicker:
55
+ {fontSize: px(50),color:Math.abs(index-pickedIndex)===1?'#999':'#eee'},
56
+ ]}
57
+ >
58
+ {item.value}
59
+ </Text>
60
+ );
61
+ };
62
+ return (
63
+ <View>
64
+ <Picker
65
+ data={pickerData}
66
+ visible={visible}
67
+ renderMaskTop={renderMaskTop}
68
+ renderMaskBottom={renderMaskBottom}
69
+ styles={{...pickerStyles,...styles}}
70
+ renderLabel={renderItem||renderLabel}
71
+ style={{...pickerStyle,...style}}
72
+ itemHeight={itemHeight}
73
+ defaultValue = {defaultValue}
74
+ onPickerChange={handlePickerChange}
75
+ onOk={handlePikerCommit}
76
+ onDismiss={handlePickerCancel}
77
+ onClose={handlePickerCancel}
78
+ >
79
+ </Picker>
80
+ </View>
81
+ );
82
+ };
83
+ const styless = StyleSheet.create({
84
+ pickerItemCom:{
85
+ textAlign:'center',
86
+ },
87
+ pickedPicker:{
88
+ color: '#333',
89
+ fontSize:px(72),
90
+ fontWeight:'bold'
91
+ },
92
+ });
93
+ export default PickerV1;
@@ -0,0 +1,96 @@
1
+ import React,{useState} from 'react';
2
+ import {View, Text, StyleSheet} from 'react-native';
3
+ import Picker from '../PickerV2Base/picker';
4
+ import px from '../../../utils/scaleSize';
5
+ const pickerStyles = {
6
+ okView:{borderLeftColor:'#F0F0F0',borderLeftWidth:1},
7
+ okText: {color: '#E86003',width:px(500)},
8
+ dismissText: {color: '#666666',width:px(500),},
9
+ container:{borderTopLeftRadius:px(20),borderTopRightRadius:px(20)},
10
+ wrappper:{borderTopLeftRadius:px(20),borderTopRightRadius:px(20)},
11
+ headerItem:{flex:0},
12
+ header:{
13
+ borderBottomWidth:px(0),
14
+ borderTopWidth:1,
15
+ borderTopColor:'#F0F0F0',
16
+ backgroundColor: '#fff'
17
+ },
18
+ maskMiddle:{borderColor:'transparent'},
19
+ }
20
+ const pickerStyle = {height:px(700)}
21
+
22
+ const PickerV2 = ({
23
+ renderMaskTop=()=>{return <View></View>},
24
+ renderMaskBottom=()=>{return <View></View>},
25
+ styles={},
26
+ style={},
27
+ itemHeight=px(140),
28
+ visible=false,
29
+ pickerData = [],
30
+ dealPickerCommit=()=>{},
31
+ dealPickerCancel = () => {},
32
+ renderItem,
33
+ defaultValue = [],
34
+ pickedIndex=0,
35
+ changePickedIndex=()=>{}
36
+ }) => {
37
+ // console.log(defaultValue)
38
+ const handlePickerChange=(item)=>{
39
+ // console.log(item)
40
+ const index = pickerData.findIndex(item_=>{
41
+ return item[0] === item_.value
42
+ })
43
+ // console.log(index)
44
+ changePickedIndex(index)
45
+ }
46
+ const handlePikerCommit = (item) => {
47
+ dealPickerCommit(item)
48
+ }
49
+ const handlePickerCancel = () => {
50
+ dealPickerCancel()
51
+ }
52
+ const renderLabel = (item, index) => {
53
+ return (
54
+ <Text
55
+ key={index}
56
+ style={[styless.pickerItemCom,
57
+ index===pickedIndex?styless.pickedPicker:
58
+ {fontSize: px(50),color:Math.abs(index-pickedIndex)===1?'#999':'#eee'},
59
+ ]}
60
+ >
61
+ {item.value}
62
+ </Text>
63
+ );
64
+ };
65
+ return (
66
+ <View>
67
+ <Picker
68
+ data={pickerData}
69
+ visible={visible}
70
+ renderMaskTop={renderMaskTop}
71
+ renderMaskBottom={renderMaskBottom}
72
+ styles={{...pickerStyles,...styles}}
73
+ renderLabel={renderItem||renderLabel}
74
+ style={{...pickerStyle,...style}}
75
+ itemHeight={itemHeight}
76
+ defaultValue = {defaultValue}
77
+ onPickerChange={handlePickerChange}
78
+ onOk={handlePikerCommit}
79
+ onDismiss={handlePickerCancel}
80
+ onClose={handlePickerCancel}
81
+ >
82
+ </Picker>
83
+ </View>
84
+ );
85
+ };
86
+ const styless = StyleSheet.create({
87
+ pickerItemCom:{
88
+ textAlign:'center',
89
+ },
90
+ pickedPicker:{
91
+ color: '#333',
92
+ fontSize:px(72),
93
+ fontWeight:'bold'
94
+ },
95
+ });
96
+ export default PickerV2;
@@ -0,0 +1,5 @@
1
+ export default (valid: boolean, component: string, message: string): void => {
2
+ if (__DEV__ && !valid) {
3
+ console.warn(`Warning: [antd_mobile_rn: ${component}] ${message}`)
4
+ }
5
+ }
@@ -0,0 +1,42 @@
1
+ export function getComponentLocale(
2
+ props: any,
3
+ context: any,
4
+ componentName: string,
5
+ getDefaultLocale: () => any,
6
+ ) {
7
+ let locale: any = {}
8
+ if (context && context.antLocale && context.antLocale[componentName]) {
9
+ locale = context.antLocale[componentName]
10
+ } else {
11
+ const defaultLocale = getDefaultLocale()
12
+ // TODO: make default lang of antd be English
13
+ // https://github.com/ant-design/ant-design/issues/6334
14
+ locale = defaultLocale.default || defaultLocale
15
+ }
16
+
17
+ let result = {
18
+ ...locale,
19
+ }
20
+ if (props.locale) {
21
+ result = {
22
+ ...result,
23
+ ...props.locale,
24
+ }
25
+ if (props.locale.lang) {
26
+ result.lang = {
27
+ ...locale.lang,
28
+ ...props.locale.lang,
29
+ }
30
+ }
31
+ }
32
+ return result
33
+ }
34
+
35
+ export function getLocaleCode(context: any) {
36
+ const localeCode = context.antLocale && context.antLocale.locale
37
+ // Had use LocaleProvide but didn't set locale
38
+ if (context.antLocale && context.antLocale.exist && !localeCode) {
39
+ return 'zh-cn'
40
+ }
41
+ return localeCode
42
+ }
@@ -0,0 +1,57 @@
1
+ import * as React from 'react'
2
+ import { Animated, EasingFunction } from 'react-native'
3
+
4
+ type animateType = (_TimingAnimationConfig: {
5
+ toValue?:
6
+ | number
7
+ | Animated.AnimatedValue
8
+ | { x: number; y: number }
9
+ | Animated.AnimatedValueXY
10
+ | Animated.AnimatedInterpolation
11
+ easing?: EasingFunction
12
+ duration?: number
13
+ delay?: number
14
+ useNativeDriver?: boolean
15
+ }) => void
16
+
17
+ interface ConfigureInterface {
18
+ initialValue: number
19
+ animate: animateType
20
+ }
21
+
22
+ // Animated.Value hook
23
+ export function useAnimate(configure: ConfigureInterface) {
24
+ const useAnimatedValue = (initialValue: number) => {
25
+ const ref = React.useRef(new Animated.Value(initialValue))
26
+ return ref.current
27
+ }
28
+
29
+ const animatedValue = useAnimatedValue(configure.initialValue)
30
+
31
+ return [animatedValue]
32
+ }
33
+
34
+ // Animated.timing hook
35
+ export function useAnimatedTiming(): [Animated.Value, animateType] {
36
+ const animatedRef = React.useRef<Animated.CompositeAnimation | void>()
37
+
38
+ const animatedFunc = React.useCallback(
39
+ ({ toValue = 1, duration = 200, easing, useNativeDriver = false }) => {
40
+ animatedRef.current?.stop()
41
+ animatedRef.current = Animated.timing(animatedValue, {
42
+ toValue,
43
+ duration,
44
+ easing,
45
+ useNativeDriver,
46
+ }).start()
47
+ },
48
+ // @ts-ignore
49
+ [animatedValue],
50
+ )
51
+ var [animatedValue] = useAnimate({
52
+ initialValue: 0,
53
+ animate: animatedFunc,
54
+ })
55
+
56
+ return [animatedValue, animatedFunc]
57
+ }
@@ -0,0 +1,30 @@
1
+ import { useEffect, useMemo, useRef } from 'react'
2
+ import {
3
+ DeviceEventEmitter,
4
+ EmitterSubscription,
5
+ GestureResponderEvent,
6
+ NativeEventEmitter,
7
+ } from 'react-native'
8
+
9
+ export const USE_CLICK_AWAY_EVENT_NAME = 'ANT_DESIGN_MOBILE_RN_USE_CLICK_AWAY'
10
+
11
+ export default function useClickAway(
12
+ onClickAway: (event: GestureResponderEvent) => void,
13
+ ) {
14
+ const TopViewEventEmitter = useMemo(
15
+ () => DeviceEventEmitter || new NativeEventEmitter(),
16
+ [],
17
+ )
18
+
19
+ const onClickAwayRef = useRef<EmitterSubscription>()
20
+
21
+ useEffect(() => {
22
+ onClickAwayRef.current = TopViewEventEmitter.addListener(
23
+ USE_CLICK_AWAY_EVENT_NAME,
24
+ onClickAway,
25
+ )
26
+ return () => {
27
+ onClickAwayRef.current?.remove?.()
28
+ }
29
+ }, [TopViewEventEmitter, onClickAway])
30
+ }
@@ -0,0 +1,5 @@
1
+ export function isPromise(obj: unknown): obj is Promise<unknown> {
2
+ return (
3
+ !!obj && typeof obj === 'object' && typeof (obj as any).then === 'function'
4
+ )
5
+ }
@@ -0,0 +1,27 @@
1
+ import React from 'react'
2
+
3
+ type AnyObject = Record<PropertyKey, any>
4
+
5
+ export function isFragment(child: any): boolean {
6
+ return child && React.isValidElement(child) && child.type === React.Fragment
7
+ }
8
+
9
+ type RenderProps = AnyObject | ((originProps: AnyObject) => AnyObject | void)
10
+
11
+ export const replaceElement = <P>(
12
+ element: React.ReactNode,
13
+ replacement: React.ReactNode,
14
+ props?: RenderProps,
15
+ ) => {
16
+ if (!React.isValidElement<P>(element)) {
17
+ return replacement
18
+ }
19
+ return React.cloneElement<P>(
20
+ element,
21
+ typeof props === 'function' ? props(element.props || {}) : props,
22
+ )
23
+ }
24
+
25
+ export function cloneElement<P>(element: React.ReactNode, props?: RenderProps) {
26
+ return replaceElement<P>(element, element, props) as React.ReactElement
27
+ }
@@ -0,0 +1,15 @@
1
+ const assignWith = require('lodash.assignwith')
2
+
3
+ export function mergeProps<A, B>(a: A, b: B): B & A
4
+ export function mergeProps<A, B, C>(a: A, b: B, c: C): C & B & A
5
+ export function mergeProps(...items: any[]) {
6
+ function customizer(objValue: any, srcValue: any) {
7
+ return srcValue === undefined ? objValue : srcValue
8
+ }
9
+
10
+ let ret = { ...items[0] }
11
+ for (let i = 1; i < items.length; i++) {
12
+ ret = assignWith(ret, items[i], customizer)
13
+ }
14
+ return ret
15
+ }
@@ -0,0 +1,24 @@
1
+ import * as React from 'react'
2
+
3
+ export type DisabledType = boolean | undefined
4
+
5
+ const DisabledContext = React.createContext<DisabledType>(false)
6
+
7
+ export interface DisabledContextProps {
8
+ disabled?: DisabledType
9
+ children?: React.ReactNode
10
+ }
11
+
12
+ export const DisabledContextProvider: React.FC<DisabledContextProps> = ({
13
+ children,
14
+ disabled,
15
+ }) => {
16
+ const originDisabled = React.useContext(DisabledContext)
17
+ return (
18
+ <DisabledContext.Provider value={disabled ?? originDisabled}>
19
+ {children}
20
+ </DisabledContext.Provider>
21
+ )
22
+ }
23
+
24
+ export default DisabledContext
@@ -0,0 +1,7 @@
1
+ import React from 'react'
2
+
3
+ export interface ConfigConsumerProps {}
4
+
5
+ export const ConfigContext = React.createContext<ConfigConsumerProps>({})
6
+
7
+ export const { Consumer: ConfigConsumer } = ConfigContext
@@ -0,0 +1,22 @@
1
+ import DatePickerView from '../date-picker-view/locale/en_US'
2
+ import DatePicker from '../date-picker/locale/en_US'
3
+ import Form from '../form/locale/en_US'
4
+ import InputItem from '../input-item/locale/en_US'
5
+ import ListView from '../list-view/locale/en_US'
6
+ import Modal from '../modal/locale/en_US'
7
+ import Pagination from '../pagination/locale/en_US'
8
+ import Picker from '../picker/locale/en_US'
9
+ import SearchBar from '../search-bar/locale/en_US'
10
+
11
+ export default {
12
+ locale: 'en',
13
+ DatePicker,
14
+ DatePickerView,
15
+ InputItem,
16
+ Modal,
17
+ Pagination,
18
+ Picker,
19
+ SearchBar,
20
+ ListView,
21
+ Form,
22
+ }
@@ -0,0 +1,22 @@
1
+ import DatePickerView from '../date-picker-view/locale/es_ES'
2
+ import DatePicker from '../date-picker/locale/es_ES'
3
+ import Form from '../form/locale/es_ES'
4
+ import InputItem from '../input-item/locale/es_ES'
5
+ import ListView from '../list-view/locale/es_ES'
6
+ import Modal from '../modal/locale/es_ES'
7
+ import Pagination from '../pagination/locale/es_ES'
8
+ import Picker from '../picker/locale/es_ES'
9
+ import SearchBar from '../search-bar/locale/es_ES'
10
+
11
+ export default {
12
+ locale: 'es',
13
+ DatePicker,
14
+ DatePickerView,
15
+ InputItem,
16
+ Modal,
17
+ Pagination,
18
+ Picker,
19
+ SearchBar,
20
+ ListView,
21
+ Form,
22
+ }
@@ -0,0 +1,22 @@
1
+ import DatePickerView from '../date-picker-view/locale/fa_IR'
2
+ import DatePicker from '../date-picker/locale/fa_IR'
3
+ import Form from '../form/locale/fa_IR'
4
+ import InputItem from '../input-item/locale/fa_IR'
5
+ import ListView from '../list-view/locale/fa_IR'
6
+ import Modal from '../modal/locale/fa_IR'
7
+ import Pagination from '../pagination/locale/fa_IR'
8
+ import Picker from '../picker/locale/fa_IR'
9
+ import SearchBar from '../search-bar/locale/fa_IR'
10
+
11
+ export default {
12
+ locale: 'fa',
13
+ DatePicker,
14
+ DatePickerView,
15
+ InputItem,
16
+ Modal,
17
+ Pagination,
18
+ Picker,
19
+ SearchBar,
20
+ ListView,
21
+ Form,
22
+ }
@@ -0,0 +1,37 @@
1
+ ---
2
+ category: Components
3
+ title: Provider
4
+ type: Other
5
+ ---
6
+
7
+ `Provider` provides a uniform localization support for built-in text of components.
8
+
9
+ ## Usage
10
+
11
+ `Provider` takes use of [context](https://facebook.github.io/react/docs/context.html), a feature of React, to accomplish global effectiveness by wrapping the app only once.
12
+
13
+
14
+ ```jsx
15
+ import enUS from '@ant-design/react-native/lib/locale-provider/en_US';
16
+
17
+ ...
18
+
19
+ return <Provider locale={enUS}><App /></Provider>;
20
+ ```
21
+
22
+ We support English and Chinese temporarily, all locale packages can be found in [here](https://github.com/ant-design/ant-design-mobile-rn/blob/master/components/locale-provider/).
23
+
24
+ ### Add a new language
25
+
26
+ If you can't find your language, you are welcome to create a locale package based on [en_US]((https://github.com/ant-design/ant-design-mobile-rn/blob/master/components/locale-provider/en_US.tsx)) and send us a pull request.
27
+
28
+ ### Other localization needs
29
+
30
+ This component aims for localization of the built-in text, if you want to support other documents, we recommend using [react-intl](https://github.com/yahoo/react-intl), refer to [Intl demo 1](http://github.com/ant-design/intl-example) and [Intl demo 2](http://yiminghe.me/learning-react/examples/react-intl.html?locale=en-US).
31
+
32
+ ## API
33
+
34
+ | Property | Description | Type | Default |
35
+ | -------- | ------------------------------------------------------------------------------------------------------------------------------- | ------ | ------- |
36
+ | locale | anguage package setting, you can find the packages in this path: `@ant-design/react-native/lib/locale-provider/` | object | - |
37
+ | theme | Theme customization [theme](https://github.com/ant-design/ant-design-mobile-rn/blob/master/components/style/themes/default.tsx) | object | - |
@@ -0,0 +1,126 @@
1
+ import type { ValidateMessages } from 'rc-field-form/lib/interface'
2
+ import React from 'react'
3
+
4
+ export interface Locale {
5
+ /** zh_CN */
6
+ locale: string
7
+ DatePicker: {
8
+ /** 确定 */
9
+ okText: string
10
+ /** 取消 */
11
+ dismissText: string
12
+ /** 请选择 */
13
+ extra: string
14
+ DatePickerLocale: {
15
+ /** 年 */
16
+ year: string
17
+ /** 月 */
18
+ month: string
19
+ /** 日 */
20
+ day: string
21
+ /** 时 */
22
+ hour: string
23
+ /** 分 */
24
+ minute: string
25
+ /** 上午 */
26
+ am: string
27
+ /** 下午 */
28
+ pm: string
29
+ }
30
+ }
31
+ DatePickerView: {
32
+ /** 年 */
33
+ year: string
34
+ /** 月 */
35
+ month: string
36
+ /** 日 */
37
+ day: string
38
+ /** 时 */
39
+ hour: string
40
+ /** 分 */
41
+ minute: string
42
+ /** 上午 */
43
+ am: string
44
+ /** 下午 */
45
+ pm: string
46
+ }
47
+ InputItem: {
48
+ /** 确定 */
49
+ confirmLabel: string
50
+ /** 退格 */
51
+ backspaceLabel: string
52
+ /** 收起键盘 */
53
+ cancelKeyboardLabel: string
54
+ }
55
+ Modal: {
56
+ /** 确定 */
57
+ okText: string
58
+ /** 取消 */
59
+ cancelText: string
60
+ /** 按钮 */
61
+ buttonText: string
62
+ }
63
+ Pagination: {
64
+ /** 上一页 */
65
+ prevText: string
66
+ /** 下一页 */
67
+ nextText: string
68
+ }
69
+ Picker: {
70
+ /** 确定 */
71
+ okText: string
72
+ /** 取消 */
73
+ dismissText: string
74
+ /** 请选择 */
75
+ extra: string
76
+ }
77
+ SearchBar: {
78
+ /** 取消 */
79
+ cancelText: string
80
+ }
81
+ ListView: {
82
+ /** 已加载完 */
83
+ done: string
84
+ /** 加载中... */
85
+ loading: string
86
+ /** 下拉刷新 */
87
+ refreshableTitlePull: string
88
+ /** 释放加载 */
89
+ refreshableTitleRelease: string
90
+ /** 加载中... */
91
+ refreshableTitleRefreshing: string
92
+ /** 暂无数据 */
93
+ noData: string
94
+ }
95
+ Form: {
96
+ optional?: string
97
+ defaultValidateMessages: ValidateMessages
98
+ }
99
+ }
100
+ export interface LocaleProviderProps {
101
+ locale?: Partial<Locale>
102
+ children?: React.ReactNode
103
+ }
104
+
105
+ export type LocaleContextProps = {
106
+ antLocale: Partial<Locale & { exist: boolean }>
107
+ }
108
+
109
+ export const LocaleContext = React.createContext<
110
+ LocaleContextProps | undefined
111
+ >(undefined)
112
+
113
+ const LocaleProvider: React.FC<LocaleProviderProps> = (props) => {
114
+ const locale = React.useMemo(() => {
115
+ return { antLocale: { ...props.locale, exist: true } }
116
+ }, [props.locale])
117
+ return (
118
+ <LocaleContext.Provider value={locale}>
119
+ {props.children}
120
+ </LocaleContext.Provider>
121
+ )
122
+ }
123
+
124
+ LocaleProvider.displayName = 'LocaleProvider'
125
+
126
+ export default React.memo(LocaleProvider)