-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from TaitoUnited/feat/web-support
Web Support 💻
- Loading branch information
Showing
10 changed files
with
280 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
import { Trans, msg } from '@lingui/macro'; | ||
import { Link } from 'expo-router'; | ||
import { useWindowDimensions } from 'react-native'; | ||
import { useSafeAreaInsets } from 'react-native-safe-area-context'; | ||
import * as DropdownMenu from 'zeego/dropdown-menu'; | ||
|
||
import StatusBar from '~components/common/StatusBar'; | ||
import { IconButton, Stack, Text } from '~components/uikit'; | ||
import { useI18n } from '~services/i18n'; | ||
import { styled, useTheme } from '~styles'; | ||
|
||
export default function Landing() { | ||
const { height } = useWindowDimensions(); | ||
const insets = useSafeAreaInsets(); | ||
const theme = useTheme(); | ||
|
||
return ( | ||
<Wrapper> | ||
<ImageBackground | ||
resizeMode="stretch" | ||
source={require('~assets/landing_background.jpg')} | ||
> | ||
<TopSection | ||
style={{ paddingTop: Math.max(insets.top, theme.space.regular) }} | ||
> | ||
<TopSectionHeader> | ||
<LanguageSelector /> | ||
</TopSectionHeader> | ||
|
||
<TopSectionBody> | ||
<Stack axis="y" spacing="medium"> | ||
<BlackText variant="headingS" align="center" withLineHeight> | ||
<Trans>Welcome to</Trans> | ||
</BlackText> | ||
<BlackText variant="headingXl" align="center"> | ||
<Trans>Taito Template</Trans> | ||
</BlackText> | ||
|
||
<BlackText | ||
variant="headingS" | ||
align="center" | ||
withLineHeight | ||
style={{ marginLeft: 16 }} | ||
> | ||
<Trans>By Taito United</Trans> 💚 | ||
</BlackText> | ||
</Stack> | ||
</TopSectionBody> | ||
</TopSection> | ||
|
||
<BottomSection style={{ minHeight: height * 0.4 }}> | ||
<Stack axis="y" spacing="regular" align="center"> | ||
<WhiteText variant="body" align="center" withLineHeight> | ||
✨ <Trans>Start your journey</Trans> ✨ | ||
</WhiteText> | ||
<Link href="/(auth)/login" asChild> | ||
<Button testID="loginButton"> | ||
<WhiteText variant="bodyBold"> | ||
<Trans>Sign in</Trans> | ||
</WhiteText> | ||
</Button> | ||
</Link> | ||
|
||
<Line /> | ||
<WhiteText variant="overlineSmall"> | ||
<Trans>Or</Trans> | ||
</WhiteText> | ||
<Line /> | ||
|
||
<Link href="/(auth)/signup" asChild> | ||
<Button testID="signInButton"> | ||
<WhiteText variant="bodyBold"> | ||
<Trans>Create an account</Trans> | ||
</WhiteText> | ||
</Button> | ||
</Link> | ||
</Stack> | ||
</BottomSection> | ||
</ImageBackground> | ||
|
||
<StatusBar transparent /> | ||
</Wrapper> | ||
); | ||
} | ||
|
||
function LanguageSelector() { | ||
const { _, setLocale } = useI18n(); | ||
|
||
return ( | ||
<DropdownMenu.Root> | ||
<DropdownMenu.Trigger> | ||
<IconButton icon="globe" color="neutral" /> | ||
</DropdownMenu.Trigger> | ||
<DropdownMenu.Content> | ||
<DropdownMenu.Item key="fi" onSelect={() => setLocale('fi')}> | ||
<DropdownMenu.ItemTitle>{_(msg`Finnish`)}</DropdownMenu.ItemTitle> | ||
</DropdownMenu.Item> | ||
<DropdownMenu.Item key="en" onSelect={() => setLocale('en')}> | ||
<DropdownMenu.ItemTitle>{_(msg`English`)}</DropdownMenu.ItemTitle> | ||
</DropdownMenu.Item> | ||
</DropdownMenu.Content> | ||
</DropdownMenu.Root> | ||
); | ||
} | ||
|
||
// NOTE: it's often the case that the landing screen is very custom and doesn't | ||
// adhere to the design system 100%. In that case, it's ok to use custom styles | ||
// that are out of the design system like here we are using hard coded white color. | ||
|
||
const Wrapper = styled('View', { | ||
position: 'relative', | ||
flex: 1, | ||
}); | ||
|
||
const ImageBackground = styled('ImageBackground', { | ||
height: '100%', | ||
width: '100%', | ||
justifyContent: 'flex-end', | ||
paddingHorizontal: '$xxs', | ||
}); | ||
|
||
const BlackText = styled(Text, { | ||
color: 'rgba(0, 0, 0, 0.8)', | ||
}); | ||
|
||
const WhiteText = styled(Text, { | ||
color: '#fff', | ||
}); | ||
|
||
const TopSection = styled('View', { | ||
flex: 1, | ||
}); | ||
|
||
const TopSectionHeader = styled('View', { | ||
flexDirection: 'row', | ||
justifyContent: 'flex-end', | ||
paddingHorizontal: '$regular', | ||
}); | ||
|
||
const TopSectionBody = styled('View', { | ||
flex: 1, | ||
flexCenter: 'column', | ||
padding: '$large', | ||
}); | ||
|
||
const BottomSection = styled('View', { | ||
padding: '$regular', | ||
paddingTop: '$large', | ||
backgroundColor: 'rgba(0, 0, 0, 0.65)', | ||
borderRadius: '$large', | ||
}); | ||
|
||
const Button = styled('TouchableHighlight', { | ||
padding: '$medium', | ||
borderRadius: '$full', | ||
backgroundColor: 'rgba(0, 0, 0, 1)', | ||
flexCenter: 'row', | ||
flexGrow: 1, | ||
width: '50%', | ||
}).attrs(() => ({ | ||
underlayColor: 'rgba(0, 0, 0, 0.6)', | ||
})); | ||
|
||
const Line = styled('View', { | ||
height: 1, | ||
width: 72, | ||
backgroundColor: 'rgba(255, 255, 255, 0.15)', | ||
}); |
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,38 @@ | ||
import { ScrollViewStyleReset } from 'expo-router/html'; | ||
|
||
// This file is web-only and used to configure the root HTML for every | ||
// web page during static rendering. | ||
// The contents of this function only run in Node.js environments and | ||
// do not have access to the DOM or browser APIs. | ||
export default function Root({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<html lang="en"> | ||
<head> | ||
<meta charSet="utf-8" /> | ||
<meta httpEquiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> | ||
|
||
{/* | ||
Disable body scrolling on web. This makes ScrollView components work closer to how they do on native. | ||
However, body scrolling is often nice to have for mobile web. If you want to enable it, remove this line. | ||
*/} | ||
<ScrollViewStyleReset /> | ||
|
||
{/* Using raw CSS styles as an escape-hatch to ensure the background color never flickers in dark-mode. */} | ||
<style dangerouslySetInnerHTML={{ __html: responsiveBackground }} /> | ||
{/* Add any additional <head> elements that you want globally available on web... */} | ||
</head> | ||
<body>{children}</body> | ||
</html> | ||
); | ||
} | ||
|
||
const responsiveBackground = ` | ||
body { | ||
background-color: #fff; | ||
} | ||
@media (prefers-color-scheme: dark) { | ||
body { | ||
background-color: #000; | ||
} | ||
}`; |
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,25 @@ | ||
import { Alert, Platform } from 'react-native'; | ||
|
||
const alertPolyfill = ( | ||
title: string, | ||
description: string, | ||
options: Array<{ | ||
text: string; | ||
onPress: () => void; | ||
style?: string; | ||
}> | ||
) => { | ||
const result = window.confirm( | ||
[title, description].filter(Boolean).join('\n') | ||
); | ||
|
||
if (result) { | ||
const confirmOption = options.find(({ style }) => style !== 'cancel'); | ||
confirmOption && confirmOption.onPress(); | ||
} else { | ||
const cancelOption = options.find(({ style }) => style === 'cancel'); | ||
cancelOption && cancelOption.onPress(); | ||
} | ||
}; | ||
|
||
export const alert = Platform.OS === 'web' ? alertPolyfill : Alert.alert; |
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.