Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Commit

Permalink
Always set keyboard type on passcode setup, ability to change keyboar…
Browse files Browse the repository at this point in the history
…d type during local passcode prompt
  • Loading branch information
moughxyz committed Oct 29, 2019
1 parent 9862aee commit a88ffcd
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 12 deletions.
10 changes: 8 additions & 2 deletions src/components/SectionHeader.js
Expand Up @@ -17,8 +17,8 @@ export default class SectionHeader extends ThemedComponent {
}
</View>
{this.props.buttonText &&
<TouchableOpacity onPress={this.props.buttonAction}>
<Text style={this.styles.button}>{this.props.buttonText}</Text>
<TouchableOpacity style={this.styles.buttonContainer} onPress={this.props.buttonAction}>
<Text style={[this.styles.button, this.props.buttonStyles]}>{this.props.buttonText}</Text>
</TouchableOpacity>
}
</View>
Expand Down Expand Up @@ -54,6 +54,12 @@ export default class SectionHeader extends ThemedComponent {
color: StyleKit.variables.stylekitNeutralColor,
},

buttonContainer: {
flex: 1,
alignItems: "flex-end",
justifyContent: "center",
},

button: {
color: StyleKit.variables.stylekitInfoColor
},
Expand Down
11 changes: 7 additions & 4 deletions src/screens/Authentication/Authenticate.js
Expand Up @@ -62,6 +62,10 @@ export default class Authenticate extends Abstract {
this.successfulSources = [];
}

get sources() {
return this.getProp("authenticationSources");
}

componentWillUnmount() {

// Typically there should be no way to exit this window if it doesn't have a cancel option.
Expand Down Expand Up @@ -106,10 +110,6 @@ export default class Authenticate extends Abstract {
this.beginNextAuthentication();
}

get sources() {
return this.getProp("authenticationSources");
}

beginNextAuthentication() {
if(this.pendingSources && this.pendingSources.length) {
let firstSource = this.pendingSources[0];
Expand Down Expand Up @@ -290,6 +290,9 @@ export default class Authenticate extends Abstract {
title={source.title + (source.status == "waiting-turn" ? " — Waiting" : "")}
subtitle={hasHeaderSubtitle && source.label}
tinted={source == this.state.activeSource}
buttonText={source.headerButtonText}
buttonAction={source.headerButtonAction}
buttonStyles={source.headerButtonStyles}
/>
{source.type == "input" &&
inputAuthenticationSource(source)
Expand Down
4 changes: 4 additions & 0 deletions src/screens/Authentication/Sources/AuthenticationSource.js
Expand Up @@ -33,6 +33,10 @@ export default class AuthenticationSource {
this.status = "did-fail";
}

isWaitingForInput() {
return this.status == "waiting-input";
}

isInSuccessState() {
return this.status == "did-succeed";
}
Expand Down
Expand Up @@ -2,6 +2,7 @@ import SF from '@SFJS/sfjs'
import Storage from '@SFJS/storageManager'
import KeysManager from '@Lib/keysManager'
import AuthenticationSource from "./AuthenticationSource"
import StyleKit from "@Style/StyleKit"

export default class AuthenticationSourceLocalPasscode extends AuthenticationSource {
constructor() {
Expand All @@ -13,6 +14,27 @@ export default class AuthenticationSourceLocalPasscode extends AuthenticationSou
});
}

get headerButtonText() {
return this.isWaitingForInput() && "Change Keyboard";
}

get headerButtonStyles() {
return {
color: StyleKit.variables.stylekitNeutralColor,
fontSize: StyleKit.constants.mainTextFontSize - 5
}
}

headerButtonAction = () => {
if(this.keyboardType == "default") {
this.keyboardType = "numeric";
} else {
this.keyboardType = "default";
}

this.requiresInterfaceReload();
}

get sort() {
return 0;
}
Expand Down
3 changes: 1 addition & 2 deletions src/screens/InputModal.js
Expand Up @@ -71,7 +71,7 @@ export default class InputModal extends Abstract {
return;
}
}
this.getProp("onSubmit")(this.state.text);
this.getProp("onSubmit")(this.state.text, this.keyboardType);
this.dismiss();
}

Expand All @@ -97,7 +97,6 @@ export default class InputModal extends Abstract {
this.keyboardType = option.key;
this.forceUpdate();
this.refreshKeyboard();
this.getProp("onKeyboardTypeChange")(option.key);
}

render() {
Expand Down
7 changes: 3 additions & 4 deletions src/screens/Settings/Settings.js
Expand Up @@ -159,7 +159,9 @@ export default class Settings extends Abstract {
secureTextEntry: true,
requireConfirm: true,
showKeyboardChooser: true,
onSubmit: async (value) => {
onSubmit: async (value, keyboardType) => {
Storage.get().setItem("passcodeKeyboardType", keyboardType);

let identifier = await SF.get().crypto.generateUUID();

SF.get().crypto.generateInitialKeysAndAuthParamsForUser(identifier, value).then((results) => {
Expand All @@ -179,9 +181,6 @@ export default class Settings extends Abstract {
Alert.alert("Passcode Error", "There was an error setting up your passcode. Please try again.");
}
});
},
onKeyboardTypeChange: (type) => {
Storage.get().setItem("passcodeKeyboardType", type);
}
});
}
Expand Down

0 comments on commit a88ffcd

Please sign in to comment.