Browse Source

neon: Fix feed icon border radius and file preview background

pull/50/head
jld3103 2 years ago
parent
commit
455952aa95
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 1
      packages/neon/lib/src/apps/files/widgets/browser_view.dart
  2. 30
      packages/neon/lib/src/apps/files/widgets/file_preview.dart
  3. 10
      packages/neon/lib/src/apps/news/widgets/feed_icon.dart
  4. 1
      packages/neon/lib/src/neon.dart
  5. 36
      packages/neon/lib/src/widgets/image_wrapper.dart

1
packages/neon/lib/src/apps/files/widgets/browser_view.dart

@ -303,6 +303,7 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
: FilePreview( : FilePreview(
bloc: widget.filesBloc, bloc: widget.filesBloc,
details: details, details: details,
withBackground: true,
borderRadius: const BorderRadius.all(Radius.circular(8)), borderRadius: const BorderRadius.all(Radius.circular(8)),
), ),
), ),

30
packages/neon/lib/src/apps/files/widgets/file_preview.dart

@ -8,8 +8,12 @@ class FilePreview extends StatelessWidget {
this.height = 40, this.height = 40,
this.color, this.color,
this.borderRadius, this.borderRadius,
this.withBackground = false,
super.key, super.key,
}); }) : assert(
(borderRadius != null && withBackground) || borderRadius == null,
'withBackground needs to be true when borderRadius is set',
);
final FilesBloc bloc; final FilesBloc bloc;
final FileDetails details; final FileDetails details;
@ -17,6 +21,7 @@ class FilePreview extends StatelessWidget {
final int height; final int height;
final Color? color; final Color? color;
final BorderRadius? borderRadius; final BorderRadius? borderRadius;
final bool withBackground;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -61,18 +66,23 @@ class FilePreview extends StatelessWidget {
children: [ children: [
if (previewData != null) ...[ if (previewData != null) ...[
Center( Center(
child: SizedBox( child: Builder(
builder: (final context) {
final child = Image.memory(
previewData,
fit: BoxFit.cover,
width: width.toDouble(), width: width.toDouble(),
height: height.toDouble(), height: height.toDouble(),
child: DecoratedBox( );
decoration: BoxDecoration( if (withBackground) {
return ImageWrapper(
backgroundColor: Colors.white,
borderRadius: borderRadius, borderRadius: borderRadius,
image: DecorationImage( child: child,
image: MemoryImage(previewData), );
fit: BoxFit.cover, }
), return child;
), },
),
), ),
), ),
], ],

10
packages/neon/lib/src/apps/news/widgets/feed_icon.dart

@ -13,15 +13,11 @@ class NewsFeedIcon extends StatelessWidget {
final BorderRadius? borderRadius; final BorderRadius? borderRadius;
@override @override
Widget build(final BuildContext context) => SizedBox( Widget build(final BuildContext context) => ImageWrapper(
backgroundColor: Colors.white,
width: size, width: size,
height: size, height: size,
child: DecoratedBox(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: borderRadius, borderRadius: borderRadius,
),
child: Center(
child: feed.faviconLink != null && feed.faviconLink != '' child: feed.faviconLink != null && feed.faviconLink != ''
? CachedURLImage( ? CachedURLImage(
url: feed.faviconLink!, url: feed.faviconLink!,
@ -35,7 +31,5 @@ class NewsFeedIcon extends StatelessWidget {
size: size, size: size,
color: Theme.of(context).colorScheme.primary, color: Theme.of(context).colorScheme.primary,
), ),
),
),
); );
} }

1
packages/neon/lib/src/neon.dart

@ -91,6 +91,7 @@ part 'widgets/custom_dialog.dart';
part 'widgets/custom_linear_progress_indicator.dart'; part 'widgets/custom_linear_progress_indicator.dart';
part 'widgets/custom_listview.dart'; part 'widgets/custom_listview.dart';
part 'widgets/exception.dart'; part 'widgets/exception.dart';
part 'widgets/image_wrapper.dart';
part 'widgets/neon_logo.dart'; part 'widgets/neon_logo.dart';
part 'widgets/nextcloud_logo.dart'; part 'widgets/nextcloud_logo.dart';
part 'widgets/result_stream_builder.dart'; part 'widgets/result_stream_builder.dart';

36
packages/neon/lib/src/widgets/image_wrapper.dart

@ -0,0 +1,36 @@
part of '../neon.dart';
class ImageWrapper extends StatelessWidget {
const ImageWrapper({
required this.child,
required this.backgroundColor,
this.width,
this.height,
this.borderRadius,
super.key,
});
final Widget child;
final Color backgroundColor;
final double? width;
final double? height;
final BorderRadius? borderRadius;
@override
Widget build(BuildContext context) => SizedBox(
width: width,
height: height,
child: DecoratedBox(
decoration: BoxDecoration(
color: backgroundColor,
borderRadius: borderRadius?.add(const BorderRadius.all(Radius.circular(1))),
),
child: Center(
child: ClipRRect(
borderRadius: borderRadius ?? BorderRadius.zero,
child: child,
),
),
),
);
}
Loading…
Cancel
Save