Skip to content

Commit

Permalink
added getting files from folder was done, solving some ui issues left…
Browse files Browse the repository at this point in the history
… to do
  • Loading branch information
sb-dor committed Aug 17, 2024
1 parent a5372dd commit cfa9ef0
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/core/utils/image_comporessor/image_compressor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ abstract final class ImageCompressor {
originalPath: file.path,
isImage: true,
);

return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

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

final class TelegramPathFolderFileModel extends TelegramPathFolderFile {
Expand All @@ -11,6 +13,25 @@ final class TelegramPathFolderFileModel extends TelegramPathFolderFile {
super.fileName,
});

TelegramPathFolderFileModel clone({
File? file,
String? originalPath,
bool? isFolder,
bool? isImage,
bool? isVideo,
String? fileExtension,
String? fileName,
}) =>
TelegramPathFolderFileModel(
file ?? this.file,
originalPath: originalPath ?? this.originalPath,
isFolder: isFolder ?? this.isFolder,
isImage: isImage ?? this.isImage,
isVideo: isVideo ?? this.isVideo,
fileExtension: fileExtension ?? this.fileExtension,
fileName: fileName ?? this.fileName,
);

TelegramPathFolderFileModel? fromEntity(
TelegramPathFolderFile? entity,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,19 @@ mixin class AppStorageFileMixin {
TelegramPathFolderFileModel? model = TelegramPathFolderFileModel(
File(each.path),
fileExtension: p.extension(each.path),
fileName: p.basenameWithoutExtension(each.path),
fileName: p.basename(each.path),
);

if (FileSystemEntity.isDirectorySync(each.path)) {
model.isFolder = true;
} else if (reusables.isImageFile(each.path)) {
model = await ImageCompressor.compressedImageFile(
model = (await ImageCompressor.compressedImageFile(
file: model.file,
directoryPath: tempPath.path,
))
?.clone(
fileExtension: model.fileExtension,
fileName: model.fileName,
);
} else if (reusables.isVideoFile(each.path)) {
model.isVideo = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class TelegramFilePickerStateModel {
void addToFolderDataList(TelegramFileImageEntity value) {
_specificFolderFilesAll.add(value);
if (_specificFolderFilesPagination.length < Constants.perPage) {
_recentFilesPagination.add(value);
_specificFolderFilesPagination.add(value);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@ class TelegramFilePickerBloc {
.getSpecificFolderData(_currentStateModel.getPathForGettingImagesFrom!)
.listen(
(data) {
debugPrint("coming file: ${data?.file}");
_events.add(SpecificFolderDataStreamHandlerEvent(data));
},
),
Expand All @@ -400,6 +399,8 @@ class TelegramFilePickerBloc {
SpecificFolderDataStreamHandlerEvent event,
) async* {
if (event.file == null) return;
debugPrint("coming file 2: ${event.file?.file}");

final value = TelegramFileImageEntity(
file: event.file!.file,
videoPlayerController:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class _TelegramBrowseFolderDataScreenState extends State<TelegramBrowseFolderDat
onTap: widget.onBackFolder,
title: "...",
),
const SizedBox(height: 20),
StreamBuilder(
stream: _telegramFilePickerBloc.states,
builder: (context, snapshot) {
Expand Down

0 comments on commit cfa9ef0

Please sign in to comment.