-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
making logic for getting files from specific app folder
- Loading branch information
Showing
4 changed files
with
54 additions
and
13 deletions.
There are no files selected for viewing
22 changes: 13 additions & 9 deletions
22
lib/features/telegram_file_picker_feature/data/repo/telegram_file_picker_repo_impl.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
|
||
import 'package:yahay/features/telegram_file_picker_feature/data/models/telegram_file_image_with_compressed_and_original_path_model.dart'; | ||
import 'package:yahay/features/telegram_file_picker_feature/domain/entities/telegram_file_image_with_compressed_and_original_path_entity.dart'; | ||
import 'package:yahay/features/telegram_file_picker_feature/domain/repo/telegram_file_picker_repo.dart'; | ||
import 'package:yahay/features/telegram_file_picker_feature/mixins/app_storage_file_mixin/app_storage_file_mixin.dart'; | ||
import 'package:yahay/features/telegram_file_picker_feature/mixins/recent_file_mixin/downloads_path_files.dart'; | ||
import 'package:yahay/features/telegram_file_picker_feature/mixins/recent_file_mixin/recent_file_mixin.dart'; | ||
|
||
class TelegramFilePickerRepoImpl | ||
with RecentFileMixin, DownloadsPathFiles | ||
with RecentFileMixin, DownloadsPathFiles, AppStorageFileMixin | ||
implements TelegramFilePickerRepo { | ||
@override | ||
Stream<TelegramFileImageWithCompressedAndOriginalPathModel?> getRecentImagesAndVideos() async* { | ||
// from mixin class | ||
yield* getAllImagesAndVideos(); | ||
} | ||
Stream<TelegramFileImageWithCompressedAndOriginalPathModel?> getRecentImagesAndVideos() => | ||
getAllImagesAndVideos(); | ||
|
||
@override | ||
Stream<TelegramFileImageWithCompressedAndOriginalPathModel?> getRecentFiles() => | ||
downloadsPathFilesData(); | ||
|
||
@override | ||
Stream<TelegramFileImageWithCompressedAndOriginalPathModel?> getRecentFiles() async* { | ||
yield* downloadsPathFilesData(); | ||
} | ||
Stream<TelegramFileImageWithCompressedAndOriginalPathEntity?> getSpecificFolderData( | ||
String path, | ||
) => | ||
getSpecificFolderDataStream(path); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...es/telegram_file_picker_feature/mixins/app_storage_file_mixin/app_storage_file_mixin.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'dart:io'; | ||
import 'dart:isolate'; | ||
import 'dart:ui'; | ||
|
||
import 'package:yahay/features/telegram_file_picker_feature/domain/entities/telegram_file_image_with_compressed_and_original_path_entity.dart'; | ||
|
||
mixin class AppStorageFileMixin { | ||
// | ||
Stream<TelegramFileImageWithCompressedAndOriginalPathEntity?> getSpecificFolderDataStream( | ||
String path, | ||
) async* { | ||
// | ||
|
||
final ReceivePort mainPort = ReceivePort(); | ||
|
||
final rootIsolateToken = RootIsolateToken.instance!; | ||
|
||
Isolate.spawn(_isolateHelper, [ | ||
rootIsolateToken, | ||
mainPort.sendPort, | ||
path, | ||
]); | ||
|
||
await for (final each in mainPort) {} | ||
} | ||
|
||
// | ||
static Future<void> _isolateHelper(List<dynamic> args) async { | ||
RootIsolateToken mainRootIsolateToken = args[0] as RootIsolateToken; | ||
SendPort sendPort = args[1] as SendPort; | ||
String path = args[2] as String; | ||
|
||
final directory = Directory(path); | ||
|
||
if (!directory.existsSync()) return; | ||
} | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters