-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(suite): brightness added as debug setting
- Loading branch information
1 parent
31687d8
commit c102ca1
Showing
5 changed files
with
68 additions
and
2 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
55 changes: 55 additions & 0 deletions
55
packages/suite/src/views/settings/SettingsDevice/Brightness.tsx
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,55 @@ | ||
import { Switch } from '@trezor/components'; | ||
import { SettingsSectionItem } from 'src/components/settings'; | ||
import { ActionColumn, TextColumn, Translation } from 'src/components/suite'; | ||
import { SettingsAnchor } from 'src/constants/suite/anchors'; | ||
import { useDevice, useDispatch, useSelector } from '../../../hooks/suite'; | ||
import { applySettings } from 'src/actions/settings/deviceSettingsActions'; | ||
import { analytics, EventType } from '@trezor/suite-analytics'; | ||
|
||
interface DeviceLabelProps { | ||
isDeviceLocked: boolean; | ||
} | ||
|
||
export const Brightness = ({ isDeviceLocked }: DeviceLabelProps) => { | ||
const dispatch = useDispatch(); | ||
const { device } = useDevice(); | ||
|
||
const showDebugMenu = useSelector(state => state.suite.settings.debug.showDebugMenu); | ||
|
||
const isSupportedDevice = true; //device?.features?.capabilities?.includes('Capability_Brightness'); | ||
|
||
if (!showDebugMenu || !isSupportedDevice) { | ||
return null; | ||
} | ||
|
||
const brightnessEnabled = true; // device?.features?.brightness ?? false; | ||
|
||
const handleChange = () => { | ||
dispatch( | ||
applySettings({ | ||
// brightness: !brightnessEnabled | ||
}), | ||
); | ||
analytics.report({ | ||
type: EventType.SettingsDeviceChangeHapticFeedback, | ||
payload: { value: !brightnessEnabled }, | ||
}); | ||
}; | ||
|
||
return ( | ||
<SettingsSectionItem anchorId={SettingsAnchor.PinProtection}> | ||
<TextColumn | ||
title={<Translation id="TR_DEVICE_SETTINGS_BRIGHTNESS_TITLE" />} | ||
description={<Translation id="TR_DEVICE_SETTINGS_BRIGHTNESS_DESC" />} | ||
/> | ||
<ActionColumn> | ||
<Switch | ||
isChecked={brightnessEnabled} | ||
onChange={handleChange} | ||
isDisabled={isDeviceLocked} | ||
dataTest="@settings/device/brightness-switch" | ||
/> | ||
</ActionColumn> | ||
</SettingsSectionItem> | ||
); | ||
}; |
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