Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share button #76

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions assets/shareicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"uri-scheme": "^1.2.0",
"yargs": "^16.2.0",
"yargs-parser": "^20.2.9",
"zod": "^3.22.4"
"zod": "^3.22.4",
"expo-sharing": "~11.5.0"
me-liu marked this conversation as resolved.
Show resolved Hide resolved
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand Down
35 changes: 24 additions & 11 deletions src/app/(BottomTabNavigation)/AllCases/CaseScreen/[caseUid].tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { router, useLocalSearchParams, useNavigation } from 'expo-router';
import * as Linking from 'expo-linking';
import { useLocalSearchParams, useNavigation } from 'expo-router';
//import * as Sharing from 'expo-sharing';
import React, { useEffect, useState } from 'react';
import { View, ScrollView, Text, TouchableOpacity } from 'react-native';
import { View, ScrollView, Text, TouchableOpacity, Share } from 'react-native';

import styles from './styles';
// eslint-disable-next-line import/namespace
import Icon from '../../../../../assets/shareicon.svg';
import CaseStatusBar from '../../../../Components/CaseStatusBar/CaseStatusBar';
import CaseSummaryCard from '../../../../Components/CaseSummaryCard/CaseSummaryCard';
import EducationalBar from '../../../../Components/EducationalBar/EducationalBar';
Expand All @@ -25,6 +27,21 @@ function CaseScreen() {
setIsLoading(false);
};

const onShare = async () => {
const addCaseUrl = Linking.createURL('?event=addCase&', {
queryParams: { caseUid },
});
console.log(addCaseUrl);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event=addCase is technically a query parameter, so maybe we can clean up this function instead of concatenating multiple partial strings.

try {
me-liu marked this conversation as resolved.
Show resolved Hide resolved
await Share.share({
//message: 'ADD CASE',
url: `${addCaseUrl}/`,
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, is there anyway to customize how the link looks when shared with someone? Sometimes apps will attach an image or additional text to the link so users don't have to see the entire link.

} catch (error) {
console.log(error);
}
};

const getStatus = async (uid: string) => {
const caseStatus = await getCaseStatus(uid);
setStatus(caseStatus);
Expand Down Expand Up @@ -54,18 +71,14 @@ function CaseScreen() {
contentContainerStyle={styles.innerScroll}
showsVerticalScrollIndicator={false}
>
<TouchableOpacity style={styles.shareContainer} onPress={onShare}>
<Text style={styles.share}>Share</Text>
<Icon style={{ marginTop: 2 }} />
</TouchableOpacity>
<View style={styles.titleContainer}>
<Text style={styles.title}>{caseData.title}</Text>
</View>
<CaseStatusBar status={caseData.caseStatus} />
<TouchableOpacity
onPress={() => {
router.push({ pathname: `AllCases/Updates/${caseUid}` });
}}
>
<Text>View Updates</Text>
</TouchableOpacity>

{status === Eligibility.ELIGIBLE && (
<EligibilityCard caseData={caseData} status={status} />
)}
Expand Down
16 changes: 14 additions & 2 deletions src/app/(BottomTabNavigation)/AllCases/CaseScreen/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ export default StyleSheet.create({
},
titleContainer: {
flexDirection: 'row',
paddingVertical: 12,
marginTop: 20,
paddingBottom: 12,
},
title: {
flex: 1,
Expand All @@ -38,4 +37,17 @@ export default StyleSheet.create({
fontWeight: 'bold',
textAlign: 'center',
},
shareContainer: {
justifyContent: 'flex-end',
flexDirection: 'row',
marginTop: 10,
marginLeft: 280,
me-liu marked this conversation as resolved.
Show resolved Hide resolved
//backgroundColor: colors.darkGrey,
},
share: {
// alignText: 'right',
color: colors.midRed,
fontSize: 16,
marginHorizontal: 3,
},
});
Loading