11import * as React from 'react' ;
22import {
3- TextStyle ,
43 TouchableHighlight ,
54 TouchableHighlightProps ,
65 View ,
7- ViewStyle ,
86} from 'react-native' ;
97
10- import { Icon } from '../../icons' ;
118import { Theme , withTheme } from '../../theme' ;
129import { SelectListSize } from '../../theme/component-variables/selectListVariables' ;
13- import { Box } from '../Layout' ;
10+ import { SelectListStyles } from '../../theme/style-getters/getSelectListStyles' ;
11+ import { Checkbox } from '../Checkbox' ;
1412import { Text } from '../Typography' ;
1513
16- export interface SelectListItemProps extends TouchableHighlightProps {
14+ export interface SelectListItemBaseProps {
15+ index ?: number ;
16+ isSelected ?: boolean ;
17+ onSelect ?: ( value : string , index : number , isSelected : boolean ) => void ;
18+ }
19+
20+ export interface SelectListItemProps
21+ extends SelectListItemBaseProps ,
22+ TouchableHighlightProps {
1723 theme : Theme ;
1824 size ?: SelectListSize ;
1925 isDisabled ?: boolean ;
20- onSelect ?: ( value : string , index : number , isSelected : boolean ) => void ;
21- testID ?: string ;
2226 label : string ;
23- isSelected ?: boolean ;
24- index ?: number ;
2527 value : string ;
26- checkedIcon ?: React . ReactNode ;
2728 /**
2829 * Inline styles for components
2930 */
30- dangerouslySetInlineStyle ?: {
31- containerStyle ?: ViewStyle ;
32- wrapperStyle ?: ViewStyle ;
33- textStyle ?: TextStyle ;
34- } ;
31+ dangerouslySetInlineStyle ?: Partial < SelectListStyles > ;
3532}
3633
3734const SelectListItemBase = ( props : SelectListItemProps ) => {
3835 const {
39- checkedIcon,
4036 dangerouslySetInlineStyle,
4137 index = 0 ,
4238 isDisabled = false ,
4339 isSelected = false ,
4440 label,
4541 onSelect = ( ) => null ,
4642 size = 'medium' ,
47- testID,
4843 theme,
4944 value,
5045 ...touchableHighlightProps
@@ -54,6 +49,7 @@ const SelectListItemBase = (props: SelectListItemProps) => {
5449 containerStyle,
5550 textStyle,
5651 focusBackgroundColor,
52+ wrapperStyle,
5753 } = theme . getSelectListStyles ( size , isDisabled , isSelected ) ;
5854
5955 return (
@@ -66,11 +62,11 @@ const SelectListItemBase = (props: SelectListItemProps) => {
6662 ...( dangerouslySetInlineStyle &&
6763 dangerouslySetInlineStyle . containerStyle ) ,
6864 } }
69- testID = { testID }
7065 { ...touchableHighlightProps }
7166 >
7267 < View
7368 style = { {
69+ ...wrapperStyle ,
7470 ...( dangerouslySetInlineStyle &&
7571 dangerouslySetInlineStyle . wrapperStyle ) ,
7672 } }
@@ -86,17 +82,7 @@ const SelectListItemBase = (props: SelectListItemProps) => {
8682 >
8783 { label }
8884 </ Text >
89- { isSelected && (
90- < Box position = "absolute" right = { 0 } marginRight = { 4 } >
91- { checkedIcon || (
92- < Icon
93- name = "check"
94- size = { 22 }
95- color = { theme . themeVariables . colors . text . success }
96- />
97- ) }
98- </ Box >
99- ) }
85+ < Checkbox isInteractive = { false } shape = "circle" isChecked = { isSelected } />
10086 </ View >
10187 </ TouchableHighlight >
10288 ) ;
0 commit comments