-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [#172975727] Adds the bonus information screen (#1850)
* [#172975727] Adds the bonus information screen * Adds missing file * Adds minor comments * Adds mocked data * Fixes lint * Supporting navigation from list to bonus information * [#172975727] fix lint warnings * [#172975727] minor changes * [#172975727] refactoring Co-authored-by: Matteo Boschi <[email protected]>
- Loading branch information
1 parent
c0de9e8
commit 4ca3b57
Showing
11 changed files
with
142 additions
and
18 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
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
91 changes: 91 additions & 0 deletions
91
ts/features/bonusVacanze/screens/BonusInformationScreen.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,91 @@ | ||
import { View } from "native-base"; | ||
import * as React from "react"; | ||
import { Image, StyleSheet } from "react-native"; | ||
import { NavigationInjectedProps } from "react-navigation"; | ||
import { connect } from "react-redux"; | ||
import { Dispatch } from "redux"; | ||
import { withLoadingSpinner } from "../../../components/helpers/withLoadingSpinner"; | ||
import BaseScreenComponent from "../../../components/screens/BaseScreenComponent"; | ||
import { EdgeBorderComponent } from "../../../components/screens/EdgeBorderComponent"; | ||
import ScreenContent from "../../../components/screens/ScreenContent"; | ||
import Markdown from "../../../components/ui/Markdown"; | ||
import I18n from "../../../i18n"; | ||
import { navigateBack } from "../../../store/actions/navigation"; | ||
import { ReduxProps } from "../../../store/actions/types"; | ||
import themeVariables from "../../../theme/variables"; | ||
import { FooterTwoButtons } from "../components/markdown/FooterTwoButtons"; | ||
import { BonusItem } from "../types/bonusList"; | ||
|
||
type NavigationParams = Readonly<{ | ||
bonusItem: BonusItem; | ||
}>; | ||
|
||
type Props = ReduxProps & | ||
NavigationInjectedProps<NavigationParams> & | ||
ReturnType<typeof mapDispatchToProps>; | ||
|
||
const styles = StyleSheet.create({ | ||
mainContent: { | ||
flex: 1 | ||
}, | ||
markdownContainer: { | ||
paddingLeft: themeVariables.contentPadding, | ||
paddingRight: themeVariables.contentPadding | ||
}, | ||
image: { | ||
resizeMode: "contain", | ||
width: "100%", | ||
height: 210, | ||
alignSelf: "center" | ||
} | ||
}); | ||
|
||
/** | ||
* A screen to explain how the bonus activation works and how it will be assigned | ||
*/ | ||
const BonusInformationScreen: React.FunctionComponent<Props> = props => { | ||
const [isMarkdownLoaded, setMarkdownLoaded] = React.useState(false); | ||
|
||
const getBonusItem = () => props.navigation.getParam("bonusItem"); | ||
|
||
const bonusItem = getBonusItem(); | ||
const ContainerComponent = withLoadingSpinner(() => ( | ||
<BaseScreenComponent goBack={true} headerTitle={bonusItem.name}> | ||
<ScreenContent | ||
title={bonusItem.name} | ||
subtitle={bonusItem.description} | ||
bounces={false} | ||
> | ||
{bonusItem.cover && ( | ||
<Image source={{ uri: bonusItem.cover }} style={styles.image} /> | ||
)} | ||
<View style={styles.markdownContainer}> | ||
<Markdown onLoadEnd={() => setMarkdownLoaded(true)}> | ||
{/* TODO Replace with correct text of bonus */ | ||
I18n.t("profile.main.privacy.exportData.info.body")} | ||
</Markdown> | ||
{isMarkdownLoaded && <EdgeBorderComponent />} | ||
</View> | ||
</ScreenContent> | ||
{isMarkdownLoaded && ( | ||
<FooterTwoButtons | ||
onRight={props.requestBonusActivation} | ||
title={I18n.t("bonus.bonusVacanza.cta.requestBonus")} | ||
onCancel={props.navigateBack} | ||
/> | ||
)} | ||
</BaseScreenComponent> | ||
)); | ||
return <ContainerComponent isLoading={!isMarkdownLoaded} />; | ||
}; | ||
|
||
const mapDispatchToProps = (dispatch: Dispatch) => ({ | ||
// TODO add bonus request action or just navigate to TOS screen (?) | ||
requestBonusActivation: () => null, | ||
navigateBack: () => dispatch(navigateBack()) | ||
}); | ||
|
||
export default connect( | ||
undefined, | ||
mapDispatchToProps | ||
)(BonusInformationScreen); |
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