Skip to content

Commit

Permalink
feat(suite): brightness added as debug setting
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-sanderson committed May 20, 2024
1 parent 31687d8 commit c102ca1
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/suite-analytics/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export enum EventType {
SettingsDeviceUpdateAutoLock = 'settings/device/update-auto-lock',
SettingsDeviceChangeOrientation = 'settings/device/change-orientation',
SettingsDeviceChangeHapticFeedback = 'settings/device/change-haptic-feedback',
SettingsDeviceChangeBrightness = 'settings/device/change-brightness',
SettingsDeviceWipe = 'settings/device/wipe',
SettingsDeviceChangePassphraseProtection = 'settings/device/change-passphrase-protection',
SettingsGeneralChangeLanguage = 'settings/general/change-language',
Expand Down
10 changes: 9 additions & 1 deletion packages/suite/src/support/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2478,13 +2478,21 @@ export default defineMessages({
id: 'TR_DEVICE_SETTINGS_CHANGE_PIN_TITLE',
},
TR_DEVICE_SETTINGS_HAPTIC_FEEDBACK_DESC: {
defaultMessage: "Enable haptic feedback for device interactions",
defaultMessage: 'Enable haptic feedback for device interactions',
id: 'TR_DEVICE_SETTINGS_HAPTIC_FEEDBACK_DESC',
},
TR_DEVICE_SETTINGS_HAPTIC_FEEDBACK_TITLE: {
defaultMessage: 'Haptic feedback',
id: 'TR_DEVICE_SETTINGS_HAPTIC_FEEDBACK_TITLE',
},
TR_DEVICE_SETTINGS_BRIGHTNESS_DESC: {
defaultMessage: 'Enable brightness customization for the display on the device',
id: 'TR_DEVICE_SETTINGS_BRIGHTNESS_DESC',
},
TR_DEVICE_SETTINGS_BRIGHTNESS_TITLE: {
defaultMessage: 'Display Brightness',
id: 'TR_DEVICE_SETTINGS_BRIGHTNESS_TITLE',
},
TR_DEVICE_SETTINGS_WIPE_CODE_TITLE: {
defaultMessage: 'Set up wipe code',
id: 'TR_DEVICE_SETTINGS_WIPE_CODE_TITLE',
Expand Down
55 changes: 55 additions & 0 deletions packages/suite/src/views/settings/SettingsDevice/Brightness.tsx
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>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const HapticFeedback = ({ isDeviceLocked }: DeviceLabelProps) => {
isChecked={hapticEnabled}
onChange={handleChange}
isDisabled={isDeviceLocked}
dataTest="@settings/device/pin-switch"
dataTest="@settings/device/haptic-switch"
/>
</ActionColumn>
</SettingsSectionItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { ChangeLanguage } from './ChangeLanguage';
import { EnableViewOnly } from './EnableViewOnly';
import { selectSuiteFlags } from 'src/reducers/suite/suiteReducer';
import { HapticFeedback } from './HapticFeedback';
import { Brightness } from './Brightness';

const deviceSettingsUnavailable = (device?: TrezorDevice, transport?: Partial<TransportInfo>) => {
const noTransportAvailable = transport && !transport.type;
Expand Down Expand Up @@ -158,6 +159,7 @@ export const SettingsDevice = () => {
<DeviceLabel isDeviceLocked={isDeviceLocked} />
<Homescreen isDeviceLocked={isDeviceLocked} />
<DisplayRotation isDeviceLocked={isDeviceLocked} />
<Brightness isDeviceLocked={isDeviceLocked} />
<HapticFeedback isDeviceLocked={isDeviceLocked} />
{pinProtection && <AutoLock isDeviceLocked={isDeviceLocked} />}
</SettingsSection>
Expand Down

0 comments on commit c102ca1

Please sign in to comment.