react-native-my-uploader-android 1.0.32 → 1.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/myuploaderandroid/DownloadFileModule.kt +162 -138
- package/android/src/main/java/com/myuploaderandroid/MyUploaderModule.kt +73 -0
- package/lib/commonjs/components/DownloadFile.js +52 -20
- package/lib/commonjs/components/DownloadFile.js.map +1 -1
- package/lib/commonjs/components/MyUploader.js +19 -2
- package/lib/commonjs/components/MyUploader.js.map +1 -1
- package/lib/commonjs/index.d.js.map +1 -1
- package/lib/commonjs/index.js +16 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/components/DownloadFile.js +52 -21
- package/lib/module/components/DownloadFile.js.map +1 -1
- package/lib/module/components/MyUploader.js +16 -0
- package/lib/module/components/MyUploader.js.map +1 -1
- package/lib/module/index.d.js.map +1 -1
- package/lib/module/index.js +3 -6
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/package.json +1 -1
- package/src/components/DownloadFile.tsx +102 -22
- package/src/components/MyUploader.tsx +20 -4
- package/src/index.d.ts +3 -2
- package/src/index.ts +3 -6
- package/src/types.ts +7 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","UploadDocumentPicker","NativeUploadPicker","NativeModules","pickFile","options","_options$multipleFile","_options$maxFiles","_options$maxSize","_options$fileTypes","_options$excludedUris","Error","nativeOptions","multipleFiles","maxFiles","maxSize","fileTypes","excludedUris","openDocument","exports","MyUploader","onSelect","onError","buttonPlaceHolder","ButtonStyle","ButtonTextStyle","disabled","isLoading","setIsLoading","useState","handlePress","files","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","UploadDocumentPicker","NativeUploadPicker","NativeModules","pickFile","options","_options$multipleFile","_options$maxFiles","_options$maxSize","_options$fileTypes","_options$excludedUris","Error","nativeOptions","multipleFiles","maxFiles","maxSize","fileTypes","excludedUris","openDocument","exports","RotateImage","base64","angle","rotatedBase64","rotateImage","error","message","MyUploader","onSelect","onError","buttonPlaceHolder","ButtonStyle","ButtonTextStyle","disabled","isLoading","setIsLoading","useState","handlePress","files","console","createElement","TouchableOpacity","style","styles","button","onPress","ActivityIndicator","color","Text","text","StyleSheet","create","backgroundColor","padding","borderRadius","alignItems","justifyContent","fontWeight","fontSize","_default"],"sources":["MyUploader.tsx"],"sourcesContent":["import React, { useState } from 'react';\r\nimport { TouchableOpacity, Text, StyleSheet, ActivityIndicator, NativeModules } from 'react-native';\r\nimport type { MyUploaderProps, DocumentPickerOptions, FileInfo, RotateImageProps } from '../types';\r\n\r\nconst { UploadDocumentPicker: NativeUploadPicker } = NativeModules;\r\n\r\n// 1. Standalone pickFile Fonksiyonu\r\nexport const pickFile = async (options: DocumentPickerOptions = {}): Promise<FileInfo[]> => {\r\n if (!NativeUploadPicker) throw new Error(\"DocumentPicker module is not linked.\");\r\n\r\n // Native tarafa gönderilecek options\r\n const nativeOptions = {\r\n multipleFiles: options.multipleFiles ?? false,\r\n maxFiles: options.maxFiles ?? 0,\r\n maxSize: options.maxSize ?? 0,\r\n fileTypes: options.fileTypes ?? ['*/*'],\r\n excludedUris: options.excludedUris ?? [],\r\n };\r\n\r\n return await NativeUploadPicker.openDocument(nativeOptions);\r\n};\r\n\r\nexport const RotateImage = async ({ base64, angle }: RotateImageProps): Promise<string> => {\r\n if (!NativeUploadPicker) {\r\n throw new Error(\"UploadDocumentPicker module is not linked.\");\r\n }\r\n\r\n try {\r\n const rotatedBase64: string =\r\n await NativeUploadPicker.rotateImage(base64, angle);\r\n\r\n // JS tarafında prefix eklenir\r\n return `data:image/jpeg;base64,${rotatedBase64}`;\r\n } catch (error: any) {\r\n throw new Error(`RotateImage Error: ${error.message}`);\r\n }\r\n};\r\n\r\n// 2. MyUploader Bileşeni\r\nconst MyUploader: React.FC<MyUploaderProps> = ({\r\n onSelect,\r\n onError,\r\n buttonPlaceHolder = \"Dosya Seç\",\r\n ButtonStyle,\r\n ButtonTextStyle,\r\n disabled = false,\r\n multipleFiles = false,\r\n fileTypes = ['*/*'],\r\n maxSize = 0,\r\n maxFiles = 0,\r\n excludedUris = [],\r\n}) => {\r\n const [isLoading, setIsLoading] = useState(false);\r\n\r\n const handlePress = async () => {\r\n if (disabled || isLoading) return;\r\n setIsLoading(true);\r\n\r\n try {\r\n const files = await pickFile({\r\n multipleFiles,\r\n fileTypes,\r\n maxSize,\r\n maxFiles,\r\n excludedUris\r\n });\r\n\r\n onSelect(files);\r\n } catch (error: any) {\r\n if (onError) {\r\n onError(error);\r\n } else {\r\n console.error(\"MyUploader Error:\", error);\r\n }\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n\r\n return (\r\n <TouchableOpacity\r\n style={[styles.button, ButtonStyle, (disabled || isLoading) && styles.disabled]}\r\n onPress={handlePress}\r\n disabled={disabled || isLoading}\r\n >\r\n {isLoading ? (\r\n <ActivityIndicator color=\"#FFF\" />\r\n ) : (\r\n <Text style={[styles.text, ButtonTextStyle]}>{buttonPlaceHolder}</Text>\r\n )}\r\n </TouchableOpacity>\r\n );\r\n};\r\n\r\nconst styles = StyleSheet.create({\r\n button: {\r\n backgroundColor: '#6200EE',\r\n padding: 12,\r\n borderRadius: 8,\r\n alignItems: 'center',\r\n justifyContent: 'center'\r\n },\r\n text: {\r\n color: '#FFF',\r\n fontWeight: '600',\r\n fontSize: 16\r\n },\r\n disabled: {\r\n backgroundColor: '#B0B0B0'\r\n }\r\n});\r\n\r\nexport default MyUploader;"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;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,CAAAc,OAAA,CAAAgD,aAAA,CAAC3D,YAAA,CAAAmE,IAAI;IAACN,KAAK,EAAE,CAACC,MAAM,CAACM,IAAI,EAAEjB,eAAe;EAAE,GAAEF,iBAAwB,CAExD,CAAC;AAEvB,CAAC;AAED,MAAMa,MAAM,GAAGO,uBAAU,CAACC,MAAM,CAAC;EAC/BP,MAAM,EAAE;IACNQ,eAAe,EAAE,SAAS;IAC1BC,OAAO,EAAE,EAAE;IACXC,YAAY,EAAE,CAAC;IACfC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDP,IAAI,EAAE;IACJF,KAAK,EAAE,MAAM;IACbU,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ,CAAC;EACDzB,QAAQ,EAAE;IACRmB,eAAe,EAAE;EACnB;AACF,CAAC,CAAC;AAAC,IAAAO,QAAA,GAAAxC,OAAA,CAAA3B,OAAA,GAEYmC,UAAU","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_types","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.d.ts"],"sourcesContent":["import * as React from 'react';\r\nimport type { DocumentPickerOptions, MyUploaderProps, FileInfo } from './types';\r\n// import type { DownloadFileProps } from './types';\r\n\r\nexport * from './types';\r\n\r\n// DownloadFile Component Tanımı (3. Bunu ekledik)\r\n// export declare const DownloadFile: React.FC<DownloadFileProps>;\r\n\r\n// pickFile Fonksiyon Tanımı\r\nexport declare function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;\r\
|
|
1
|
+
{"version":3,"names":["_types","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.d.ts"],"sourcesContent":["import * as React from 'react';\r\nimport type { DocumentPickerOptions, MyUploaderProps, FileInfo, DownloadFileProps ,RotateImageProps } from './types';\r\n// import type { DownloadFileProps } from './types';\r\n\r\nexport * from './types';\r\n\r\n// DownloadFile Component Tanımı (3. Bunu ekledik)\r\n// export declare const DownloadFile: React.FC<DownloadFileProps>;\r\n\r\n// pickFile Fonksiyon Tanımı\r\nexport declare function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;\r\nexport declare function RotateImage(props:RotateImageProps):Promise<string>;\r\nexport declare const DownloadFile :React.FC<DownloadFileProps>;\r\nexport declare const MyUploader: React.FC<MyUploaderProps>;\r\n\r\n// Varsayılan dışa aktarım (İsteğe bağlı, genellikle ana bileşen verilir)\r\ndeclare const _default: React.FC<MyUploaderProps>;\r\nexport default _default;"],"mappings":";;;;;AAIA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -5,14 +5,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
7
|
MyUploader: true,
|
|
8
|
-
pickFile: true
|
|
8
|
+
pickFile: true,
|
|
9
|
+
RotateImage: true,
|
|
10
|
+
DownloadFile: true
|
|
9
11
|
};
|
|
12
|
+
Object.defineProperty(exports, "DownloadFile", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _DownloadFile.DownloadFile;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
10
18
|
Object.defineProperty(exports, "MyUploader", {
|
|
11
19
|
enumerable: true,
|
|
12
20
|
get: function () {
|
|
13
21
|
return _MyUploader.default;
|
|
14
22
|
}
|
|
15
23
|
});
|
|
24
|
+
Object.defineProperty(exports, "RotateImage", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _MyUploader.RotateImage;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
16
30
|
exports.default = void 0;
|
|
17
31
|
Object.defineProperty(exports, "pickFile", {
|
|
18
32
|
enumerable: true,
|
|
@@ -21,6 +35,7 @@ Object.defineProperty(exports, "pickFile", {
|
|
|
21
35
|
}
|
|
22
36
|
});
|
|
23
37
|
var _MyUploader = _interopRequireWildcard(require("./components/MyUploader"));
|
|
38
|
+
var _DownloadFile = require("./components/DownloadFile");
|
|
24
39
|
var _types = require("./types");
|
|
25
40
|
Object.keys(_types).forEach(function (key) {
|
|
26
41
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -34,9 +49,6 @@ Object.keys(_types).forEach(function (key) {
|
|
|
34
49
|
});
|
|
35
50
|
});
|
|
36
51
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
37
|
-
// import DownloadFile from "./components/DownloadFile";
|
|
38
|
-
// 2. Diğerlerini NAMED olarak dışa aktar (import { DownloadFile, pickFile } ... için)
|
|
39
|
-
// export { DownloadFile, pickFile };
|
|
40
52
|
// Sadece bu paketle ilgili olanları dışa aktar
|
|
41
53
|
// Varsayılan dışa aktarım olarak da ana bileşeni verelim
|
|
42
54
|
var _default = exports.default = _MyUploader.default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_MyUploader","_interopRequireWildcard","require","_types","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","set","getOwnPropertyDescriptor","_default","MyUploader"],"sources":["index.ts"],"sourcesContent":["import MyUploader,{pickFile} from \"./components/MyUploader\";\r\
|
|
1
|
+
{"version":3,"names":["_MyUploader","_interopRequireWildcard","require","_DownloadFile","_types","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","set","getOwnPropertyDescriptor","_default","MyUploader"],"sources":["index.ts"],"sourcesContent":["import MyUploader,{pickFile,RotateImage} from \"./components/MyUploader\";\r\nimport {DownloadFile} from \"./components/DownloadFile\";\r\n\r\n\r\n// Sadece bu paketle ilgili olanları dışa aktar\r\nexport { MyUploader, pickFile ,DownloadFile ,RotateImage };\r\nexport * from './types';\r\n\r\n// Varsayılan dışa aktarım olarak da ana bileşeni verelim\r\nexport default MyUploader;\r\n\r\n\r\n\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AAAAG,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAAwB,SAAAP,wBAAAgB,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAlB,uBAAA,YAAAA,CAAAgB,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAP,GAAA,CAAAC,CAAA,GAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAR,cAAA,CAAAC,IAAA,CAAAM,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAlB,MAAA,CAAAS,cAAA,KAAAT,MAAA,CAAAyB,wBAAA,CAAAb,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAR,GAAA,IAAAQ,CAAA,CAAAK,GAAA,IAAAN,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAFxB;AAIA;AAAA,IAAAa,QAAA,GAAAlB,OAAA,CAAAc,OAAA,GACeK,mBAAU","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["// import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\n// export interface FileInfo {\r\n// fileName: string;\r\n// fileSize: number; \r\n// fileType: string | null;\r\n// fileUri: string;\r\n// base64: string;\r\n// }\r\n\r\n// export interface MyUploaderProps{\r\n// onSelect: (files: FileInfo[]) => void;\r\n// onError?: (error: Error) => void;\r\n// buttonPlaceHolder?: string;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// disabled?: boolean; \r\n// multipleFiles?: boolean;\r\n// fileTypes?: string[];\r\n// maxSize?: number;\r\n// maxFiles?: number;\r\n// excludedUris?: string[];\r\n// }\r\n\r\n// export interface DownloadedFileInfo {\r\n// originalUrl: string;\r\n// localUri: string;\r\n// }\r\n\r\n// export interface SkippedFileInfo {\r\n// originalUrl: string;\r\n// reason: string; \r\n// }\r\n\r\n\r\n\r\n// export interface UploadFileProps {\r\n// files: string[];\r\n// multipleLoad?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean; \r\n// maxSize?: number;\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: Error) => void;\r\n// }\r\n\r\n// export interface DownloadFileProps {\r\n// files: string[];\r\n// multipleDownload?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean;\r\n// maxSize?: number; // MB\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: ViewStyle;\r\n// ButtonTextStyle?: TextStyle;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: any) => void;\r\n// }\r\n// export interface DownloadResult {\r\n// successful: { originalUrl: string; localUri: string | null }[];\r\n// skipped: { originalUrl: string; reason: string }[];\r\n// }\r\n\r\n\r\nimport type { ViewStyle, TextStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileUri: string;\r\n fileName: string;\r\n fileType: string;\r\n fileSize: number;\r\n base64?: string | null;\r\n}\r\n\r\n\r\n// ----- MyUploader & pickFile Props -----\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[]; // örn: ['image/*', 'application/pdf']\r\n maxSize?: number; // MB cinsinden\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n}\r\n\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n onSelect: (files: FileInfo[]) => void;\r\n onError?: (error: Error) => void;\r\n buttonPlaceHolder?: string;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n disabled?: boolean;\r\n}\r\n\r\n// ----- DownloadFile Props -----\r\nexport interface DownloadFileProps {\r\n files: string[];\r\n multipleDownload?: boolean; // multipleFiles yerine multipleDownload (İsim karışmaması için)\r\n disabled?: boolean;\r\n debug?: boolean;\r\n maxSize?: number; // MB\r\n fileTypes?: string[]; // İndirilecek dosyanın Content-Type kontrolü\r\n buttonPlaceHolder?: string;\r\n buttonIcon?: React.ReactNode;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n onSuccess?: (result: DownloadResult) => void;\r\n onError?: (error: any) => void;\r\n}\r\n\r\n\r\nexport interface DownloadResult {\r\n successful: { originalUrl: string; localUri: string | null }[];\r\n skipped: { originalUrl: string; reason: string }[];\r\n}"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["// import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\n// export interface FileInfo {\r\n// fileName: string;\r\n// fileSize: number; \r\n// fileType: string | null;\r\n// fileUri: string;\r\n// base64: string;\r\n// }\r\n\r\n// export interface MyUploaderProps{\r\n// onSelect: (files: FileInfo[]) => void;\r\n// onError?: (error: Error) => void;\r\n// buttonPlaceHolder?: string;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// disabled?: boolean; \r\n// multipleFiles?: boolean;\r\n// fileTypes?: string[];\r\n// maxSize?: number;\r\n// maxFiles?: number;\r\n// excludedUris?: string[];\r\n// }\r\n\r\n// export interface DownloadedFileInfo {\r\n// originalUrl: string;\r\n// localUri: string;\r\n// }\r\n\r\n// export interface SkippedFileInfo {\r\n// originalUrl: string;\r\n// reason: string; \r\n// }\r\n\r\n\r\n\r\n// export interface UploadFileProps {\r\n// files: string[];\r\n// multipleLoad?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean; \r\n// maxSize?: number;\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: Error) => void;\r\n// }\r\n\r\n// export interface DownloadFileProps {\r\n// files: string[];\r\n// multipleDownload?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean;\r\n// maxSize?: number; // MB\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: ViewStyle;\r\n// ButtonTextStyle?: TextStyle;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: any) => void;\r\n// }\r\n// export interface DownloadResult {\r\n// successful: { originalUrl: string; localUri: string | null }[];\r\n// skipped: { originalUrl: string; reason: string }[];\r\n// }\r\n\r\n\r\nimport type { ViewStyle, TextStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileUri: string;\r\n fileName: string;\r\n fileType: string;\r\n fileSize: number;\r\n base64?: string | null;\r\n}\r\n\r\n\r\n// ----- MyUploader & pickFile Props -----\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[]; // örn: ['image/*', 'application/pdf']\r\n maxSize?: number; // MB cinsinden\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n}\r\n\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n onSelect: (files: FileInfo[]) => void;\r\n onError?: (error: Error) => void;\r\n buttonPlaceHolder?: string;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n disabled?: boolean;\r\n}\r\n\r\n// ----- DownloadFile Props -----\r\nexport interface DownloadFileProps {\r\n files: string[];\r\n multipleDownload?: boolean; // multipleFiles yerine multipleDownload (İsim karışmaması için)\r\n disabled?: boolean;\r\n debug?: boolean;\r\n maxSize?: number; // MB\r\n fileTypes?: string[]; // İndirilecek dosyanın Content-Type kontrolü\r\n buttonPlaceHolder?: string;\r\n buttonIcon?: React.ReactNode;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n onSuccess?: (result: DownloadResult) => void;\r\n onError?: (error: any) => void;\r\n}\r\n\r\n\r\nexport interface DownloadResult {\r\n successful: { originalUrl: string; localUri: string | null }[];\r\n skipped: { originalUrl: string; reason: string }[];\r\n}\r\n\r\n\r\n///rotateImage\r\n\r\nexport interface RotateImageProps{\r\n base64: string, angle: number\r\n}"],"mappings":"","ignoreList":[]}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { TouchableOpacity, Text, StyleSheet, ActivityIndicator, NativeModules } from 'react-native';
|
|
2
|
+
import { TouchableOpacity, Text, StyleSheet, ActivityIndicator, NativeModules, Alert } from 'react-native';
|
|
3
3
|
const {
|
|
4
|
-
|
|
4
|
+
DownloadFileModule
|
|
5
5
|
} = NativeModules;
|
|
6
|
-
const DownloadFile = ({
|
|
6
|
+
export const DownloadFile = ({
|
|
7
7
|
files,
|
|
8
8
|
multipleDownload = false,
|
|
9
9
|
disabled = false,
|
|
10
10
|
debug = false,
|
|
11
11
|
maxSize = 0,
|
|
12
|
-
fileTypes = [
|
|
12
|
+
fileTypes = [],
|
|
13
13
|
buttonPlaceHolder = 'Dosyaları İndir',
|
|
14
14
|
buttonIcon,
|
|
15
15
|
ButtonStyle,
|
|
@@ -18,6 +18,14 @@ const DownloadFile = ({
|
|
|
18
18
|
onError
|
|
19
19
|
}) => {
|
|
20
20
|
const [isLoading, setIsLoading] = useState(false);
|
|
21
|
+
if (!DownloadFileModule) {
|
|
22
|
+
console.warn("DownloadFileModule bulunamadı. Native tarafın kurulduğundan emin olun.");
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const NativeDownloadModuleWrapper = (url, options) => {
|
|
26
|
+
// 🔥 Kotlin Promise metoduyla birebir uyumlu
|
|
27
|
+
return DownloadFileModule.downloadFile(url, options);
|
|
28
|
+
};
|
|
21
29
|
const handlePress = async () => {
|
|
22
30
|
if (disabled || isLoading || !files.length) return;
|
|
23
31
|
setIsLoading(true);
|
|
@@ -26,33 +34,57 @@ const DownloadFile = ({
|
|
|
26
34
|
maxSize,
|
|
27
35
|
fileTypes
|
|
28
36
|
};
|
|
29
|
-
|
|
37
|
+
|
|
38
|
+
// ✅ undefined güvenli
|
|
39
|
+
const targetFiles = (multipleDownload ? files : [files[0]]).filter(file => typeof file === 'string' && file.trim().length > 0);
|
|
40
|
+
const sizeErrors = [];
|
|
41
|
+
const typeErrors = [];
|
|
42
|
+
const otherErrors = [];
|
|
43
|
+
const successFiles = [];
|
|
30
44
|
try {
|
|
31
|
-
const promises = targetFiles.map(url =>
|
|
45
|
+
const promises = targetFiles.map(url => NativeDownloadModuleWrapper(url, options));
|
|
32
46
|
const results = await Promise.allSettled(promises);
|
|
33
|
-
const final = {
|
|
34
|
-
successful: [],
|
|
35
|
-
skipped: []
|
|
36
|
-
};
|
|
37
47
|
results.forEach((res, index) => {
|
|
38
|
-
var _targetFiles$index;
|
|
48
|
+
var _targetFiles$index, _originalUrl$split$po;
|
|
39
49
|
const originalUrl = (_targetFiles$index = targetFiles[index]) !== null && _targetFiles$index !== void 0 ? _targetFiles$index : "";
|
|
50
|
+
const fileName = ((_originalUrl$split$po = originalUrl.split('/').pop()) === null || _originalUrl$split$po === void 0 ? void 0 : _originalUrl$split$po.split('?')[0]) || `Dosya ${index + 1}`;
|
|
40
51
|
if (res.status === 'fulfilled') {
|
|
41
|
-
|
|
52
|
+
successFiles.push({
|
|
42
53
|
originalUrl,
|
|
43
54
|
localUri: res.value
|
|
44
55
|
});
|
|
45
56
|
} else {
|
|
46
|
-
var _res$reason;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
var _res$reason, _res$reason2;
|
|
58
|
+
const errorCode = (_res$reason = res.reason) === null || _res$reason === void 0 ? void 0 : _res$reason.code;
|
|
59
|
+
const errorMsg = ((_res$reason2 = res.reason) === null || _res$reason2 === void 0 ? void 0 : _res$reason2.message) || 'Bilinmeyen hata';
|
|
60
|
+
if (errorCode === 'ERR_SIZE_LIMIT') {
|
|
61
|
+
sizeErrors.push(fileName);
|
|
62
|
+
} else if (errorCode === 'ERR_TYPE_MISMATCH') {
|
|
63
|
+
typeErrors.push(fileName);
|
|
64
|
+
} else {
|
|
65
|
+
otherErrors.push(`${fileName}: ${errorMsg}`);
|
|
66
|
+
}
|
|
51
67
|
}
|
|
52
68
|
});
|
|
53
|
-
if (
|
|
69
|
+
if (sizeErrors.length > 0) {
|
|
70
|
+
Alert.alert('Boyut Sınırı Aşıldı', `Aşağıdaki dosyalar ${maxSize}MB sınırını aştığı için indirilemedi:\n\n${sizeErrors.join('\n')}`);
|
|
71
|
+
}
|
|
72
|
+
if (typeErrors.length > 0) {
|
|
73
|
+
Alert.alert('Desteklenmeyen Dosya Tipi', `Sadece şu formatlar izin verilmektedir: [${fileTypes.join(', ')}]\n\nUygun olmayan dosyalar:\n\n${typeErrors.join('\n')}`);
|
|
74
|
+
}
|
|
75
|
+
if (otherErrors.length > 0 && debug) {
|
|
76
|
+
Alert.alert('İndirme Hatası', otherErrors.join('\n'));
|
|
77
|
+
}
|
|
78
|
+
const finalResult = {
|
|
79
|
+
successful: successFiles,
|
|
80
|
+
skipped: [...sizeErrors, ...typeErrors, ...otherErrors].map(name => ({
|
|
81
|
+
originalUrl: name,
|
|
82
|
+
reason: 'Failed'
|
|
83
|
+
}))
|
|
84
|
+
};
|
|
85
|
+
onSuccess === null || onSuccess === void 0 || onSuccess(finalResult);
|
|
54
86
|
} catch (e) {
|
|
55
|
-
|
|
87
|
+
onError === null || onError === void 0 || onError(e);
|
|
56
88
|
} finally {
|
|
57
89
|
setIsLoading(false);
|
|
58
90
|
}
|
|
@@ -63,7 +95,7 @@ const DownloadFile = ({
|
|
|
63
95
|
disabled: disabled || isLoading
|
|
64
96
|
}, isLoading ? /*#__PURE__*/React.createElement(ActivityIndicator, {
|
|
65
97
|
color: "#FFF"
|
|
66
|
-
}) : buttonIcon
|
|
98
|
+
}) : buttonIcon || /*#__PURE__*/React.createElement(Text, {
|
|
67
99
|
style: [styles.text, ButtonTextStyle]
|
|
68
100
|
}, buttonPlaceHolder));
|
|
69
101
|
};
|
|
@@ -82,5 +114,4 @@ const styles = StyleSheet.create({
|
|
|
82
114
|
backgroundColor: '#AAA'
|
|
83
115
|
}
|
|
84
116
|
});
|
|
85
|
-
export default DownloadFile;
|
|
86
117
|
//# sourceMappingURL=DownloadFile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useState","TouchableOpacity","Text","StyleSheet","ActivityIndicator","NativeModules","
|
|
1
|
+
{"version":3,"names":["React","useState","TouchableOpacity","Text","StyleSheet","ActivityIndicator","NativeModules","Alert","DownloadFileModule","DownloadFile","files","multipleDownload","disabled","debug","maxSize","fileTypes","buttonPlaceHolder","buttonIcon","ButtonStyle","ButtonTextStyle","onSuccess","onError","isLoading","setIsLoading","console","warn","NativeDownloadModuleWrapper","url","options","downloadFile","handlePress","length","targetFiles","filter","file","trim","sizeErrors","typeErrors","otherErrors","successFiles","promises","map","results","Promise","allSettled","forEach","res","index","_targetFiles$index","_originalUrl$split$po","originalUrl","fileName","split","pop","status","push","localUri","value","_res$reason","_res$reason2","errorCode","reason","code","errorMsg","message","alert","join","finalResult","successful","skipped","name","e","createElement","style","styles","button","onPress","color","text","create","backgroundColor","padding","borderRadius","alignItems","fontWeight"],"sources":["DownloadFile.tsx"],"sourcesContent":["import React, { useState } from 'react';\r\nimport {\r\n TouchableOpacity,\r\n Text,\r\n StyleSheet,\r\n ActivityIndicator,\r\n NativeModules,\r\n Alert,\r\n} from 'react-native';\r\nimport type { DownloadFileProps, DownloadResult } from '../types';\r\n\r\nconst { DownloadFileModule } = NativeModules;\r\n\r\nexport const DownloadFile: React.FC<DownloadFileProps> = ({\r\n files,\r\n multipleDownload = false,\r\n disabled = false,\r\n debug = false,\r\n maxSize = 0,\r\n fileTypes = [],\r\n buttonPlaceHolder = 'Dosyaları İndir',\r\n buttonIcon,\r\n ButtonStyle,\r\n ButtonTextStyle,\r\n onSuccess,\r\n onError,\r\n}) => {\r\n const [isLoading, setIsLoading] = useState(false);\r\n\r\n if (!DownloadFileModule) {\r\n console.warn(\"DownloadFileModule bulunamadı. Native tarafın kurulduğundan emin olun.\");\r\n return null;\r\n }\r\n\r\n const NativeDownloadModuleWrapper = (\r\n url: string,\r\n options: any\r\n ): Promise<string> => {\r\n // 🔥 Kotlin Promise metoduyla birebir uyumlu\r\n return DownloadFileModule.downloadFile(url, options);\r\n };\r\n\r\n const handlePress = async () => {\r\n if (disabled || isLoading || !files.length) return;\r\n setIsLoading(true);\r\n\r\n const options = { debug, maxSize, fileTypes };\r\n\r\n // ✅ undefined güvenli\r\n const targetFiles: string[] = (\r\n multipleDownload ? files : [files[0]]\r\n ).filter((file): file is string => typeof file === 'string' && file.trim().length > 0);\r\n\r\n const sizeErrors: string[] = [];\r\n const typeErrors: string[] = [];\r\n const otherErrors: string[] = [];\r\n const successFiles: DownloadResult['successful'] = [];\r\n\r\n try {\r\n const promises = targetFiles.map(url =>\r\n NativeDownloadModuleWrapper(url, options)\r\n );\r\n\r\n const results = await Promise.allSettled(promises);\r\n\r\n results.forEach((res, index) => {\r\n const originalUrl = targetFiles[index] ?? \"\";\r\n const fileName =\r\n originalUrl.split('/').pop()?.split('?')[0] ||\r\n `Dosya ${index + 1}`;\r\n\r\n if (res.status === 'fulfilled') {\r\n successFiles.push({\r\n originalUrl,\r\n localUri: res.value,\r\n });\r\n } else {\r\n const errorCode = res.reason?.code;\r\n const errorMsg = res.reason?.message || 'Bilinmeyen hata';\r\n\r\n if (errorCode === 'ERR_SIZE_LIMIT') {\r\n sizeErrors.push(fileName);\r\n } else if (errorCode === 'ERR_TYPE_MISMATCH') {\r\n typeErrors.push(fileName);\r\n } else {\r\n otherErrors.push(`${fileName}: ${errorMsg}`);\r\n }\r\n }\r\n });\r\n\r\n if (sizeErrors.length > 0) {\r\n Alert.alert(\r\n 'Boyut Sınırı Aşıldı',\r\n `Aşağıdaki dosyalar ${maxSize}MB sınırını aştığı için indirilemedi:\\n\\n${sizeErrors.join(\r\n '\\n'\r\n )}`\r\n );\r\n }\r\n\r\n if (typeErrors.length > 0) {\r\n Alert.alert(\r\n 'Desteklenmeyen Dosya Tipi',\r\n `Sadece şu formatlar izin verilmektedir: [${fileTypes.join(\r\n ', '\r\n )}]\\n\\nUygun olmayan dosyalar:\\n\\n${typeErrors.join('\\n')}`\r\n );\r\n }\r\n\r\n if (otherErrors.length > 0 && debug) {\r\n Alert.alert('İndirme Hatası', otherErrors.join('\\n'));\r\n }\r\n\r\n const finalResult: DownloadResult = {\r\n successful: successFiles,\r\n skipped: [...sizeErrors, ...typeErrors, ...otherErrors].map(\r\n name => ({\r\n originalUrl: name,\r\n reason: 'Failed',\r\n })\r\n ),\r\n };\r\n\r\n onSuccess?.(finalResult);\r\n } catch (e) {\r\n onError?.(e);\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n\r\n return (\r\n <TouchableOpacity\r\n style={[styles.button, ButtonStyle, (disabled || isLoading) && styles.disabled]}\r\n onPress={handlePress}\r\n disabled={disabled || isLoading}\r\n >\r\n {isLoading ? (\r\n <ActivityIndicator color=\"#FFF\" />\r\n ) : (\r\n buttonIcon || (\r\n <Text style={[styles.text, ButtonTextStyle]}>\r\n {buttonPlaceHolder}\r\n </Text>\r\n )\r\n )}\r\n </TouchableOpacity>\r\n );\r\n};\r\n\r\nconst styles = StyleSheet.create({\r\n button: {\r\n backgroundColor: '#03DAC6',\r\n padding: 12,\r\n borderRadius: 8,\r\n alignItems: 'center',\r\n },\r\n text: {\r\n color: '#000',\r\n fontWeight: 'bold',\r\n },\r\n disabled: {\r\n backgroundColor: '#AAA',\r\n },\r\n});\r\n\r\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SACEC,gBAAgB,EAChBC,IAAI,EACJC,UAAU,EACVC,iBAAiB,EACjBC,aAAa,EACbC,KAAK,QACA,cAAc;AAGrB,MAAM;EAAEC;AAAmB,CAAC,GAAGF,aAAa;AAE5C,OAAO,MAAMG,YAAyC,GAAGA,CAAC;EACxDC,KAAK;EACLC,gBAAgB,GAAG,KAAK;EACxBC,QAAQ,GAAG,KAAK;EAChBC,KAAK,GAAG,KAAK;EACbC,OAAO,GAAG,CAAC;EACXC,SAAS,GAAG,EAAE;EACdC,iBAAiB,GAAG,iBAAiB;EACrCC,UAAU;EACVC,WAAW;EACXC,eAAe;EACfC,SAAS;EACTC;AACF,CAAC,KAAK;EACJ,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGtB,QAAQ,CAAC,KAAK,CAAC;EAEjD,IAAI,CAACO,kBAAkB,EAAE;IACvBgB,OAAO,CAACC,IAAI,CAAC,wEAAwE,CAAC;IACtF,OAAO,IAAI;EACb;EAEA,MAAMC,2BAA2B,GAAGA,CAClCC,GAAW,EACXC,OAAY,KACQ;IACpB;IACA,OAAOpB,kBAAkB,CAACqB,YAAY,CAACF,GAAG,EAAEC,OAAO,CAAC;EACtD,CAAC;EAED,MAAME,WAAW,GAAG,MAAAA,CAAA,KAAY;IAC9B,IAAIlB,QAAQ,IAAIU,SAAS,IAAI,CAACZ,KAAK,CAACqB,MAAM,EAAE;IAC5CR,YAAY,CAAC,IA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pickFile = async (options = {}) => {
|
|
|
19
19
|
};
|
|
20
20
|
return await NativeUploadPicker.openDocument(nativeOptions);
|
|
21
21
|
};
|
|
22
|
+
export const RotateImage = async ({
|
|
23
|
+
base64,
|
|
24
|
+
angle
|
|
25
|
+
}) => {
|
|
26
|
+
if (!NativeUploadPicker) {
|
|
27
|
+
throw new Error("UploadDocumentPicker module is not linked.");
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const rotatedBase64 = await NativeUploadPicker.rotateImage(base64, angle);
|
|
31
|
+
|
|
32
|
+
// JS tarafında prefix eklenir
|
|
33
|
+
return `data:image/jpeg;base64,${rotatedBase64}`;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
throw new Error(`RotateImage Error: ${error.message}`);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
22
38
|
|
|
23
39
|
// 2. MyUploader Bileşeni
|
|
24
40
|
const MyUploader = ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useState","TouchableOpacity","Text","StyleSheet","ActivityIndicator","NativeModules","UploadDocumentPicker","NativeUploadPicker","pickFile","options","_options$multipleFile","_options$maxFiles","_options$maxSize","_options$fileTypes","_options$excludedUris","Error","nativeOptions","multipleFiles","maxFiles","maxSize","fileTypes","excludedUris","openDocument","MyUploader","onSelect","onError","buttonPlaceHolder","ButtonStyle","ButtonTextStyle","disabled","isLoading","setIsLoading","handlePress","files","
|
|
1
|
+
{"version":3,"names":["React","useState","TouchableOpacity","Text","StyleSheet","ActivityIndicator","NativeModules","UploadDocumentPicker","NativeUploadPicker","pickFile","options","_options$multipleFile","_options$maxFiles","_options$maxSize","_options$fileTypes","_options$excludedUris","Error","nativeOptions","multipleFiles","maxFiles","maxSize","fileTypes","excludedUris","openDocument","RotateImage","base64","angle","rotatedBase64","rotateImage","error","message","MyUploader","onSelect","onError","buttonPlaceHolder","ButtonStyle","ButtonTextStyle","disabled","isLoading","setIsLoading","handlePress","files","console","createElement","style","styles","button","onPress","color","text","create","backgroundColor","padding","borderRadius","alignItems","justifyContent","fontWeight","fontSize"],"sources":["MyUploader.tsx"],"sourcesContent":["import React, { useState } from 'react';\r\nimport { TouchableOpacity, Text, StyleSheet, ActivityIndicator, NativeModules } from 'react-native';\r\nimport type { MyUploaderProps, DocumentPickerOptions, FileInfo, RotateImageProps } from '../types';\r\n\r\nconst { UploadDocumentPicker: NativeUploadPicker } = NativeModules;\r\n\r\n// 1. Standalone pickFile Fonksiyonu\r\nexport const pickFile = async (options: DocumentPickerOptions = {}): Promise<FileInfo[]> => {\r\n if (!NativeUploadPicker) throw new Error(\"DocumentPicker module is not linked.\");\r\n\r\n // Native tarafa gönderilecek options\r\n const nativeOptions = {\r\n multipleFiles: options.multipleFiles ?? false,\r\n maxFiles: options.maxFiles ?? 0,\r\n maxSize: options.maxSize ?? 0,\r\n fileTypes: options.fileTypes ?? ['*/*'],\r\n excludedUris: options.excludedUris ?? [],\r\n };\r\n\r\n return await NativeUploadPicker.openDocument(nativeOptions);\r\n};\r\n\r\nexport const RotateImage = async ({ base64, angle }: RotateImageProps): Promise<string> => {\r\n if (!NativeUploadPicker) {\r\n throw new Error(\"UploadDocumentPicker module is not linked.\");\r\n }\r\n\r\n try {\r\n const rotatedBase64: string =\r\n await NativeUploadPicker.rotateImage(base64, angle);\r\n\r\n // JS tarafında prefix eklenir\r\n return `data:image/jpeg;base64,${rotatedBase64}`;\r\n } catch (error: any) {\r\n throw new Error(`RotateImage Error: ${error.message}`);\r\n }\r\n};\r\n\r\n// 2. MyUploader Bileşeni\r\nconst MyUploader: React.FC<MyUploaderProps> = ({\r\n onSelect,\r\n onError,\r\n buttonPlaceHolder = \"Dosya Seç\",\r\n ButtonStyle,\r\n ButtonTextStyle,\r\n disabled = false,\r\n multipleFiles = false,\r\n fileTypes = ['*/*'],\r\n maxSize = 0,\r\n maxFiles = 0,\r\n excludedUris = [],\r\n}) => {\r\n const [isLoading, setIsLoading] = useState(false);\r\n\r\n const handlePress = async () => {\r\n if (disabled || isLoading) return;\r\n setIsLoading(true);\r\n\r\n try {\r\n const files = await pickFile({\r\n multipleFiles,\r\n fileTypes,\r\n maxSize,\r\n maxFiles,\r\n excludedUris\r\n });\r\n\r\n onSelect(files);\r\n } catch (error: any) {\r\n if (onError) {\r\n onError(error);\r\n } else {\r\n console.error(\"MyUploader Error:\", error);\r\n }\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n\r\n return (\r\n <TouchableOpacity\r\n style={[styles.button, ButtonStyle, (disabled || isLoading) && styles.disabled]}\r\n onPress={handlePress}\r\n disabled={disabled || isLoading}\r\n >\r\n {isLoading ? (\r\n <ActivityIndicator color=\"#FFF\" />\r\n ) : (\r\n <Text style={[styles.text, ButtonTextStyle]}>{buttonPlaceHolder}</Text>\r\n )}\r\n </TouchableOpacity>\r\n );\r\n};\r\n\r\nconst styles = StyleSheet.create({\r\n button: {\r\n backgroundColor: '#6200EE',\r\n padding: 12,\r\n borderRadius: 8,\r\n alignItems: 'center',\r\n justifyContent: 'center'\r\n },\r\n text: {\r\n color: '#FFF',\r\n fontWeight: '600',\r\n fontSize: 16\r\n },\r\n disabled: {\r\n backgroundColor: '#B0B0B0'\r\n }\r\n});\r\n\r\nexport default MyUploader;"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,gBAAgB,EAAEC,IAAI,EAAEC,UAAU,EAAEC,iBAAiB,EAAEC,aAAa,QAAQ,cAAc;AAGnG,MAAM;EAAEC,oBAAoB,EAAEC;AAAmB,CAAC,GAAGF,aAAa;;AAElE;AACA,OAAO,MAAMG,QAAQ,GAAG,MAAAA,CAAOC,OAA8B,GAAG,CAAC,CAAC,KAA0B;EAAA,IAAAC,qBAAA,EAAAC,iBAAA,EAAAC,gBAAA,EAAAC,kBAAA,EAAAC,qBAAA;EAC1F,IAAI,CAACP,kBAAkB,EAAE,MAAM,IAAIQ,KAAK,CAAC,sCAAsC,CAAC;;EAEhF;EACA,MAAMC,aAAa,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;IACNK,eAAe,EAAE,SAAS;IAC1BC,OAAO,EAAE,EAAE;IACXC,YAAY,EAAE,CAAC;IACfC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDN,IAAI,EAAE;IACJD,KAAK,EAAE,MAAM;IACbQ,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ,CAAC;EACDpB,QAAQ,EAAE;IACRc,eAAe,EAAE;EACnB;AACF,CAAC,CAAC;AAEF,eAAepB,UAAU","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.d.ts"],"sourcesContent":["import * as React from 'react';\r\nimport type { DocumentPickerOptions, MyUploaderProps, FileInfo } from './types';\r\n// import type { DownloadFileProps } from './types';\r\n\r\nexport * from './types';\r\n\r\n// DownloadFile Component Tanımı (3. Bunu ekledik)\r\n// export declare const DownloadFile: React.FC<DownloadFileProps>;\r\n\r\n// pickFile Fonksiyon Tanımı\r\nexport declare function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;\r\
|
|
1
|
+
{"version":3,"names":[],"sources":["index.d.ts"],"sourcesContent":["import * as React from 'react';\r\nimport type { DocumentPickerOptions, MyUploaderProps, FileInfo, DownloadFileProps ,RotateImageProps } from './types';\r\n// import type { DownloadFileProps } from './types';\r\n\r\nexport * from './types';\r\n\r\n// DownloadFile Component Tanımı (3. Bunu ekledik)\r\n// export declare const DownloadFile: React.FC<DownloadFileProps>;\r\n\r\n// pickFile Fonksiyon Tanımı\r\nexport declare function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;\r\nexport declare function RotateImage(props:RotateImageProps):Promise<string>;\r\nexport declare const DownloadFile :React.FC<DownloadFileProps>;\r\nexport declare const MyUploader: React.FC<MyUploaderProps>;\r\n\r\n// Varsayılan dışa aktarım (İsteğe bağlı, genellikle ana bileşen verilir)\r\ndeclare const _default: React.FC<MyUploaderProps>;\r\nexport default _default;"],"mappings":"AAEA;;AAEA,cAAc,SAAS;;AAEvB;AACA;;AAEA;;AAMA;AAAA","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import MyUploader, { pickFile } from "./components/MyUploader";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// 2. Diğerlerini NAMED olarak dışa aktar (import { DownloadFile, pickFile } ... için)
|
|
5
|
-
// export { DownloadFile, pickFile };
|
|
1
|
+
import MyUploader, { pickFile, RotateImage } from "./components/MyUploader";
|
|
2
|
+
import { DownloadFile } from "./components/DownloadFile";
|
|
6
3
|
|
|
7
4
|
// Sadece bu paketle ilgili olanları dışa aktar
|
|
8
|
-
export { MyUploader, pickFile };
|
|
5
|
+
export { MyUploader, pickFile, DownloadFile, RotateImage };
|
|
9
6
|
export * from './types';
|
|
10
7
|
|
|
11
8
|
// Varsayılan dışa aktarım olarak da ana bileşeni verelim
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["MyUploader","pickFile"],"sources":["index.ts"],"sourcesContent":["import MyUploader,{pickFile} from \"./components/MyUploader\";\r\
|
|
1
|
+
{"version":3,"names":["MyUploader","pickFile","RotateImage","DownloadFile"],"sources":["index.ts"],"sourcesContent":["import MyUploader,{pickFile,RotateImage} from \"./components/MyUploader\";\r\nimport {DownloadFile} from \"./components/DownloadFile\";\r\n\r\n\r\n// Sadece bu paketle ilgili olanları dışa aktar\r\nexport { MyUploader, pickFile ,DownloadFile ,RotateImage };\r\nexport * from './types';\r\n\r\n// Varsayılan dışa aktarım olarak da ana bileşeni verelim\r\nexport default MyUploader;\r\n\r\n\r\n\r\n"],"mappings":"AAAA,OAAOA,UAAU,IAAEC,QAAQ,EAACC,WAAW,QAAO,yBAAyB;AACvE,SAAQC,YAAY,QAAO,2BAA2B;;AAGtD;AACA,SAASH,UAAU,EAAEC,QAAQ,EAAEE,YAAY,EAAED,WAAW;AACxD,cAAc,SAAS;;AAEvB;AACA,eAAeF,UAAU","ignoreList":[]}
|
package/lib/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["// import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\n// export interface FileInfo {\r\n// fileName: string;\r\n// fileSize: number; \r\n// fileType: string | null;\r\n// fileUri: string;\r\n// base64: string;\r\n// }\r\n\r\n// export interface MyUploaderProps{\r\n// onSelect: (files: FileInfo[]) => void;\r\n// onError?: (error: Error) => void;\r\n// buttonPlaceHolder?: string;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// disabled?: boolean; \r\n// multipleFiles?: boolean;\r\n// fileTypes?: string[];\r\n// maxSize?: number;\r\n// maxFiles?: number;\r\n// excludedUris?: string[];\r\n// }\r\n\r\n// export interface DownloadedFileInfo {\r\n// originalUrl: string;\r\n// localUri: string;\r\n// }\r\n\r\n// export interface SkippedFileInfo {\r\n// originalUrl: string;\r\n// reason: string; \r\n// }\r\n\r\n\r\n\r\n// export interface UploadFileProps {\r\n// files: string[];\r\n// multipleLoad?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean; \r\n// maxSize?: number;\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: Error) => void;\r\n// }\r\n\r\n// export interface DownloadFileProps {\r\n// files: string[];\r\n// multipleDownload?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean;\r\n// maxSize?: number; // MB\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: ViewStyle;\r\n// ButtonTextStyle?: TextStyle;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: any) => void;\r\n// }\r\n// export interface DownloadResult {\r\n// successful: { originalUrl: string; localUri: string | null }[];\r\n// skipped: { originalUrl: string; reason: string }[];\r\n// }\r\n\r\n\r\nimport type { ViewStyle, TextStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileUri: string;\r\n fileName: string;\r\n fileType: string;\r\n fileSize: number;\r\n base64?: string | null;\r\n}\r\n\r\n\r\n// ----- MyUploader & pickFile Props -----\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[]; // örn: ['image/*', 'application/pdf']\r\n maxSize?: number; // MB cinsinden\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n}\r\n\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n onSelect: (files: FileInfo[]) => void;\r\n onError?: (error: Error) => void;\r\n buttonPlaceHolder?: string;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n disabled?: boolean;\r\n}\r\n\r\n// ----- DownloadFile Props -----\r\nexport interface DownloadFileProps {\r\n files: string[];\r\n multipleDownload?: boolean; // multipleFiles yerine multipleDownload (İsim karışmaması için)\r\n disabled?: boolean;\r\n debug?: boolean;\r\n maxSize?: number; // MB\r\n fileTypes?: string[]; // İndirilecek dosyanın Content-Type kontrolü\r\n buttonPlaceHolder?: string;\r\n buttonIcon?: React.ReactNode;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n onSuccess?: (result: DownloadResult) => void;\r\n onError?: (error: any) => void;\r\n}\r\n\r\n\r\nexport interface DownloadResult {\r\n successful: { originalUrl: string; localUri: string | null }[];\r\n skipped: { originalUrl: string; reason: string }[];\r\n}"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["// import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\n// export interface FileInfo {\r\n// fileName: string;\r\n// fileSize: number; \r\n// fileType: string | null;\r\n// fileUri: string;\r\n// base64: string;\r\n// }\r\n\r\n// export interface MyUploaderProps{\r\n// onSelect: (files: FileInfo[]) => void;\r\n// onError?: (error: Error) => void;\r\n// buttonPlaceHolder?: string;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// disabled?: boolean; \r\n// multipleFiles?: boolean;\r\n// fileTypes?: string[];\r\n// maxSize?: number;\r\n// maxFiles?: number;\r\n// excludedUris?: string[];\r\n// }\r\n\r\n// export interface DownloadedFileInfo {\r\n// originalUrl: string;\r\n// localUri: string;\r\n// }\r\n\r\n// export interface SkippedFileInfo {\r\n// originalUrl: string;\r\n// reason: string; \r\n// }\r\n\r\n\r\n\r\n// export interface UploadFileProps {\r\n// files: string[];\r\n// multipleLoad?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean; \r\n// maxSize?: number;\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: Error) => void;\r\n// }\r\n\r\n// export interface DownloadFileProps {\r\n// files: string[];\r\n// multipleDownload?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean;\r\n// maxSize?: number; // MB\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: ViewStyle;\r\n// ButtonTextStyle?: TextStyle;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: any) => void;\r\n// }\r\n// export interface DownloadResult {\r\n// successful: { originalUrl: string; localUri: string | null }[];\r\n// skipped: { originalUrl: string; reason: string }[];\r\n// }\r\n\r\n\r\nimport type { ViewStyle, TextStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileUri: string;\r\n fileName: string;\r\n fileType: string;\r\n fileSize: number;\r\n base64?: string | null;\r\n}\r\n\r\n\r\n// ----- MyUploader & pickFile Props -----\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[]; // örn: ['image/*', 'application/pdf']\r\n maxSize?: number; // MB cinsinden\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n}\r\n\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n onSelect: (files: FileInfo[]) => void;\r\n onError?: (error: Error) => void;\r\n buttonPlaceHolder?: string;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n disabled?: boolean;\r\n}\r\n\r\n// ----- DownloadFile Props -----\r\nexport interface DownloadFileProps {\r\n files: string[];\r\n multipleDownload?: boolean; // multipleFiles yerine multipleDownload (İsim karışmaması için)\r\n disabled?: boolean;\r\n debug?: boolean;\r\n maxSize?: number; // MB\r\n fileTypes?: string[]; // İndirilecek dosyanın Content-Type kontrolü\r\n buttonPlaceHolder?: string;\r\n buttonIcon?: React.ReactNode;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n onSuccess?: (result: DownloadResult) => void;\r\n onError?: (error: any) => void;\r\n}\r\n\r\n\r\nexport interface DownloadResult {\r\n successful: { originalUrl: string; localUri: string | null }[];\r\n skipped: { originalUrl: string; reason: string }[];\r\n}\r\n\r\n\r\n///rotateImage\r\n\r\nexport interface RotateImageProps{\r\n base64: string, angle: number\r\n}"],"mappings":"","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
TouchableOpacity,
|
|
4
|
+
Text,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
ActivityIndicator,
|
|
7
|
+
NativeModules,
|
|
8
|
+
Alert,
|
|
9
|
+
} from 'react-native';
|
|
3
10
|
import type { DownloadFileProps, DownloadResult } from '../types';
|
|
4
11
|
|
|
12
|
+
const { DownloadFileModule } = NativeModules;
|
|
5
13
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const DownloadFile: React.FC<DownloadFileProps> = ({
|
|
14
|
+
export const DownloadFile: React.FC<DownloadFileProps> = ({
|
|
10
15
|
files,
|
|
11
16
|
multipleDownload = false,
|
|
12
17
|
disabled = false,
|
|
13
18
|
debug = false,
|
|
14
19
|
maxSize = 0,
|
|
15
|
-
fileTypes = [
|
|
20
|
+
fileTypes = [],
|
|
16
21
|
buttonPlaceHolder = 'Dosyaları İndir',
|
|
17
22
|
buttonIcon,
|
|
18
23
|
ButtonStyle,
|
|
@@ -22,35 +27,102 @@ const DownloadFile: React.FC<DownloadFileProps> = ({
|
|
|
22
27
|
}) => {
|
|
23
28
|
const [isLoading, setIsLoading] = useState(false);
|
|
24
29
|
|
|
30
|
+
if (!DownloadFileModule) {
|
|
31
|
+
console.warn("DownloadFileModule bulunamadı. Native tarafın kurulduğundan emin olun.");
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const NativeDownloadModuleWrapper = (
|
|
36
|
+
url: string,
|
|
37
|
+
options: any
|
|
38
|
+
): Promise<string> => {
|
|
39
|
+
// 🔥 Kotlin Promise metoduyla birebir uyumlu
|
|
40
|
+
return DownloadFileModule.downloadFile(url, options);
|
|
41
|
+
};
|
|
42
|
+
|
|
25
43
|
const handlePress = async () => {
|
|
26
44
|
if (disabled || isLoading || !files.length) return;
|
|
27
45
|
setIsLoading(true);
|
|
28
46
|
|
|
29
47
|
const options = { debug, maxSize, fileTypes };
|
|
30
|
-
|
|
48
|
+
|
|
49
|
+
// ✅ undefined güvenli
|
|
50
|
+
const targetFiles: string[] = (
|
|
51
|
+
multipleDownload ? files : [files[0]]
|
|
52
|
+
).filter((file): file is string => typeof file === 'string' && file.trim().length > 0);
|
|
53
|
+
|
|
54
|
+
const sizeErrors: string[] = [];
|
|
55
|
+
const typeErrors: string[] = [];
|
|
56
|
+
const otherErrors: string[] = [];
|
|
57
|
+
const successFiles: DownloadResult['successful'] = [];
|
|
31
58
|
|
|
32
59
|
try {
|
|
33
|
-
const promises = targetFiles.map(url =>
|
|
60
|
+
const promises = targetFiles.map(url =>
|
|
61
|
+
NativeDownloadModuleWrapper(url, options)
|
|
62
|
+
);
|
|
63
|
+
|
|
34
64
|
const results = await Promise.allSettled(promises);
|
|
35
|
-
|
|
36
|
-
const final: DownloadResult = { successful: [], skipped: [] };
|
|
37
65
|
|
|
38
66
|
results.forEach((res, index) => {
|
|
39
67
|
const originalUrl = targetFiles[index] ?? "";
|
|
68
|
+
const fileName =
|
|
69
|
+
originalUrl.split('/').pop()?.split('?')[0] ||
|
|
70
|
+
`Dosya ${index + 1}`;
|
|
71
|
+
|
|
40
72
|
if (res.status === 'fulfilled') {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
originalUrl,
|
|
45
|
-
reason: res.reason?.message || "Bilinmeyen Hata"
|
|
73
|
+
successFiles.push({
|
|
74
|
+
originalUrl,
|
|
75
|
+
localUri: res.value,
|
|
46
76
|
});
|
|
77
|
+
} else {
|
|
78
|
+
const errorCode = res.reason?.code;
|
|
79
|
+
const errorMsg = res.reason?.message || 'Bilinmeyen hata';
|
|
80
|
+
|
|
81
|
+
if (errorCode === 'ERR_SIZE_LIMIT') {
|
|
82
|
+
sizeErrors.push(fileName);
|
|
83
|
+
} else if (errorCode === 'ERR_TYPE_MISMATCH') {
|
|
84
|
+
typeErrors.push(fileName);
|
|
85
|
+
} else {
|
|
86
|
+
otherErrors.push(`${fileName}: ${errorMsg}`);
|
|
87
|
+
}
|
|
47
88
|
}
|
|
48
89
|
});
|
|
49
90
|
|
|
50
|
-
if (
|
|
91
|
+
if (sizeErrors.length > 0) {
|
|
92
|
+
Alert.alert(
|
|
93
|
+
'Boyut Sınırı Aşıldı',
|
|
94
|
+
`Aşağıdaki dosyalar ${maxSize}MB sınırını aştığı için indirilemedi:\n\n${sizeErrors.join(
|
|
95
|
+
'\n'
|
|
96
|
+
)}`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (typeErrors.length > 0) {
|
|
101
|
+
Alert.alert(
|
|
102
|
+
'Desteklenmeyen Dosya Tipi',
|
|
103
|
+
`Sadece şu formatlar izin verilmektedir: [${fileTypes.join(
|
|
104
|
+
', '
|
|
105
|
+
)}]\n\nUygun olmayan dosyalar:\n\n${typeErrors.join('\n')}`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (otherErrors.length > 0 && debug) {
|
|
110
|
+
Alert.alert('İndirme Hatası', otherErrors.join('\n'));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const finalResult: DownloadResult = {
|
|
114
|
+
successful: successFiles,
|
|
115
|
+
skipped: [...sizeErrors, ...typeErrors, ...otherErrors].map(
|
|
116
|
+
name => ({
|
|
117
|
+
originalUrl: name,
|
|
118
|
+
reason: 'Failed',
|
|
119
|
+
})
|
|
120
|
+
),
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
onSuccess?.(finalResult);
|
|
51
124
|
} catch (e) {
|
|
52
|
-
|
|
53
|
-
else console.error(e);
|
|
125
|
+
onError?.(e);
|
|
54
126
|
} finally {
|
|
55
127
|
setIsLoading(false);
|
|
56
128
|
}
|
|
@@ -65,7 +137,11 @@ const DownloadFile: React.FC<DownloadFileProps> = ({
|
|
|
65
137
|
{isLoading ? (
|
|
66
138
|
<ActivityIndicator color="#FFF" />
|
|
67
139
|
) : (
|
|
68
|
-
buttonIcon
|
|
140
|
+
buttonIcon || (
|
|
141
|
+
<Text style={[styles.text, ButtonTextStyle]}>
|
|
142
|
+
{buttonPlaceHolder}
|
|
143
|
+
</Text>
|
|
144
|
+
)
|
|
69
145
|
)}
|
|
70
146
|
</TouchableOpacity>
|
|
71
147
|
);
|
|
@@ -78,8 +154,12 @@ const styles = StyleSheet.create({
|
|
|
78
154
|
borderRadius: 8,
|
|
79
155
|
alignItems: 'center',
|
|
80
156
|
},
|
|
81
|
-
text: {
|
|
82
|
-
|
|
157
|
+
text: {
|
|
158
|
+
color: '#000',
|
|
159
|
+
fontWeight: 'bold',
|
|
160
|
+
},
|
|
161
|
+
disabled: {
|
|
162
|
+
backgroundColor: '#AAA',
|
|
163
|
+
},
|
|
83
164
|
});
|
|
84
165
|
|
|
85
|
-
export default DownloadFile;
|