diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index a7291d9..2e02b40 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -16,7 +16,7 @@ jobs: # Checkout the repo - uses: actions/checkout@v4 with: - repository: ${{github.event.pull_request.head.repo.full_name}} + fetch-depth: 0 # Use the flutter-action to set up flutter, and cache dependencies - uses: subosito/flutter-action@v2 diff --git a/coverage/lcov.info b/coverage/lcov.info new file mode 100644 index 0000000..d77ae87 --- /dev/null +++ b/coverage/lcov.info @@ -0,0 +1,193 @@ +SF:lib/main.dart +DA:14,2 +DA:16,1 +DA:17,1 +DA:21,1 +DA:23,1 +DA:25,1 +DA:26,1 +DA:27,1 +LF:8 +LH:8 +end_of_record +SF:lib/src/utils/routes.dart +DA:7,3 +DA:8,3 +DA:10,3 +DA:11,1 +DA:12,1 +DA:13,1 +DA:14,1 +DA:15,1 +DA:16,2 +DA:18,1 +DA:19,1 +DA:20,1 +DA:22,1 +DA:24,1 +DA:25,3 +DA:26,1 +DA:27,2 +DA:32,1 +DA:36,1 +DA:39,1 +DA:40,1 +DA:41,1 +DA:42,2 +DA:43,2 +DA:49,1 +DA:53,1 +DA:54,2 +DA:55,2 +DA:66,1 +DA:67,1 +DA:68,1 +DA:69,1 +DA:70,1 +DA:72,1 +DA:76,1 +DA:77,1 +DA:78,1 +DA:79,1 +DA:81,1 +LF:39 +LH:39 +end_of_record +SF:lib/src/pages/example.dart +DA:5,1 +DA:7,1 +DA:8,1 +DA:15,1 +DA:17,2 +DA:19,1 +DA:20,1 +DA:21,1 +DA:22,1 +DA:23,4 +DA:28,1 +DA:30,1 +DA:33,1 +DA:35,1 +DA:43,1 +DA:44,1 +DA:46,1 +DA:47,1 +DA:48,1 +DA:49,1 +DA:50,1 +DA:51,1 +DA:52,1 +DA:53,1 +DA:56,1 +DA:58,1 +DA:59,1 +DA:60,1 +DA:62,0 +DA:63,0 +DA:72,1 +DA:73,0 +DA:74,0 +DA:75,0 +DA:77,0 +DA:84,1 +DA:85,1 +DA:87,0 +DA:89,1 +DA:90,1 +DA:91,1 +DA:92,1 +DA:97,1 +DA:98,1 +DA:100,1 +DA:102,1 +DA:103,1 +DA:104,1 +DA:106,1 +DA:108,0 +DA:110,1 +DA:113,0 +DA:114,0 +DA:116,1 +DA:118,1 +DA:119,1 +DA:120,0 +DA:121,0 +DA:124,1 +DA:125,1 +DA:127,1 +DA:128,1 +DA:129,1 +DA:131,1 +DA:132,1 +DA:139,1 +DA:140,1 +DA:142,1 +DA:143,8 +DA:148,1 +DA:149,0 +DA:150,1 +DA:151,1 +DA:152,1 +DA:155,1 +DA:157,2 +DA:158,0 +DA:166,1 +DA:167,1 +DA:168,1 +DA:170,0 +DA:171,0 +DA:174,1 +DA:178,0 +DA:180,1 +DA:188,0 +DA:189,1 +DA:190,1 +DA:191,1 +DA:192,1 +DA:198,1 +DA:200,1 +DA:201,1 +DA:202,2 +DA:203,2 +DA:204,2 +DA:205,2 +DA:206,2 +DA:207,1 +DA:209,1 +DA:211,1 +DA:212,1 +DA:213,1 +DA:214,1 +DA:215,1 +DA:216,1 +DA:220,1 +DA:221,1 +DA:223,1 +DA:225,1 +DA:226,1 +DA:234,1 +DA:235,1 +DA:237,1 +DA:239,0 +DA:242,1 +DA:243,1 +DA:248,0 +DA:249,0 +DA:250,0 +DA:253,1 +DA:266,1 +DA:267,1 +DA:269,1 +DA:271,1 +DA:272,1 +DA:273,1 +DA:279,1 +LF:128 +LH:106 +end_of_record +SF:lib/src/pages/home.dart +DA:5,1 +DA:7,1 +LF:2 +LH:2 +end_of_record diff --git a/lib/main.dart b/lib/main.dart index cb59c45..65d0904 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -3,10 +3,12 @@ import 'package:zeta_flutter/zeta_flutter.dart'; import 'package:zeta_flutter_template/src/utils/routes.dart'; +// coverage:ignore-start void main() async { WidgetsFlutterBinding.ensureInitialized(); runApp(const MyApp()); } +// coverage:ignore-end class MyApp extends StatefulWidget { const MyApp({super.key}); diff --git a/lib/src/pages/example.dart b/lib/src/pages/example.dart index 75c7fb3..19c6c29 100644 --- a/lib/src/pages/example.dart +++ b/lib/src/pages/example.dart @@ -20,6 +20,7 @@ class _ExamplePageState extends State { controller: _scrollController, child: Column( children: [ + Text('Screen Size: ${MediaQuery.of(context).size}'), const ZetaAccordion( title: 'Accordion', child: Text('Expanded'), @@ -57,7 +58,7 @@ class _ExamplePageState extends State { child: Row( children: [ ZetaButton( - label: 'Button', + label: 'Open Dialog', onPressed: () { showZetaDialog( context, @@ -199,10 +200,10 @@ class _ExamplePageState extends State { child: Row( children: [ SizedBox(width: 250, child: ZetaDateInput(label: 'Date Input')), - const SizedBox(width: 250, child: ZetaPasswordInput(label: 'Password input')), - const SizedBox(width: 250, child: ZetaPhoneInput(label: 'Phone Input')), - const SizedBox(width: 250, child: ZetaTimeInput(label: 'Phone Input')), - const SizedBox(width: 250, child: ZetaTextInput(label: 'Phone Input')), + SizedBox(width: 250, child: ZetaPasswordInput(label: 'Password input')), + SizedBox(width: 250, child: ZetaPhoneInput(label: 'Phone Input')), + SizedBox(width: 250, child: ZetaTimeInput(label: 'Phone Input')), + SizedBox(width: 250, child: ZetaTextInput(label: 'Phone Input')), SizedBox( width: 250, child: ZetaSelectInput( @@ -238,7 +239,7 @@ class _ExamplePageState extends State { onActionButtonPressed: () {}, title: const Text('Screen Header Bar'), ), - const ZetaSearchBar(), + ZetaSearchBar(), ZetaSegmentedControl( segments: const [ ZetaButtonSegment(value: 1, child: Text('Segmented')), diff --git a/lib/src/utils/routes.dart b/lib/src/utils/routes.dart index 8dd7b5e..87138c4 100644 --- a/lib/src/utils/routes.dart +++ b/lib/src/utils/routes.dart @@ -13,7 +13,7 @@ final goRouter = GoRouter( builder: (context, state, navigationShell) { return LayoutBuilder( builder: (context, constraints) { - final showBottomBar = constraints.maxWidth < 479; + final showBottomBar = constraints.maxWidth < 500; final body = CustomScrollView( slivers: [ @@ -42,8 +42,8 @@ final goRouter = GoRouter( onSelect: (value) => navigationShell.goBranch(value), selectedIndex: state.fullPath == '/' ? 0 : 1, items: const [ - ZetaNavigationRailItem(label: 'Welcome', icon: Icon(ZetaIcons.content_round)), - ZetaNavigationRailItem(label: 'Example', icon: Icon(ZetaIcons.star_round)), + ZetaNavigationRailItem(label: 'Welcome', icon: Icon(ZetaIcons.content)), + ZetaNavigationRailItem(label: 'Example', icon: Icon(ZetaIcons.star)), ], ), Expanded(child: body), @@ -54,8 +54,8 @@ final goRouter = GoRouter( onTap: (value) => navigationShell.goBranch(value), currentIndex: state.fullPath == '/' ? 0 : 1, items: const [ - ZetaNavigationBarItem(icon: ZetaIcons.content_round, label: 'Welcome'), - ZetaNavigationBarItem(icon: ZetaIcons.star_round, label: 'Example'), + ZetaNavigationBarItem(icon: ZetaIcons.content, label: 'Welcome'), + ZetaNavigationBarItem(icon: ZetaIcons.star, label: 'Example'), ], ) : null, diff --git a/macos/Runner/AppDelegate.swift b/macos/Runner/AppDelegate.swift index d53ef64..8e02df2 100644 --- a/macos/Runner/AppDelegate.swift +++ b/macos/Runner/AppDelegate.swift @@ -1,7 +1,7 @@ import Cocoa import FlutterMacOS -@NSApplicationMain +@main class AppDelegate: FlutterAppDelegate { override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { return true diff --git a/pubspec.yaml b/pubspec.yaml index b4926c7..f6bdefb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -31,7 +31,7 @@ dependencies: flutter: sdk: flutter go_router: ^14.2.0 - zeta_flutter: ^0.14.0 + zeta_flutter: ^0.15.1 dev_dependencies: flutter_test: diff --git a/test/widget_test.dart b/test/widget_test.dart index 4a97701..826f4f9 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -5,26 +5,110 @@ // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. -import 'package:flutter/material.dart'; +import 'dart:ui'; + +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:zeta_flutter/zeta_flutter.dart'; import 'package:zeta_flutter_template/main.dart'; void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { + testWidgets('App runs', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + }); + + testWidgets('Bottom navigation bar works on small screen', (WidgetTester tester) async { + // Set the screen size to a small value + tester.view.devicePixelRatio = 1.0; + tester.view.physicalSize = const Size(481, 480); + + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + await tester.pumpAndSettle(); + + // Find the bottom navigation bar widget + final bottomNavigationBarFinder = find.byType(ZetaNavigationBar); + + // Verify that the bottom navigation bar is present + expect(bottomNavigationBarFinder, findsOneWidget); + + // Perform a tap on the first item of the bottom navigation bar + await tester.tap(find.byIcon(ZetaIcons.content_round)); + await tester.pump(); + + // Verify that the first item is selected + expect(bottomNavigationBarFinder, findsOneWidget); + expect(tester.widget(bottomNavigationBarFinder).currentIndex, 0); + + // Perform a tap on the second item of the bottom navigation bar + await tester.tap(find.byIcon(ZetaIcons.star_round)); + await tester.pump(); + + // // Verify that the second item is selected + expect(bottomNavigationBarFinder, findsOneWidget); + expect(tester.widget(bottomNavigationBarFinder).currentIndex, 1); + }); + + testWidgets('Side navigation bar works on large screen', (WidgetTester tester) async { + // Set the screen size to a small value + tester.view.devicePixelRatio = 1.0; + tester.view.physicalSize = const Size(881, 480); + + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Find the bottom navigation bar widget + final navigationRailFinder = find.byType(ZetaNavigationRail); + + // Verify that the bottom navigation bar is present + expect(navigationRailFinder, findsOneWidget); + + // Perform a tap on the first item of the bottom navigation bar + await tester.tap(find.byIcon(ZetaIcons.content)); + await tester.pump(); + + // Verify that the first item is selected + expect(navigationRailFinder, findsOneWidget); + expect(tester.widget(navigationRailFinder).selectedIndex, 0); + + // Perform a tap on the second item of the bottom navigation bar + await tester.tap(find.byIcon(ZetaIcons.star)); + await tester.pump(); + + // // Verify that the second item is selected + expect(navigationRailFinder, findsOneWidget); + expect(tester.widget(navigationRailFinder).selectedIndex, 1); + }); + + testWidgets('Switching between light and dark mode', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MyApp()); - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); + // Find the switch widget + final switchFinder = find.byType(ZetaSwitch).first; + + // Verify that the switch is present + // expect(switchFinder, findsOneWidget); + + // Get the current brightness mode + final zetaFinder = find.byType(Zeta); + final initialBrightness = tester.widget(zetaFinder).brightness; + // final brightnessMode = tester.binding.window.platformBrightness; + + // Perform a tap on the switch to toggle the brightness mode + await tester.tap(switchFinder); + await tester.pump(); + + // Verify that the brightness mode has changed + expect(tester.widget(zetaFinder).brightness, isNot(initialBrightness)); - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); + // Perform another tap on the switch to toggle back to the original brightness mode + await tester.tap(switchFinder); await tester.pump(); - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); + // Verify that the brightness mode has changed back to the original mode + expect(tester.widget(zetaFinder).brightness, initialBrightness); }); }