feat: major ui/ux improvements

This commit is contained in:
gasaichandesu
2025-08-30 21:46:16 +04:00
parent 58d7808a8d
commit 4b1cecbefd
20 changed files with 440 additions and 261 deletions
+38 -21
View File
@@ -35,12 +35,8 @@ class HomeScreenBloc extends Bloc<HomeScreenEvent, HomeScreenState> {
void _setupHandlers() {
on<HomeScreenLoad>(_onHomeScreenLoad);
on<HomeScreenDownloadRequested>(_onHomeScreenDownloadRequested);
on<HomeScreenDownloadPaused>((event, emit) {
// _downloadManager.pauseDownload();
// emit(HomeScreenDownloadPausedState());
});
on<HomeScreenDownloadPaused>(_onHomeScreenDownloadPaused);
on<HomeScreenOutputDirRequested>(_onHomeOutputDirRequested);
on<HomeScreenDownloadProgressUpdated>(
_onHomeScreenDownloadProgressUpdated,
transformer: (events, mapper) =>
@@ -66,21 +62,8 @@ class HomeScreenBloc extends Bloc<HomeScreenEvent, HomeScreenState> {
Emitter<HomeScreenState> emit,
) async {
if (state.model.outputPath == null) {
final directory = await FilePicker.platform.getDirectoryPath(
dialogTitle: 'Please select installation directory',
);
if (directory == null) {
return;
}
await _preferencesRepository.setOutputDir(Uri.directory(directory));
emit(
HomeScreenReadyToDownloadState(
model: state.model.copyWith(outputPath: Uri.directory(directory)),
),
);
emit(HomeScreenOutputDirSelectionState(model: state.model.copyWith()));
return;
}
_downloadProgressSubscription = _downloadManager
@@ -91,6 +74,8 @@ class HomeScreenBloc extends Bloc<HomeScreenEvent, HomeScreenState> {
),
)
.listen((progress) => add(HomeScreenDownloadProgressUpdated(progress)));
emit(HomeScreenDownloadInitializing(model: state.model.copyWith()));
}
void _onHomeScreenDownloadProgressUpdated(
@@ -111,4 +96,36 @@ class HomeScreenBloc extends Bloc<HomeScreenEvent, HomeScreenState> {
return super.close();
}
FutureOr<void> _onHomeScreenDownloadPaused(
HomeScreenDownloadPaused event,
Emitter<HomeScreenState> emit,
) async {
await _downloadManager.pause(_downloadId);
emit(HomeScreenDownloadPausedState(model: state.model.copyWith()));
}
FutureOr<void> _onHomeOutputDirRequested(
HomeScreenOutputDirRequested event,
Emitter<HomeScreenState> emit,
) async {
emit(HomeScreenReadyToDownloadState(model: state.model.copyWith()));
final directory = await FilePicker.platform.getDirectoryPath(
dialogTitle: 'Please select installation directory',
);
if (directory == null) {
return;
}
await _preferencesRepository.setOutputDir(Uri.directory(directory));
emit(
HomeScreenReadyToDownloadState(
model: state.model.copyWith(outputPath: Uri.directory(directory)),
),
);
}
}
@@ -7,6 +7,8 @@ final class HomeScreenLoad extends HomeScreenEvent {}
final class HomeScreenDownloadRequested extends HomeScreenEvent {}
final class HomeScreenOutputDirRequested extends HomeScreenEvent {}
final class HomeScreenDownloadPaused extends HomeScreenEvent {}
final class HomeScreenDownloadProgressUpdated extends HomeScreenEvent {
@@ -19,6 +19,18 @@ final class HomeScreenDownloadPausedState extends HomeScreenState {
const HomeScreenDownloadPausedState({required super.model});
}
final class HomeScreenDownloadInitializing extends HomeScreenState {
const HomeScreenDownloadInitializing({required super.model});
}
final class HomeScreenDownloadingState extends HomeScreenState {
const HomeScreenDownloadingState({required super.model});
}
final class HomeScreenOutputDirSelectionState extends HomeScreenState {
const HomeScreenOutputDirSelectionState({required super.model});
}
final class HomeScreenReadyToPlayState extends HomeScreenState {
const HomeScreenReadyToPlayState({required super.model});
}