-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/saving-section-in-cloudstorage
- Loading branch information
Showing
10 changed files
with
137 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
"localizable", | ||
"mostrado", | ||
"página", | ||
"Texto" | ||
"Texto", | ||
"goldens" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
library io_crossword_ui; | ||
|
||
export 'src/theme/theme.dart'; | ||
export 'src/widgets/widgets.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
packages/io_crossword_ui/lib/src/widgets/io_crossword_card.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export 'io_crossword_card.dart'; |
Binary file added
BIN
+49 KB
packages/io_crossword_ui/test/src/widgets/goldens/io_crossword_card__desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20.6 KB
...io_crossword_ui/test/src/widgets/goldens/io_crossword_card__mobile_portrait.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions
79
packages/io_crossword_ui/test/src/widgets/io_crossword_card_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/// The test tags, as defined in the [`dart_test.yaml`]. | ||
abstract class TestTag { | ||
static const golden = 'golden'; | ||
} |