-
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] RangeCell styling refactor #18157
Changes from 34 commits
5f3a400
25832f0
335154d
d137d38
8d37161
ae5715f
a1cf07b
f0b3b28
a807c31
ca3b8d4
a390d88
90fe027
a1d9a10
833cc76
103493e
74d020a
8c127b9
84ade89
11e0911
1debc8c
4a897fd
80a4714
047a08e
7ee822e
6d4dde4
014cd20
9f28b60
2e5c346
2d643c0
f66a118
80104f1
93b7d58
26e7939
d321afd
b9c2b64
cf85c25
500d414
5d89738
7cd2f4f
ac07efa
135c4eb
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.borderStyle { | ||
border-bottom-width: 1px; | ||
} | ||
|
||
.isSelected { | ||
border-bottom-width: 2px; | ||
border-color: $blue-wordpress; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.isSelected { | ||
border-width: 2px; | ||
border-color: $blue-wordpress; | ||
} | ||
|
||
.borderStyle { | ||
border-width: 1px; | ||
border-radius: 4px; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { Platform, AccessibilityInfo, findNodeHandle, TextInput, Slider } from 'react-native'; | ||
import { Platform, AccessibilityInfo, findNodeHandle, TextInput, Slider, View } from 'react-native'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { _x, __, sprintf } from '@wordpress/i18n'; | ||
import { Component } from '@wordpress/element'; | ||
import { withPreferredColorScheme } from '@wordpress/compose'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import Cell from './cell'; | ||
import styles from './range-cell.scss'; | ||
import borderStyles from './borderStyles.scss'; | ||
|
||
class BottomSheetRangeCell extends Component { | ||
constructor( props ) { | ||
|
@@ -115,9 +117,11 @@ class BottomSheetRangeCell extends Component { | |
maximumValue = 10, | ||
disabled, | ||
step = 1, | ||
minimumTrackTintColor = '#00669b', | ||
preferredColorScheme, | ||
minimumTrackTintColor = preferredColorScheme === 'light' ? '#00669b' : '#5198d9', | ||
maximumTrackTintColor = Platform.OS === 'ios' ? '#e9eff3' : '#909090', | ||
thumbTintColor = Platform.OS === 'android' && '#00669b', | ||
getStylesFromColorScheme, | ||
...cellProps | ||
} = this.props; | ||
|
||
|
@@ -130,49 +134,60 @@ class BottomSheetRangeCell extends Component { | |
cellProps.label, value | ||
); | ||
|
||
const defaultSliderStyle = getStylesFromColorScheme( styles.sliderTextInput, styles.sliderDarkTextInput ); | ||
|
||
return ( | ||
<Cell | ||
{ ...cellProps } | ||
cellContainerStyle={ styles.cellContainerStyles } | ||
cellRowContainerStyle={ styles.cellRowStyles } | ||
accessibilityRole={ 'none' } | ||
editable={ false } | ||
accessible={ accessible } | ||
onPress={ this.onCellPress } | ||
accessibilityLabel={ accessibilityLabel } | ||
allowReset={ this.handleReset } | ||
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. It's interesting that the root Just by curiosity, I added 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.
That's correct, I don't think there are any other planned components at the moment that will need an explicit 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. One more note: if we do end up adding 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. Currently we don't have many 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.
|
||
accessibilityHint={ | ||
/* translators: accessibility text (hint for focusing a slider) */ | ||
__( 'Double tap to change the value using slider' ) | ||
} | ||
> | ||
<Slider | ||
value={ this.validateInput( sliderValue ) } | ||
defaultValue={ defaultValue } | ||
disabled={ disabled } | ||
step={ step } | ||
minimumValue={ minimumValue } | ||
maximumValue={ maximumValue } | ||
minimumTrackTintColor={ minimumTrackTintColor } | ||
maximumTrackTintColor={ maximumTrackTintColor } | ||
thumbTintColor={ thumbTintColor } | ||
onValueChange={ this.handleChange } | ||
onSlidingComplete={ this.handleValueSave } | ||
ref={ ( slider ) => { | ||
this.sliderRef = slider; | ||
} } | ||
style={ styles.slider } | ||
accessibilityRole={ 'adjustable' } | ||
/> | ||
<TextInput | ||
style={ [ styles.sliderTextInput, hasFocus ? styles.isSelected : {} ] } | ||
onChangeText={ this.handleChange } | ||
onFocus={ this.handleToggleFocus } | ||
onBlur={ this.handleToggleFocus } | ||
keyboardType="number-pad" | ||
returnKeyType="done" | ||
value={ `${ sliderValue }` } | ||
/> | ||
<View style={ styles.container }> | ||
<Slider | ||
value={ this.validateInput( sliderValue ) } | ||
defaultValue={ defaultValue } | ||
disabled={ disabled } | ||
step={ step } | ||
minimumValue={ minimumValue } | ||
maximumValue={ maximumValue } | ||
minimumTrackTintColor={ minimumTrackTintColor } | ||
maximumTrackTintColor={ maximumTrackTintColor } | ||
thumbTintColor={ thumbTintColor } | ||
onValueChange={ this.handleChange } | ||
onSlidingComplete={ this.handleValueSave } | ||
ref={ ( slider ) => { | ||
this.sliderRef = slider; | ||
} } | ||
style={ styles.slider } | ||
accessibilityRole={ 'adjustable' } | ||
/> | ||
<TextInput | ||
style={ [ | ||
defaultSliderStyle, | ||
borderStyles.borderStyle, | ||
hasFocus && borderStyles.isSelected, | ||
] } | ||
onChangeText={ this.handleChange } | ||
onFocus={ this.handleToggleFocus } | ||
onBlur={ this.handleToggleFocus } | ||
keyboardType="number-pad" | ||
returnKeyType="done" | ||
value={ `${ sliderValue }` } | ||
/> | ||
</View> | ||
</Cell> | ||
); | ||
} | ||
} | ||
|
||
export default BottomSheetRangeCell; | ||
export default withPreferredColorScheme( BottomSheetRangeCell ); |
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.
@etoledom If we remove
numberOfLines={ 1 }
we can have a not truncated label and it will look like:wdyt?
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've also checked how it will affect other settings:
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.
Looks better than cropping!
Let's go with it if it does't affect other instances of cells and controls.
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.
Again, better than cropping. Looks good to me :)