浏览代码

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 年前
父节点
当前提交
8cf13388fd
共有 2 个文件被更改,包括 19 次插入5 次删除
  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 查看文件

@@ -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 查看文件

@@ -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


正在加载...
取消
保存