diff --git a/app/lib/widgets/common/picker.dart b/app/lib/widgets/common/picker.dart index baed001e9..f0ec4962f 100644 --- a/app/lib/widgets/common/picker.dart +++ b/app/lib/widgets/common/picker.dart @@ -56,53 +56,47 @@ Future showSheetBuilder({ context: context, isScrollControlled: false, builder: (context) { - return clearAppTheme( - context: context, - child: Opacity( - opacity: 1, - child: Material( - color: null, - clipBehavior: Clip.antiAlias, - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const SizedBox(height: 6), + return SafeArea( + child: Material( + clipBehavior: Clip.antiAlias, + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox(height: 6), + Align( + alignment: Alignment.topCenter, + child: Container( + height: 4, + width: MediaQuery.of(context).size.width / 6, + decoration: BoxDecoration( + borderRadius: const BorderRadius.all(Radius.circular(16)), + color: Colors.grey[400]), + ), + ), + const SizedBox(height: 12), + if (title != null) Align( alignment: Alignment.topCenter, - child: Container( - height: 4, - width: MediaQuery.of(context).size.width / 6, - decoration: BoxDecoration( - borderRadius: - const BorderRadius.all(Radius.circular(16)), - color: Colors.grey[400]), + child: Text( + title, + style: TextStyle( + fontSize: 19, + fontWeight: FontWeight.w400, + color: Colors.grey[500]), ), ), - const SizedBox(height: 12), - if (title != null) - Align( - alignment: Alignment.topCenter, - child: Text( - title, - style: TextStyle( - fontSize: 19, - fontWeight: FontWeight.w400, - color: Colors.grey[500]), - ), - ), - if (title != null) const SizedBox(height: 12), - child(context), - const SizedBox(height: 6), - actions != null - ? Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: actions(context), - ) - : const SizedBox(height: 0), - const SizedBox(height: 6), - ], - ), + if (title != null) const SizedBox(height: 12), + child(context), + const SizedBox(height: 6), + actions != null + ? Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: actions(context), + ) + : const SizedBox(height: 0), + const SizedBox(height: 6), + ], ), ), ); diff --git a/app/test_goldens/widgets/common/goldens/picker_dark.png b/app/test_goldens/widgets/common/goldens/picker_dark.png new file mode 100644 index 000000000..0219f3ec5 Binary files /dev/null and b/app/test_goldens/widgets/common/goldens/picker_dark.png differ diff --git a/app/test_goldens/widgets/common/goldens/picker_light.png b/app/test_goldens/widgets/common/goldens/picker_light.png new file mode 100644 index 000000000..710c57c47 Binary files /dev/null and b/app/test_goldens/widgets/common/goldens/picker_light.png differ diff --git a/app/test_goldens/widgets/common/picker_test.dart b/app/test_goldens/widgets/common/picker_test.dart new file mode 100644 index 000000000..505c1b32a --- /dev/null +++ b/app/test_goldens/widgets/common/picker_test.dart @@ -0,0 +1,58 @@ +// Copyright (c) 2024 Sharezone UG (haftungsbeschränkt) +// Licensed under the EUPL-1.2-or-later. +// +// You may obtain a copy of the Licence at: +// https://joinup.ec.europa.eu/software/page/eupl +// +// SPDX-License-Identifier: EUPL-1.2 + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:golden_toolkit/golden_toolkit.dart'; +import 'package:sharezone/widgets/common/picker.dart'; +import 'package:sharezone_widgets/sharezone_widgets.dart'; + +void main() { + group('selectItem()', () { + Future pumpPage(WidgetTester tester, ThemeData theme) async { + await tester.pumpWidgetBuilder( + Scaffold( + body: Builder( + builder: (context) => ElevatedButton( + onPressed: () async { + await selectItem( + context: context, + items: ['a', 'b', 'c'], + builder: (context, item) => ListTile( + title: Text(item), + onTap: () { + Navigator.pop(context, item); + }, + ), + ); + }, + child: const Text('Open Picker'), + ), + ), + ), + wrapper: materialAppWrapper(theme: theme), + ); + } + + testGoldens('should render as expected (light mode)', (tester) async { + await pumpPage(tester, getLightTheme()); + + await tester.tap(find.text('Open Picker')); + + await screenMatchesGolden(tester, 'picker_light'); + }); + + testGoldens('should render as expected (dark mode)', (tester) async { + await pumpPage(tester, getDarkTheme()); + + await tester.tap(find.text('Open Picker')); + + await screenMatchesGolden(tester, 'picker_dark'); + }); + }); +}