Skip to content

Commit

Permalink
still dealing with ui
Browse files Browse the repository at this point in the history
  • Loading branch information
sb-dor committed Aug 16, 2024
1 parent 02bc409 commit bc89370
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:yahay/core/app_routing/app_router.dart';
import 'package:yahay/core/utils/global_context/global_context.dart';
import 'package:yahay/features/telegram_file_picker_feature/domain/entities/telegram_file_folder_enums.dart';
import 'package:yahay/features/telegram_file_picker_feature/domain/usecases/sheet_opener/telegram_app_folder_sheet_opener.dart';
import 'package:yahay/features/telegram_file_picker_feature/view/bloc/telegram_file_picker_bloc.dart';
import 'package:yahay/features/telegram_file_picker_feature/view/bloc/telegram_file_picker_events.dart';
Expand Down Expand Up @@ -47,7 +48,8 @@ class TelegramStorageFilePickerDataModel {
title: "Yahay",
content: "Browse the app's folder",
onTap: () async {
_telegramBloc.events.add(const SelectScreenForFilesPickerScreenEvent(1));
_telegramBloc.events.add(const SelectScreenForFilesPickerScreenEvent(
TelegramFileFolderEnum.browseTheAppsFolder));
},
),
TelegramStorageFilePickerDataModel(
Expand All @@ -60,7 +62,8 @@ class TelegramStorageFilePickerDataModel {
title: "Gallery",
content: "To send images without compression",
onTap: () {
_telegramBloc.events.add(const SelectScreenForFilesPickerScreenEvent(2));
_telegramBloc.events.add(const SelectScreenForFilesPickerScreenEvent(
TelegramFileFolderEnum.browseTheGalleryFolder));
},
),
];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
enum TelegramFileFolderEnum {
recentDownloadsScreen,
browseTheAppsFolder,
browseTheFolder,
browseTheGalleryFolder,
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:path/path.dart';
import 'package:yahay/core/global_usages/constants/constants.dart';
import 'package:yahay/core/utils/global_context/global_context.dart';
import 'package:yahay/features/telegram_file_picker_feature/data/models/telegram_file_image_model.dart';
import 'package:yahay/features/telegram_file_picker_feature/domain/entities/telegram_file_folder_enums.dart';
import 'package:yahay/features/telegram_file_picker_feature/domain/entities/telegram_file_image_entity.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/view/bloc/telegram_file_picker_state.dart';
Expand Down Expand Up @@ -67,11 +68,12 @@ class TelegramFilePickerStateModel {

Timer? get openButtonSectionTimer => _openButtonSectionTimer;

int _filePickerScreenSelectedScreen = 0;
TelegramFileFolderEnum _filePickerScreenSelectedScreen =
TelegramFileFolderEnum.recentDownloadsScreen;

int get filePickerScreenSelectedScreen => _filePickerScreenSelectedScreen;
TelegramFileFolderEnum get filePickerScreenSelectedScreen => _filePickerScreenSelectedScreen;

void selectScreen(int screen) {
void selectScreen(TelegramFileFolderEnum screen) {
_filePickerScreenSelectedScreen = screen;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:yahay/features/telegram_file_picker_feature/domain/entities/telegram_file_folder_enums.dart';
import 'package:yahay/features/telegram_file_picker_feature/domain/entities/telegram_file_image_entity.dart';
import 'package:yahay/features/telegram_file_picker_feature/domain/entities/telegram_file_image_with_compressed_and_original_path_entity.dart';

Expand Down Expand Up @@ -98,7 +99,7 @@ final class BrowseInternalStorageAndSelectFilesEvent extends TelegramFilePickerE
}

final class SelectScreenForFilesPickerScreenEvent extends TelegramFilePickerEvents {
final int screen;
final TelegramFileFolderEnum screen;

const SelectScreenForFilesPickerScreenEvent(this.screen);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:yahay/features/telegram_file_picker_feature/domain/entities/telegram_file_folder_enums.dart';
import 'package:yahay/features/telegram_file_picker_feature/mixins/folder_creator/folder_creator.dart';
import 'package:yahay/features/telegram_file_picker_feature/view/bloc/telegram_file_picker_bloc.dart';
import 'package:yahay/features/telegram_file_picker_feature/view/bloc/telegram_file_picker_events.dart';
Expand Down Expand Up @@ -33,7 +34,8 @@ class _TelegramBrowseAppFolderScreenState extends State<TelegramBrowseAppFolderS
const SizedBox(height: 20),
TelegramFolderWidget(
onTap: () {
_telegramFilePickerBloc.events.add(const SelectScreenForFilesPickerScreenEvent(0));
_telegramFilePickerBloc.events.add(const SelectScreenForFilesPickerScreenEvent(
TelegramFileFolderEnum.recentDownloadsScreen));
},
title: "...",
),
Expand All @@ -45,7 +47,16 @@ class _TelegramBrowseAppFolderScreenState extends State<TelegramBrowseAppFolderS
itemCount: foldersName.length,
itemBuilder: (context, index) {
return TelegramFolderWidget(
onTap: () {},
onTap: () {
// init here for folder data
// _telegramFilePickerBloc.events.add(data);
//
_telegramFilePickerBloc.events.add(
const SelectScreenForFilesPickerScreenEvent(
TelegramFileFolderEnum.browseTheFolder,
),
);
},
title: foldersName[index],
);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import 'package:flutter/material.dart';
import 'package:yahay/features/telegram_file_picker_feature/domain/entities/telegram_file_folder_enums.dart';
import 'package:yahay/features/telegram_file_picker_feature/view/bloc/telegram_file_picker_bloc.dart';
import 'package:yahay/features/telegram_file_picker_feature/view/bloc/telegram_file_picker_events.dart';
import 'package:yahay/features/telegram_file_picker_feature/view/pages/screens/telegram_app_folder_screen/telegram_browse_folder_widget.dart';
import 'package:yahay/injections/injections.dart';

class TelegramBrowseFolderDataScreen extends StatefulWidget {
const TelegramBrowseFolderDataScreen({super.key});

final VoidCallback onBackFolder;

const TelegramBrowseFolderDataScreen({
super.key,
required this.onBackFolder,
});

@override
State<TelegramBrowseFolderDataScreen> createState() => _TelegramBrowseFolderDataScreenState();
Expand All @@ -29,9 +36,7 @@ class _TelegramBrowseFolderDataScreenState extends State<TelegramBrowseFolderDat
children: [
const SizedBox(height: 20),
TelegramFolderWidget(
onTap: () {
_telegramFilePickerBloc.events.add(const SelectScreenForFilesPickerScreenEvent(0));
},
onTap: widget.onBackFolder,
title: "...",
),
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:yahay/features/telegram_file_picker_feature/domain/entities/telegram_file_folder_enums.dart';
import 'package:yahay/features/telegram_file_picker_feature/view/bloc/telegram_file_picker_bloc.dart';
import 'package:yahay/features/telegram_file_picker_feature/view/bloc/telegram_file_picker_events.dart';
import 'package:yahay/features/telegram_file_picker_feature/view/bloc/telegram_file_picker_state.dart';
Expand Down Expand Up @@ -30,7 +31,7 @@ class _TelegramFilesPickerScreenState extends State<TelegramFilesPickerScreen> {
void initState() {
super.initState();
_telegramFilePickerBloc = widget.telegramFilePickerBloc;
final currentStateModel = _telegramFilePickerBloc.states.value.telegramFilePickerStateModel;
// final currentStateModel = _telegramFilePickerBloc.states.value.telegramFilePickerStateModel;
widget.parentScrollController.addListener(() {
if (widget.parentScrollController.offset ==
widget.parentScrollController.position.maxScrollExtent &&
Expand Down Expand Up @@ -84,18 +85,21 @@ class _TelegramFilesPickerScreenState extends State<TelegramFilesPickerScreen> {
controller: widget.parentScrollController,
children: [
Visibility(
visible: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == 0,
visible: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen ==
TelegramFileFolderEnum.recentDownloadsScreen,
maintainAnimation: true,
maintainState: true,
child: AnimatedSlide(
curve: Curves.fastOutSlowIn,
duration: const Duration(milliseconds: 300),
offset: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == 0
offset: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen ==
TelegramFileFolderEnum.recentDownloadsScreen
? Offset.zero
: const Offset(1, 0),
child: AnimatedOpacity(
opacity:
state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == 0
state.telegramFilePickerStateModel.filePickerScreenSelectedScreen ==
TelegramFileFolderEnum.recentDownloadsScreen
? 1
: 0,
duration: const Duration(seconds: 1),
Expand All @@ -113,64 +117,122 @@ class _TelegramFilesPickerScreenState extends State<TelegramFilesPickerScreen> {
),
),
),
// apps folder
Visibility(
maintainAnimation: true,
maintainState: true,
visible: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == 1,
visible: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen ==
TelegramFileFolderEnum.browseTheAppsFolder,
child: PopScope(
canPop: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == 1
canPop: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen ==
TelegramFileFolderEnum.browseTheAppsFolder
? false
: true,
onPopInvokedWithResult: (v, r) {
_telegramFilePickerBloc.events
.add(const SelectScreenForFilesPickerScreenEvent(0));
_telegramFilePickerBloc.events.add(
const SelectScreenForFilesPickerScreenEvent(
TelegramFileFolderEnum.recentDownloadsScreen));
},
child: AnimatedSlide(
curve: Curves.fastOutSlowIn,
duration: const Duration(milliseconds: 300),
offset:
state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == 1
? Offset.zero
: const Offset(1, 0),
offset: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen ==
TelegramFileFolderEnum.browseTheAppsFolder
? Offset.zero
: const Offset(1, 0),
child: AnimatedOpacity(
opacity:
state.telegramFilePickerStateModel.filePickerScreenSelectedScreen ==
1
TelegramFileFolderEnum.browseTheAppsFolder
? 1
: 0,
duration: const Duration(seconds: 1),
child: const TelegramBrowseAppFolderScreen()),
),
),
),

Visibility(
child: PopScope(
canPop: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == 2
canPop: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen ==
TelegramFileFolderEnum.browseTheFolder
? false
: true,
onPopInvokedWithResult: (v, r) {
_telegramFilePickerBloc.events
.add(const SelectScreenForFilesPickerScreenEvent(0));
_telegramFilePickerBloc.events.add(
const SelectScreenForFilesPickerScreenEvent(
TelegramFileFolderEnum.browseTheAppsFolder,
),
);
},
child: AnimatedSlide(
curve: Curves.fastOutSlowIn,
duration: const Duration(milliseconds: 300),
offset:
state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == 2
? Offset.zero
: const Offset(1, 0),
offset: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen ==
TelegramFileFolderEnum.browseTheFolder
? Offset.zero
: const Offset(1, 0),
child: AnimatedOpacity(
opacity:
state.telegramFilePickerStateModel.filePickerScreenSelectedScreen ==
2
? 1
: 0,
duration: const Duration(seconds: 1),
child: const TelegramBrowseFolderDataScreen()),
opacity:
state.telegramFilePickerStateModel.filePickerScreenSelectedScreen ==
TelegramFileFolderEnum.browseTheFolder
? 1
: 0,
duration: const Duration(seconds: 1),
child: TelegramBrowseFolderDataScreen(
onBackFolder: () {
_telegramFilePickerBloc.events.add(
const SelectScreenForFilesPickerScreenEvent(
TelegramFileFolderEnum.browseTheAppsFolder,
),
);
},
),
),
),
),
),

// gallery folder data
Visibility(
child: PopScope(
canPop: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen ==
TelegramFileFolderEnum.browseTheGalleryFolder
? false
: true,
onPopInvokedWithResult: (v, r) {
_telegramFilePickerBloc.events.add(
const SelectScreenForFilesPickerScreenEvent(
TelegramFileFolderEnum.recentDownloadsScreen));
},
child: AnimatedSlide(
curve: Curves.fastOutSlowIn,
duration: const Duration(milliseconds: 300),
offset: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen ==
TelegramFileFolderEnum.browseTheGalleryFolder
? Offset.zero
: const Offset(1, 0),
child: AnimatedOpacity(
opacity:
state.telegramFilePickerStateModel.filePickerScreenSelectedScreen ==
TelegramFileFolderEnum.browseTheGalleryFolder
? 1
: 0,
duration: const Duration(seconds: 1),
child: TelegramBrowseFolderDataScreen(
onBackFolder: () {
_telegramFilePickerBloc.events.add(
const SelectScreenForFilesPickerScreenEvent(
TelegramFileFolderEnum.recentDownloadsScreen,
),
);
},
),
),
),
),
),
], //TelegramBrowseFolderDataScreen
],
);
}
},
Expand Down

0 comments on commit bc89370

Please sign in to comment.