Skip to content

Commit c13349b

Browse files
committed
Merge branch 'tlg/rn-theme' into 'develop'
App: New Theme System See merge request polycentric/polycentric!483
2 parents 947f7ed + 3d0be87 commit c13349b

42 files changed

Lines changed: 1551 additions & 415 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/polycentric/app/(tabs)/_layout.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Ionicons } from '@expo/vector-icons';
33
import { BlurView } from 'expo-blur';
44
import { StyleSheet } from 'react-native';
55
import { TAB_BAR_HEIGHT } from '@/constants';
6-
import { useTheme } from '@/theme';
6+
import { useLegacyTheme } from '@/legacyTheme';
77

88
function TabBarBackground() {
99
return (
@@ -21,15 +21,15 @@ function TabBarBackground() {
2121
const ICON_SIZE = 20;
2222

2323
export default function TabLayout() {
24-
const { theme } = useTheme();
24+
const { legacyTheme } = useLegacyTheme();
2525

2626
return (
2727
<Tabs
2828
screenOptions={{
2929
headerShown: false,
3030
tabBarShowLabel: false,
31-
tabBarActiveTintColor: theme.colors.primary,
32-
tabBarInactiveTintColor: theme.colors.neutralSurface,
31+
tabBarActiveTintColor: legacyTheme.colors.primary,
32+
tabBarInactiveTintColor: legacyTheme.colors.neutralSurface,
3333
tabBarBackground: () => <TabBarBackground />,
3434
tabBarStyle: {
3535
position: 'absolute',

apps/polycentric/app/(tabs)/feed/profile/[publicKey].tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import {
1010
} from '@/lib/polycentric-hooks';
1111
import { types } from '@polycentric/react-native';
1212
import { Routes } from '@/constants';
13-
import { useTheme } from '@/theme';
13+
import { useLegacyTheme } from '@/legacyTheme';
1414

1515
export default function Profile() {
1616
const router = useRouter();
17-
const { theme } = useTheme();
17+
const { legacyTheme } = useLegacyTheme();
1818
const { width: screenWidth } = useWindowDimensions();
1919
const { publicKey: publicKeyParam } = useLocalSearchParams<{
2020
publicKey: string;
@@ -56,8 +56,8 @@ export default function Profile() {
5656
edit={edit}
5757
screenWidth={screenWidth}
5858
bannerColors={[
59-
theme.colors.backgroundSecondary,
60-
theme.colors.backgroundPrimary,
59+
legacyTheme.colors.backgroundSecondary,
60+
legacyTheme.colors.backgroundPrimary,
6161
]}
6262
onBack={() => router.back()}
6363
/>

apps/polycentric/app/(tabs)/settings/index.tsx

Lines changed: 62 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,66 @@
1-
import { useState, useCallback, useEffect } from 'react';
2-
import { ScrollView, Linking, ActivityIndicator } from 'react-native';
3-
import { Ionicons } from '@expo/vector-icons';
41
import {
5-
Screen,
6-
PageHeader,
7-
ListItemGroup,
8-
ListItem,
9-
IdentityBadge,
10-
Text,
2+
Avatar,
113
Box,
12-
IconButton,
13-
TextInput,
144
Button,
5+
IconButton,
6+
IdentityBadge,
157
LinkButton,
16-
Avatar,
8+
ListItem,
9+
ListItemGroup,
10+
PageHeader,
11+
Screen,
12+
Text,
13+
TextInput,
1714
} from '@/components';
18-
import { useSheet } from '@/lib/sheet';
15+
import { REPORT_BUG_URL, SOURCE_CODE_URL, TAB_BAR_HEIGHT } from '@/constants';
16+
import { useLegacyTheme } from '@/legacyTheme';
17+
import { confirm } from '@/lib/dialogs/alert';
1918
import {
19+
identiconUrl,
20+
publicKeyToString,
21+
toBase64,
2022
useCurrentIdentity,
2123
usePolycentric,
2224
usePolycentricContext,
2325
useUsername,
24-
publicKeyToString,
25-
identiconUrl,
26-
toBase64,
2726
} from '@/lib/polycentric-hooks';
27+
import { useSheet } from '@/lib/sheet';
28+
import { Atoms, useTheme } from '@/theme';
29+
import { Ionicons } from '@expo/vector-icons';
2830
import { types } from '@polycentric/react-native';
29-
import { useTheme } from '@/theme';
30-
import { TAB_BAR_HEIGHT, SOURCE_CODE_URL, REPORT_BUG_URL } from '@/constants';
31-
import { confirm } from '@/lib/dialogs/alert';
31+
import { useCallback, useEffect, useState } from 'react';
32+
import { ActivityIndicator, Linking, ScrollView, View } from 'react-native';
33+
34+
function AppearanceSettingRow() {
35+
const { theme, setActiveThemeName } = useTheme();
36+
const { setLegacyThemeMode } = useLegacyTheme();
37+
38+
const onPress = () => {
39+
const next = theme.name === 'dark' ? 'light' : 'dark';
40+
setActiveThemeName(next);
41+
setLegacyThemeMode(next);
42+
};
43+
44+
return (
45+
<ListItem onPress={onPress}>
46+
<View
47+
style={[Atoms.flex_row, Atoms.align_center, Atoms.gap_md, Atoms.pl_xs]}
48+
>
49+
<Ionicons
50+
name={theme.name === 'dark' ? 'moon' : 'sunny'}
51+
size={22}
52+
style={theme.atoms.icon_accent}
53+
/>
54+
<Text variant="body" style={theme.atoms.text}>
55+
Theme
56+
</Text>
57+
</View>
58+
</ListItem>
59+
);
60+
}
3261

3362
export default function Settings() {
34-
const { theme } = useTheme();
63+
const { legacyTheme } = useLegacyTheme();
3564
const { Sheet: IdentitySheet, present: presentIdentity } = useSheet();
3665
const { Sheet: ServersSheet, present: presentServers } = useSheet();
3766
const currentIdentity = useCurrentIdentity();
@@ -44,7 +73,7 @@ export default function Settings() {
4473
<ScrollView
4574
showsVerticalScrollIndicator={false}
4675
contentContainerStyle={{
47-
gap: theme.spacing.xl,
76+
gap: legacyTheme.spacing.xl,
4877
paddingBottom: TAB_BAR_HEIGHT + 16,
4978
}}
5079
>
@@ -57,6 +86,10 @@ export default function Settings() {
5786
</>
5887
</ListItemWrapper>
5988

89+
<ListItemGroup label="Appearance">
90+
<AppearanceSettingRow />
91+
</ListItemGroup>
92+
6093
<ListItemGroup label="Servers">
6194
<ListItemWrapper onPress={() => presentServers()}>
6295
<Text variant="body">Polycentric servers</Text>
@@ -85,7 +118,7 @@ function IdentitySettingsContent({
85118
}: {
86119
publicKey: types.PublicKey;
87120
}) {
88-
const { theme } = useTheme();
121+
const { legacyTheme } = useLegacyTheme();
89122
const client = usePolycentric();
90123
const { identity } = useCurrentIdentity();
91124
const username = useUsername(publicKey);
@@ -230,7 +263,7 @@ function IdentitySettingsContent({
230263
<Box
231264
style={{
232265
height: 1,
233-
backgroundColor: theme.colors.neutralSurfaceOpacity20,
266+
backgroundColor: legacyTheme.colors.neutralSurfaceOpacity20,
234267
}}
235268
/>
236269

@@ -255,7 +288,7 @@ function ServersSheetContent() {
255288
const client = usePolycentric();
256289
const { store } = usePolycentricContext();
257290
const { identity } = useCurrentIdentity();
258-
const { theme } = useTheme();
291+
const { legacyTheme } = useLegacyTheme();
259292

260293
const [servers, setServers] = useState<string[]>([]);
261294
const [isEditing, setIsEditing] = useState(false);
@@ -357,7 +390,7 @@ function ServersSheetContent() {
357390
<Ionicons
358391
name="remove-circle-outline"
359392
size={22}
360-
color={theme.colors.destructive}
393+
color={legacyTheme.colors.destructive}
361394
/>
362395
)}
363396
onPress={() => handleRemoveServer(server)}
@@ -391,8 +424,8 @@ function ServersSheetContent() {
391424
size={28}
392425
color={
393426
newServerUrl.trim()
394-
? theme.colors.primary
395-
: theme.colors.neutralSurface
427+
? legacyTheme.colors.primary
428+
: legacyTheme.colors.neutralSurface
396429
}
397430
/>
398431
)}
@@ -412,7 +445,7 @@ function ListItemWrapper({
412445
children: React.ReactNode;
413446
onPress: () => void;
414447
}) {
415-
const { theme } = useTheme();
448+
const { legacyTheme } = useLegacyTheme();
416449

417450
return (
418451
<ListItem onPress={onPress}>
@@ -426,7 +459,7 @@ function ListItemWrapper({
426459
<Ionicons
427460
name="chevron-forward"
428461
size={18}
429-
color={theme.colors.neutralSurface}
462+
color={legacyTheme.colors.neutralSurface}
430463
/>
431464
</Box>
432465
</ListItem>

0 commit comments

Comments
 (0)