Skip to content

Commit

Permalink
Merge pull request #3458 from tloncorp/lb/android-fixes
Browse files Browse the repository at this point in the history
mobile: android polish omnibus
  • Loading branch information
latter-bolden authored Apr 29, 2024
2 parents f08ace0 + db0ca7f commit bc66c51
Show file tree
Hide file tree
Showing 26 changed files with 624 additions and 319 deletions.
36 changes: 17 additions & 19 deletions apps/tlon-mobile/cosmos.imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@
import { RendererConfig, UserModuleWrappers } from 'react-cosmos-core';

import * as fixture0 from './src/App.fixture';
import * as fixture17 from './src/fixtures/ActionSheet.fixture';
import * as fixture16 from './src/fixtures/Button.fixture';
import * as fixture15 from './src/fixtures/Channel.fixture';
import * as fixture14 from './src/fixtures/ChannelHeader.fixture';
import * as fixture13 from './src/fixtures/ChannelSwitcherSheet.fixture';
import * as fixture12 from './src/fixtures/ChatReference.fixture';
import * as fixture16 from './src/fixtures/ActionSheet.fixture';
import * as fixture15 from './src/fixtures/Button.fixture';
import * as fixture14 from './src/fixtures/Channel.fixture';
import * as fixture13 from './src/fixtures/ChannelHeader.fixture';
import * as fixture12 from './src/fixtures/ChannelSwitcherSheet.fixture';
import * as fixture11 from './src/fixtures/GroupList.fixture';
import * as fixture10 from './src/fixtures/GroupListItem.fixture';
import * as fixture9 from './src/fixtures/HeaderButton.fixture';
import * as fixture8 from './src/fixtures/ImageViewer.fixture';
import * as fixture7 from './src/fixtures/Input.fixture';
import * as fixture6 from './src/fixtures/MessageInput.fixture';
import * as fixture5 from './src/fixtures/PostScreen.fixture';
import * as fixture4 from './src/fixtures/ReferenceSkeleton.fixture';
import * as fixture6 from './src/fixtures/MessageActions.fixture';
import * as fixture5 from './src/fixtures/MessageInput.fixture';
import * as fixture4 from './src/fixtures/PostScreen.fixture';
import * as fixture3 from './src/fixtures/ScreenHeader.fixture';
import * as fixture2 from './src/fixtures/SearchBar.fixture';
import * as fixture1 from './src/fixtures/TlonButton.fixture';
import * as decorator0 from './src/fixtures/cosmos.decorator';

export const rendererConfig: RendererConfig = {
playgroundUrl: 'http://localhost:5000',
playgroundUrl: 'http://localhost:5001',
rendererUrl: null,
};

Expand All @@ -32,20 +31,19 @@ const fixtures = {
'src/fixtures/TlonButton.fixture.tsx': { module: fixture1 },
'src/fixtures/SearchBar.fixture.tsx': { module: fixture2 },
'src/fixtures/ScreenHeader.fixture.tsx': { module: fixture3 },
'src/fixtures/ReferenceSkeleton.fixture.tsx': { module: fixture4 },
'src/fixtures/PostScreen.fixture.tsx': { module: fixture5 },
'src/fixtures/MessageInput.fixture.tsx': { module: fixture6 },
'src/fixtures/PostScreen.fixture.tsx': { module: fixture4 },
'src/fixtures/MessageInput.fixture.tsx': { module: fixture5 },
'src/fixtures/MessageActions.fixture.tsx': { module: fixture6 },
'src/fixtures/Input.fixture.tsx': { module: fixture7 },
'src/fixtures/ImageViewer.fixture.tsx': { module: fixture8 },
'src/fixtures/HeaderButton.fixture.tsx': { module: fixture9 },
'src/fixtures/GroupListItem.fixture.tsx': { module: fixture10 },
'src/fixtures/GroupList.fixture.tsx': { module: fixture11 },
'src/fixtures/ChatReference.fixture.tsx': { module: fixture12 },
'src/fixtures/ChannelSwitcherSheet.fixture.tsx': { module: fixture13 },
'src/fixtures/ChannelHeader.fixture.tsx': { module: fixture14 },
'src/fixtures/Channel.fixture.tsx': { module: fixture15 },
'src/fixtures/Button.fixture.tsx': { module: fixture16 },
'src/fixtures/ActionSheet.fixture.tsx': { module: fixture17 },
'src/fixtures/ChannelSwitcherSheet.fixture.tsx': { module: fixture12 },
'src/fixtures/ChannelHeader.fixture.tsx': { module: fixture13 },
'src/fixtures/Channel.fixture.tsx': { module: fixture14 },
'src/fixtures/Button.fixture.tsx': { module: fixture15 },
'src/fixtures/ActionSheet.fixture.tsx': { module: fixture16 },
};

