-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow to disable the password prompt at application open and re…
…sume (#250) ## Description Closes: DPM-160 This PR introduces a setting in the Security section that enables the user to disable the password prompt for unlocking the application when it is started and when it is resumed from the background. Here the final result: ![screen-20231030-113942 mp4](https://github.com/desmos-labs/dpm/assets/6245917/0fb278fe-e53f-4be8-975e-24704a1de0e4) --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] provided a link to the relevant issue or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed all author checklist items have been addressed
- Loading branch information
Showing
12 changed files
with
155 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { StackScreenProps } from '@react-navigation/stack'; | ||
import Flexible from 'components/Flexible'; | ||
import Spacer from 'components/Spacer'; | ||
import StyledSafeAreaView from 'components/StyledSafeAreaView'; | ||
import TopBar from 'components/TopBar'; | ||
import Typography from 'components/Typography'; | ||
import { RootNavigatorParamList } from 'navigation/RootNavigator'; | ||
import ROUTES from 'navigation/routes'; | ||
import React from 'react'; | ||
import useStyles from './useStyles'; | ||
|
||
export interface SettingsSwitchScreenProps { | ||
/** | ||
* Text that will be displayed in the top bar and | ||
* as a label for the toggle. | ||
*/ | ||
readonly title: string; | ||
/** | ||
* Description text that will be displayed above the | ||
* switch. | ||
*/ | ||
readonly description: string; | ||
/** | ||
* Initial setting value. | ||
*/ | ||
readonly intialValue: boolean; | ||
/** | ||
* Function to toggle the setting. | ||
*/ | ||
readonly toggleSetting: () => any; | ||
} | ||
|
||
type NavProps = StackScreenProps<RootNavigatorParamList, ROUTES.SETTINGS_SWITCH_SCREEN>; | ||
|
||
/** | ||
* Screen that display a switch with a detailed description about | ||
* what the switch does. | ||
*/ | ||
const SettingsSwitchScreen: React.FC<NavProps> = (props) => { | ||
const { route } = props; | ||
const { title, description, intialValue, toggleSetting } = route.params; | ||
const styles = useStyles(); | ||
const [settingValue, setSettingValue] = React.useState(intialValue); | ||
|
||
const onSwitchPress = React.useCallback(async () => { | ||
try { | ||
await toggleSetting(); | ||
setSettingValue((currentValue) => !currentValue); | ||
} catch (e) { | ||
// Ingnored. | ||
} | ||
}, [toggleSetting]); | ||
|
||
return ( | ||
<StyledSafeAreaView topBar={<TopBar stackProps={props} title={title} />}> | ||
<Typography.Regular16>{description}</Typography.Regular16> | ||
<Spacer paddingTop={16} /> | ||
<Flexible.SectionSwitch | ||
style={styles.switch} | ||
title={title} | ||
label={title} | ||
value={settingValue} | ||
isDisabled={false} | ||
onPress={onSwitchPress} | ||
/> | ||
</StyledSafeAreaView> | ||
); | ||
}; | ||
|
||
export default SettingsSwitchScreen; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { makeStyle } from 'config/theme'; | ||
|
||
const useStyles = makeStyle(() => ({ | ||
switch: { | ||
paddingHorizontal: 0, | ||
}, | ||
})); | ||
|
||
export default useStyles; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters