Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: illegible text in modal due to wrong background color #1926

Merged
merged 1 commit into from
Feb 5, 2025
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
2 changes: 1 addition & 1 deletion lib/features/surveys/tools/run_surveys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Future<void> runSurvey({
pageListBuilder: (modalSheetContext) {
return [
ModalUtils.modalSheetPage(
context: modalSheetContext,
context: context,
backgroundColor: themeData.canvasColor,
isTopBarLayerAlwaysVisible: false,
showCloseButton: false,
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/modals.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ModalUtils {
}) {
final textTheme = context.textTheme;
return WoltModalSheetPage(
backgroundColor: context.colorScheme.surfaceContainerLow,
backgroundColor: context.colorScheme.surfaceContainerHigh,
hasSabGradient: false,
topBarTitle:
title != null ? Text(title, style: textTheme.titleSmall) : null,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: lotti
description: Achieve your goals and keep your data private with Lotti.
publish_to: 'none'
version: 0.9.567+2874
version: 0.9.567+2875

msix_config:
display_name: LottiApp
Expand Down
133 changes: 133 additions & 0 deletions test/utils/modals_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:lotti/utils/modals.dart';
import 'package:wolt_modal_sheet/wolt_modal_sheet.dart';

void main() {
group('ModalUtils', () {
testWidgets('modalTypeBuilder returns bottomSheet for small screens',
(tester) async {
await tester.binding.setSurfaceSize(const Size(300, 600));

await tester.pumpWidget(
MaterialApp(
home: Builder(
builder: (context) {
final modalType = ModalUtils.modalTypeBuilder(context);
expect(modalType, isA<WoltModalType>());
expect(
modalType.runtimeType.toString(),
'WoltDialogType',
);
return const Scaffold();
},
),
),
);
});

testWidgets('modalTypeBuilder returns dialog for large screens',
(tester) async {
await tester.binding.setSurfaceSize(const Size(1024, 800));

await tester.pumpWidget(
MaterialApp(
home: Builder(
builder: (context) {
final modalType = ModalUtils.modalTypeBuilder(context);
expect(modalType, isA<WoltModalType>());
expect(modalType.runtimeType.toString(), 'WoltDialogType');
return const Scaffold();
},
),
),
);
});

testWidgets('modalSheetPage creates page with title and close button',
(tester) async {
await tester.pumpWidget(
MaterialApp(
home: Builder(
builder: (context) {
final page = ModalUtils.modalSheetPage(
context: context,
title: 'Test Title',
child: const Text('Test Content'),
);

expect(page, isA<WoltModalSheetPage>());
expect(page.topBarTitle, isA<Text>());
expect(page.trailingNavBarWidget, isA<IconButton>());
expect(page.child, isA<Padding>());
return const Scaffold();
},
),
),
);
});

testWidgets('modalSheetPage creates page without title and close button',
(tester) async {
await tester.pumpWidget(
MaterialApp(
home: Builder(
builder: (context) {
final page = ModalUtils.modalSheetPage(
context: context,
child: const Text('Test Content'),
showCloseButton: false,
);

expect(page, isA<WoltModalSheetPage>());
expect(page.topBarTitle, isNull);
expect(page.trailingNavBarWidget, isNull);
expect(page.child, isA<Padding>());
return const Scaffold();
},
),
),
);
});

testWidgets('showSinglePageModal shows modal and can be closed',
(tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Builder(
builder: (context) {
return ElevatedButton(
onPressed: () {
ModalUtils.showSinglePageModal(
context: context,
title: 'Test Modal',
builder: (context) => const Text('Modal Content'),
);
},
child: const Text('Show Modal'),
);
},
),
),
),
);

// Open modal
await tester.tap(find.text('Show Modal'));
await tester.pumpAndSettle();

// Verify modal content is visible
expect(find.text('Modal Content'), findsOneWidget);
expect(find.text('Test Modal'), findsOneWidget);

// Close modal using close button
await tester.tap(find.byIcon(Icons.close));
await tester.pumpAndSettle();

// Verify modal is closed
expect(find.text('Modal Content'), findsNothing);
expect(find.text('Test Modal'), findsNothing);
});
});
}
Loading