Skip to content

Commit

Permalink
refactor(files_app): Remove background of file previews
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <kate@provokateurin.de>
  • Loading branch information
provokateurin committed Aug 30, 2024
1 parent dd01a21 commit 0be6b59
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ class _FileIcon extends StatelessWidget {
: FilePreview(
bloc: bloc,
details: details,
withBackground: true,
borderRadius: const BorderRadius.all(Radius.circular(8)),
),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,53 +13,36 @@ class FilePreview extends StatelessWidget {
required this.details,
this.size = const Size.square(largeIconSize),
this.color,
this.borderRadius,
this.withBackground = false,
super.key,
}) : assert(
(borderRadius != null && withBackground) || borderRadius == null,
'withBackground needs to be true when borderRadius is set',
);
});

final FilesBloc bloc;
final FileDetails details;
final Size size;
final Color? color;
final BorderRadius? borderRadius;
final bool withBackground;

@override
Widget build(BuildContext context) {
final color = this.color ?? Theme.of(context).colorScheme.primary;

Widget child;
if (details.isDirectory) {
child = Icon(
AdaptiveIcons.folder,
color: color,
size: size.shortestSide,
);
} else {
child = FilePreviewImage(
file: details,
size: size,
account: NeonProvider.of<Account>(context),
);
}

return SizedBox.fromSize(
size: size,
child: Builder(
builder: (context) {
if (details.isDirectory) {
return Icon(
AdaptiveIcons.folder,
color: color,
size: size.shortestSide,
);
}

final preview = FilePreviewImage(
file: details,
size: size,
account: NeonProvider.of<Account>(context),
);

if (withBackground) {
return NeonImageWrapper(
borderRadius: borderRadius,
child: preview,
);
}

return preview;
},
),
child: child,
);
}
}
Expand Down

0 comments on commit 0be6b59

Please sign in to comment.