Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion lib/features/connections/driver_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ import 'package:flutter/material.dart' as material;
import 'package:flutter_svg/flutter_svg.dart';
import 'package:querya_desktop/shared/widgets/widgets.dart';

/// Brightens every channel (x1.9 and a small lift), alpha untouched.
const _liftDarkIcon = material.ColorFilter.matrix(<double>[
1.9, 0, 0, 0, 40, //
0, 1.9, 0, 0, 40,
0, 0, 1.9, 0, 40,
0, 0, 0, 1, 0,
]);

/// Renders a bundled or extension-provided database icon with one fallback.
class DriverIcon extends StatelessWidget {
const DriverIcon({
Expand Down Expand Up @@ -37,7 +45,7 @@ class DriverIcon extends StatelessWidget {
}
if (assetPath != null) {
final cacheSize = (size * MediaQuery.devicePixelRatioOf(context)).toInt();
return material.Image.asset(
final image = material.Image.asset(
assetPath!,
width: size,
height: size,
Expand All @@ -47,6 +55,16 @@ class DriverIcon extends StatelessWidget {
filterQuality: material.FilterQuality.medium,
errorBuilder: (_, __, ___) => fallback,
);
// The MySQL dolphin is dark blue and nearly vanishes on a dark surface
// (#1824): lift it there, leave the light theme alone.
if (assetPath!.endsWith('mysql_icon.png') &&
material.Theme.of(context).brightness == material.Brightness.dark) {
return material.ColorFiltered(
colorFilter: _liftDarkIcon,
child: image,
);
}
return image;
}
return fallback;
}
Expand Down
6 changes: 5 additions & 1 deletion lib/features/mongodb/mongo_collections_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ class _MongoCollectionsViewState extends material.State<MongoCollectionsView> {
_statsTotal = 0;
});
try {
final names = await widget.connection.listCollections(widget.database);
// The sidebar tree lists them sorted by name; the same order here
// (#1824) instead of the server's.
final names = [
...await widget.connection.listCollections(widget.database),
]..sort();
if (!mounted || gen != _loadGeneration) return;

setState(() {
Expand Down
31 changes: 31 additions & 0 deletions test/features/connections/driver_icon_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,35 @@ void main() {

expect(find.byIcon(material.Icons.extension_rounded), findsOneWidget);
});

Future<void> pumpIcon(WidgetTester tester, String asset,
{bool light = false}) async {
await tester.pumpWidget(
queryaThemeTestShell(
theme: light ? material.ThemeData.light() : null,
child: DriverIcon(
assetPath: asset,
size: 32,
fallbackIcon: material.Icons.storage_rounded,
),
),
);
}

group('MySQL logo on a dark surface (#1824)', () {
testWidgets('is lifted on the dark theme', (tester) async {
await pumpIcon(tester, 'assets/images/mysql_icon.png');
expect(find.byType(material.ColorFiltered), findsOneWidget);
});

testWidgets('is left alone on the light theme', (tester) async {
await pumpIcon(tester, 'assets/images/mysql_icon.png', light: true);
expect(find.byType(material.ColorFiltered), findsNothing);
});

testWidgets('other logos are never filtered', (tester) async {
await pumpIcon(tester, 'assets/images/postgresql_icon.png');
expect(find.byType(material.ColorFiltered), findsNothing);
});
});
}
Loading