-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/events search re 1910 (#775)
* feat(event): serach WIP * WIP * feat: events filter desktop WIP * feat: search mobile * feat: search ipad
- Loading branch information
Showing
20 changed files
with
3,062 additions
and
2,263 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nodeLinker: node-modules |
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,43 @@ | ||
import { styled, View } from 'tamagui' | ||
|
||
export const Card = styled(View, { | ||
name: 'VoxRadio', | ||
animation: 'bouncy', | ||
variants: { | ||
unstyled: { | ||
false: { | ||
justifyContent: 'center', | ||
height: '$3', | ||
cursor: 'pointer', | ||
width: '100%', | ||
borderRadius: '$4', | ||
padding: '$3', | ||
backgroundColor: '$background', | ||
borderColor: '$borderColor', | ||
borderWidth: 1, | ||
focusStyle: { | ||
backgroundColor: '$backgroundFocus', | ||
borderColor: '$borderColorFocus', | ||
}, | ||
hoverStyle: { | ||
backgroundColor: '$backgroundHover', | ||
borderColor: '$borderColorHover', | ||
}, | ||
}, | ||
}, | ||
active: { | ||
true: { | ||
color: '$colorFocus', | ||
hoverStyle: { | ||
backgroundColor: '$backgroundFocus', | ||
borderColor: '$borderColorFocus', | ||
}, | ||
backgroundColor: '$backgroundFocus', | ||
borderColor: '$borderColorFocus', | ||
}, | ||
}, | ||
} as const, | ||
defaultVariants: { | ||
unstyled: process.env.TAMAGUI_HEADLESS === '1' ? true : false, | ||
}, | ||
}) |
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,63 @@ | ||
import React, { useEffect } from 'react' | ||
import { Keyboard } from 'react-native' | ||
import EventFilterForm from '@/components/EventFilterForm/EventFilterForm' | ||
import VoxCard from '@/components/VoxCard/VoxCard' | ||
import { Sheet, useMedia } from 'tamagui' | ||
import { create } from 'zustand' | ||
|
||
type BottomSheetFilterStates = { | ||
open: boolean | ||
position: number | ||
setOpen: (open: boolean) => void | ||
setPosition: (position: number) => void | ||
} | ||
|
||
export const bottomSheetFilterStates = create<BottomSheetFilterStates>((set) => ({ | ||
open: false, | ||
position: 1, | ||
setOpen: (open) => set({ open }), | ||
setPosition: (position) => set({ position }), | ||
})) | ||
|
||
const BottomSheetFilter = () => { | ||
const states = bottomSheetFilterStates() | ||
const media = useMedia() | ||
useEffect(() => { | ||
const keyboardDidShowListener = Keyboard.addListener('keyboardWillHide', () => { | ||
states.setOpen(false) | ||
}) | ||
return () => { | ||
keyboardDidShowListener.remove() | ||
} | ||
}) | ||
|
||
return media.md ? ( | ||
<Sheet | ||
dismissOnSnapToBottom | ||
moveOnKeyboardChange | ||
snapPointsMode="fit" | ||
animation="medium" | ||
onOpenChange={(open: boolean) => { | ||
states.setOpen(open) | ||
if (!open) { | ||
Keyboard.dismiss() | ||
} | ||
}} | ||
open={states.open} | ||
modal | ||
defaultOpen={false} | ||
> | ||
<Sheet.Overlay /> | ||
<Sheet.Frame overflow="hidden" bg="$white1" position="relative" flex={1}> | ||
<Sheet.Handle backgroundColor="$gray9" mt="$3" height={5} /> | ||
<VoxCard bg="$colorTransparent"> | ||
<VoxCard.Content pt="$1"> | ||
<EventFilterForm /> | ||
</VoxCard.Content> | ||
</VoxCard> | ||
</Sheet.Frame> | ||
</Sheet> | ||
) : null | ||
} | ||
|
||
export default BottomSheetFilter |
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,86 @@ | ||
import React, { RefObject } from 'react' | ||
import { TextInput } from 'react-native' | ||
import { LineSwitch } from '@/components/base/Switch/Switch' | ||
import Text from '@/components/base/Text' | ||
import { YStack } from 'tamagui' | ||
import { create } from 'zustand' | ||
import VoxCard from '../VoxCard/VoxCard' | ||
import SearchBox from './SearchBox' | ||
import { ZoneValue, zoneValues } from './ZoneFilter' | ||
|
||
export type EventFilters = { | ||
zone: ZoneValue | ||
search: string | ||
showPast: boolean | ||
showCancelled: boolean | ||
} | ||
|
||
export type FiltersState = { | ||
searchInputRef: React.RefObject<TextInput | null> | ||
value: EventFilters | ||
setValue: (value: EventFilters) => void | ||
} | ||
|
||
export const defaultEventFilters: EventFilters = { | ||
zone: zoneValues[0], | ||
search: '', | ||
showPast: false, | ||
showCancelled: false, | ||
} | ||
|
||
export const eventFiltersState = create<FiltersState>((set) => ({ | ||
searchInputRef: React.createRef(), | ||
value: defaultEventFilters, | ||
setValue: (x) => set({ value: x }), | ||
})) | ||
|
||
export const Controller = <N extends keyof EventFilters>(props: { | ||
name: N | ||
children: (p: { value: EventFilters[N]; onChange: (v: EventFilters[N]) => void; ref: FiltersState['searchInputRef'] | undefined }) => React.ReactNode | ||
}) => { | ||
const { value, setValue, searchInputRef } = eventFiltersState() | ||
return props.children({ | ||
value: value[props.name], | ||
onChange: (v) => setValue({ ...value, [props.name]: v }), | ||
ref: props.name === 'search' ? searchInputRef : undefined, | ||
}) | ||
} | ||
|
||
type EventFiltersProps = { | ||
onSearchFocus?: () => void | ||
} | ||
|
||
const EventFilters = ({ onSearchFocus }: EventFiltersProps) => { | ||
return ( | ||
<VoxCard bg="$colorTransparent"> | ||
<YStack gap="$5"> | ||
<Controller name="search"> | ||
{(p) => <SearchBox enterKeyHint="done" value={p.value} ref={p.ref as RefObject<TextInput>} onChange={p.onChange} onFocus={onSearchFocus} />} | ||
</Controller> | ||
{/* <Controller name="zone">{(p) => <ZoneFilter {...p} />}</Controller> */} | ||
<YStack gap="$3"> | ||
<Text fontWeight="$5">Temporalité</Text> | ||
<Controller name="showPast"> | ||
{(p) => ( | ||
<LineSwitch checked={p.value} onCheckedChange={p.onChange}> | ||
Afficher les évènements passées | ||
</LineSwitch> | ||
)} | ||
</Controller> | ||
{/* <Controller name="showCancelled"> | ||
{(p) => ( | ||
<LineSwitch checked={p.value} onCheckedChange={p.onChange}> | ||
Afficher les évènements annulées | ||
</LineSwitch> | ||
)} | ||
</Controller> */} | ||
</YStack> | ||
</YStack> | ||
</VoxCard> | ||
) | ||
} | ||
const MemoizedEF = React.memo(EventFilters) | ||
|
||
MemoizedEF.displayName = 'EventFilters' | ||
|
||
export default MemoizedEF |
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,41 @@ | ||
import React, { ComponentProps, forwardRef, useCallback } from 'react' | ||
import { TextInput, TextInputProps } from 'react-native' | ||
import { useForwardRef } from '@/hooks/useForwardRef' | ||
import { Search, XCircle } from '@tamagui/lucide-icons' | ||
import Input from '../base/Input/Input' | ||
import Button from '../Button/Button' | ||
|
||
type SearchBoxProps = { | ||
value: string | ||
onChange: (value: string) => void | ||
onFocus?: TextInputProps['onFocus'] | ||
} & Omit<ComponentProps<typeof Input>, 'value' | 'onChange' | 'onFocus'> | ||
|
||
const SearchBox = forwardRef<TextInput, SearchBoxProps>(({ value, onChange, onFocus, ...rest }, ref) => { | ||
const searchInputRef = useForwardRef(ref) | ||
|
||
const IconRight = useCallback((props: { isInputFill: boolean }) => { | ||
return props.isInputFill ? ( | ||
<Button variant="text" onPress={() => onChange('')}> | ||
<XCircle /> | ||
</Button> | ||
) : ( | ||
<Search /> | ||
) | ||
}, []) | ||
|
||
return ( | ||
<Input | ||
placeholder="Rechercher un événement" | ||
size={'$4'} | ||
ref={searchInputRef} | ||
value={value} | ||
onFocus={onFocus} | ||
iconRight={<IconRight isInputFill={value.length > 0} />} | ||
onChangeText={onChange} | ||
{...rest} | ||
/> | ||
) | ||
}) | ||
|
||
export default SearchBox |
Oops, something went wrong.