-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
215 additions
and
2 deletions.
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
105 changes: 105 additions & 0 deletions
105
forui/test/src/widgets/sheet/modal_sheet_golden_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,105 @@ | ||
@Tags(['golden']) | ||
library; | ||
|
||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import 'package:forui/forui.dart'; | ||
import '../../test_scaffold.dart'; | ||
|
||
void main() { | ||
group('FModalSheet', () { | ||
for (final side in Layout.values) { | ||
testWidgets('default - $side', (tester) async { | ||
await tester.pumpWidget( | ||
TestScaffold.app( | ||
child: Builder( | ||
builder: (context) => FButton.icon( | ||
child: FIcon(FAssets.icons.chevronRight), | ||
onPress: () => showFModalSheet( | ||
context: context, | ||
side: side, | ||
builder: (context) => Container( | ||
height: double.infinity, | ||
width: double.infinity, | ||
color: context.theme.colorScheme.background, | ||
child: const Center(child: Text('Sheet')), | ||
), | ||
), | ||
), | ||
), | ||
), | ||
); | ||
|
||
await tester.tap(find.byType(FButton)); | ||
await tester.pumpAndSettle(); | ||
|
||
await expectLater(find.byType(TestScaffold), matchesGoldenFile('sheet/modal/default-$side.png')); | ||
}); | ||
|
||
testWidgets('constrained - $side', (tester) async { | ||
await tester.pumpWidget( | ||
TestScaffold.app( | ||
child: Builder( | ||
builder: (context) => FButton.icon( | ||
child: FIcon(FAssets.icons.chevronRight), | ||
onPress: () => showFModalSheet( | ||
context: context, | ||
side: side, | ||
constraints: const BoxConstraints(maxHeight: 200, maxWidth: 200), | ||
builder: (context) => Container( | ||
height: double.infinity, | ||
width: double.infinity, | ||
color: context.theme.colorScheme.background, | ||
child: const Center(child: Text('Sheet')), | ||
), | ||
), | ||
), | ||
), | ||
), | ||
); | ||
|
||
await tester.tap(find.byType(FButton)); | ||
await tester.pumpAndSettle(); | ||
|
||
await expectLater(find.byType(TestScaffold), matchesGoldenFile('sheet/modal/constrained-$side.png')); | ||
}); | ||
|
||
testWidgets('scrollable - $side', (tester) async { | ||
await tester.pumpWidget( | ||
TestScaffold.app( | ||
child: Builder( | ||
builder: (context) => FButton.icon( | ||
child: FIcon(FAssets.icons.chevronRight), | ||
onPress: () => showFModalSheet( | ||
context: context, | ||
side: side, | ||
mainAxisMaxRatio: null, | ||
builder: (context) => Container( | ||
height: double.infinity, | ||
width: double.infinity, | ||
color: context.theme.colorScheme.background, | ||
child: ListView.builder( | ||
scrollDirection: side.vertical ? Axis.vertical : Axis.horizontal, | ||
itemBuilder: (context, index) => Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: Text('Tile $index'), | ||
), | ||
itemCount: 20, | ||
), | ||
), | ||
), | ||
), | ||
), | ||
), | ||
); | ||
|
||
await tester.tap(find.byType(FButton)); | ||
await tester.pumpAndSettle(); | ||
|
||
await expectLater(find.byType(TestScaffold), matchesGoldenFile('sheet/modal/scrollable-$side.png')); | ||
}); | ||
} | ||
}); | ||
} |
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,108 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import 'package:forui/forui.dart'; | ||
import '../../test_scaffold.dart'; | ||
|
||
void main() { | ||
group('FModalSheet', () { | ||
testWidgets('tap on barrier dismisses', (tester) async { | ||
await tester.pumpWidget( | ||
TestScaffold.app( | ||
child: Builder( | ||
builder: (context) => FButton.icon( | ||
child: FIcon(FAssets.icons.chevronRight), | ||
onPress: () => showFModalSheet( | ||
context: context, | ||
side: Layout.btt, | ||
builder: (context) => Container( | ||
height: double.infinity, | ||
width: double.infinity, | ||
color: context.theme.colorScheme.background, | ||
child: const Center(child: Text('sheet')), | ||
), | ||
), | ||
), | ||
), | ||
), | ||
); | ||
|
||
await tester.tap(find.byType(FButton)); | ||
await tester.pumpAndSettle(const Duration(seconds: 1)); | ||
expect(find.text('sheet'), findsOne); | ||
|
||
await tester.tapAt(const Offset(100, 100)); | ||
await tester.pumpAndSettle(const Duration(seconds: 1)); | ||
expect(find.text('sheet'), findsNothing); | ||
}); | ||
|
||
for (final (side, offset) in [ | ||
(Layout.btt, const Offset(0, 300)), | ||
(Layout.ttb, const Offset(0, -300)), | ||
(Layout.ltr, const Offset(-300, 0)), | ||
(Layout.rtl, const Offset(300, 0)), | ||
]) { | ||
testWidgets('drag to dismiss - $side', (tester) async { | ||
await tester.pumpWidget( | ||
TestScaffold.app( | ||
child: Builder( | ||
builder: (context) => FButton.icon( | ||
child: FIcon(FAssets.icons.chevronRight), | ||
onPress: () => showFModalSheet( | ||
context: context, | ||
side: side, | ||
builder: (context) => Container( | ||
height: double.infinity, | ||
width: double.infinity, | ||
color: context.theme.colorScheme.background, | ||
child: const Center(child: Text('sheet')), | ||
), | ||
), | ||
), | ||
), | ||
), | ||
); | ||
|
||
await tester.tap(find.byType(FButton)); | ||
await tester.pumpAndSettle(const Duration(seconds: 1)); | ||
expect(find.text('sheet'), findsOne); | ||
|
||
await tester.drag(find.text('sheet'), offset); | ||
await tester.pumpAndSettle(const Duration(seconds: 1)); | ||
expect(find.text('sheet'), findsNothing); | ||
}); | ||
|
||
testWidgets('drag to dismiss on non-draggable - $side', (tester) async { | ||
await tester.pumpWidget( | ||
TestScaffold.app( | ||
child: Builder( | ||
builder: (context) => FButton.icon( | ||
child: FIcon(FAssets.icons.chevronRight), | ||
onPress: () => showFModalSheet( | ||
context: context, | ||
side: side, | ||
draggable: false, | ||
builder: (context) => Container( | ||
height: double.infinity, | ||
width: double.infinity, | ||
color: context.theme.colorScheme.background, | ||
child: const Center(child: Text('sheet')), | ||
), | ||
), | ||
), | ||
), | ||
), | ||
); | ||
|
||
await tester.tap(find.byType(FButton)); | ||
await tester.pumpAndSettle(const Duration(seconds: 1)); | ||
expect(find.text('sheet'), findsOne); | ||
|
||
await tester.drag(find.text('sheet'), offset); | ||
await tester.pumpAndSettle(const Duration(seconds: 1)); | ||
expect(find.text('sheet'), findsOne); | ||
}); | ||
} | ||
}); | ||
} |