Browse Source

Merge pull request #590 from nextcloud/fix/files_bloc_propagation

fix(neon_files): bloc propagation
pull/601/head
Nikolas Rimikis 1 year ago committed by GitHub
parent
commit
2c500ae406
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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,
)) ...[
FileListTile(
context: context,
bloc: widget.filesBloc,
browserBloc: widget.bloc,
details: FileDetails.fromUploadTask(
task: uploadTask,
),
@ -91,7 +92,8 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
);
return FileListTile(
context: context,
bloc: widget.filesBloc,
browserBloc: widget.bloc,
details: details,
enableFileActions: widget.enableFileActions,
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_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<FilesBloc>(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<FilesBloc>(context);
Widget icon = Center(
child: details.hasTask
? StreamBuilder<double>(

Loading…
Cancel
Save