From 75504708abd6ca67945b4af71f025fd7d82974b2 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Fri, 18 Aug 2023 09:23:12 +0200 Subject: [PATCH] fix(neon_files): bloc propagation Signed-off-by: Nikolas Rimikis --- .../neon/neon_files/lib/widgets/browser_view.dart | 6 ++++-- .../neon_files/lib/widgets/file_list_tile.dart | 15 +++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/neon/neon_files/lib/widgets/browser_view.dart b/packages/neon/neon_files/lib/widgets/browser_view.dart index b65d5cfd..912daeac 100644 --- a/packages/neon/neon_files/lib/widgets/browser_view.dart +++ b/packages/neon/neon_files/lib/widgets/browser_view.dart @@ -64,7 +64,8 @@ class _FilesBrowserViewState extends State { false, )) ...[ FileListTile( - context: context, + bloc: widget.filesBloc, + browserBloc: widget.bloc, details: FileDetails.fromUploadTask( task: uploadTask, ), @@ -91,7 +92,8 @@ class _FilesBrowserViewState extends State { ); return FileListTile( - context: context, + bloc: widget.filesBloc, + browserBloc: widget.bloc, details: details, enableFileActions: widget.enableFileActions, onPickFile: widget.onPickFile, diff --git a/packages/neon/neon_files/lib/widgets/file_list_tile.dart b/packages/neon/neon_files/lib/widgets/file_list_tile.dart index c03db4ee..3db2d1f8 100644 --- a/packages/neon/neon_files/lib/widgets/file_list_tile.dart +++ b/packages/neon/neon_files/lib/widgets/file_list_tile.dart @@ -4,27 +4,25 @@ import 'package:material_design_icons_flutter/material_design_icons_flutter.dart import 'package:neon/widgets.dart'; import 'package:neon_files/neon_files.dart'; import 'package:neon_files/widgets/actions.dart'; -import 'package:provider/provider.dart'; class FileListTile extends StatelessWidget { const FileListTile({ - required this.context, + required this.bloc, + required this.browserBloc, required this.details, this.enableFileActions = true, this.onPickFile, super.key, }); - final BuildContext context; + final FilesBloc bloc; + final FilesBrowserBloc browserBloc; final FileDetails details; final bool enableFileActions; final Function(FileDetails)? onPickFile; @override Widget build(final BuildContext context) { - final bloc = Provider.of(context); - final browserBloc = bloc.browser; - // When the ETag is null it means we are uploading this file right now final onTap = details.isDirectory || details.etag != null ? () { @@ -63,6 +61,7 @@ class FileListTile extends StatelessWidget { ), leading: _FileIcon( details: details, + bloc: bloc, ), trailing: !details.hasTask && enableFileActions ? FileActions(details: details) @@ -76,14 +75,14 @@ class FileListTile extends StatelessWidget { class _FileIcon extends StatelessWidget { const _FileIcon({ required this.details, + required this.bloc, }); final FileDetails details; + final FilesBloc bloc; @override Widget build(final BuildContext context) { - final bloc = Provider.of(context); - Widget icon = Center( child: details.hasTask ? StreamBuilder(