1- import { ViewStyle } from 'react-native' ;
1+ import { Platform , ViewStyle } from 'react-native' ;
22
33import { Theme } from '../../theme/ThemeInterface' ;
44
5- export type PickerAppearanceStyles = ViewStyle & {
6- backgroundColor : string ;
5+ export type NativePickerAppearanceStyles = ViewStyle & {
76 borderColor : string ;
87 color : string ;
98} ;
109
11- export type BaseState = PickerAppearanceStyles ;
12- export type DisabledState = Partial < PickerAppearanceStyles > ;
13- export type InvalidState = Partial < PickerAppearanceStyles > ;
14- export type FocusState = Partial < PickerAppearanceStyles > ;
10+ export type BaseState = NativePickerAppearanceStyles ;
11+ export type DisabledState = Partial < NativePickerAppearanceStyles > ;
12+ export type InvalidState = Partial < NativePickerAppearanceStyles > ;
13+ export type FocusState = Partial < NativePickerAppearanceStyles > ;
1514
1615export type SizeStyles = ViewStyle & {
1716 borderRadius : number ;
@@ -21,27 +20,28 @@ export type SizeStyles = ViewStyle & {
2120 paddingRight : number ;
2221} ;
2322
24- export interface PickerSizes {
23+ export interface NativePickerSizes {
2524 small : SizeStyles ;
2625 medium : SizeStyles ;
2726 large : SizeStyles ;
2827}
2928
30- export type PickerSize = keyof PickerSizes ;
29+ export type NativePickerSize = keyof NativePickerSizes ;
3130
32- export interface PickerVariables {
31+ export interface NativePickerVariables {
3332 base : BaseState ;
3433 disabled : DisabledState ;
3534 focus : FocusState ;
3635 invalid : InvalidState ;
3736 placeholderTextColor : string ;
38- sizes : PickerSizes ;
37+ sizes : NativePickerSizes ;
3938}
4039
41- export const getPickerVariables = ( theme : Theme ) : PickerVariables => {
40+ export const getNativePickerVariables = (
41+ theme : Theme ,
42+ ) : NativePickerVariables => {
4243 return {
4344 base : {
44- backgroundColor : theme . colors . background . plain ,
4545 borderColor : theme . colors . border . default ,
4646 borderWidth : 1 ,
4747 color : theme . colors . text . default ,
@@ -60,55 +60,78 @@ export const getPickerVariables = (theme: Theme): PickerVariables => {
6060 fontSize : theme . textSizes . small ,
6161 height : theme . controlHeights . small ,
6262 paddingLeft : theme . controlPaddings . small ,
63- paddingRight : theme . controlPaddings . small ,
63+ paddingRight : 40 ,
6464 } ,
6565
6666 medium : {
6767 borderRadius : theme . controlBorderRadius . medium ,
6868 fontSize : theme . textSizes . medium ,
6969 height : theme . controlHeights . medium ,
7070 paddingLeft : theme . controlPaddings . medium ,
71- paddingRight : theme . controlPaddings . medium ,
71+ paddingRight : 40 ,
7272 } ,
7373
7474 large : {
7575 borderRadius : theme . controlBorderRadius . large ,
7676 fontSize : theme . textSizes . large ,
7777 height : theme . controlHeights . large ,
7878 paddingLeft : theme . controlPaddings . large ,
79- paddingRight : theme . controlPaddings . large ,
79+ paddingRight : 40 ,
8080 } ,
8181 } ,
8282 } ;
8383} ;
8484
85- export interface PickerStyles {
85+ export interface NativePickerStyles {
86+ containerStyle : ViewStyle ;
87+ rightContainerStyle : ViewStyle ;
8688 pickerStyle : ViewStyle ;
8789 itemStyle : any ;
8890}
8991
90- export interface PickerStylesProps {
91- size : PickerSize ;
92+ export interface NativePickerStylesProps {
93+ size : NativePickerSize ;
9294}
93- export type GetPickerStyles = (
94- pickerStylesProps : PickerStylesProps ,
95+ export type GetNativePickerStyles = (
96+ pickerStylesProps : NativePickerStylesProps ,
9597 theme : Theme ,
96- ) => PickerStyles ;
98+ ) => NativePickerStyles ;
9799
98- export const getPickerStyles : GetPickerStyles = ( pickerStylesProps , theme ) => {
99- const pickerVariables = getPickerVariables ( theme ) ;
100+ export const getNativePickerStyles : GetNativePickerStyles = (
101+ pickerStylesProps ,
102+ theme ,
103+ ) => {
104+ const pickerVariables = getNativePickerVariables ( theme ) ;
100105 const { base, sizes } = pickerVariables ;
101106 const { size } = pickerStylesProps ;
102107
103108 const { fontSize, ...sizeStyles } = sizes [ size ] ;
104109
105110 return {
111+ containerStyle : {
112+ backgroundColor : theme . colors . background . plain ,
113+ position : 'relative' ,
114+ } ,
106115 itemStyle : {
107116 fontSize,
108117 } ,
109118 pickerStyle : {
119+ backgroundColor : 'transparent' ,
110120 ...base ,
111121 ...sizeStyles ,
122+ ...( Platform . OS === 'web' && {
123+ appearance : 'none' ,
124+ } ) ,
125+ } ,
126+ rightContainerStyle : {
127+ alignItems : 'center' ,
128+ display : 'flex' ,
129+ height : '100%' ,
130+ justifyContent : 'center' ,
131+ paddingHorizontal : 8 ,
132+ position : 'absolute' ,
133+ right : 0 ,
134+ zIndex : - 1 ,
112135 } ,
113136 } ;
114137} ;
0 commit comments