Browse Source

feat(neon_dashboard): Support server icons as dashboard widget icons

Signed-off-by: jld3103 <jld3103yt@gmail.com>
pull/1141/head
jld3103 1 year ago
parent
commit
b74c599bfa
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 32
      packages/neon/neon_dashboard/lib/src/widgets/widget.dart

32
packages/neon/neon_dashboard/lib/src/widgets/widget.dart

@ -47,11 +47,7 @@ class DashboardWidget extends StatelessWidget {
), ),
leading: SizedBox.square( leading: SizedBox.square(
dimension: largeIconSize, dimension: largeIconSize,
child: NeonUrlImage( child: _buildWidgetIcon(context),
url: widget.iconUrl,
svgColorFilter: ColorFilter.mode(Theme.of(context).colorScheme.primary, BlendMode.srcIn),
size: const Size.square(largeIconSize),
),
), ),
), ),
const SizedBox( const SizedBox(
@ -82,6 +78,32 @@ class DashboardWidget extends StatelessWidget {
); );
} }
Widget? _buildWidgetIcon(final BuildContext context) {
final colorFilter = ColorFilter.mode(Theme.of(context).colorScheme.primary, BlendMode.srcIn);
if (widget.iconUrl.isNotEmpty) {
return NeonUrlImage(
url: widget.iconUrl,
svgColorFilter: colorFilter,
size: const Size.square(largeIconSize),
);
}
if (widget.iconClass.isNotEmpty) {
return NeonServerIcon(
icon: widget.iconClass,
colorFilter: colorFilter,
size: largeIconSize,
);
}
return Icon(
Icons.question_mark,
color: Theme.of(context).colorScheme.primary,
size: largeIconSize,
);
}
Widget? _renderMessage(final String? message) { Widget? _renderMessage(final String? message) {
if (message == null || message.isEmpty) { if (message == null || message.isEmpty) {
return null; return null;

Loading…
Cancel
Save