Skip to content

Commit

Permalink
Issue 205 (#502)
Browse files Browse the repository at this point in the history
* v0.6.13

Support to disable a picker field

Refactor code

Change DatePicker style if is disabled

* Change enabled property on picker

* Update package.json
  • Loading branch information
Moreno97 authored and alvaromb committed Jun 29, 2018
1 parent 655a9b6 commit 467fe8f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
11 changes: 10 additions & 1 deletion lib/stylesheets/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ var stylesheet = Object.freeze({
active: {
borderBottomWidth: 1,
borderColor: BORDER_COLOR
},
notEditable: {
height: 44,
flexDirection: "row",
alignItems: "center",
backgroundColor: DISABLED_BACKGROUND_COLOR
}
},
pickerValue: {
Expand All @@ -184,7 +190,10 @@ var stylesheet = Object.freeze({
},
dateTouchable: {
normal: {},
error: {}
error: {},
notEditable: {
backgroundColor: DISABLED_BACKGROUND_COLOR
}
},
dateValue: {
normal: {
Expand Down
5 changes: 5 additions & 0 deletions lib/templates/bootstrap/datepicker.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ class CollapsibleDatePickerIOS extends React.Component {
datepickerStyle = stylesheet.datepicker.error;
dateValueStyle = stylesheet.dateValue.error;
}

if (locals.disabled) {
touchableStyle = stylesheet.dateTouchable.notEditable;
}

let formattedValue = locals.value ? String(locals.value) : "";
if (locals.config) {
if (locals.config.format && formattedValue) {
Expand Down
2 changes: 1 addition & 1 deletion lib/templates/bootstrap/select.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function select(locals) {
selectedValue={locals.value}
onValueChange={locals.onChange}
help={locals.help}
enabled={locals.enabled}
enabled={!locals.disabled}
mode={locals.mode}
prompt={locals.prompt}
itemStyle={locals.itemStyle}
Expand Down
7 changes: 6 additions & 1 deletion lib/templates/bootstrap/select.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ class CollapsiblePickerIOS extends React.Component {
pickerValue = stylesheet.pickerValue.error;
}

if (locals.disabled) {
touchableStyle = stylesheet.pickerTouchable.notEditable;
}

const options = locals.options.map(({ value, text }) => (
<Picker.Item key={value} value={value} label={text} />
));
Expand All @@ -101,6 +105,7 @@ class CollapsiblePickerIOS extends React.Component {
]}
>
<TouchableOpacity
disabled={locals.disabled}
style={[
touchableStyle,
this.state.isCollapsed ? {} : touchableStyleActive
Expand All @@ -119,7 +124,7 @@ class CollapsiblePickerIOS extends React.Component {
selectedValue={locals.value}
onValueChange={locals.onChange}
help={locals.help}
enabled={locals.enabled}
enabled={!locals.disabled}
mode={locals.mode}
prompt={locals.prompt}
itemStyle={locals.itemStyle}
Expand Down

0 comments on commit 467fe8f

Please sign in to comment.