-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RNMobile] Add disabled style to Cell
component
#50665
Changes from all commits
74d18c0
14c87a9
c3a571f
88cda9f
4b93566
44968cb
763d198
ec82149
f877e8e
cbba7c6
1723d2f
f0ad3ff
bd19b0a
124e7be
5b7590f
2ac07ab
78e23ba
ad34c7f
0a8de68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,7 @@ class BottomSheetCell extends Component { | |
accessibilityHint, | ||
accessibilityRole, | ||
disabled = false, | ||
disabledStyle = styles.cellDisabled, | ||
activeOpacity, | ||
onPress, | ||
onLongPress, | ||
|
@@ -223,11 +224,22 @@ class BottomSheetCell extends Component { | |
styles.cellValue, | ||
styles.cellTextDark | ||
); | ||
const finalStyle = { | ||
const textInputStyle = { | ||
...cellValueStyle, | ||
...valueStyle, | ||
...styleRTL, | ||
}; | ||
const placeholderTextColor = disabled | ||
? this.props.getStylesFromColorScheme( | ||
styles.placeholderColorDisabled, | ||
styles.placeholderColorDisabledDark | ||
).color | ||
: styles.placeholderColor.color; | ||
const textStyle = { | ||
...( disabled && styles.cellDisabled ), | ||
...cellValueStyle, | ||
...valueStyle, | ||
}; | ||
|
||
// To be able to show the `middle` ellipsizeMode on editable cells | ||
// we show the TextInput just when the user wants to edit the value, | ||
|
@@ -238,10 +250,10 @@ class BottomSheetCell extends Component { | |
<TextInput | ||
ref={ ( c ) => ( this._valueTextInput = c ) } | ||
numberOfLines={ 1 } | ||
style={ finalStyle } | ||
style={ textInputStyle } | ||
value={ value } | ||
placeholder={ valuePlaceholder } | ||
placeholderTextColor={ '#87a6bc' } | ||
placeholderTextColor={ placeholderTextColor } | ||
onChangeText={ onChangeValue } | ||
editable={ isValueEditable } | ||
pointerEvents={ | ||
|
@@ -251,11 +263,12 @@ class BottomSheetCell extends Component { | |
onBlur={ finishEditing } | ||
onSubmitEditing={ onSubmit } | ||
keyboardType={ this.typeToKeyboardType( type, step ) } | ||
disabled={ disabled } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The text input is also disabled. |
||
{ ...valueProps } | ||
/> | ||
) : ( | ||
<Text | ||
style={ { ...cellValueStyle, ...valueStyle } } | ||
style={ textStyle } | ||
numberOfLines={ 1 } | ||
ellipsizeMode={ 'middle' } | ||
> | ||
|
@@ -418,7 +431,15 @@ class BottomSheetCell extends Component { | |
/> | ||
) } | ||
{ showValue && getValueComponent() } | ||
{ children } | ||
<View | ||
style={ [ | ||
disabled && disabledStyle, | ||
styles.cellRowContainer, | ||
] } | ||
pointerEvents={ disabled ? 'none' : 'auto' } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although the parent component ( |
||
> | ||
{ children } | ||
</View> | ||
</View> | ||
{ help && ( | ||
<Text style={ [ cellHelpStyle, styles.placeholderColor ] }> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -218,14 +218,15 @@ class BottomSheetRangeCell extends Component { | |
activeOpacity={ 1 } | ||
accessible={ false } | ||
valueStyle={ styles.valueStyle } | ||
disabled={ disabled } | ||
> | ||
<View style={ containerStyle }> | ||
{ preview } | ||
<Slider | ||
testID={ `Slider ${ cellProps.label }` } | ||
value={ sliderValue } | ||
defaultValue={ defaultValue } | ||
disabled={ disabled } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On iOS the default disabled style of the Slider already makes it transparent. So, in order to avoid making it too transparent with the Cell's disabled style, we only disable it on Android. |
||
disabled={ disabled && ! isIOS } | ||
step={ step } | ||
minimumValue={ minimumValue } | ||
maximumValue={ maximumValue } | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -284,7 +284,15 @@ | |||
|
||||
// used in both light and dark modes | ||||
.placeholderColor { | ||||
color: #87a6bc; | ||||
color: $gray; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed this color is already defined globally:
|
||||
} | ||||
|
||||
.placeholderColorDisabled { | ||||
color: lighten($gray, 20%); | ||||
} | ||||
|
||||
.placeholderColorDisabledDark { | ||||
color: lighten($gray-dark, 10%); | ||||
} | ||||
|
||||
.applyButton { | ||||
|
@@ -317,3 +325,7 @@ | |||
.cellSubLabelTextDark { | ||||
color: $sub-heading-dark; | ||||
} | ||||
|
||||
.cellDisabled { | ||||
opacity: 0.3; | ||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ import { __, _x, sprintf } from '@wordpress/i18n'; | |
*/ | ||
import Cell from './cell'; | ||
|
||
const EMPTY_STYLE = {}; | ||
|
||
export default function BottomSheetSwitchCell( props ) { | ||
const { value, onValueChange, disabled, ...cellProps } = props; | ||
|
||
|
@@ -61,6 +63,7 @@ export default function BottomSheetSwitchCell( props ) { | |
editable={ false } | ||
value={ '' } | ||
disabled={ disabled } | ||
disabledStyle={ EMPTY_STYLE } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the case of the |
||
> | ||
<Switch | ||
value={ value } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I finally calculated the placeholder text color to handle the different cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. I noticed this when I started my review and then noted you updated this code. :) The raw hex values stood out to me even when working on the Clear Button issue from a while ago -- thanks for addressing them here!