From 82d4c3d8d2c6eb6ab71b543933866bb4a8ed4ec3 Mon Sep 17 00:00:00 2001 From: Shravya Ramesh Date: Fri, 23 Apr 2021 15:55:36 -0700 Subject: comments --- src/components/profile/BadgeTutorial.tsx | 83 ++++++++++++++++++++++++++ src/components/profile/BadgeTutorialScreen.tsx | 82 ------------------------- src/components/profile/ProfileHeader.tsx | 8 +-- src/utils/common.ts | 4 -- 4 files changed, 87 insertions(+), 90 deletions(-) create mode 100644 src/components/profile/BadgeTutorial.tsx delete mode 100644 src/components/profile/BadgeTutorialScreen.tsx (limited to 'src') diff --git a/src/components/profile/BadgeTutorial.tsx b/src/components/profile/BadgeTutorial.tsx new file mode 100644 index 00000000..a6cdc4dc --- /dev/null +++ b/src/components/profile/BadgeTutorial.tsx @@ -0,0 +1,83 @@ +import AsyncStorage from '@react-native-community/async-storage'; +import React, {useState} from 'react'; +import { + Image, + Modal, + StyleSheet, + Text, + TouchableOpacity, + View, +} from 'react-native'; +import {PROFILE_CUTOUT_TOP_Y} from '../../constants'; +import {normalize} from '../../utils'; +import {UniversityIcon} from './'; +import {UniversityIconProps} from './UniversityIcon'; + +interface BadgeTutorialProps { + uniIconProps: UniversityIconProps; + setShowBadgeTutorial: Function; +} + +const BadgeTutorial: React.FC = ({ + 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 ( + + + + + Tap on the univeristy icon to edit your badges! + + + + + + + + + ); +}; +const styles = StyleSheet.create({ + viewWrapper: { + flex: 1, + backgroundColor: 'rgba(0, 0, 0, 0.5)', + }, + modalView: { + backgroundColor: '#fff', + }, + textContainerStyles: {top: '30%', width: '60%', alignSelf: 'center'}, + textStyles: { + color: 'white', + fontWeight: '700', + fontSize: normalize(20), + lineHeight: normalize(25), + textAlign: 'center', + }, +}); + +export default BadgeTutorial; diff --git a/src/components/profile/BadgeTutorialScreen.tsx b/src/components/profile/BadgeTutorialScreen.tsx deleted file mode 100644 index 30aced42..00000000 --- a/src/components/profile/BadgeTutorialScreen.tsx +++ /dev/null @@ -1,82 +0,0 @@ -import React, {useState} from 'react'; -import { - Image, - Modal, - StyleSheet, - Text, - TouchableOpacity, - View, -} from 'react-native'; -import {PROFILE_CUTOUT_TOP_Y} from '../../constants'; -import {normalize, setHasSeenBadgeTutorial} from '../../utils'; -import {UniversityIcon} from './'; -import {UniversityIconProps} from './UniversityIcon'; - -interface BadgeTutorialScreenProps { - uniIconProps: UniversityIconProps; - setShowBadgeTutorial: Function; -} - -const BadgeTutorialScreen: React.FC = ({ - uniIconProps, - setShowBadgeTutorial, -}) => { - const [showModal, setShowModal] = useState(true); - const {layout, university, university_class} = uniIconProps; - return ( - - { - setHasSeenBadgeTutorial(); - setShowBadgeTutorial(false); - setShowModal(false); - }} - style={styles.viewWrapper}> - - - Tap on the univeristy icon to edit your badges! - - - - - - - - - ); -}; -const styles = StyleSheet.create({ - viewWrapper: { - flex: 1, - backgroundColor: 'rgba(0, 0, 0, 0.5)', - }, - modalView: { - backgroundColor: '#fff', - }, - textContainerStyles: {top: '30%', width: '60%', alignSelf: 'center'}, - textStyles: { - color: 'white', - fontWeight: '700', - fontSize: normalize(20), - lineHeight: normalize(25), - textAlign: 'center', - }, -}); - -export default BadgeTutorialScreen; 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 = ({ 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 = ({ setIsOpen={setDrawerVisible} /> {userId === loggedInUserId && measure && ( - { return false; }; -export const setHasSeenBadgeTutorial = async () => { - await AsyncStorage.setItem('hasSeenBadgeTutorial', 'true'); -}; - export const getUniversityBadge = ( university: UniversityType, type: UniversityBadgeType, -- cgit v1.2.3-70-g09d2