Files
jellyfin-audio-player/src/screens/Onboarding/index.tsx

81 lines
2.5 KiB
TypeScript
Raw Normal View History

2020-08-09 17:49:36 +02:00
import React, { useCallback, useEffect } from 'react';
import styled from 'styled-components/native';
import { useNavigation } from '@react-navigation/native';
import { NavigationProp } from 'screens';
2022-05-18 22:10:06 +02:00
import { useAppDispatch, useTypedSelector } from 'store';
2020-08-09 17:49:36 +02:00
import { setOnboardingStatus } from 'store/settings/actions';
2020-11-02 22:50:00 +01:00
import { t } from '@localisation';
2022-01-02 21:14:05 +01:00
import Button from 'components/Button';
import { Header, Text as BaseText } from 'components/Typography';
import { ShadowWrapper } from 'components/Shadow';
2020-08-09 17:49:36 +02:00
const Container = styled.SafeAreaView`
flex: 1;
justify-content: center;
`;
const TextContainer = styled.ScrollView`
padding: 25px;
`;
const Text = styled(BaseText)`
2020-08-09 17:49:36 +02:00
text-align: center;
margin-bottom: 16px;
2020-08-09 17:49:36 +02:00
`;
const ButtonContainer = styled.View`
margin-top: 50px;
`;
const Logo = styled.Image`
width: 150px;
height: 150px;
margin: 0 auto 50px auto;
border-radius: 12px;
border: 1px solid #e6e6e6;
2020-08-09 17:49:36 +02:00
`;
function Onboarding() {
// Get account from Redux and dispatcher
const account = useTypedSelector(state => state.settings.jellyfin);
2022-05-18 22:10:06 +02:00
const dispatch = useAppDispatch();
2020-08-09 17:49:36 +02:00
// Also retrieve the navigation handler so that we can open the modal in
// which the Jellyfin server is set
const navigation = useNavigation<NavigationProp>();
const handleClick = useCallback(() => navigation.navigate('SetJellyfinServer'), [navigation]);
// We'll also respond to any change in the account, setting the onboarding
// status to true, so that the app becomes available.
useEffect(() => {
if (account) {
dispatch(setOnboardingStatus(true));
}
}, [account, dispatch]);
return (
<Container>
<TextContainer contentContainerStyle={{ flexGrow: 1, justifyContent: 'center' }}>
<ShadowWrapper size="medium">
<Logo source={require('../../assets/icons/app-icon.png')} />
</ShadowWrapper>
<Header style={{ textAlign: 'center', marginBottom: 24 }}>
2020-11-02 22:50:00 +01:00
{t('onboarding-welcome')}
</Header>
2020-08-09 17:49:36 +02:00
<Text>
2020-11-02 22:50:00 +01:00
{t('onboarding-intro')}
2020-08-09 17:49:36 +02:00
</Text>
<Text>
2020-11-02 22:50:00 +01:00
{t('onboarding-cta')}
2020-08-09 17:49:36 +02:00
</Text>
<ButtonContainer>
2022-01-02 21:14:05 +01:00
<Button
title={t('set-jellyfin-server')}
onPress={handleClick}/>
2020-08-09 17:49:36 +02:00
</ButtonContainer>
</TextContainer>
</Container>
);
}
export default Onboarding;