1- import { ViewStyle } from 'react-native' ;
1+ import { TextStyle , ViewStyle } from 'react-native' ;
22
3- import { Theme } from '../../theme/ThemeInterface' ;
4- import { CheckboxShape } from './Checkbox' ;
3+ import { ControlSize , Theme } from '../../theme/ThemeInterface' ;
4+ import { CheckboxLabelPosition , CheckboxShape } from './Checkbox' ;
55
66export interface ShapeStyle {
77 circle : ViewStyle ;
88 square : ViewStyle ;
99}
1010
1111export interface CheckboxVariables {
12- base : ViewStyle ;
1312 disabled : ViewStyle ;
1413 checked : ViewStyle ;
1514 checkedFocus : ViewStyle ;
1615 uncheckedFocus : ViewStyle ;
1716 shape : ShapeStyle ;
1817}
1918
20- export const getCheckboxVariables = ( theme : Theme ) : CheckboxVariables => {
21- return {
22- base : {
23- backgroundColor : theme . colors . background . content ,
24- borderColor : theme . colors . border . default ,
25- borderWidth : 1 ,
26- height : 32 ,
27- width : 32 ,
28- } ,
29- checked : {
30- backgroundColor : theme . colors . background . primaryDefault ,
31- borderColor : 'transparent' ,
32- } ,
33- checkedFocus : {
34- backgroundColor : theme . colors . background . primaryDark ,
35- } ,
36- disabled : {
37- backgroundColor : theme . colors . background . greyDark ,
38- borderColor : theme . colors . border . default ,
39- } ,
40- shape : {
41- circle : {
42- borderRadius : 999 ,
43- } ,
44- square : {
45- borderRadius : theme . controlBorderRadius . small ,
46- } ,
47- } ,
48- uncheckedFocus : {
49- backgroundColor : theme . colors . background . greyLight ,
50- } ,
51- } ;
52- } ;
53-
5419export interface CheckboxStylesProps {
5520 isChecked : boolean ;
5621 isDisabled : boolean ;
5722 shape : CheckboxShape ;
23+ labelPosition : CheckboxLabelPosition ;
24+ hasLabel : boolean ;
25+ checkColor : string ;
26+ size : ControlSize ;
5827}
5928
6029export interface CheckboxStyles {
30+ touchableStyle : ViewStyle ;
31+ outerWrapperStyle : ViewStyle ;
6132 checkboxStyle : ViewStyle ;
62- checkboxFocusBackgroundColor ?: string ;
33+ textStyle : TextStyle ;
34+ iconColor : string ;
35+ checkboxFocusBackgroundColor : string ;
6336}
6437
6538export type GetCheckboxStyles = (
@@ -68,20 +41,57 @@ export type GetCheckboxStyles = (
6841) => CheckboxStyles ;
6942
7043export const getCheckboxStyles : GetCheckboxStyles = (
71- { isChecked, isDisabled, shape } ,
44+ { isChecked, isDisabled, shape, hasLabel , labelPosition , checkColor , size } ,
7245 theme ,
7346) => {
74- const checkboxVariables = getCheckboxVariables ( theme ) ;
47+ const sizeValue = theme . controlHeights [ size ] ;
7548
7649 return {
7750 checkboxFocusBackgroundColor : isChecked
78- ? checkboxVariables . checkedFocus . backgroundColor
79- : checkboxVariables . uncheckedFocus . backgroundColor ,
51+ ? theme . colors . background . primaryDark
52+ : theme . colors . background . greyLight ,
53+
8054 checkboxStyle : {
81- ...checkboxVariables . base ,
82- ...( isChecked ? checkboxVariables . checked : { } ) ,
83- ...( isDisabled ? checkboxVariables . disabled : { } ) ,
84- ...checkboxVariables . shape [ shape ] ,
55+ alignItems : 'center' ,
56+ backgroundColor : theme . colors . background . content ,
57+ borderColor : theme . colors . border . default ,
58+ borderWidth : 1 ,
59+ height : sizeValue ,
60+ justifyContent : 'center' ,
61+ width : sizeValue ,
62+ ...( hasLabel
63+ ? labelPosition === 'right'
64+ ? { marginRight : 8 }
65+ : { marginLeft : 8 }
66+ : { } ) ,
67+ ...( isChecked
68+ ? {
69+ backgroundColor : theme . colors . background . primaryDefault ,
70+ borderColor : 'transparent' ,
71+ }
72+ : { } ) ,
73+ ...( isDisabled
74+ ? {
75+ backgroundColor : theme . colors . background . greyDark ,
76+ borderColor : theme . colors . border . default ,
77+ }
78+ : { } ) ,
79+ ...{
80+ circle : {
81+ borderRadius : 999 ,
82+ } ,
83+ square : {
84+ borderRadius : theme . controlBorderRadius . small ,
85+ } ,
86+ } [ shape ] ,
87+ } ,
88+ iconColor : checkColor || theme . colors . text . white ,
89+
90+ outerWrapperStyle : {
91+ alignItems : 'center' ,
92+ flexDirection : 'row' ,
8593 } ,
94+ textStyle : { } ,
95+ touchableStyle : { } ,
8696 } ;
8797} ;
0 commit comments