Merge branch 'master' of gitea.presley.nz:brandon.presley/Massive
This commit is contained in:
commit
62ca3ef1c4
|
@ -1,6 +1,5 @@
|
||||||
import {NavigationProp, useNavigation} from '@react-navigation/native'
|
import {NavigationProp, useNavigation} from '@react-navigation/native'
|
||||||
import {useCallback, useState} from 'react'
|
import {useCallback, useState} from 'react'
|
||||||
import {Platform} from 'react-native'
|
|
||||||
import DocumentPicker from 'react-native-document-picker'
|
import DocumentPicker from 'react-native-document-picker'
|
||||||
import {FileSystem} from 'react-native-file-access'
|
import {FileSystem} from 'react-native-file-access'
|
||||||
import {Divider, IconButton, Menu} from 'react-native-paper'
|
import {Divider, IconButton, Menu} from 'react-native-paper'
|
||||||
|
@ -154,16 +153,8 @@ export default function DrawerMenu({name}: {name: keyof DrawerParamList}) {
|
||||||
icon="more-vert"
|
icon="more-vert"
|
||||||
/>
|
/>
|
||||||
}>
|
}>
|
||||||
{Platform.OS === 'android' && (
|
<Menu.Item icon="arrow-downward" onPress={download} title="Download" />
|
||||||
<>
|
|
||||||
<Menu.Item
|
|
||||||
icon="arrow-downward"
|
|
||||||
onPress={download}
|
|
||||||
title="Download"
|
|
||||||
/>
|
|
||||||
<Menu.Item icon="arrow-upward" onPress={upload} title="Upload" />
|
<Menu.Item icon="arrow-upward" onPress={upload} title="Upload" />
|
||||||
</>
|
|
||||||
)}
|
|
||||||
<Divider />
|
<Divider />
|
||||||
<Menu.Item
|
<Menu.Item
|
||||||
icon="delete"
|
icon="delete"
|
||||||
|
|
|
@ -47,6 +47,10 @@
|
||||||
<array>
|
<array>
|
||||||
<string>armv7</string>
|
<string>armv7</string>
|
||||||
</array>
|
</array>
|
||||||
|
<key>UIFileSharingEnabled</key>
|
||||||
|
<true/>
|
||||||
|
<key>LSSupportsOpeningDocumentsInPlace</key>
|
||||||
|
<true/>
|
||||||
<key>UISupportedInterfaceOrientations</key>
|
<key>UISupportedInterfaceOrientations</key>
|
||||||
<array>
|
<array>
|
||||||
<string>UIInterfaceOrientationPortrait</string>
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
|
|
8
write.ts
8
write.ts
|
@ -1,9 +1,11 @@
|
||||||
import {NativeModules, PermissionsAndroid} from 'react-native'
|
import {PermissionsAndroid, Platform} from 'react-native'
|
||||||
import {Dirs, FileSystem} from 'react-native-file-access'
|
import {Dirs, FileSystem} from 'react-native-file-access'
|
||||||
|
import {toast} from './toast'
|
||||||
|
|
||||||
export const write = async (name: string, data: string) => {
|
export const write = async (name: string, data: string) => {
|
||||||
const filePath = `${Dirs.DocumentDir}/${name}`
|
const filePath = `${Dirs.DocumentDir}/${name}`
|
||||||
const permission = async () => {
|
const permission = async () => {
|
||||||
|
if (Platform.OS !== 'android') return true
|
||||||
const granted = await PermissionsAndroid.request(
|
const granted = await PermissionsAndroid.request(
|
||||||
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
|
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
|
||||||
)
|
)
|
||||||
|
@ -12,7 +14,7 @@ export const write = async (name: string, data: string) => {
|
||||||
const granted = await permission()
|
const granted = await permission()
|
||||||
if (!granted) return
|
if (!granted) return
|
||||||
await FileSystem.writeFile(filePath, data)
|
await FileSystem.writeFile(filePath, data)
|
||||||
if (!FileSystem.exists(filePath)) return
|
if (Platform.OS === 'android')
|
||||||
await FileSystem.cpExternal(filePath, name, 'downloads')
|
await FileSystem.cpExternal(filePath, name, 'downloads')
|
||||||
NativeModules.DownloadModule.show(name)
|
toast(`Downloaded ${name}`)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user