forked from xcarpentier/react-native-country-picker-modal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.tsx
80 lines (76 loc) · 2.37 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import React, { ReactNode } from 'react'
import { FlagButtonProps } from './FlagButton'
import {
TranslationLanguageCode,
CountryCode,
Country,
Region,
Subregion,
} from './types'
import { CountryProvider, DEFAULT_COUNTRY_CONTEXT } from './CountryContext'
import { ThemeProvider, DEFAULT_THEME, Theme } from './CountryTheme'
import { CountryFilterProps } from './CountryFilter'
import { StyleProp, ViewStyle, ModalProps, FlatListProps } from 'react-native'
import { CountryPicker } from './CountryPicker'
interface Props {
allowFontScaling?: boolean
countryCode: CountryCode
region?: Region
subregion?: Subregion
countryCodes?: CountryCode[]
excludeCountries?: CountryCode[]
preferredCountries?: CountryCode[]
theme?: Theme
translation?: TranslationLanguageCode
modalProps?: ModalProps
filterProps?: CountryFilterProps
flatListProps?: FlatListProps<Country>
placeholder?: string
withAlphaFilter?: boolean
withCallingCode?: boolean
withCurrency?: boolean
withEmoji?: boolean
withCountryNameButton?: boolean
withCurrencyButton?: boolean
withCallingCodeButton?: boolean
withCloseButton?: boolean
withFlagButton?: boolean
withFilter?: boolean
withFlag?: boolean
withModal?: boolean
disableNativeModal?: boolean
visible?: boolean
containerButtonStyle?: StyleProp<ViewStyle>
renderFlagButton?(props: FlagButtonProps): ReactNode
renderCountryFilter?(props: CountryFilterProps): ReactNode
onSelect(country: Country): void
onOpen?(): void
onClose?(): void
}
const Main = ({ theme, translation, ...props }: Props) => {
return (
<ThemeProvider theme={{ ...DEFAULT_THEME, ...theme }}>
<CountryProvider value={{ ...DEFAULT_COUNTRY_CONTEXT, translation }}>
<CountryPicker {...props} />
</CountryProvider>
</ThemeProvider>
)
}
Main.defaultProps = {
onSelect: () => {},
withEmoji: true,
}
export default Main
export {
getCountriesAsync as getAllCountries,
getCountryCallingCodeAsync as getCallingCode,
} from './CountryService'
export { CountryModal } from './CountryModal'
export { DARK_THEME, DEFAULT_THEME } from './CountryTheme'
export { CountryFilter } from './CountryFilter'
export { CountryList } from './CountryList'
export { FlagButton } from './FlagButton'
export { Flag } from './Flag'
export { HeaderModal } from './HeaderModal'
export { CountryModalProvider } from './CountryModalProvider'
export * from './types'