-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move theme controls to its own screen (#4866)
- Loading branch information
Showing
16 changed files
with
204 additions
and
78 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,5 @@ | ||
import {createSinglePathSVG} from './TEMPLATE' | ||
|
||
export const Moon_Stroke2_Corner0_Rounded = createSinglePathSVG({ | ||
path: 'M12.097 2.53a1 1 0 0 1-.041 1.07 6 6 0 0 0 8.345 8.344 1 1 0 0 1 1.563.908c-.434 5.122-4.728 9.144-9.962 9.144-5.522 0-9.998-4.476-9.998-9.998 0-5.234 4.021-9.528 9.144-9.962a1 1 0 0 1 .949.494ZM9.424 4.424a7.998 7.998 0 1 0 10.152 10.152A8 8 0 0 1 9.424 4.424Z', | ||
}) |
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,5 @@ | ||
import {createSinglePathSVG} from './TEMPLATE' | ||
|
||
export const Phone_Stroke2_Corner0_Rounded = createSinglePathSVG({ | ||
path: 'M5 4a3 3 0 0 1 3-3h8a3 3 0 0 1 3 3v16a3 3 0 0 1-3 3H8a3 3 0 0 1-3-3V4Zm3-1a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1H8Zm2 2a1 1 0 0 1 1-1h2a1 1 0 1 1 0 2h-2a1 1 0 0 1-1-1Z', | ||
}) |
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,135 @@ | ||
import React, {useCallback} from 'react' | ||
import {View} from 'react-native' | ||
import Animated, { | ||
FadeInDown, | ||
FadeOutDown, | ||
LayoutAnimationConfig, | ||
} from 'react-native-reanimated' | ||
import {msg, Trans} from '@lingui/macro' | ||
import {useLingui} from '@lingui/react' | ||
|
||
import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' | ||
import {CommonNavigatorParams, NativeStackScreenProps} from '#/lib/routes/types' | ||
import {s} from '#/lib/styles' | ||
import {useSetThemePrefs, useThemePrefs} from '#/state/shell' | ||
import {SimpleViewHeader} from '#/view/com/util/SimpleViewHeader' | ||
import {ScrollView} from '#/view/com/util/Views' | ||
import {atoms as a, native, useTheme} from '#/alf' | ||
import * as ToggleButton from '#/components/forms/ToggleButton' | ||
import {Moon_Stroke2_Corner0_Rounded as MoonIcon} from '#/components/icons/Moon' | ||
import {Phone_Stroke2_Corner0_Rounded as PhoneIcon} from '#/components/icons/Phone' | ||
import {Text} from '#/components/Typography' | ||
|
||
type Props = NativeStackScreenProps<CommonNavigatorParams, 'AppearanceSettings'> | ||
export function AppearanceSettingsScreen({}: Props) { | ||
const {_} = useLingui() | ||
const t = useTheme() | ||
const {isTabletOrMobile} = useWebMediaQueries() | ||
|
||
const {colorMode, darkTheme} = useThemePrefs() | ||
const {setColorMode, setDarkTheme} = useSetThemePrefs() | ||
|
||
const onChangeAppearance = useCallback( | ||
(keys: string[]) => { | ||
const appearance = keys.find(key => key !== colorMode) as | ||
| 'system' | ||
| 'light' | ||
| 'dark' | ||
| undefined | ||
if (!appearance) return | ||
setColorMode(appearance) | ||
}, | ||
[setColorMode, colorMode], | ||
) | ||
|
||
const onChangeDarkTheme = useCallback( | ||
(keys: string[]) => { | ||
const theme = keys.find(key => key !== darkTheme) as | ||
| 'dim' | ||
| 'dark' | ||
| undefined | ||
if (!theme) return | ||
setDarkTheme(theme) | ||
}, | ||
[setDarkTheme, darkTheme], | ||
) | ||
|
||
return ( | ||
<LayoutAnimationConfig skipExiting skipEntering> | ||
<View testID="preferencesThreadsScreen" style={s.hContentRegion}> | ||
<ScrollView | ||
// @ts-ignore web only -prf | ||
dataSet={{'stable-gutters': 1}} | ||
contentContainerStyle={{paddingBottom: 75}}> | ||
<SimpleViewHeader | ||
showBackButton={isTabletOrMobile} | ||
style={[t.atoms.border_contrast_medium, a.border_b]}> | ||
<View style={a.flex_1}> | ||
<Text style={[a.text_2xl, a.font_bold]}> | ||
<Trans>Appearance</Trans> | ||
</Text> | ||
</View> | ||
</SimpleViewHeader> | ||
|
||
<View style={[a.p_xl, a.gap_lg]}> | ||
<View style={[a.flex_row, a.align_center, a.gap_md]}> | ||
<PhoneIcon style={t.atoms.text} /> | ||
<Text style={a.text_md}> | ||
<Trans>Mode</Trans> | ||
</Text> | ||
</View> | ||
<ToggleButton.Group | ||
label={_(msg`Dark mode`)} | ||
values={[colorMode]} | ||
onChange={onChangeAppearance}> | ||
<ToggleButton.Button label={_(msg`System`)} name="system"> | ||
<ToggleButton.ButtonText> | ||
<Trans>System</Trans> | ||
</ToggleButton.ButtonText> | ||
</ToggleButton.Button> | ||
<ToggleButton.Button label={_(msg`Light`)} name="light"> | ||
<ToggleButton.ButtonText> | ||
<Trans>Light</Trans> | ||
</ToggleButton.ButtonText> | ||
</ToggleButton.Button> | ||
<ToggleButton.Button label={_(msg`Dark`)} name="dark"> | ||
<ToggleButton.ButtonText> | ||
<Trans>Dark</Trans> | ||
</ToggleButton.ButtonText> | ||
</ToggleButton.Button> | ||
</ToggleButton.Group> | ||
{colorMode !== 'light' && ( | ||
<Animated.View | ||
entering={native(FadeInDown)} | ||
exiting={native(FadeOutDown)} | ||
style={[a.mt_md, a.gap_lg]}> | ||
<View style={[a.flex_row, a.align_center, a.gap_md]}> | ||
<MoonIcon style={t.atoms.text} /> | ||
<Text style={a.text_md}> | ||
<Trans>Dark theme</Trans> | ||
</Text> | ||
</View> | ||
|
||
<ToggleButton.Group | ||
label={_(msg`Dark theme`)} | ||
values={[darkTheme ?? 'dim']} | ||
onChange={onChangeDarkTheme}> | ||
<ToggleButton.Button label={_(msg`Dim`)} name="dim"> | ||
<ToggleButton.ButtonText> | ||
<Trans>Dim</Trans> | ||
</ToggleButton.ButtonText> | ||
</ToggleButton.Button> | ||
<ToggleButton.Button label={_(msg`Dark`)} name="dark"> | ||
<ToggleButton.ButtonText> | ||
<Trans>Dark</Trans> | ||
</ToggleButton.ButtonText> | ||
</ToggleButton.Button> | ||
</ToggleButton.Group> | ||
</Animated.View> | ||
)} | ||
</View> | ||
</ScrollView> | ||
</View> | ||
</LayoutAnimationConfig> | ||
) | ||
} |
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
Oops, something went wrong.