Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

native: low-priority omnibus #3593

Merged
merged 8 commits into from
Jun 11, 2024
48 changes: 29 additions & 19 deletions apps/tlon-mobile/src/screens/ChatListScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import * as db from '@tloncorp/shared/dist/db';
import * as logic from '@tloncorp/shared/dist/logic';
import * as store from '@tloncorp/shared/dist/store';
import {
ChatList,
ChatOptionsSheet,
ChatList, // ChatOptionsSheet,
ContactsProvider,
FloatingActionButton,
GroupPreviewSheet,
Expand All @@ -32,9 +31,12 @@ type ChatListScreenProps = NativeStackScreenProps<
export default function ChatListScreen(
props: ChatListScreenProps & { contacts: db.Contact[] }
) {
const [longPressedItem, setLongPressedItem] = useState<db.Channel | null>(
null
);
{
/* FIXME: Disabling long-press on ChatListScreen items for now */
}
// const [longPressedItem, setLongPressedItem] = useState<db.Channel | null>(
// null
// );
const [selectedGroup, setSelectedGroup] = useState<db.Group | null>(null);
const [startDmOpen, setStartDmOpen] = useState(false);
const [addGroupOpen, setAddGroupOpen] = useState(false);
Expand Down Expand Up @@ -101,9 +103,12 @@ export default function ChatListScreen(
[props.navigation]
);

const onLongPressItem = useCallback((item: db.Channel | db.Group) => {
logic.isChannel(item) ? setLongPressedItem(item) : null;
}, []);
{
/* FIXME: Disabling long-press on ChatListScreen items for now */
}
// const onLongPressItem = useCallback((item: db.Channel | db.Group) => {
// logic.isChannel(item) ? setLongPressedItem(item) : null;
// }, []);

const handleDmOpenChange = useCallback((open: boolean) => {
if (!open) {
Expand All @@ -123,14 +128,17 @@ export default function ChatListScreen(
}
}, []);

const handleChatOptionsOpenChange = useCallback(
(open: boolean) => {
if (!open) {
setLongPressedItem(null);
}
},
[setLongPressedItem]
);
{
/* FIXME: Disabling long-press on ChatListScreen items for now */
}
// const handleChatOptionsOpenChange = useCallback(
// (open: boolean) => {
// if (!open) {
// setLongPressedItem(null);
// }
// },
// [setLongPressedItem]
// );

const handleGroupCreated = useCallback(
({ channel }: { channel: db.Channel }) => goToChannel({ channel }),
Expand All @@ -155,7 +163,8 @@ export default function ChatListScreen(
pinned={resolvedChats.pinned}
unpinned={resolvedChats.unpinned}
pendingChats={resolvedChats.pendingChats}
onLongPressItem={onLongPressItem}
// FIXME: Disabling long-press on ChatListScreen items for now
// onLongPressItem={onLongPressItem}
onPressItem={onPressChat}
/>
) : null}
Expand Down Expand Up @@ -190,11 +199,12 @@ export default function ChatListScreen(
/>
</ContextMenu>
</View>
<ChatOptionsSheet
{/* FIXME: Disabling long-press on ChatListScreen items for now */}
{/* <ChatOptionsSheet
open={longPressedItem !== null}
onOpenChange={handleChatOptionsOpenChange}
channel={longPressedItem ?? undefined}
/>
/> */}
<StartDmSheet
goToDm={goToDm}
open={startDmOpen}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default function UploadedImagePreview({
resetImageAttachment: () => void;
uploading?: boolean;
}) {

return (
<XStack
padding="$l"
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/components/Channel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export function Channel({
>
<ReferencesProvider>
<View
paddingBottom={bottom}
paddingBottom={isChatChannel ? bottom : 'unset'}
backgroundColor="$background"
flex={1}
>
Expand Down Expand Up @@ -330,7 +330,7 @@ export function Channel({
{!isChatChannel && canWrite && !showBigInput && (
<View
position="absolute"
bottom="$s"
bottom={bottom}
flex={1}
width="100%"
alignItems="center"
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/components/ChannelListItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function ChannelListItemIcon({
<ListItem.TextIcon
fallbackText={utils.getChannelTitle(model)}
backgroundColor={backgroundColor ?? '$secondaryBackground'}
rounded={model.type === 'groupDm'}
/>
);
}
Expand Down
37 changes: 26 additions & 11 deletions packages/ui/src/components/ChannelNavSections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,32 @@ export default function ChannelNavSections({
[channels, group.navSections]
);

const hasSomeUnGroupedChannels = useMemo(
const sectionHasChannels = useMemo(
() => unGroupedChannels.length > 0,
[unGroupedChannels]
);

return (
<YStack paddingBottom={paddingBottom} alignSelf="stretch" gap="$s">
{group.navSections?.map((section) => (
<ChannelNavSection
key={section.id}
section={section}
channels={channels}
onSelect={onSelect}
/>
))}
{hasSomeUnGroupedChannels && (
{group.navSections?.map((section) => {
const sectionChannels = channels.filter((c) =>
section.channels?.some((sc) => sc.channelId === c.id)
);

if (sectionChannels.length === 0) {
return null;
}

return (
<ChannelNavSection
key={section.id}
section={section}
channels={sectionChannels}
onSelect={onSelect}
/>
);
})}
{sectionHasChannels && (
<YStack>
<SizableText
paddingHorizontal="$l"
Expand All @@ -53,7 +63,12 @@ export default function ChannelNavSections({
All Channels
</SizableText>
{unGroupedChannels.map((item) => (
<ChannelListItem key={item.id} model={item} onPress={onSelect} />
<ChannelListItem
key={item.id}
model={item}
onPress={onSelect}
useTypeIcon={true}
/>
))}
</YStack>
)}
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/src/components/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,14 @@ const ListItemImageIcon = ({
const ListItemTextIcon = ({
fallbackText,
backgroundColor,
rounded,
}: {
fallbackText: string;
backgroundColor?: ColorProp;
rounded?: boolean;
}) => {
return (
<ListItemIconContainer backgroundColor={backgroundColor}>
<ListItemIconContainer backgroundColor={backgroundColor} rounded={rounded}>
<View flex={1} alignItems="center" justifyContent="center">
<Text fontSize={16} color="$primaryText">
{fallbackText.slice(0, 1).toUpperCase()}
Expand Down
6 changes: 1 addition & 5 deletions packages/ui/src/components/ProfileScreenView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,11 @@ export function Wrapped(props: Props) {
)}
</View>
<View marginTop="$xl">
<ProfileAction title="Edit profile" icon="Draw" />
<ProfileAction
title="App Settings"
icon="Settings"
onPress={props.onAppSettingsPressed}
/>
<ProfileAction title="Connected Accounts" icon="Face" />
<ProfileAction title="Submit Feedback" icon="Mail" />
<ProfileAction title="Contact Support" icon="Messages" />
</View>
</YStack>
</ScrollView>
Expand Down Expand Up @@ -115,7 +111,7 @@ function ProfileRow({
borderRadius={dark ? '$xl' : undefined}
>
<Avatar size="$5xl" contactId={contactId} contact={contact} />
<View marginLeft="$l">
<View marginLeft="$l" flex={1}>
{contact?.nickname ? (
<YStack>
<ContactName
Expand Down