mirror of
https://github.com/tooot-app/app
synced 2025-02-14 19:00:50 +01:00
Get back to the tutorial
This commit is contained in:
parent
fe2e7b4372
commit
02c78d5f68
@ -17,7 +17,7 @@
|
||||
<key>HostAppBundleIdentifier</key>
|
||||
<string>com.xmflsct.app.tooot</string>
|
||||
<key>HostAppURLScheme</key>
|
||||
<string>tooot://</string>
|
||||
<string>tooot-share://</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionAttributes</key>
|
||||
|
@ -6,6 +6,8 @@
|
||||
#import <React/RCTLinkingManager.h>
|
||||
#import <React/RCTConvert.h>
|
||||
|
||||
#import <RNShareMenu/ShareMenuManager.h>
|
||||
|
||||
#if defined(FB_SONARKIT_ENABLED) && __has_include(<FlipperKit/FlipperClient.h>)
|
||||
#import <FlipperKit/FlipperClient.h>
|
||||
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
|
||||
@ -81,6 +83,13 @@ static void InitializeFlipper(UIApplication *application) {
|
||||
|
||||
// Linking API
|
||||
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
|
||||
NSString *urlString = url.absoluteString;
|
||||
|
||||
if ([urlString hasPrefix:@"tooot-share://"]) {
|
||||
NSLog(@"Entered with the following string: %@s", urlString);
|
||||
return [ShareMenuManager application:application openURL:url options:options];
|
||||
}
|
||||
|
||||
return [RCTLinkingManager application:application openURL:url options:options];
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
<string>com.xmflsct.app.tooot</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>tooot-share</string>
|
||||
<string>tooot</string>
|
||||
</array>
|
||||
</dict>
|
||||
|
@ -75,7 +75,6 @@
|
||||
"react-native-fast-image": "8.5.11",
|
||||
"react-native-feather": "1.1.2",
|
||||
"react-native-flash-message": "0.2.1",
|
||||
"react-native-fs": "^2.19.0",
|
||||
"react-native-gesture-handler": "2.4.1",
|
||||
"react-native-htmlview": "0.16.0",
|
||||
"react-native-pager-view": "5.4.11",
|
||||
@ -86,7 +85,6 @@
|
||||
"react-native-svg": "12.3.0",
|
||||
"react-native-swipe-list-view": "3.2.9",
|
||||
"react-native-tab-view": "3.1.1",
|
||||
"react-native-uuid": "^2.0.1",
|
||||
"react-query": "3.38.0",
|
||||
"react-redux": "8.0.1",
|
||||
"react-timeago": "6.2.1",
|
||||
|
@ -1,20 +1,19 @@
|
||||
diff --git a/node_modules/@types/react-native-share-menu/index.d.ts b/node_modules/@types/react-native-share-menu/index.d.ts
|
||||
index f52822c..23d9f99 100755
|
||||
index f52822c..b1d3bdd 100755
|
||||
--- a/node_modules/@types/react-native-share-menu/index.d.ts
|
||||
+++ b/node_modules/@types/react-native-share-menu/index.d.ts
|
||||
@@ -6,9 +6,8 @@
|
||||
@@ -6,9 +6,7 @@
|
||||
// Minimum TypeScript Version: 3.7
|
||||
|
||||
export interface ShareData {
|
||||
- mimeType: string;
|
||||
- data: string | string[];
|
||||
- extraData?: object | undefined;
|
||||
+ data: {data: {mimeType: string; data: string}[]};
|
||||
+ extraData?: {share: {mimeType: string; data: string}[]} | undefined;
|
||||
+ data: {mimeType: string; data: string}[];
|
||||
}
|
||||
|
||||
export type ShareCallback = (share?: ShareData) => void;
|
||||
@@ -28,7 +27,7 @@ interface ShareMenuReactView {
|
||||
@@ -28,7 +26,7 @@ interface ShareMenuReactView {
|
||||
dismissExtension(error?: string): void;
|
||||
openApp(): void;
|
||||
continueInApp(extraData?: object): void;
|
||||
|
@ -161,25 +161,18 @@ const Screens: React.FC<Props> = ({ localCorrupt }) => {
|
||||
|
||||
// Share Extension
|
||||
const handleShare = useCallback(
|
||||
(item?: {
|
||||
extraData?: { share: { mimeType: string; data: string }[] }
|
||||
}) => {
|
||||
(item?: { data?: { mimeType: string; data: string }[] }) => {
|
||||
if (instanceActive < 0) {
|
||||
return
|
||||
}
|
||||
if (
|
||||
!item ||
|
||||
!item.extraData ||
|
||||
!Array.isArray(item.extraData.share) ||
|
||||
!item.extraData.share.length
|
||||
) {
|
||||
if (!item || !item.data || !Array.isArray(item.data) || !item.data) {
|
||||
return
|
||||
}
|
||||
|
||||
let text: string | undefined = undefined
|
||||
let images: { type: string; uri: string }[] = []
|
||||
let video: { type: string; uri: string } | undefined = undefined
|
||||
item.extraData.share.forEach((d, i) => {
|
||||
item.data.forEach((d, i) => {
|
||||
const typesImage = ['png', 'jpg', 'jpeg', 'gif']
|
||||
const typesVideo = ['mp4', 'm4v', 'mov', 'webm']
|
||||
const { mimeType, data } = d
|
||||
@ -219,12 +212,10 @@ const Screens: React.FC<Props> = ({ localCorrupt }) => {
|
||||
[instanceActive]
|
||||
)
|
||||
useEffect(() => {
|
||||
console.log('getting intial share')
|
||||
ShareMenu.getInitialShare(handleShare)
|
||||
ShareMenu.getInitialShare(item => handleShare(item))
|
||||
}, [])
|
||||
useEffect(() => {
|
||||
console.log('getting just share')
|
||||
const listener = ShareMenu.addNewShareListener(handleShare)
|
||||
const listener = ShareMenu.addNewShareListener(item => handleShare(item))
|
||||
return () => {
|
||||
listener.remove()
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Appearance, Platform, Pressable, Text } from 'react-native'
|
||||
import { useEffect } from 'react'
|
||||
import { Appearance, Pressable } from 'react-native'
|
||||
import { Circle } from 'react-native-animated-spinkit'
|
||||
import RNFS from 'react-native-fs'
|
||||
import { ShareMenuReactView } from 'react-native-share-menu'
|
||||
import uuid from 'react-native-uuid'
|
||||
|
||||
// mimeType
|
||||
// text/plain - text only, website URL, video?!
|
||||
@ -21,58 +19,9 @@ const colors = {
|
||||
}
|
||||
}
|
||||
|
||||
const clearDir = async (dir: string) => {
|
||||
try {
|
||||
const files = await RNFS.readDir(dir)
|
||||
for (const file of files) {
|
||||
await RNFS.unlink(file.path)
|
||||
}
|
||||
} catch (err: any) {
|
||||
console.warn(err.message)
|
||||
}
|
||||
}
|
||||
|
||||
const ShareExtension = () => {
|
||||
const [errorMessage, setErrorMessage] = useState<string>()
|
||||
|
||||
useEffect(() => {
|
||||
ShareMenuReactView.data().then(async ({ data }) => {
|
||||
console.log('length', data.length)
|
||||
const newData = []
|
||||
switch (Platform.OS) {
|
||||
case 'ios':
|
||||
for (const d of data) {
|
||||
if (d.data.startsWith('file:///')) {
|
||||
const extension = d.data.split('.').pop()?.toLowerCase()
|
||||
const filename = `${uuid.v4()}.${extension}`
|
||||
const groupDirectory = await RNFS.pathForGroup(
|
||||
'group.com.xmflsct.app.tooot'
|
||||
)
|
||||
await clearDir(groupDirectory)
|
||||
const newFilepath = `file://${groupDirectory}/${filename}`
|
||||
console.log('newFilepath', newFilepath)
|
||||
try {
|
||||
await RNFS.copyFile(d.data, newFilepath)
|
||||
newData.push({ ...d, data: newFilepath })
|
||||
} catch (err: any) {
|
||||
setErrorMessage(err.message)
|
||||
console.warn(err.message)
|
||||
}
|
||||
} else {
|
||||
newData.push(d)
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'android':
|
||||
break
|
||||
default:
|
||||
return
|
||||
}
|
||||
console.log('new data', newData)
|
||||
if (!errorMessage) {
|
||||
ShareMenuReactView.continueInApp({ share: newData })
|
||||
}
|
||||
})
|
||||
ShareMenuReactView.continueInApp()
|
||||
}, [])
|
||||
|
||||
const theme = Appearance.getColorScheme() || 'light'
|
||||
@ -85,19 +34,8 @@ const ShareExtension = () => {
|
||||
alignItems: 'center',
|
||||
backgroundColor: colors.background[theme]
|
||||
}}
|
||||
onPress={() => {
|
||||
if (errorMessage) {
|
||||
ShareMenuReactView.dismissExtension(errorMessage)
|
||||
}
|
||||
}}
|
||||
>
|
||||
{!errorMessage ? (
|
||||
<Text style={{ fontSize: 16, color: colors.primary[theme] }}>
|
||||
{errorMessage}
|
||||
</Text>
|
||||
) : (
|
||||
<Circle size={18} color={colors.primary[theme]} />
|
||||
)}
|
||||
<Circle size={18} color={colors.primary[theme]} />
|
||||
</Pressable>
|
||||
)
|
||||
}
|
||||
|
23
yarn.lock
23
yarn.lock
@ -2576,11 +2576,6 @@ balanced-match@^1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
|
||||
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
|
||||
|
||||
base-64@^0.1.0:
|
||||
version "0.1.0"
|
||||
resolved "https://registry.yarnpkg.com/base-64/-/base-64-0.1.0.tgz#780a99c84e7d600260361511c4877613bf24f6bb"
|
||||
integrity sha1-eAqZyE59YAJgNhURxId2E78k9rs=
|
||||
|
||||
base64-js@^1.1.2, base64-js@^1.2.3, base64-js@^1.3.0, base64-js@^1.5.1:
|
||||
version "1.5.1"
|
||||
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
|
||||
@ -6302,14 +6297,6 @@ react-native-flash-message@0.2.1:
|
||||
prop-types "^15.8.1"
|
||||
react-native-iphone-x-helper "^1.3.1"
|
||||
|
||||
react-native-fs@^2.19.0:
|
||||
version "2.19.0"
|
||||
resolved "https://registry.yarnpkg.com/react-native-fs/-/react-native-fs-2.19.0.tgz#5747eb52a5a3d2b31c8fb76f5f8044d0a855122c"
|
||||
integrity sha512-Yl09IbETkV5UJcBtVtBLttyTmiAhJIHpGA/LvredI5dYiw3MXMMVu42bzELiuH2Bwj7F+qd0fMNvgfBDiDxd2A==
|
||||
dependencies:
|
||||
base-64 "^0.1.0"
|
||||
utf8 "^3.0.0"
|
||||
|
||||
react-native-gesture-handler@2.4.1:
|
||||
version "2.4.1"
|
||||
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-2.4.1.tgz#f4cb1784b6dcdf41ae35b4fff6022ec21038e2cd"
|
||||
@ -6388,11 +6375,6 @@ react-native-tab-view@3.1.1:
|
||||
resolved "https://registry.yarnpkg.com/react-native-tab-view/-/react-native-tab-view-3.1.1.tgz#1f8d7a835ab4f5b1b1407ec8dddc1053b53fa3c6"
|
||||
integrity sha512-M5pRN6utQfytKWoKlKVzg5NbkYu308qNoW1khGTtEOTs1k14p2dHJ/BWOJoJYHKbPVUyZldbG9MFT7gUl4YHnw==
|
||||
|
||||
react-native-uuid@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/react-native-uuid/-/react-native-uuid-2.0.1.tgz#ed4e2dfb1683eddb66967eb5dca140dfe1abddb9"
|
||||
integrity sha512-cptnoIbL53GTCrWlb/+jrDC6tvb7ypIyzbXNJcpR3Vab0mkeaaVd5qnB3f0whXYzS+SMoSQLcUUB0gEWqkPC0g==
|
||||
|
||||
react-native@0.67.4:
|
||||
version "0.67.4"
|
||||
resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.67.4.tgz#57a1503daa81f66a61f521ff67b259f126d87f9c"
|
||||
@ -7550,11 +7532,6 @@ use@^3.1.0:
|
||||
resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f"
|
||||
integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==
|
||||
|
||||
utf8@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/utf8/-/utf8-3.0.0.tgz#f052eed1364d696e769ef058b183df88c87f69d1"
|
||||
integrity sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ==
|
||||
|
||||
util-deprecate@~1.0.1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
|
||||
|
Loading…
x
Reference in New Issue
Block a user