-
Notifications
You must be signed in to change notification settings - Fork 26
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 #3397 from tloncorp/lb/native-channel-search
mobile: channel search
- Loading branch information
Showing
51 changed files
with
1,039 additions
and
87 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Icon } from '@tloncorp/ui'; | ||
import { Input } from '@tloncorp/ui/src/components/Input'; | ||
|
||
export default { | ||
['Basic']: () => ( | ||
<Input size="$m"> | ||
<Input.Area placeholder="Enter details..." /> | ||
</Input> | ||
), | ||
['With Left Icon']: () => ( | ||
<Input> | ||
<Input.Icon> | ||
<Icon type="Face" /> | ||
</Input.Icon> | ||
<Input.Area placeholder="Find pal" /> | ||
</Input> | ||
), | ||
}; |
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,10 @@ | ||
import { SearchBar } from '@tloncorp/ui'; | ||
|
||
export default { | ||
base: ( | ||
<SearchBar | ||
onChangeQuery={() => {}} | ||
placeholder="Search in Internet Cafe..." | ||
/> | ||
), | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import type { NativeStackScreenProps } from '@react-navigation/native-stack'; | ||
import { useChannelSearch } from '@tloncorp/shared/dist'; | ||
import * as db from '@tloncorp/shared/dist/db'; | ||
import { XStack, YStack } from '@tloncorp/ui'; | ||
import { Button, SearchBar, SearchResults } from '@tloncorp/ui'; | ||
import { useCallback, useLayoutEffect, useState } from 'react'; | ||
import { SafeAreaView } from 'react-native-safe-area-context'; | ||
|
||
import type { HomeStackParamList } from '../types'; | ||
|
||
type ChannelSearchProps = NativeStackScreenProps< | ||
HomeStackParamList, | ||
'ChannelSearch' | ||
>; | ||
|
||
export default function ChannelSearch({ | ||
route, | ||
navigation, | ||
}: ChannelSearchProps) { | ||
const { channel } = route.params; | ||
const { result: group } = db.useGroupByChannel(channel.id); | ||
const [query, setQuery] = useState(''); | ||
const { posts, loading, errored, hasMore, loadMore, searchedThroughDate } = | ||
useChannelSearch(channel.id, query); | ||
|
||
// handle full screen view without bottom nav, resets on dismout | ||
useLayoutEffect(() => { | ||
navigation.getParent()?.setOptions({ | ||
headerShown: false, | ||
tabBarStyle: { display: 'none' }, | ||
}); | ||
|
||
return () => { | ||
navigation.getParent()?.setOptions({ | ||
tabBarStyle: undefined, | ||
}); | ||
}; | ||
}, [navigation]); | ||
|
||
const navigateToPost = useCallback( | ||
(post: db.PostWithRelations) => { | ||
navigation.navigate('Channel', { | ||
group: group!, | ||
channel, | ||
selectedPost: post, | ||
}); | ||
}, | ||
[channel, group, navigation] | ||
); | ||
|
||
return ( | ||
<SafeAreaView edges={['top']} style={{ flex: 1 }}> | ||
<YStack flex={1} paddingHorizontal="$l"> | ||
<XStack gap="$l"> | ||
<SearchBar | ||
onChangeQuery={setQuery} | ||
placeholder={`Search ${channel.title}`} | ||
/> | ||
<Button minimal onPress={() => navigation.pop()}> | ||
<Button.Text>Cancel</Button.Text> | ||
</Button> | ||
</XStack> | ||
|
||
<SearchResults | ||
posts={posts ?? []} | ||
navigateToPost={navigateToPost} | ||
search={{ | ||
query, | ||
loading, | ||
errored, | ||
hasMore, | ||
loadMore, | ||
searchComplete: !loading && !hasMore, | ||
numResults: posts?.length ?? 0, | ||
searchedThroughDate, | ||
}} | ||
/> | ||
</YStack> | ||
</SafeAreaView> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
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.