Browse Source

Disable minus or plus buttons in Counter when we reach min or max value

Fixes: https://github.com/lesspass/lesspass/issues/362
pull/367/head
Guillaume Vincent 6 years ago
parent
commit
8cf13388fd
2 changed files with 19 additions and 5 deletions
  1. +16
    -5
      packages/mobile/src/password/Counter.js
  2. +3
    -0
      packages/mobile/src/password/PasswordGeneratorScreen.js

+ 16
- 5
packages/mobile/src/password/Counter.js View File

@@ -28,7 +28,14 @@ export default class Counter extends Component {
};

render() {
const { label, value, onValueChange, ...props } = this.props;
const {
label,
value,
onValueChange,
minValue,
maxValue,
...props
} = this.props;
const { isValid } = this.state;
const isValidBackgroundColor = isValid
? Theme.colors.primary
@@ -65,8 +72,10 @@ export default class Counter extends Component {
}}
onPress={() => {
const newValue = value - 1;
this.checkOptionsAreValid(newValue);
this.setNewValue(newValue);
if (!minValue || newValue >= minValue) {
this.checkOptionsAreValid(newValue);
this.setNewValue(newValue);
}
}}
>
<Icon
@@ -121,8 +130,10 @@ export default class Counter extends Component {
}}
onPress={() => {
const newValue = value + 1;
this.checkOptionsAreValid(newValue);
this.setNewValue(newValue);
if (!maxValue || newValue <= maxValue) {
this.checkOptionsAreValid(newValue);
this.setNewValue(newValue);
}
}}
>
<Icon


+ 3
- 0
packages/mobile/src/password/PasswordGeneratorScreen.js View File

@@ -193,6 +193,8 @@ export class PasswordGeneratorScreen extends Component {
label="Length"
value={length}
isValueValid={isLengthValid}
minValue={5}
maxValue={35}
onValueChange={value => {
this.setState({
length: value
@@ -203,6 +205,7 @@ export class PasswordGeneratorScreen extends Component {
label="Counter"
value={counter}
isValueValid={isCounterValid}
minValue={1}
onValueChange={value => {
this.setState({
counter: value


Loading…
Cancel
Save