-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(PC-31854) feat(venue): add video section + fake video player component
- Loading branch information
Mathieu Meissonnier
committed
Sep 20, 2024
1 parent
a331434
commit 63572e1
Showing
15 changed files
with
197 additions
and
2 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
64 changes: 64 additions & 0 deletions
64
src/features/venue/components/VideoSection/FakeVideoPlayer.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,64 @@ | ||
import React, { FunctionComponent } from 'react' | ||
import { View } from 'react-native' | ||
// eslint-disable-next-line no-restricted-imports | ||
import FastImage, { Source } from 'react-native-fast-image' | ||
import styled from 'styled-components/native' | ||
|
||
import { TouchableOpacity } from 'ui/components/TouchableOpacity' | ||
import { Play } from 'ui/svg/icons/Play' | ||
import { getSpacing } from 'ui/theme' | ||
|
||
type FakeVideoPlayerProps = { | ||
imageSource: number | Source | ||
width: number | ||
height: number | ||
onPress: () => void | ||
} | ||
|
||
export const FakeVideoPlayer: FunctionComponent<FakeVideoPlayerProps> = ({ | ||
imageSource, | ||
width, | ||
height, | ||
onPress, | ||
}) => { | ||
return ( | ||
<TouchableOpacity onPress={onPress}> | ||
<Container height={height} width={width}> | ||
<PlayIconWrapper shouldRasterizeIOS> | ||
<PlayIcon /> | ||
</PlayIconWrapper> | ||
<BackgroundImage source={imageSource} resizeMode="cover" /> | ||
</Container> | ||
</TouchableOpacity> | ||
) | ||
} | ||
|
||
const Container = styled.View<Pick<FakeVideoPlayerProps, 'height' | 'width'>>( | ||
({ theme, width, height }) => ({ | ||
width, | ||
height, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
backgroundColor: theme.colors.black, | ||
}) | ||
) | ||
|
||
const PlayIconWrapper = styled(View)({ | ||
position: 'absolute', | ||
width: '100%', | ||
height: '100%', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
zIndex: 2, | ||
}) | ||
|
||
const BackgroundImage = styled(FastImage)({ | ||
width: '100%', | ||
height: '100%', | ||
opacity: 0.4, | ||
}) | ||
|
||
const PlayIcon = styled(Play).attrs(({ theme }) => ({ | ||
size: getSpacing(24), | ||
color: theme.colors.brownLight, | ||
}))`` |
49 changes: 49 additions & 0 deletions
49
src/features/venue/components/VideoSection/VideoSection.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,49 @@ | ||
import React, { useRef } from 'react' | ||
import { useWindowDimensions } from 'react-native' | ||
import { useTheme } from 'styled-components' | ||
import styled from 'styled-components/native' | ||
|
||
import { VenueTypeCodeKey } from 'api/gen' | ||
import { | ||
getVideoPlayerDimensions, | ||
RATIO169, | ||
} from 'features/home/components/helpers/getVideoPlayerDimensions' | ||
import { FakeVideoPlayer } from 'features/venue/components/VideoSection/FakeVideoPlayer' | ||
import { getFakeVideoBackground } from 'features/venue/helpers/getFakeVideoBackground' | ||
import { SectionWithDivider } from 'ui/components/SectionWithDivider' | ||
import { getSpacing, Spacer, Typo } from 'ui/theme' | ||
import { getHeadingAttrs } from 'ui/theme/typographyAttrs/getHeadingAttrs' | ||
|
||
type VideoSectionProps = { | ||
onPress: () => void | ||
venueType?: VenueTypeCodeKey | null | ||
} | ||
|
||
export const VideoSection = ({ venueType, onPress }: VideoSectionProps) => { | ||
const { isDesktopViewport } = useTheme() | ||
const { width: windowWidth } = useWindowDimensions() | ||
const { playerHeight, playerWidth } = getVideoPlayerDimensions( | ||
isDesktopViewport, | ||
windowWidth, | ||
RATIO169 | ||
) | ||
|
||
const fakeVideoBackgroundSource = useRef(getFakeVideoBackground(venueType)).current | ||
|
||
return ( | ||
<SectionWithDivider visible gap={6}> | ||
<Title /> | ||
<FakeVideoPlayer | ||
imageSource={fakeVideoBackgroundSource} | ||
height={playerHeight} | ||
width={playerWidth} | ||
onPress={onPress} | ||
/> | ||
<Spacer.Column numberOfSpaces={2} /> | ||
</SectionWithDivider> | ||
) | ||
} | ||
|
||
const Title = styled(Typo.Title3).attrs({ ...getHeadingAttrs(2), children: 'Vidéo de ce lieu' })({ | ||
marginLeft: getSpacing(6), | ||
}) |
9 changes: 9 additions & 0 deletions
9
src/features/venue/components/VideoSection/VideoSection.web.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,9 @@ | ||
import { Source } from 'react-native-fast-image' | ||
|
||
type VideoSectionProps = { | ||
title: string | ||
source: number | Source | ||
onPress: () => void | ||
} | ||
|
||
export const VideoSection = (_props: VideoSectionProps) => null |
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,34 @@ | ||
import { VenueTypeCodeKey } from 'api/gen' | ||
import bookstore from 'ui/images/bg-bookstore.jpeg' | ||
import concert from 'ui/images/bg-concert.jpeg' | ||
import movie from 'ui/images/bg-movie.jpeg' | ||
import museum from 'ui/images/bg-museum.jpeg' | ||
import other from 'ui/images/bg-other.jpeg' | ||
import store from 'ui/images/bg-store.jpeg' | ||
|
||
export const getFakeVideoBackground = (type?: VenueTypeCodeKey | null) => { | ||
switch (type) { | ||
case VenueTypeCodeKey.BOOKSTORE: | ||
case VenueTypeCodeKey.LIBRARY: | ||
return bookstore | ||
case VenueTypeCodeKey.MOVIE: | ||
case VenueTypeCodeKey.TRAVELING_CINEMA: | ||
return movie | ||
case VenueTypeCodeKey.FESTIVAL: | ||
case VenueTypeCodeKey.CONCERT_HALL: | ||
case VenueTypeCodeKey.PERFORMING_ARTS: | ||
return concert | ||
case VenueTypeCodeKey.RECORD_STORE: | ||
case VenueTypeCodeKey.DISTRIBUTION_STORE: | ||
case VenueTypeCodeKey.CREATIVE_ARTS_STORE: | ||
case VenueTypeCodeKey.MUSICAL_INSTRUMENT_STORE: | ||
return store | ||
case VenueTypeCodeKey.VISUAL_ARTS: | ||
case VenueTypeCodeKey.CULTURAL_CENTRE: | ||
case VenueTypeCodeKey.MUSEUM: | ||
case VenueTypeCodeKey.PATRIMONY_TOURISM: | ||
return museum | ||
default: | ||
return other | ||
} | ||
} |
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,9 @@ | ||
declare module '*.png' { | ||
const value: any | ||
export = value | ||
} | ||
|
||
declare module '*.jpeg' { | ||
const value: any | ||
export = value | ||
} |
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.