From b9a3297b64a11a1fb898e34aa81472c3c0f98cf6 Mon Sep 17 00:00:00 2001 From: Alejandro Santiago Date: Wed, 13 Mar 2024 11:12:05 +0000 Subject: [PATCH] feat: defined `IoCrosswordCard` (#58) --- .github/cspell.json | 3 +- packages/io_crossword_ui/dart_test.yaml | 9 ++ .../io_crossword_ui/lib/io_crossword_ui.dart | 1 + .../lib/src/theme/io_crossword_theme.dart | 2 + .../lib/src/widgets/io_crossword_card.dart | 39 +++++++++ .../lib/src/widgets/widgets.dart | 1 + .../goldens/io_crossword_card__desktop.png | Bin 0 -> 50163 bytes .../io_crossword_card__mobile_portrait.png | Bin 0 -> 21060 bytes .../src/widgets/io_crossword_card_test.dart | 79 ++++++++++++++++++ packages/io_crossword_ui/test/test_tag.dart | 4 + 10 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 packages/io_crossword_ui/dart_test.yaml create mode 100644 packages/io_crossword_ui/lib/src/widgets/io_crossword_card.dart create mode 100644 packages/io_crossword_ui/lib/src/widgets/widgets.dart create mode 100644 packages/io_crossword_ui/test/src/widgets/goldens/io_crossword_card__desktop.png create mode 100644 packages/io_crossword_ui/test/src/widgets/goldens/io_crossword_card__mobile_portrait.png create mode 100644 packages/io_crossword_ui/test/src/widgets/io_crossword_card_test.dart create mode 100644 packages/io_crossword_ui/test/test_tag.dart diff --git a/.github/cspell.json b/.github/cspell.json index 38d3a9d30..c737d40b4 100644 --- a/.github/cspell.json +++ b/.github/cspell.json @@ -21,6 +21,7 @@ "localizable", "mostrado", "página", - "Texto" + "Texto", + "goldens" ] } diff --git a/packages/io_crossword_ui/dart_test.yaml b/packages/io_crossword_ui/dart_test.yaml new file mode 100644 index 000000000..c727e0ec3 --- /dev/null +++ b/packages/io_crossword_ui/dart_test.yaml @@ -0,0 +1,9 @@ +# File used to configure Dart tests within this package. +# +# See also: +# +# * [dart_test.yaml documentation](https://github.com/dart-lang/test/blob/master/pkgs/test/doc/configuration.md) + +tags: + # Identifies those tests that rely on `matchesGoldenFile()`. + golden: {} diff --git a/packages/io_crossword_ui/lib/io_crossword_ui.dart b/packages/io_crossword_ui/lib/io_crossword_ui.dart index 6ae2fbaba..cf313c63b 100644 --- a/packages/io_crossword_ui/lib/io_crossword_ui.dart +++ b/packages/io_crossword_ui/lib/io_crossword_ui.dart @@ -2,3 +2,4 @@ library io_crossword_ui; export 'src/theme/theme.dart'; +export 'src/widgets/widgets.dart'; diff --git a/packages/io_crossword_ui/lib/src/theme/io_crossword_theme.dart b/packages/io_crossword_ui/lib/src/theme/io_crossword_theme.dart index 23aa5d4a4..c3a21328c 100644 --- a/packages/io_crossword_ui/lib/src/theme/io_crossword_theme.dart +++ b/packages/io_crossword_ui/lib/src/theme/io_crossword_theme.dart @@ -23,6 +23,8 @@ class IoCrosswordTheme { return ColorScheme.fromSeed( seedColor: IoCrosswordColors.seedBlue, background: IoCrosswordColors.seedBlack, + surface: IoCrosswordColors.seedWhite, + surfaceTint: IoCrosswordColors.seedWhite, ); } diff --git a/packages/io_crossword_ui/lib/src/widgets/io_crossword_card.dart b/packages/io_crossword_ui/lib/src/widgets/io_crossword_card.dart new file mode 100644 index 000000000..612dc767a --- /dev/null +++ b/packages/io_crossword_ui/lib/src/widgets/io_crossword_card.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; + +/// {@template io_crossword_card} +/// A panel with slightly rounded corners and an elevation shadow. +/// +/// An [IoCrosswordCard] is meant to be the main container of the page. They are +/// not meant to be nested between each other. +/// +/// It has a fixed maximum size that adjusts according to the device's +/// layout size. Note that it does not support orientation changes, it assumes +/// the orientation is fixed to portrait. +/// {@endtemplate} +class IoCrosswordCard extends StatelessWidget { + /// {@macro io_crossword_card} + const IoCrosswordCard({super.key, this.child}); + + /// The widget below this widget in the tree. + /// + /// If this [child] size is bigger than the [IoCrosswordCard]'s size, + /// you should consider scrolling the content. + /// + /// The [child] will be expanded to fill the [IoCrosswordCard]. + final Widget? child; + + @override + Widget build(BuildContext context) { + return SafeArea( + minimum: const EdgeInsets.all(16), + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 358, maxHeight: 540), + child: Material( + type: MaterialType.card, + borderRadius: BorderRadius.circular(24), + child: SizedBox.expand(child: child), + ), + ), + ); + } +} diff --git a/packages/io_crossword_ui/lib/src/widgets/widgets.dart b/packages/io_crossword_ui/lib/src/widgets/widgets.dart new file mode 100644 index 000000000..695410029 --- /dev/null +++ b/packages/io_crossword_ui/lib/src/widgets/widgets.dart @@ -0,0 +1 @@ +export 'io_crossword_card.dart'; diff --git a/packages/io_crossword_ui/test/src/widgets/goldens/io_crossword_card__desktop.png b/packages/io_crossword_ui/test/src/widgets/goldens/io_crossword_card__desktop.png new file mode 100644 index 0000000000000000000000000000000000000000..d72afb9018524857b9d2fb35d82d7a79a09f7d2e GIT binary patch literal 50163 zcmeI52~ZT*y2o2d&_ooKD5wY|MsYzF1#tlxS40p{Q4mnLVgx~10}&&lTTbX z>X}Ri58ug$P7#Cxp|^R1iDz_o>xLPH3Pj;ewS~^#1q3Su>PmgOr&_IPy*$|GSC7r3 zX=1->08jV}#isqXtyW_7Z=1HQ444fLGG_Y!j(7>r70t2gtC=8q$qBO8-h|s{PAp!%dhA0f28lp6?YKYLlsUZS` zRSj-gdt0&DhBzNN*D+R!VOMiKpeRVH*RMTHO3|>$Lb3gH!nmvY zG`Y23Op=s49XLs{Bson^S$h_>G_K2yT20$_VeJCAW*Paz6;X4_B2~h-Opz`sEaXT? zNEH3^vjS7^*`PyoI&Y*iWwl#Zn@nlI$nz<;0>;NyfBQ7EHl5yE@e}%+=9w4OY_>{B zssw#g7Ex0BcW(98Lr?3y>`T0VS^?CRH+T7#`Bf`KM0746Tc5x5(f0WPdP z{v!8YXyPxo+=R~k@7_hkege7(N|vSFomsWsM`4=QU|Dm)_#;n2sOEMfuypX?Pn^N0 zHi&K3uYWE(*mfuLmV1wUardM2?N#7i2G^zc^^*m+Y^$m|9%%b?m=+AB)w;qRR#%~! z&FjIkZ&($qYD}}3=jZ2__#E`$)Om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KPqkjdG6`mOt9p2MlV}6LEphBFR!cP`^dC6#WRKW;+72#9P}KYM{J;?P|WCON0AH$dHjQn z^8jvEy|e=ide@n|42To-9*Av6F%y8Q*{gI!KL0~Ch|P%GybrJkTuz*n|TGFQjVsk#;&2y=?kAGh{(E|G0Hz*ZfBf&xG0y_j%9mhxW|f29oYS0PYg!+k6n$r1z3#T>OL=Ix`@W zdI|L#m}075txZ&qO57{AbUP6J1^GkktDlqA6CXpfeROnqdsJe3wW6iUNiYf00$4M( zMnjJZeFxvA&@`ZnsihwE@lHivm$X8sG=yV?iyUH;>Cef^4~uk7uW{9(mvX@yaYL7=X3ae>7kOI8hFbhyN{6KE)dEh=2;ie+?6C`0=+`80-7@$NC;^unW#; SA(t6I9gjI=Z9zA4zxq!MPNClb literal 0 HcmV?d00001 diff --git a/packages/io_crossword_ui/test/src/widgets/io_crossword_card_test.dart b/packages/io_crossword_ui/test/src/widgets/io_crossword_card_test.dart new file mode 100644 index 000000000..bcc517533 --- /dev/null +++ b/packages/io_crossword_ui/test/src/widgets/io_crossword_card_test.dart @@ -0,0 +1,79 @@ +// ignore_for_file: prefer_const_constructors + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:io_crossword_ui/io_crossword_ui.dart'; + +import '../../test_tag.dart'; + +void main() { + group('$IoCrosswordCard', () { + testWidgets('renders successfully', (tester) async { + await tester.pumpWidget(const IoCrosswordCard(child: FlutterLogo())); + expect(find.byType(IoCrosswordCard), findsOneWidget); + }); + + testWidgets('renders its child', (tester) async { + const child = FlutterLogo(); + await tester.pumpWidget(const IoCrosswordCard(child: child)); + expect(find.byWidget(child), findsOneWidget); + }); + + group('renders as expected', () { + Uri goldenKey(String name) => + Uri.parse('goldens/io_crossword_card__$name.png'); + + testWidgets( + 'when portrait mobile', + tags: TestTag.golden, + (tester) async { + await tester.binding.setSurfaceSize(const Size(390, 844)); + + await tester.pumpWidget( + _GoldenSubject(child: IoCrosswordCard()), + ); + + await expectLater( + find.byType(IoCrosswordCard), + matchesGoldenFile(goldenKey('mobile_portrait')), + ); + }, + ); + + testWidgets( + 'when desktop', + tags: TestTag.golden, + (tester) async { + await tester.binding.setSurfaceSize(const Size(1440, 800)); + + await tester.pumpWidget( + _GoldenSubject(child: IoCrosswordCard()), + ); + + await expectLater( + find.byType(IoCrosswordCard), + matchesGoldenFile(goldenKey('desktop')), + ); + }, + ); + }); + }); +} + +class _GoldenSubject extends StatelessWidget { + const _GoldenSubject({required this.child}); + + final IoCrosswordCard child; + + @override + Widget build(BuildContext context) { + final themeData = IoCrosswordTheme.themeData; + return Theme( + data: IoCrosswordTheme.themeData, + child: ColoredBox( + color: themeData.colorScheme.background, + child: Center(child: child), + ), + ); + } +} diff --git a/packages/io_crossword_ui/test/test_tag.dart b/packages/io_crossword_ui/test/test_tag.dart new file mode 100644 index 000000000..ce39fa36f --- /dev/null +++ b/packages/io_crossword_ui/test/test_tag.dart @@ -0,0 +1,4 @@ +/// The test tags, as defined in the [`dart_test.yaml`]. +abstract class TestTag { + static const golden = 'golden'; +}