Skip to content

Commit

Permalink
Merge pull request #4288 from tloncorp/ja/color-fixes
Browse files Browse the repository at this point in the history
native: color fixes
  • Loading branch information
jamesacklin authored Dec 16, 2024
2 parents 33e8ce6 + 3010d45 commit a19f3d4
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 15 deletions.
4 changes: 3 additions & 1 deletion packages/app/features/settings/ThemeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { useContext, useEffect, useState } from 'react';
import { ScrollView, YStack } from 'tamagui';
import type { ThemeName } from 'tamagui';
import { useTheme } from 'tamagui';

import { useIsDarkMode } from '../../hooks/useIsDarkMode';
import { RootStackParamList } from '../../navigation/types';
Expand All @@ -20,6 +21,7 @@ import { ThemeContext, clearTheme, setTheme } from '../../provider';
type Props = NativeStackScreenProps<RootStackParamList, 'Theme'>;

export function ThemeScreen(props: Props) {
const theme = useTheme();
const { setActiveTheme } = useContext(ThemeContext);
const isDarkMode = useIsDarkMode();
const [selectedTheme, setSelectedTheme] = useState<ThemeName | 'auto'>(
Expand Down Expand Up @@ -71,7 +73,7 @@ export function ThemeScreen(props: Props) {
}, []);

return (
<View backgroundColor="$background" flex={1}>
<View backgroundColor={theme?.background?.val} flex={1}>
<ScreenHeader
title="Theme"
backAction={() => props.navigation.goBack()}
Expand Down
5 changes: 3 additions & 2 deletions packages/app/features/top/ActivityScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as db from '@tloncorp/shared/db';
import * as store from '@tloncorp/shared/store';
import { ActivityScreenView, NavBarView, View } from '@tloncorp/ui';
import { useCallback, useMemo } from 'react';
import { useTheme } from 'tamagui';

import { useCurrentUserId } from '../../hooks/useCurrentUser';
import { useGroupActions } from '../../hooks/useGroupActions';
Expand All @@ -14,6 +15,7 @@ import { useRootNavigation } from '../../navigation/utils';
type Props = NativeStackScreenProps<RootStackParamList, 'Activity'>;

export function ActivityScreen(props: Props) {
const theme = useTheme();
const isFocused = useIsFocused();
const currentUserId = useCurrentUserId();
const [contactsTabEnabled] = useFeatureFlag('contactsTab');
Expand Down Expand Up @@ -69,9 +71,8 @@ export function ActivityScreen(props: Props) {
},
[props.navigation]
);

return (
<View backgroundColor="$background" flex={1}>
<View backgroundColor={theme.background?.val} flex={1}>
<ActivityScreenView
bucketFetchers={bucketedActivity}
isFocused={isFocused}
Expand Down
21 changes: 16 additions & 5 deletions packages/app/features/top/ChatListScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ import {
WelcomeSheet,
} from '@tloncorp/ui';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { ColorTokens, useTheme } from 'tamagui';

import { TLON_EMPLOYEE_GROUP } from '../../constants';
import {
INVITE_SERVICE_ENDPOINT,
INVITE_SERVICE_IS_DEV,
} from '../../constants';
import { useChatSettingsNavigation } from '../../hooks/useChatSettingsNavigation';
import { useCurrentUserId } from '../../hooks/useCurrentUser';
import { useGroupActions } from '../../hooks/useGroupActions';
Expand Down Expand Up @@ -58,6 +55,19 @@ export function ChatListScreenView({
const [screenTitle, setScreenTitle] = useState('Home');
const [inviteSheetGroup, setInviteSheetGroup] = useState<db.Group | null>();
const personalInvite = db.personalInviteLink.useValue();
const viewedPersonalInvite = db.hasViewedPersonalInvite.useValue();
const theme = useTheme();
const inviteButtonColor = useMemo(
() =>
(viewedPersonalInvite
? theme?.primaryText?.val
: theme?.positiveActionText?.val) as ColorTokens,
[
theme?.positiveActionText?.val,
theme?.primaryText?.val,
viewedPersonalInvite,
]
);

const [activeTab, setActiveTab] = useState<'all' | 'groups' | 'messages'>(
'all'
Expand Down Expand Up @@ -236,6 +246,7 @@ export function ChatListScreenView({

const handlePersonalInvitePress = useCallback(() => {
logger.trackEvent(AnalyticsEvent.PersonalInvitePressed);
db.hasViewedPersonalInvite.setValue(true);
setPersonalInviteOpen(true);
}, []);

Expand All @@ -261,7 +272,7 @@ export function ChatListScreenView({
personalInvite ? (
<ScreenHeader.IconButton
type="Send"
color="$blue"
color={inviteButtonColor}
onPress={handlePersonalInvitePress}
/>
) : undefined
Expand Down
4 changes: 3 additions & 1 deletion packages/app/features/top/ContactsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import {
} from '@tloncorp/ui';
import { useCallback } from 'react';
import { Alert } from 'react-native';
import { useTheme } from 'tamagui';

import { useCurrentUserId } from '../../hooks/useCurrentUser';
import type { RootStackParamList } from '../../navigation/types';

type Props = NativeStackScreenProps<RootStackParamList, 'Contacts'>;

export default function ContactsScreen(props: Props) {
const theme = useTheme();
const {
navigation: { navigate },
} = props;
Expand Down Expand Up @@ -63,7 +65,7 @@ export default function ContactsScreen(props: Props) {

return (
<AppDataContextProvider contacts={contacts} currentUserId={currentUser}>
<View backgroundColor="$background" flex={1}>
<View backgroundColor={theme?.background?.val} flex={1}>
<ScreenHeader
title="Contacts"
leftControls={
Expand Down
5 changes: 5 additions & 0 deletions packages/shared/src/db/keyValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ export const personalInviteLink = createStorageItem<string | null>({
defaultValue: null,
});

export const hasViewedPersonalInvite = createStorageItem<boolean>({
key: 'hasViewedPersonalInvite',
defaultValue: false,
});

export const postDraft = (opts: {
key: string;
type: 'caption' | 'text' | undefined; // matches GalleryDraftType
Expand Down
5 changes: 3 additions & 2 deletions packages/ui/src/components/ChatList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Animated, {
useAnimatedStyle,
useSharedValue,
} from 'react-native-reanimated';
import { Text, View, YStack, getTokenValue } from 'tamagui';
import { Text, View, YStack, getTokenValue, useTheme } from 'tamagui';

import { useCalm, useChatOptions } from '../contexts';
import { getChannelTitle, getGroupTitle } from '../utils';
Expand Down Expand Up @@ -242,6 +242,7 @@ const ChatListSearch = React.memo(function ChatListSearchComponent({
onPressClear: () => void;
onPressClose: () => void;
}) {
const theme = useTheme();
const [contentHeight, setContentHeight] = useState(0);

const openProgress = useSharedValue(isOpen ? 1 : 0);
Expand Down Expand Up @@ -277,7 +278,7 @@ const ChatListSearch = React.memo(function ChatListSearchComponent({
<YStack
onLayout={handleContentLayout}
flexShrink={0}
backgroundColor="$background"
backgroundColor={theme.background.val}
gap="$m"
position="absolute"
top={0}
Expand Down
6 changes: 3 additions & 3 deletions packages/ui/src/components/ProfileStatusSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ export default function ProfileStatusSheet({
}}
/>
<Button
hero
onPress={handleSave}
disabled={!isValid}
paddingHorizontal="$l"
paddingVertical="$l"
borderColor="transparent"
>
<Icon type="Send" color="$background" />
<Icon type="ArrowUp" />
</Button>
</XStack>
</YStack>
Expand Down
5 changes: 4 additions & 1 deletion packages/ui/src/components/UserProfileScreenView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
XStack,
YStack,
styled,
useTheme,
useWindowDimensions,
} from 'tamagui';

Expand All @@ -41,6 +42,7 @@ interface Props {
}

export function UserProfileScreenView(props: Props) {
const theme = useTheme();
const insets = useSafeAreaInsets();
const currentUserId = useCurrentUserId();
const userContact = useContact(props.userId);
Expand Down Expand Up @@ -79,7 +81,7 @@ export function UserProfileScreenView(props: Props) {
}, [currentUserId, props.userId, userContact]);

return (
<View flex={1} backgroundColor={'$secondaryBackground'}>
<View flex={1} backgroundColor={theme.secondaryBackground.val}>
<ScreenHeader
title="Profile"
leftControls={<ScreenHeader.BackButton onPress={props.onBack} />}
Expand Down Expand Up @@ -345,6 +347,7 @@ function UserInfoRow(props: { userId: string; hasNickname: boolean }) {
<>
<ContactName
contactId={props.userId}
color="$primaryText"
mode="nickname"
fontSize={24}
lineHeight={24}
Expand Down

0 comments on commit a19f3d4

Please sign in to comment.