const decorators = {
Expand Down
11 changes: 7 additions & 4 deletions apps/tlon-mobile/src/fixtures/Channel.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,21 @@ const fakeLoadingMostRecentFile: Upload = {
size: [100, 100],
};

const ChannelFixtureWrapper = ({ children }: PropsWithChildren) => {
const ChannelFixtureWrapper = ({
children,
theme,
}: PropsWithChildren<{ theme?: 'light' | 'dark' }>) => {
const { bottom } = useSafeAreaInsets();
return (
<FixtureWrapper fillWidth fillHeight>
<FixtureWrapper fillWidth fillHeight theme={theme}>
<View paddingBottom={bottom} backgroundColor="$background">
{children}
</View>
</FixtureWrapper>
);
};

const ChannelFixture = () => {
export const ChannelFixture = (props: { theme?: 'light' | 'dark' }) => {
const [open, setOpen] = useState(false);
const [currentChannel, setCurrentChannel] = useState<db.Channel | null>(null);
const { bottom } = useSafeAreaInsets();
Expand All @@ -72,7 +75,7 @@ const ChannelFixture = () => {
}, []);

return (
<ChannelFixtureWrapper>
<ChannelFixtureWrapper theme={props.theme}>
<Channel
posts={posts}
currentUserId="~zod"
Expand Down
54 changes: 29 additions & 25 deletions apps/tlon-mobile/src/fixtures/FixtureWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ColorProp } from '@tloncorp/ui';
import { View } from '@tloncorp/ui';
import { Theme, View } from '@tloncorp/ui';
import type { PropsWithChildren } from 'react';
import { GestureHandlerRootView } from 'react-native-gesture-handler';

Expand All @@ -11,45 +11,49 @@ export const FixtureWrapper = ({
children,
backgroundColor,
innerBackgroundColor,
theme = 'light',
}: PropsWithChildren<{
fillWidth?: boolean;
fillHeight?: boolean;
verticalAlign?: 'top' | 'center' | 'bottom';
horizontalAlign?: 'left' | 'center' | 'right';
backgroundColor?: ColorProp;
innerBackgroundColor?: ColorProp;
theme?: 'light' | 'dark';
}>) => {
return (
<GestureHandlerRootView style={{ flex: 1 }}>
<View
backgroundColor={backgroundColor ?? '$secondaryBackground'}
flex={1}
flexDirection="column"
width={fillWidth ? '100%' : 'unset'}
height={fillHeight ? '100%' : 'unset'}
justifyContent={
verticalAlign === 'top'
? 'flex-start'
: verticalAlign === 'bottom'
? 'flex-end'
: 'center'
}
alignItems={
horizontalAlign === 'left'
? 'flex-start'
: horizontalAlign === 'right'
? 'flex-end'
: 'center'
}
>
<Theme name={theme}>
<View
backgroundColor={innerBackgroundColor ?? '$background'}
backgroundColor={backgroundColor ?? '$secondaryBackground'}
flex={1}
flexDirection="column"
width={fillWidth ? '100%' : 'unset'}
height={fillHeight ? '100%' : 'unset'}
justifyContent={
verticalAlign === 'top'
? 'flex-start'
: verticalAlign === 'bottom'
? 'flex-end'
: 'center'
}
alignItems={
horizontalAlign === 'left'
? 'flex-start'
: horizontalAlign === 'right'
? 'flex-end'
: 'center'
}
>
{children}
<View
backgroundColor={innerBackgroundColor ?? '$background'}
width={fillWidth ? '100%' : 'unset'}
height={fillHeight ? '100%' : 'unset'}
>
{children}
</View>
</View>
</View>
</Theme>
</GestureHandlerRootView>
);
};
59 changes: 59 additions & 0 deletions apps/tlon-mobile/src/fixtures/MessageActions.fixture.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import * as db from '@tloncorp/shared/dist/db';
import { ChatMessageActions, Modal, ZStack } from '@tloncorp/ui';
import { createRef, useEffect, useState } from 'react';
import { View } from 'react-native';

import { ChannelFixture } from './Channel.fixture';
import { FixtureWrapper } from './FixtureWrapper';
import { createFakePosts, group } from './fakeData';

const post = createFakePosts(1)[0];

function MessageActions() {
const [currentChannel, setCurrentChannel] = useState<db.Channel | null>(null);
const refStub = createRef<View>();

useEffect(() => {
if (group) {
const firstChatChannel = group.channels?.find((c) => c.type === 'chat');
if (firstChatChannel) {
setCurrentChannel(firstChatChannel);
}
}
}, []);

if (currentChannel) {
return (
<Modal visible={true} onDismiss={() => null}>
<ChatMessageActions
currentUserId={'~latter-bolden'}
post={post}
postRef={refStub}
onDismiss={() => null}
channelType={currentChannel.type}
/>
</Modal>
);
}

return null;
}

export default {
light: (
<FixtureWrapper fillHeight fillWidth>
<ZStack flex={1}>
<ChannelFixture />
<MessageActions />
</ZStack>
</FixtureWrapper>
),
dark: (
<FixtureWrapper fillHeight fillWidth theme="dark">
<ZStack flex={1}>
<ChannelFixture theme="dark" />
<MessageActions />
</ZStack>
</FixtureWrapper>
),
};
13 changes: 13 additions & 0 deletions apps/tlon-mobile/src/navigation/RootStack.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
import { useFocusEffect } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { Platform, StatusBar } from 'react-native';

import { useIsDarkMode } from '../hooks/useIsDarkMode';
import ImageViewerScreen from '../screens/ImageViewerScreen';
import type { RootStackParamList } from '../types';
import { TabStack } from './TabStack';

const Root = createNativeStackNavigator<RootStackParamList>();

export function RootStack() {
const isDarkMode = useIsDarkMode();

// Android status bar has a solid color by default, so we clear it
useFocusEffect(() => {
if (Platform.OS === 'android') {
StatusBar.setBackgroundColor('transparent');
StatusBar.setBarStyle(isDarkMode ? 'light-content' : 'dark-content');
}
});

return (
<Root.Navigator
initialRouteName="Tabs"
Expand Down
65 changes: 0 additions & 65 deletions packages/ui/src/components/ActionList.tsx

This file was deleted.

13 changes: 13 additions & 0 deletions packages/ui/src/components/ActionList/ListFrame.android.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { YStack, styled } from 'tamagui';

const ListFrame = styled(YStack, {
overflow: 'hidden',
backgroundColor: '$secondaryBackground',
shadowColor: '$black',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.25,
shadowRadius: 3.84,
elevation: 5,
});

export default ListFrame;
31 changes: 31 additions & 0 deletions packages/ui/src/components/ActionList/ListFrame.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { BlurView } from 'expo-blur';
import { ComponentProps, PropsWithChildren } from 'react';
import { YStack, styled } from 'tamagui';

import { ListItemFrame } from '../ListItem';

const ListFrame = styled(YStack, {
overflow: 'hidden',
borderRadius: '$m',
});

const ListFrameComponent = (
props: PropsWithChildren<
ComponentProps<typeof ListItemFrame> & ComponentProps<typeof BlurView>
>
) => {
const { children, intensity, tint, ...rest } = props;
return (
<ListFrame {...rest}>
<BlurView
style={{ flex: 1 }}
intensity={intensity ?? 80}
tint={tint ?? 'extraLight'}
>
{children}
</BlurView>
</ListFrame>
);
};

export default ListFrameComponent;
Loading

0 comments on commit bc66c51

Please sign in to comment.