Skip to content

Commit

Permalink
Merge pull request #285 from cultuurnet/bugfix/UIT-213-onboarding-scroll
Browse files Browse the repository at this point in the history
Onboarding screen styling on smaller devices
  • Loading branch information
chennara authored Nov 14, 2023
2 parents d07ca36 + 1667333 commit 2fe8b7c
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 47 deletions.
9 changes: 5 additions & 4 deletions src/_components/safeAreaView/SafeAreaView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { forwardRef } from 'react';
import { ScrollView, ScrollViewProps, StatusBarStyle } from 'react-native';
import { ScrollView, ScrollViewProps, StatusBarStyle, StyleProp, ViewStyle } from 'react-native';
import { NativeSafeAreaViewProps as RNSafeAreaViewProps } from 'react-native-safe-area-context';

import { ThemeColor } from '../../_styles/theme';
Expand All @@ -11,6 +11,7 @@ export type TSafeAreaViewProps = {
barStyle?: StatusBarStyle;
isScrollable?: boolean;
stickyHeaderIndices?: number[];
style?: StyleProp<ViewStyle>;
} & RNSafeAreaViewProps &
Pick<ScrollViewProps, 'keyboardShouldPersistTaps'>;

Expand All @@ -29,10 +30,10 @@ const SafeAreaView = forwardRef<ScrollView, TSafeAreaViewProps>(
) => {
if (isScrollable) {
return (
<Styled.SafeAreaViewContainer backgroundColor={backgroundColor} isScrollable={isScrollable} {...props}>
<Styled.SafeAreaViewContainer backgroundColor={backgroundColor} {...props}>
<FocusAwareStatusBar barStyle={barStyle} />
<ScrollView
contentContainerStyle={{ paddingBottom: 95 }}
contentContainerStyle={[{ flexGrow: 1 }, props.style]}
keyboardShouldPersistTaps={keyboardShouldPersistTaps}
ref={ref}
stickyHeaderIndices={stickyHeaderIndices}
Expand All @@ -43,7 +44,7 @@ const SafeAreaView = forwardRef<ScrollView, TSafeAreaViewProps>(
);
} else {
return (
<Styled.SafeAreaViewContainer backgroundColor={backgroundColor} isScrollable={isScrollable} {...props}>
<Styled.SafeAreaViewContainer backgroundColor={backgroundColor} {...props}>
<FocusAwareStatusBar barStyle={barStyle} />
{children}
</Styled.SafeAreaViewContainer>
Expand Down
2 changes: 1 addition & 1 deletion src/_components/safeAreaView/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from 'styled-components/native';
import { ThemeColor } from '../../_styles/theme';
import { getColor } from '../../_utils';

export const SafeAreaViewContainer = styled(SafeAreaView)<{ backgroundColor: ThemeColor; isScrollable?: boolean }>`
export const SafeAreaViewContainer = styled(SafeAreaView)<{ backgroundColor: ThemeColor }>`
background-color: ${({ backgroundColor }) => getColor(backgroundColor)};
flex: 1;
`;
1 change: 0 additions & 1 deletion src/_routing/_components/RootStackNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export const RootStackNavigator = () => {
<RootStack.Screen component={Error} name="Error" options={{ gestureEnabled: false }} />
<RootStack.Screen component={Search} name="Search" />
</RootStack.Group>

<RootStack.Screen
component={About}
name="About"
Expand Down
10 changes: 4 additions & 6 deletions src/onboarding/Onboarding.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useWindowDimensions } from 'react-native';
import { t } from 'i18next';

import { Counter } from '../_assets/images';
import { Analytics, SafeAreaView, Typography } from '../_components';
import { Analytics, Button, SafeAreaView, Typography } from '../_components';
import { ConfigUrl } from '../_config';
import { useStackNavigation, useToggle } from '../_hooks';
import { StorageKey } from '../_models';
Expand All @@ -12,7 +11,6 @@ import * as Styled from './style';
const Onboarding = () => {
const [isChecked, toggleChecked] = useToggle(false);
const navigation = useStackNavigation();
const { height } = useWindowDimensions();

const onPress = () => {
storage.set(StorageKey.IsPolicyApproved, true);
Expand All @@ -22,12 +20,12 @@ const Onboarding = () => {
return (
<>
<Analytics screenName="Onboarding" />
<SafeAreaView backgroundColor="neutral.0" barStyle="dark-content" isScrollable={false}>
<SafeAreaView backgroundColor="neutral.0" barStyle="dark-content">
<Styled.TopContainer>
<Styled.TitleText color="secondary.700" fontStyle="bold" size="large">
{t('ONBOARDING.TITLE')}
</Styled.TitleText>
{height > 600 && <Styled.Image source={Counter} />}
<Styled.Image source={Counter} />
<Styled.IntroText align="center" color="neutral.900">
{t('ONBOARDING.INTRO')}
</Styled.IntroText>
Expand All @@ -46,7 +44,7 @@ const Onboarding = () => {
/>
</Styled.TopContainer>
<Styled.BottomContainer>
<Styled.ConfirmButton disabled={!isChecked} label={t('ONBOARDING.CONFIRM')} onPress={onPress} />
<Button disabled={!isChecked} label={t('ONBOARDING.CONFIRM')} onPress={onPress} />
</Styled.BottomContainer>
</SafeAreaView>
</>
Expand Down
10 changes: 2 additions & 8 deletions src/onboarding/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import styled from 'styled-components/native';
import { Button, Checkbox, Typography } from '../_components';

export const TopContainer = styled.View`
flex: 1;
padding: 0px 16px;
align-items: center;
`;
Expand Down Expand Up @@ -35,16 +36,9 @@ export const ConfirmViewContainer = styled.View`
`;

export const BottomContainer = styled.View`
position: absolute;
bottom: 35px;
width: 100%;
padding: 16px;
`;

export const LinkButton = styled(Button)`
margin: 0 5px;
`;

export const ConfirmButton = styled(Button)`
margin: 0 auto;
width: 90%;
`;
6 changes: 0 additions & 6 deletions src/profile/UitpasCard/style.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import styled from 'styled-components/native';

import { SafeAreaView } from '../../_components';

const CARD_MARGIN = 20;

export const ContentContainer = styled.View<{ screenWidth: number }>`
Expand Down Expand Up @@ -29,10 +27,6 @@ export const CardContainer = styled.View`
margin: 25px 0px;
`;

export const SafeAreaViewContainer = styled(SafeAreaView)`
background-color: ${({ theme }) => theme.palette.neutral['100']};
`;

export const LogoContainer = styled.View`
margin-left: -40px;
margin-top: 15px;
Expand Down
4 changes: 1 addition & 3 deletions src/profile/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const ActionButton = styled(Button)`

export const SafeAreaViewContainer = styled(SafeAreaView)`
background-color: ${({ theme }) => theme.palette.neutral['100']};
padding-bottom: 40px;
padding-bottom: 95px;
`;

export const TopContent = styled.View`
Expand All @@ -31,8 +31,6 @@ export const Divider = styled.View`
height: 4px;
`;



export const TopContainer = styled.View`
position: relative;
/* background-color: ${({ theme }) => theme.palette.secondary['500']}; */
Expand Down
32 changes: 15 additions & 17 deletions src/shop/Shop.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';

import { Analytics, EnlargedHeader, SafeAreaView } from '../_components';
import { Analytics, EnlargedHeader } from '../_components';
import { TMainNavigationProp } from '../_routing';
import { useGetMe } from '../profile/_queries/useGetMe';
import { CategoryFilters } from './_components/categoryFilters/CategoryFilters';
Expand Down Expand Up @@ -41,29 +41,27 @@ const Shop = ({ navigation }: TProps) => {
return (
<>
<Analytics screenName="rewardshop" />
<SafeAreaView edges={['left', 'right']} isScrollable>
<Styled.SafeAreaViewContainer edges={['left', 'right']} isScrollable>
<EnlargedHeader height={30} />
<Styled.SearchContainer>
<Styled.SearchButton onPress={() => navigation.push('Search')}>
<Styled.SearchInput editable={false} placeholder={t('SHOP.SEARCH.PLACEHOLDER')} pointerEvents="none" />
</Styled.SearchButton>
<Styled.SearchIcon color="primary.700" name="Search" size={18} />
</Styled.SearchContainer>
<>
<WelcomeGiftsBanner />
<CategoryFilters />
{sections.map(({ section, category, title, horizontal }) => (
<RewardsSection
category={category}
horizontal={horizontal}
key={title}
onLoaded={onSectionLoaded}
section={section}
title={t(title, { city: user?.address?.city || t('SHOP.SECTIONS.CITY_FALLBACK') })}
/>
))}
</>
</SafeAreaView>
<WelcomeGiftsBanner />
<CategoryFilters />
{sections.map(({ section, category, title, horizontal }) => (
<RewardsSection
category={category}
horizontal={horizontal}
key={title}
onLoaded={onSectionLoaded}
section={section}
title={t(title, { city: user?.address?.city || t('SHOP.SECTIONS.CITY_FALLBACK') })}
/>
))}
</Styled.SafeAreaViewContainer>
</>
);
};
Expand Down
6 changes: 5 additions & 1 deletion src/shop/style.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import styled from 'styled-components/native';

import { Icon, TouchableRipple } from '../_components';
import { Icon, SafeAreaView, TouchableRipple } from '../_components';
import { theme } from '../_styles/theme';

export const SafeAreaViewContainer = styled(SafeAreaView)`
padding-bottom: 95px;
`;

export const SearchContainer = styled.View<{ paddingTop?: number }>`
background-color: ${theme.palette.secondary[500]};
padding: ${({ paddingTop = 0 }) =>
Expand Down

0 comments on commit 2fe8b7c

Please sign in to comment.