Skip to content

Commit

Permalink
making logic for getting files from specific app folder
Browse files Browse the repository at this point in the history
  • Loading branch information
sb-dor committed Aug 16, 2024
1 parent bc89370 commit d5e2bbe
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 13 deletions.
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);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import 'package:yahay/features/telegram_file_picker_feature/domain/entities/telegram_file_image_with_compressed_and_original_path_entity.dart';

// means that other classes can't "extend" it
Expand All @@ -9,4 +8,7 @@ abstract interface class TelegramFilePickerRepo {

// for getting all download's path files here
Stream<TelegramFileImageWithCompressedAndOriginalPathEntity?> getRecentFiles();

// for getting specific app folder data, does not matter what
Stream<TelegramFileImageWithCompressedAndOriginalPathEntity?> getSpecificFolderData(String path);
}
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;
}
//
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ import 'package:yahay/features/telegram_file_picker_feature/data/models/telegram
import 'package:yahay/features/telegram_file_picker_feature/domain/entities/telegram_file_image_asset_entity.dart';
import 'package:yahay/injections/injections.dart';


mixin class CompressImage {}

mixin class RecentFileMixin {
final _permissions = snoopy<PermissionsService>();

Expand Down

0 comments on commit d5e2bbe

Please sign in to comment.