Explorar el Código

Fix Dialog UI background color

pull/674/head
Guillaume Vincent hace 3 años
padre
commit
6632740baa
Se han modificado 5 ficheros con 85 adiciones y 96 borrados
  1. +2
    -2
      mobile/ios/LessPass.xcodeproj/project.pbxproj
  2. +1
    -1
      mobile/package.json
  3. +4
    -5
      mobile/src/settings/SettingsScreen.js
  4. +77
    -87
      mobile/src/settings/TextInputModal.js
  5. +1
    -1
      mobile/src/version.json

+ 2
- 2
mobile/ios/LessPass.xcodeproj/project.pbxproj Ver fichero

@@ -355,7 +355,7 @@
); );
INFOPLIST_FILE = LessPass/Info.plist; INFOPLIST_FILE = LessPass/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 9.5.1;
MARKETING_VERSION = 9.5.2;
OTHER_LDFLAGS = ( OTHER_LDFLAGS = (
"$(inherited)", "$(inherited)",
"-ObjC", "-ObjC",
@@ -384,7 +384,7 @@
DEVELOPMENT_TEAM = 5Y4MF2AT83; DEVELOPMENT_TEAM = 5Y4MF2AT83;
INFOPLIST_FILE = LessPass/Info.plist; INFOPLIST_FILE = LessPass/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 9.5.1;
MARKETING_VERSION = 9.5.2;
OTHER_LDFLAGS = ( OTHER_LDFLAGS = (
"$(inherited)", "$(inherited)",
"-ObjC", "-ObjC",


+ 1
- 1
mobile/package.json Ver fichero

@@ -1,6 +1,6 @@
{ {
"name": "lesspass-mobile", "name": "lesspass-mobile",
"version": "9.5.1",
"version": "9.5.2",
"description": "LessPass mobile application", "description": "LessPass mobile application",
"license": "(MPL-2.0 OR GPL-3.0)", "license": "(MPL-2.0 OR GPL-3.0)",
"author": "Guillaume Vincent <guillaume@oslab.fr>", "author": "Guillaume Vincent <guillaume@oslab.fr>",


+ 4
- 5
mobile/src/settings/SettingsScreen.js Ver fichero

@@ -9,7 +9,6 @@ import TextInputModal from "./TextInputModal";
import Switch from "../ui/Switch"; import Switch from "../ui/Switch";
import KeepMasterPasswordOption from "./KeepMasterPasswordOption"; import KeepMasterPasswordOption from "./KeepMasterPasswordOption";
import { version } from "../version.json"; import { version } from "../version.json";
import Styles from "../ui/Styles";


export class SettingsScreen extends Component { export class SettingsScreen extends Component {
constructor(props) { constructor(props) {
@@ -52,7 +51,7 @@ export class SettingsScreen extends Component {
<List.Section title="LESSPASS DATABASE"> <List.Section title="LESSPASS DATABASE">
<TextInputModal <TextInputModal
label="Default URL" label="Default URL"
value={baseURL}
initialValue={baseURL}
onOk={(value) => setSettings({ baseURL: value })} onOk={(value) => setSettings({ baseURL: value })}
modalTitle="LessPass Database default URL" modalTitle="LessPass Database default URL"
/> />
@@ -71,7 +70,7 @@ export class SettingsScreen extends Component {
<TextInputModal <TextInputModal
isRequired={false} isRequired={false}
label="Login" label="Login"
value={defaultPasswordProfileLogin}
initialValue={defaultPasswordProfileLogin}
onOk={(value) => onOk={(value) =>
setSettings({ defaultPasswordProfileLogin: value }) setSettings({ defaultPasswordProfileLogin: value })
} }
@@ -80,7 +79,7 @@ export class SettingsScreen extends Component {
<Divider /> <Divider />
<TextInputModal <TextInputModal
label="Password length" label="Password length"
value={defaultGeneratedPasswordLength}
initialValue={defaultGeneratedPasswordLength}
variant="numeric" variant="numeric"
onOk={(value) => { onOk={(value) => {
setSettings({ setSettings({
@@ -92,7 +91,7 @@ export class SettingsScreen extends Component {
<Divider /> <Divider />
<TextInputModal <TextInputModal
label="Counter" label="Counter"
value={defaultCounter}
initialValue={defaultCounter}
variant="numeric" variant="numeric"
onOk={(value) => { onOk={(value) => {
setSettings({ setSettings({


+ 77
- 87
mobile/src/settings/TextInputModal.js Ver fichero

@@ -1,102 +1,92 @@
import React, { Component } from "react";
import React, { useEffect, useState } from "react";
import { View } from "react-native"; import { View } from "react-native";
import { import {
Button, Button,
Portal, Portal,
Dialog, Dialog,
TextInput,
List, List,
Text, Text,
useTheme,
} from "react-native-paper"; } from "react-native-paper";
import Styles from "../ui/Styles"; import Styles from "../ui/Styles";
import TextInput from "../ui/TextInput";


export default class TextInputModal extends Component {
constructor(props) {
super(props);
const { value, variant, isRequired = true } = props;
this.state = {
value,
isValid: this.checkInputIsValid(value, variant, isRequired),
showModal: false,
};
}
export default function TextInputModal({
modalTitle,
modalDescription,
initialValue = "",
label,
onOk,
isRequired = true,
variant = "text",
}) {
const [value, setValue] = useState(initialValue);
const [showModal, setShowModal] = useState(false);
const [isValid, setIsValid] = useState(true);
const theme = useTheme();


_hideModal = () => {
const { value } = this.props;
this.setState({ showModal: false, value });
const variants = {
text: "default",
email: "email-address",
numeric: "numeric",
}; };
const keyboardType = variants[variant];


getKeyboardType = (variant) => {
const variants = {
text: "default",
email: "email-address",
numeric: "numeric",
};
return variants[variant];
};

checkInputIsValid = (value, variant, isRequired) => {
if (isRequired && !value) return false;
let isValid = variant === "numeric" ? !isNaN(value) : true;
return isValid;
};

onChange = (value, variant, isRequired) => {
const isValid = this.checkInputIsValid(value, variant, isRequired);
this.setState({ value, isValid });
};
useEffect(() => {
if (isRequired && !value) {
setIsValid(false);
} else {
setIsValid(variant === "numeric" ? !isNaN(value) : true);
}
}, [value, variant, isRequired]);


render() {
const { value, isValid, showModal } = this.state;
const {
label,
onOk,
modalTitle,
modalDescription,
variant = "text",
isRequired,
} = this.props;
return (
<View>
<Portal>
<Dialog onDismiss={this._hideModal} visible={showModal}>
<Dialog.Title>{modalTitle}</Dialog.Title>
<Dialog.ScrollArea style={{ maxHeight: 170, paddingHorizontal: 0 }}>
<View style={{ padding: 10 }}>
<TextInput
style={Styles.input}
value={variant === "numeric" ? value.toString() : value}
keyboardType={this.getKeyboardType(variant)}
secureTextEntry={variant === "password"}
onChangeText={(value) =>
this.onChange(value, variant, isRequired)
}
/>
{modalDescription ? <Text /> : null}
</View>
</Dialog.ScrollArea>
<Dialog.Actions>
<Button primary onPress={this._hideModal}>
Cancel
</Button>
<Button
primary
disabled={!isValid}
onPress={() =>
this.setState({ showModal: false }, () => onOk(value))
}
>
Ok
</Button>
</Dialog.Actions>
</Dialog>
</Portal>
<List.Item
title={label}
description={value}
onPress={() => this.setState({ showModal: true })}
/>
</View>
);
}
return (
<>
<Portal>
<Dialog
onDismiss={() => setShowModal(false)}
visible={showModal}
style={{ backgroundColor: theme.colors.background }}
>
<Dialog.Title>{modalTitle}</Dialog.Title>
<Dialog.ScrollArea style={{ maxHeight: 170, paddingHorizontal: 0 }}>
<View style={{ padding: 10 }}>
<TextInput
style={Styles.input}
value={variant === "numeric" ? value.toString() : value}
keyboardType={keyboardType}
secureTextEntry={variant === "password"}
onChangeText={setValue}
/>
{modalDescription ? <Text>{modalDescription}</Text> : null}
</View>
</Dialog.ScrollArea>
<Dialog.Actions>
<Button onPress={() => setShowModal(false)} mode="outlined">
Cancel
</Button>
<Button
disabled={!isValid}
onPress={() => {
setShowModal(false);
onOk(value);
}}
mode="contained"
style={{ marginLeft: 20 }}
>
Save
</Button>
</Dialog.Actions>
</Dialog>
</Portal>
<List.Item
title={label}
description={initialValue}
onPress={() => {
setShowModal(true);
setValue("");
}}
/>
</>
);
} }

+ 1
- 1
mobile/src/version.json Ver fichero

@@ -1,3 +1,3 @@
{ {
"version": "9.5.1"
"version": "9.5.2"
} }

Cargando…
Cancelar
Guardar