diff --git a/forui/CHANGELOG.md b/forui/CHANGELOG.md index 3a4ed739f..896d446c0 100644 --- a/forui/CHANGELOG.md +++ b/forui/CHANGELOG.md @@ -1,3 +1,12 @@ +## 0.2.0 + +* Add `NestedHeader` widget. + +### Breaking changes + +* `FHeaderActionStyle.action` parameter has been renamed to `FHeaderStyle.actionStyle`. +* `FHeaderActionStyle.padding` parameter has been moved to `FHeaderStyle.actionSpacing`. + ## 0.1.0 * Initial release! 🚀 diff --git a/forui/test/golden/nested-header/zinc-dark-header.png b/forui/test/golden/nested-header/zinc-dark-header.png new file mode 100644 index 000000000..5404af175 Binary files /dev/null and b/forui/test/golden/nested-header/zinc-dark-header.png differ diff --git a/forui/test/golden/nested-header/zinc-dark-raw-constructor.png b/forui/test/golden/nested-header/zinc-dark-raw-constructor.png new file mode 100644 index 000000000..020000c67 Binary files /dev/null and b/forui/test/golden/nested-header/zinc-dark-raw-constructor.png differ diff --git a/forui/test/golden/nested-header/zinc-dark-raw-title.png b/forui/test/golden/nested-header/zinc-dark-raw-title.png new file mode 100644 index 000000000..aef0c48d4 Binary files /dev/null and b/forui/test/golden/nested-header/zinc-dark-raw-title.png differ diff --git a/forui/test/golden/nested-header/zinc-light-header.png b/forui/test/golden/nested-header/zinc-light-header.png new file mode 100644 index 000000000..6b54dac10 Binary files /dev/null and b/forui/test/golden/nested-header/zinc-light-header.png differ diff --git a/forui/test/golden/nested-header/zinc-light-raw-constructor.png b/forui/test/golden/nested-header/zinc-light-raw-constructor.png new file mode 100644 index 000000000..9255de717 Binary files /dev/null and b/forui/test/golden/nested-header/zinc-light-raw-constructor.png differ diff --git a/forui/test/golden/nested-header/zinc-light-raw-title.png b/forui/test/golden/nested-header/zinc-light-raw-title.png new file mode 100644 index 000000000..218408e11 Binary files /dev/null and b/forui/test/golden/nested-header/zinc-light-raw-title.png differ diff --git a/forui/test/src/widgets/header/header_golden_test.dart b/forui/test/src/widgets/header/header_golden_test.dart index 5bb84e2ce..46b7e9f11 100644 --- a/forui/test/src/widgets/header/header_golden_test.dart +++ b/forui/test/src/widgets/header/header_golden_test.dart @@ -1,7 +1,7 @@ @Tags(['golden']) library; -import 'package:flutter/cupertino.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/forui/test/src/widgets/header/header_test.dart b/forui/test/src/widgets/header/header_test.dart index 22743a29d..8b7c9b5d2 100644 --- a/forui/test/src/widgets/header/header_test.dart +++ b/forui/test/src/widgets/header/header_test.dart @@ -1,4 +1,4 @@ -import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/forui/test/src/widgets/nested_header/nested_header_golden_test.dart b/forui/test/src/widgets/nested_header/nested_header_golden_test.dart new file mode 100644 index 000000000..6b677dfa2 --- /dev/null +++ b/forui/test/src/widgets/nested_header/nested_header_golden_test.dart @@ -0,0 +1,114 @@ +@Tags(['golden']) +library; + +import 'package:flutter/widgets.dart'; + +import 'package:flutter_test/flutter_test.dart'; + +import 'package:forui/forui.dart'; +import '../../test_scaffold.dart'; + +void main() { + group('FNestedHeader', () { + for (final (name, theme, _) in TestScaffold.themes) { + testWidgets('$name with FNestedHeader actions', (tester) async { + await tester.pumpWidget( + TestScaffold( + data: theme, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20), + child: FNestedHeader( + title: 'Title', + rightActions: [ + FNestedHeaderAction( + icon: FAssets.icons.alarmClock, + onPress: null, + ), + FNestedHeaderAction( + icon: FAssets.icons.plus, + onPress: () {}, + ), + ], + onPop: () {}, + ), + ), + ), + ); + + await expectLater( + find.byType(TestScaffold), + matchesGoldenFile('nested-header/$name-header.png'), + ); + }); + + testWidgets('$name with raw title', (tester) async { + await tester.pumpWidget( + TestScaffold( + data: theme, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20), + child: FNestedHeader( + rawTitle: const Text('Title'), + rightActions: [ + FNestedHeaderAction( + icon: FAssets.icons.alarmClock, + onPress: null, + ), + FNestedHeaderAction( + icon: FAssets.icons.plus, + onPress: () {}, + ), + ], + onPop: null, + ), + ), + ), + ); + + await expectLater( + find.byType(TestScaffold), + matchesGoldenFile('nested-header/$name-raw-title.png'), + ); + }); + + testWidgets('$name with raw constructor', (tester) async { + await tester.pumpWidget( + TestScaffold( + data: theme, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20), + child: FNestedHeader.raw( + rawTitle: const Text('Title'), + leftActions: [ + FNestedHeaderAction( + icon: FAssets.icons.orbit, + onPress: () {}, + ), + FNestedHeaderAction( + icon: FAssets.icons.airVent, + onPress: () {}, + ), + ], + rightActions: [ + FNestedHeaderAction( + icon: FAssets.icons.alarmClock, + onPress: null, + ), + FNestedHeaderAction( + icon: FAssets.icons.plus, + onPress: () {}, + ), + ], + ), + ), + ), + ); + + await expectLater( + find.byType(TestScaffold), + matchesGoldenFile('nested-header/$name-raw-constructor.png'), + ); + }); + } + }); +} diff --git a/forui/test/src/widgets/nested_header/nested_header_test.dart b/forui/test/src/widgets/nested_header/nested_header_test.dart new file mode 100644 index 000000000..28041fee9 --- /dev/null +++ b/forui/test/src/widgets/nested_header/nested_header_test.dart @@ -0,0 +1,41 @@ +import 'package:flutter/widgets.dart'; + +import 'package:flutter_test/flutter_test.dart'; + +import 'package:forui/forui.dart'; + +void main() { + group('FNestedHeader', () { + for (final (title, rawTitle) in [ + ('', null), + (null, const SizedBox()), + ]) { + testWidgets('constructor does not throw error', (tester) async { + expect( + () => FNestedHeader( + title: title, + rawTitle: rawTitle, + onPop: null, + ), + returnsNormally, + ); + }); + } + + for (final (title, rawTitle) in [ + (null, null), + ('', const SizedBox()), + ]) { + testWidgets('constructor throws error', (tester) async { + expect( + () => FNestedHeader( + title: title, + rawTitle: rawTitle, + onPop: () {}, + ), + throwsAssertionError, + ); + }); + } + }); +}