From 65ffcc01f5d9a5a4f684b2bf697c15e967f16c1c Mon Sep 17 00:00:00 2001 From: Felix Hallenberg Date: Sun, 17 Dec 2023 13:02:59 +0200 Subject: [PATCH] Show status-box for 'you' and 'vacationing' in MentorCards --- src/Screens/components/MentorCard.tsx | 6 +- src/Screens/components/MentorList.tsx | 73 ++++++++++--------- src/Screens/components/MentorTitle.tsx | 9 ++- src/Screens/components/MentorTitleSpecial.tsx | 52 +++++++++++++ src/localization/en.ts | 2 + src/localization/fi.ts | 2 + 6 files changed, 104 insertions(+), 40 deletions(-) create mode 100644 src/Screens/components/MentorTitleSpecial.tsx diff --git a/src/Screens/components/MentorCard.tsx b/src/Screens/components/MentorCard.tsx index feae6ea0..5d6d96e0 100644 --- a/src/Screens/components/MentorCard.tsx +++ b/src/Screens/components/MentorCard.tsx @@ -1,15 +1,15 @@ import React from 'react'; import RN from 'react-native'; - import * as api from '../../api/mentors'; +import colors from './colors'; +import fonts from './fonts'; + import Button from './Button'; import Card, { cardBorderRadius } from './Card'; import MentorTitle from './MentorTitle'; import MentorStory from './MentorStory'; import Skills from './Skills'; -import colors from './colors'; -import fonts from './fonts'; interface Props { style?: RN.StyleProp; diff --git a/src/Screens/components/MentorList.tsx b/src/Screens/components/MentorList.tsx index 1bc644f0..143aef31 100644 --- a/src/Screens/components/MentorList.tsx +++ b/src/Screens/components/MentorList.tsx @@ -10,8 +10,9 @@ import * as mentorsState from '../../state/reducers/mentors'; import useLayout from '../../lib/use-layout'; -import MentorCard from '../components/MentorCard'; -import RemoteData from '../components/RemoteData'; +import MentorCard from './MentorCard'; +import RemoteData from './RemoteData'; +import { MentorTitleSpecial } from './MentorTitleSpecial'; type Props = { onPress?: (mentor: mentorApi.Mentor) => void | undefined; @@ -44,30 +45,28 @@ export default ({ onPress, testID }: Props) => { > {mentors => ( - - buddyId} - horizontal={true} - testID={'components.mentorList'} - /> - + buddyId} + horizontal={true} + testID={'components.mentorList'} + /> )} ); }; -const mentorCardBottomMargin = 16; +const mentorCardBottomMargin = 32; const renderMentorCard = ( @@ -77,18 +76,21 @@ const renderMentorCard = ) => ({ item }: { item: mentorApi.Mentor }) => ( - + + + + ); const styles = RN.StyleSheet.create({ @@ -98,13 +100,14 @@ const styles = RN.StyleSheet.create({ flex: 1, alignSelf: 'stretch', }, - carouselContainer: { - flex: 1, - }, scrollContainer: { paddingHorizontal: 16 }, card: { alignSelf: 'stretch', flexGrow: 1, marginBottom: mentorCardBottomMargin, }, + hiddenContainer: { + paddingTop: 8, + overflow: 'hidden', + }, }); diff --git a/src/Screens/components/MentorTitle.tsx b/src/Screens/components/MentorTitle.tsx index 99653ef4..7820d401 100644 --- a/src/Screens/components/MentorTitle.tsx +++ b/src/Screens/components/MentorTitle.tsx @@ -1,7 +1,6 @@ import React from 'react'; import RN from 'react-native'; import { SafeAreaView } from 'react-native-safe-area-context'; - import * as mentorApi from '../../api/mentors'; import Message from './Message'; @@ -33,7 +32,13 @@ const MentorTitle: React.FC = ({ const hasRegion = region.length > 0; return ( - + {!onPress ? null : ( = ({ + mentor: { buddyId, is_vacationing }, +}) => { + const isMe = useSelector(tokenState.isMe(buddyId)); + + const message = isMe + ? 'main.mentor.special.you' + : 'main.mentor.special.notAvailable'; + + const shouldShow = isMe || is_vacationing; + + return shouldShow ? ( + + + + ) : null; +}; + +const styles = RN.StyleSheet.create({ + special: { + position: 'absolute', + right: 40, + top: 0, + borderRadius: 4, + padding: 8, + zIndex: 10, + }, + text: { + ...fonts.smallBold, + color: colors.darkestBlue, + }, +}); diff --git a/src/localization/en.ts b/src/localization/en.ts index 3c6dc9d2..9d815ee2 100644 --- a/src/localization/en.ts +++ b/src/localization/en.ts @@ -60,6 +60,8 @@ export const messages: { [key in MessageId]: string } = { 'main.chat.unban.confirmation.button': 'Restore', 'main.mentor.other': 'I can also support with:', + 'main.mentor.special.notAvailable': 'Not available', + 'main.mentor.special.you': 'You', 'main.mentor.story': 'My story', 'main.mentor.subject': 'Subject:', diff --git a/src/localization/fi.ts b/src/localization/fi.ts index 0680e9a9..fa36ba7f 100644 --- a/src/localization/fi.ts +++ b/src/localization/fi.ts @@ -59,6 +59,8 @@ export const messages = { 'main.chat.unban.confirmation.button': 'Palauta', 'main.mentor.other': 'Pystyn auttamaan näissä:', + 'main.mentor.special.notAvailable': 'Ei tavoitettavissa', + 'main.mentor.special.you': 'Sinä', 'main.mentor.story': 'Tarinani', 'main.mentor.subject': 'Aihealue:',