-
-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1184 from The-Commit-Company/fetch-channels-and-d…
…ms-list-on-app-homepage feat(mobile): channel list UI
- Loading branch information
Showing
30 changed files
with
271 additions
and
24 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,112 @@ | ||
import { View } from 'react-native'; | ||
import { Text } from '@components/nativewindui/Text'; | ||
import { ThemeToggle } from '@components/nativewindui/ThemeToggle'; | ||
import ChannelList from '@components/features/chat/ChannelList/ChannelList'; | ||
|
||
export default function Home() { | ||
return ( | ||
<View className="flex flex-1 items-center justify-center"> | ||
<Text className="text-4xl font-bold">Home</Text> | ||
<View className="flex flex-col gap-4"> | ||
<ThemeToggle /> | ||
<ChannelList | ||
channels={[ | ||
{ | ||
name: "channel_001", | ||
channel_name: "general", | ||
type: "Public", | ||
channel_description: "A channel for general discussions.", | ||
is_direct_message: 0, | ||
is_self_message: 0, | ||
is_archived: 0, | ||
creation: "2024-01-01T12:00:00Z", | ||
owner: "user_001", | ||
last_message_details: { | ||
sender: "user_002", | ||
content: "Hello everyone!", | ||
}, | ||
last_message_timestamp: "2024-12-01T10:00:00Z", | ||
}, | ||
{ | ||
name: "channel_002", | ||
channel_name: "announcements", | ||
type: "Open", | ||
channel_description: "Official announcements and updates.", | ||
is_direct_message: 0, | ||
is_self_message: 0, | ||
is_archived: 0, | ||
creation: "2024-01-10T15:00:00Z", | ||
owner: "user_003", | ||
last_message_details: { | ||
sender: "admin", | ||
content: "Welcome to the new announcements channel!", | ||
}, | ||
last_message_timestamp: "2024-12-05T14:30:00Z", | ||
}, | ||
{ | ||
name: "channel_003", | ||
channel_name: "team-alpha", | ||
type: "Private", | ||
channel_description: "A private channel for Team Alpha members.", | ||
is_direct_message: 0, | ||
is_self_message: 0, | ||
is_archived: 0, | ||
creation: "2024-02-15T10:00:00Z", | ||
owner: "user_004", | ||
last_message_details: { | ||
sender: "user_005", | ||
content: "Let's finalize the project timeline.", | ||
}, | ||
last_message_timestamp: "2024-12-10T09:15:00Z", | ||
}, | ||
{ | ||
name: "channel_004", | ||
channel_name: "support", | ||
type: "Public", | ||
channel_description: "A place to get support and ask questions.", | ||
is_direct_message: 0, | ||
is_self_message: 0, | ||
is_archived: 0, | ||
creation: "2024-03-20T08:30:00Z", | ||
owner: "user_006", | ||
last_message_details: { | ||
sender: "user_007", | ||
content: "Can someone help with deployment?", | ||
}, | ||
last_message_timestamp: "2024-12-12T16:45:00Z", | ||
}, | ||
{ | ||
name: "channel_005", | ||
channel_name: "fun-zone", | ||
type: "Open", | ||
channel_description: "A channel for fun and casual chats.", | ||
is_direct_message: 0, | ||
is_self_message: 0, | ||
is_archived: 0, | ||
creation: "2024-04-01T12:00:00Z", | ||
owner: "user_008", | ||
last_message_details: { | ||
sender: "user_009", | ||
content: "Check out this meme!", | ||
}, | ||
last_message_timestamp: "2024-12-15T11:00:00Z", | ||
}, | ||
{ | ||
name: "channel_006", | ||
channel_name: "dev-discussions", | ||
type: "Private", | ||
channel_description: "Discussions about development and code.", | ||
is_direct_message: 0, | ||
is_self_message: 0, | ||
is_archived: 0, | ||
creation: "2024-05-25T09:00:00Z", | ||
owner: "user_010", | ||
last_message_details: { | ||
sender: "user_011", | ||
content: "Have you seen the latest React update?", | ||
}, | ||
last_message_timestamp: "2024-12-18T14:00:00Z", | ||
}, | ||
]} | ||
onChannelSelect={() => console.log('channel selected')} | ||
onLongPress={() => console.log('channel long pressed')} /> | ||
</View> | ||
) | ||
} |
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
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
apps/mobile/components/features/chat/ChannelList/ChannelIcon.tsx
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,18 @@ | ||
import GlobeIcon from '@assets/icons/GlobeIcon.svg'; | ||
import HashIcon from '@assets/icons/HashIcon.svg'; | ||
import LockIcon from '@assets/icons/LockIcon.svg'; | ||
|
||
const iconSize = 18 | ||
|
||
export const ChannelIcon = ({ type, fill, size = iconSize }: { type: string, fill?: string, size?: number }) => { | ||
switch (type) { | ||
case 'Open': | ||
return <GlobeIcon fill={fill} height={size} width={size} /> | ||
case 'Private': | ||
return <LockIcon fill={fill} height={size} width={size} /> | ||
case 'Public': | ||
return <HashIcon fill={fill} height={size} width={size} /> | ||
default: | ||
return <HashIcon fill={fill} height={size} width={size} /> | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
apps/mobile/components/features/chat/ChannelList/ChannelList.tsx
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,93 @@ | ||
import React, { useState } from 'react'; | ||
import { View, TouchableOpacity, Pressable, StyleSheet } from 'react-native'; | ||
import { ChannelListItem } from '../../../../types/channels'; | ||
import { ChannelIcon } from './ChannelIcon'; | ||
import { Text } from '@components/nativewindui/Text'; | ||
import ChevronDownIcon from '@assets/icons/ChevronDownIcon.svg'; | ||
import ChevronRightIcon from '@assets/icons/ChevronRightIcon.svg'; | ||
import { useColorScheme } from '@hooks/useColorScheme'; | ||
import PlusIcon from '@assets/icons/PlusIcon.svg'; | ||
|
||
interface ChannelListProps { | ||
channels: ChannelListItem[]; | ||
onChannelSelect: (channelId: string) => void; | ||
onLongPress: (channelId: string) => void; | ||
} | ||
|
||
const ChannelList = ({ channels, onChannelSelect, onLongPress }: ChannelListProps) => { | ||
|
||
const [isExpanded, setIsExpanded] = useState(true) | ||
const colors = useColorScheme() | ||
|
||
const toggleAccordion = () => { | ||
setIsExpanded((prev) => !prev) | ||
} | ||
|
||
return ( | ||
<View style={styles.container}> | ||
<TouchableOpacity onPress={toggleAccordion} style={styles.header} activeOpacity={0.7}> | ||
<Text style={styles.headerText}>Channels</Text> | ||
{isExpanded ? <ChevronDownIcon fill={colors.colors.icon} /> : <ChevronRightIcon fill={colors.colors.icon} />} | ||
</TouchableOpacity> | ||
{isExpanded && <> | ||
{channels.map((channel) => ( | ||
<Pressable | ||
key={channel.name} | ||
onPress={() => onChannelSelect(channel.name)} | ||
onLongPress={() => onLongPress(channel.name)} | ||
style={styles.channelRow} | ||
> | ||
<ChannelIcon type={channel.type} fill={colors.colors.icon} /> | ||
<Text style={styles.channelText}>{channel.channel_name}</Text> | ||
</Pressable> | ||
))} | ||
<Pressable style={styles.addChannelButton} | ||
onPress={() => console.log('Create channel pressed')}> | ||
<PlusIcon fill={colors.colors.icon} height={18} width={18} /> | ||
<Text style={styles.addChannelText}>Add Channel</Text> | ||
</Pressable> | ||
</>} | ||
</View> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
padding: 10, | ||
}, | ||
header: { | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
paddingVertical: 12, | ||
paddingHorizontal: 10, | ||
}, | ||
headerText: { | ||
fontWeight: '600', | ||
fontSize: 16, | ||
}, | ||
channelRow: { | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
paddingVertical: 6, | ||
paddingHorizontal: 10, | ||
borderRadius: 10, | ||
}, | ||
channelText: { | ||
marginLeft: 12, | ||
fontSize: 16, | ||
}, | ||
addChannelButton: { | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
paddingVertical: 12, | ||
paddingHorizontal: 10, | ||
borderRadius: 10, | ||
}, | ||
addChannelText: { | ||
marginLeft: 12, | ||
fontSize: 16, | ||
}, | ||
}) | ||
|
||
export default ChannelList |
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
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.