aretherecookies-mobile/js/pages/LandingPage.js

73 lines
1.8 KiB
JavaScript
Raw Normal View History

2018-04-22 11:29:08 -05:00
// @flow
2019-09-21 15:45:07 +00:00
import React from "react";
import { View, Text, AsyncStorage } from "react-native";
// import atcCookieImage from '../imgs/atc-cookie-logo.png';
2019-09-21 15:45:07 +00:00
import { Link } from "react-router-native";
import RouterButton from "react-router-native-button";
import { compose, withHandlers, withState } from "recompose";
import { withRouterContext } from "../enhancers/routeEnhancers";
2018-04-22 11:29:08 -05:00
2019-09-21 15:45:07 +00:00
import theme from "../ui-theme";
2018-04-22 11:29:08 -05:00
2018-05-19 11:17:08 -05:00
type Props = {
skipIfAlreadyChosen: () => void,
setLoading: (val: boolean) => void,
loading: boolean,
router: {
history: {
2019-09-21 15:45:07 +00:00
replace: (route: string) => void
}
}
2018-05-19 11:17:08 -05:00
};
const LandingPage = ({ skipIfAlreadyChosen, loading }: Props) => {
if (loading) {
skipIfAlreadyChosen();
return null;
}
2018-04-22 11:29:08 -05:00
return (
<View
style={{
2019-09-21 15:45:07 +00:00
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
2018-04-22 11:29:08 -05:00
flex: 1,
2019-09-21 15:45:07 +00:00
height: "100%"
}}
>
{/* <Image
2018-05-19 11:17:08 -05:00
source={atcCookieImage}
style={{ height: 320, marginBottom: 10 }}
resizeMode="contain"
/> */}
2019-09-21 15:45:07 +00:00
<Text style={{ fontSize: 24, marginBottom: 30, textAlign: "center", width: 330 }}>
2018-04-22 11:29:08 -05:00
We need to use your location to bring you the best experience possible.
</Text>
2018-05-19 11:17:08 -05:00
<View style={{ width: 275, marginBottom: 30 }}>
2018-08-19 20:02:43 -05:00
<RouterButton to="/list/food" replace title="OK, fine" color={theme.palette.primaryColor} />
2018-04-22 11:29:08 -05:00
</View>
2018-05-19 11:17:08 -05:00
<Link to="/zipcode" replace>
<Text style={{ color: theme.palette.primaryColor, marginBottom: 20, fontSize: 16 }}>
I'd rather not.
</Text>
2018-04-22 11:29:08 -05:00
</Link>
</View>
);
};
2018-05-19 11:17:08 -05:00
export default compose(
withRouterContext,
2019-09-21 15:45:07 +00:00
withState("loading", "setLoading", true),
2018-05-19 11:17:08 -05:00
withHandlers({
skipIfAlreadyChosen: (props: Props) => async () => {
2019-09-21 15:45:07 +00:00
const zipcode = await AsyncStorage.getItem("zipcode");
2018-05-19 11:17:08 -05:00
if (zipcode) {
2019-09-21 15:45:07 +00:00
props.router.history.replace("/list/food");
2018-05-19 11:17:08 -05:00
} else {
props.setLoading(false);
}
2019-09-21 15:45:07 +00:00
}
2018-05-19 11:17:08 -05:00
})
)(LandingPage);