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. 36
      packages/neon/lib/src/apps/files/widgets/file_preview.dart
  3. 38
      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)),
), ),
), ),

36
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(
width: width.toDouble(), builder: (final context) {
height: height.toDouble(), final child = Image.memory(
child: DecoratedBox( previewData,
decoration: BoxDecoration( fit: BoxFit.cover,
borderRadius: borderRadius, width: width.toDouble(),
image: DecorationImage( height: height.toDouble(),
image: MemoryImage(previewData), );
fit: BoxFit.cover, if (withBackground) {
), return ImageWrapper(
), backgroundColor: Colors.white,
), borderRadius: borderRadius,
child: child,
);
}
return child;
},
), ),
), ),
], ],

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

@ -13,29 +13,23 @@ 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( borderRadius: borderRadius,
decoration: BoxDecoration( child: feed.faviconLink != null && feed.faviconLink != ''
color: Colors.white, ? CachedURLImage(
borderRadius: borderRadius, url: feed.faviconLink!,
), requestManager: Provider.of<RequestManager>(context),
child: Center( client: RxBlocProvider.of<AccountsBloc>(context).activeAccount.value!.client,
child: feed.faviconLink != null && feed.faviconLink != '' height: size,
? CachedURLImage( width: size,
url: feed.faviconLink!, )
requestManager: Provider.of<RequestManager>(context), : Icon(
client: RxBlocProvider.of<AccountsBloc>(context).activeAccount.value!.client, Icons.rss_feed,
height: size, size: size,
width: size, color: Theme.of(context).colorScheme.primary,
) ),
: Icon(
Icons.rss_feed,
size: size,
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