Browse Source

fix(neon_files): bloc propagation

Signed-off-by: Nikolas Rimikis <rimikis.nikolas@gmail.com>
pull/590/head
Nikolas Rimikis 1 year ago
parent
commit
75504708ab
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 6
      packages/neon/neon_files/lib/widgets/browser_view.dart
  2. 15
      packages/neon/neon_files/lib/widgets/file_list_tile.dart

6
packages/neon/neon_files/lib/widgets/browser_view.dart

@ -64,7 +64,8 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
false, false,
)) ...[ )) ...[
FileListTile( FileListTile(
context: context, bloc: widget.filesBloc,
browserBloc: widget.bloc,
details: FileDetails.fromUploadTask( details: FileDetails.fromUploadTask(
task: uploadTask, task: uploadTask,
), ),
@ -91,7 +92,8 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
); );
return FileListTile( return FileListTile(
context: context, bloc: widget.filesBloc,
browserBloc: widget.bloc,
details: details, details: details,
enableFileActions: widget.enableFileActions, enableFileActions: widget.enableFileActions,
onPickFile: widget.onPickFile, onPickFile: widget.onPickFile,

15
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/widgets.dart';
import 'package:neon_files/neon_files.dart'; import 'package:neon_files/neon_files.dart';
import 'package:neon_files/widgets/actions.dart'; import 'package:neon_files/widgets/actions.dart';
import 'package:provider/provider.dart';
class FileListTile extends StatelessWidget { class FileListTile extends StatelessWidget {
const FileListTile({ const FileListTile({
required this.context, required this.bloc,
required this.browserBloc,
required this.details, required this.details,
this.enableFileActions = true, this.enableFileActions = true,
this.onPickFile, this.onPickFile,
super.key, super.key,
}); });
final BuildContext context; final FilesBloc bloc;
final FilesBrowserBloc browserBloc;
final FileDetails details; final FileDetails details;
final bool enableFileActions; final bool enableFileActions;
final Function(FileDetails)? onPickFile; final Function(FileDetails)? onPickFile;
@override @override
Widget build(final BuildContext context) { Widget build(final BuildContext context) {
final bloc = Provider.of<FilesBloc>(context);
final browserBloc = bloc.browser;
// When the ETag is null it means we are uploading this file right now // When the ETag is null it means we are uploading this file right now
final onTap = details.isDirectory || details.etag != null final onTap = details.isDirectory || details.etag != null
? () { ? () {
@ -63,6 +61,7 @@ class FileListTile extends StatelessWidget {
), ),
leading: _FileIcon( leading: _FileIcon(
details: details, details: details,
bloc: bloc,
), ),
trailing: !details.hasTask && enableFileActions trailing: !details.hasTask && enableFileActions
? FileActions(details: details) ? FileActions(details: details)
@ -76,14 +75,14 @@ class FileListTile extends StatelessWidget {
class _FileIcon extends StatelessWidget { class _FileIcon extends StatelessWidget {
const _FileIcon({ const _FileIcon({
required this.details, required this.details,
required this.bloc,
}); });
final FileDetails details; final FileDetails details;
final FilesBloc bloc;
@override @override
Widget build(final BuildContext context) { Widget build(final BuildContext context) {
final bloc = Provider.of<FilesBloc>(context);
Widget icon = Center( Widget icon = Center(
child: details.hasTask child: details.hasTask
? StreamBuilder<double>( ? StreamBuilder<double>(

Loading…
Cancel
Save