diff options
author | Shravya Ramesh <shravs1208@gmail.com> | 2021-04-23 15:55:36 -0700 |
---|---|---|
committer | Shravya Ramesh <shravs1208@gmail.com> | 2021-04-23 15:55:36 -0700 |
commit | 82d4c3d8d2c6eb6ab71b543933866bb4a8ed4ec3 (patch) | |
tree | 2da9296e377863ccf490f21b51a482e2d83d2c9c /src | |
parent | 45d0a3aeb97c71cd73a198fc7f1aea67e0996009 (diff) |
comments
Diffstat (limited to 'src')
-rw-r--r-- | src/components/profile/BadgeTutorial.tsx (renamed from src/components/profile/BadgeTutorialScreen.tsx) | 23 | ||||
-rw-r--r-- | src/components/profile/ProfileHeader.tsx | 8 | ||||
-rw-r--r-- | src/utils/common.ts | 4 |
3 files changed, 16 insertions, 19 deletions
diff --git a/src/components/profile/BadgeTutorialScreen.tsx b/src/components/profile/BadgeTutorial.tsx index 30aced42..a6cdc4dc 100644 --- a/src/components/profile/BadgeTutorialScreen.tsx +++ b/src/components/profile/BadgeTutorial.tsx @@ -1,3 +1,4 @@ +import AsyncStorage from '@react-native-community/async-storage'; import React, {useState} from 'react'; import { Image, @@ -8,34 +9,34 @@ import { View, } from 'react-native'; import {PROFILE_CUTOUT_TOP_Y} from '../../constants'; -import {normalize, setHasSeenBadgeTutorial} from '../../utils'; +import {normalize} from '../../utils'; import {UniversityIcon} from './'; import {UniversityIconProps} from './UniversityIcon'; -interface BadgeTutorialScreenProps { +interface BadgeTutorialProps { uniIconProps: UniversityIconProps; setShowBadgeTutorial: Function; } -const BadgeTutorialScreen: React.FC<BadgeTutorialScreenProps> = ({ +const BadgeTutorial: React.FC<BadgeTutorialProps> = ({ uniIconProps, setShowBadgeTutorial, }) => { const [showModal, setShowModal] = useState(true); const {layout, university, university_class} = uniIconProps; + + const onTap = async () => { + await AsyncStorage.setItem('hasSeenBadgeTutorial', 'true'); + setShowBadgeTutorial(false); + setShowModal(false); + }; return ( <Modal animationType="fade" transparent visible={showModal} presentationStyle="overFullScreen"> - <TouchableOpacity - onPress={() => { - setHasSeenBadgeTutorial(); - setShowBadgeTutorial(false); - setShowModal(false); - }} - style={styles.viewWrapper}> + <TouchableOpacity onPress={onTap} style={styles.viewWrapper}> <View style={styles.textContainerStyles}> <Text style={styles.textStyles}> Tap on the univeristy icon to edit your badges! @@ -79,4 +80,4 @@ const styles = StyleSheet.create({ }, }); -export default BadgeTutorialScreen; +export default BadgeTutorial; diff --git a/src/components/profile/ProfileHeader.tsx b/src/components/profile/ProfileHeader.tsx index 665ce0a0..e4f864f2 100644 --- a/src/components/profile/ProfileHeader.tsx +++ b/src/components/profile/ProfileHeader.tsx @@ -9,7 +9,7 @@ import {ScreenType} from '../../types'; import {hasSeenBadgeTutorial, normalize} from '../../utils'; import BadgeDetailView from '../common/BadgeDetailView'; import Avatar from './Avatar'; -import BadgeTutorialScreen from './BadgeTutorialScreen'; +import BadgeTutorial from './BadgeTutorial'; import FriendsCount from './FriendsCount'; import ProfileMoreInfoDrawer from './ProfileMoreInfoDrawer'; import UniversityIcon from './UniversityIcon'; @@ -64,11 +64,11 @@ const ProfileHeader: React.FC<ProfileHeaderProps> = ({ useLayoutEffect(() => { setTimeout(() => { - measureStuff(); + measureUniversityIcon(); }, 1000); }, []); - const measureStuff = async () => { + const measureUniversityIcon = async () => { const badgeSeen = await hasSeenBadgeTutorial(); if (!badgeSeen && containerRef.current && childRef.current) { childRef?.current?.measureLayout( @@ -97,7 +97,7 @@ const ProfileHeader: React.FC<ProfileHeaderProps> = ({ setIsOpen={setDrawerVisible} /> {userId === loggedInUserId && measure && ( - <BadgeTutorialScreen + <BadgeTutorial uniIconProps={{ university: university, university_class: university_class, diff --git a/src/utils/common.ts b/src/utils/common.ts index 868d7b8e..ce4ab7d1 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -145,10 +145,6 @@ export const hasSeenBadgeTutorial = async () => { return false; }; -export const setHasSeenBadgeTutorial = async () => { - await AsyncStorage.setItem('hasSeenBadgeTutorial', 'true'); -}; - export const getUniversityBadge = ( university: UniversityType, type: UniversityBadgeType, |