diff --git a/lib/src/pages/example.dart b/lib/src/pages/example.dart index 75c7fb3..de2c3e6 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'), @@ -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..bc009c1 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -5,26 +5,80 @@ // 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 our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); + // Verify that the first item is selected + expect(navigationRailFinder, findsOneWidget); + expect(tester.widget(navigationRailFinder).selectedIndex, 0); - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); + // Perform a tap on the second item of the bottom navigation bar + await tester.tap(find.byIcon(ZetaIcons.star)); await tester.pump(); - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); + // // Verify that the second item is selected + expect(navigationRailFinder, findsOneWidget); + expect(tester.widget(navigationRailFinder).selectedIndex, 1); }); }