-
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.
- Loading branch information
1 parent
f52657c
commit 35ab359
Showing
14 changed files
with
290 additions
and
103 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/features/offer/components/OfferCine/CineContentCTA.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,30 @@ | ||
import React, { FC } from 'react' | ||
import styled from 'styled-components/native' | ||
|
||
import { useOfferCTA } from 'features/offer/components/OfferContent/OfferCTAProvider' | ||
import { ButtonWithLinearGradient } from 'ui/components/buttons/buttonWithLinearGradient/ButtonWithLinearGradient' | ||
import { StickyBottomWrapper } from 'ui/components/StickyBottomWrapper/StickyBottomWrapper' | ||
import { Spacer } from 'ui/theme' | ||
|
||
export const CineContentCTA: FC = () => { | ||
const { onPress, wording } = useOfferCTA() | ||
|
||
return ( | ||
<StickyBottomWrapper> | ||
<CallToActionContainer> | ||
<Spacer.Column numberOfSpaces={6} /> | ||
<ButtonWithLinearGradient wording={wording} onPress={onPress} /> | ||
<Spacer.Column numberOfSpaces={6} /> | ||
</CallToActionContainer> | ||
</StickyBottomWrapper> | ||
) | ||
} | ||
|
||
const CallToActionContainer = styled.View(({ theme }) => ({ | ||
alignSelf: 'center', | ||
paddingHorizontal: theme.contentPage.marginHorizontal, | ||
width: '100%', | ||
...(!theme.isMobileViewport && { | ||
maxWidth: theme.contentPage.maxWidth, | ||
}), | ||
})) |
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
43 changes: 43 additions & 0 deletions
43
src/features/offer/components/OfferContent/OfferCTAProvider.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,43 @@ | ||
import React, { createContext, useContext, ReactNode, useState, useCallback, useMemo } from 'react' | ||
|
||
interface OfferCTAContextValue { | ||
wording: string | ||
onPress: () => void | ||
setButton: (wording: string, onPress: () => void) => void | ||
showButton: (isVisible: boolean) => void | ||
isButtonVisible: boolean | ||
} | ||
|
||
const OfferCTAContext = createContext<OfferCTAContextValue | undefined>(undefined) | ||
|
||
interface OfferCTAProviderProps { | ||
children: ReactNode | ||
} | ||
|
||
export const OfferCTAProvider: React.FC<OfferCTAProviderProps> = ({ children }) => { | ||
const [wording, setWording] = useState<string>('') | ||
const [isVisible, setIsVisible] = useState<boolean>(false) | ||
const [onPress, setOnPress] = useState<() => void>(() => () => { | ||
return | ||
}) | ||
|
||
const setButton = useCallback((newWording: string, newOnPress: () => void) => { | ||
setWording(newWording) | ||
setOnPress(() => newOnPress) | ||
}, []) | ||
|
||
const value = useMemo( | ||
() => ({ wording, onPress, setButton, showButton: setIsVisible, isButtonVisible: isVisible }), | ||
[isVisible, onPress, setButton, wording] | ||
) | ||
|
||
return <OfferCTAContext.Provider value={value}>{children}</OfferCTAContext.Provider> | ||
} | ||
|
||
export const useOfferCTA = (): OfferCTAContextValue => { | ||
const context = useContext(OfferCTAContext) | ||
if (!context) { | ||
throw new Error('useOfferCTAButton must be used within an OfferCTAProvider') | ||
} | ||
return context | ||
} |
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.