Skip to content

Commit

Permalink
Update upload_form.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagocarvalhodev committed Oct 14, 2024
1 parent 210cf7e commit a3c5396
Showing 1 changed file with 42 additions and 31 deletions.
73 changes: 42 additions & 31 deletions lib/components/upload_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ Future<void> promptToUpload(
);

if (files != null) {
_showUploadForm(context, cubit: cubit, driveDetailCubit: driveDetailCubit);
cubit.selectFiles(files, parentFolderId);
return;
} else if (isFolderUpload) {
cubit.pickFilesFromFolder(context: context, parentFolderId: parentFolderId);
} else {
Expand All @@ -128,41 +130,50 @@ Future<void> promptToUpload(

cubit.stream.listen((state) async {
if (state is UploadLoadingFilesSuccess) {
final uploadCubit = BlocProvider<UploadCubit>(
create: (context) => cubit,
);
_showUploadForm(context,
cubit: cubit, driveDetailCubit: driveDetailCubit);
}
});
}

final uploadPaymentMethodBloc = BlocProvider(
create: (context) => UploadPaymentMethodBloc(
context.read<ProfileCubit>(),
context.read<ArDriveUploadPreparationManager>(),
context.read<ArDriveAuth>(),
),
);
Future<void> _showUploadForm(
BuildContext context, {
required UploadCubit cubit,
required DriveDetailCubit driveDetailCubit,
}) async {
final uploadCubit = BlocProvider<UploadCubit>(
create: (context) => cubit,
);

final uploadPaymentMethodBloc = BlocProvider(
create: (context) => UploadPaymentMethodBloc(
context.read<ProfileCubit>(),
context.read<ArDriveUploadPreparationManager>(),
context.read<ArDriveAuth>(),
),
);

await showCongestionDependentModalDialog(
await showCongestionDependentModalDialog(
context,
() {
if (!context.mounted) {
return;
}
showArDriveDialog(
context,
() {
if (!context.mounted) {
return;
}
showArDriveDialog(
context,
content: MultiBlocProvider(
providers: [
uploadCubit,
uploadPaymentMethodBloc,
],
child: UploadForm(
driveDetailCubit: driveDetailCubit,
),
),
barrierDismissible: false,
);
},
content: MultiBlocProvider(
providers: [
uploadCubit,
uploadPaymentMethodBloc,
],
child: UploadForm(
driveDetailCubit: driveDetailCubit,
),
),
barrierDismissible: false,
);
}
});
},
);
}

class UploadForm extends StatefulWidget {
Expand Down

0 comments on commit a3c5396

Please sign in to comment.