From 13ce4a960b68922f5e9d18dba98b69aad7a4fc7e Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 12 Oct 2024 15:49:54 -0400 Subject: [PATCH 1/8] Added nav bar --- flutter_app/.metadata | 29 +++------- flutter_app/lib/main.dart | 4 ++ flutter_app/lib/screens/home_screen.dart | 23 ++++---- flutter_app/lib/widgets/nav_bar_widget.dart | 64 +++++++++++++++++++++ flutter_app/pubspec.lock | 4 +- flutter_app/test/widget_test.dart | 30 ++++++++++ 6 files changed, 119 insertions(+), 35 deletions(-) create mode 100644 flutter_app/lib/widgets/nav_bar_widget.dart create mode 100644 flutter_app/test/widget_test.dart diff --git a/flutter_app/.metadata b/flutter_app/.metadata index 6e12c20..ea59ad0 100644 --- a/flutter_app/.metadata +++ b/flutter_app/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled and should not be manually edited. version: - revision: "761747bfc538b5af34aa0d3fac380f1bc331ec49" + revision: "2663184aa79047d0a33a14a3b607954f8fdd8730" channel: "stable" project_type: app @@ -13,26 +13,11 @@ project_type: app migration: platforms: - platform: root - create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 - base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 - - platform: android - create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 - base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 - - platform: ios - create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 - base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 - - platform: linux - create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 - base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 - - platform: macos - create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 - base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 - - platform: web - create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 - base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 - platform: windows - create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 - base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 # User provided section @@ -41,5 +26,5 @@ migration: # # Files that are not part of the templates will be ignored by default. unmanaged_files: - - "lib/main.dart" - - "ios/Runner.xcodeproj/project.pbxproj" + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/flutter_app/lib/main.dart b/flutter_app/lib/main.dart index 878e68d..da1e559 100644 --- a/flutter_app/lib/main.dart +++ b/flutter_app/lib/main.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:imacs/screens/home_screen.dart'; +import 'package:imacs/widgets/nav_bar_widget.dart'; void main() async { runApp(const App()); @@ -17,6 +18,9 @@ class App extends StatelessWidget { ), routes: { '/': (BuildContext context) => HomePage(title: 'WARG IMACS'), + '/logs': (BuildContext context) => const Placeholder(child: NavBar()), + '/camera': (BuildContext context) => const Placeholder(child: NavBar()), + '/sitl': (BuildContext context) => const Placeholder(child: NavBar()), }, ); } diff --git a/flutter_app/lib/screens/home_screen.dart b/flutter_app/lib/screens/home_screen.dart index 93f369c..09802e9 100644 --- a/flutter_app/lib/screens/home_screen.dart +++ b/flutter_app/lib/screens/home_screen.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:imacs/modules/mavlink_communication.dart'; import 'package:imacs/modules/get_drone_information.dart'; import 'package:imacs/widgets/drone_information_widget.dart'; +import 'package:imacs/widgets/nav_bar_widget.dart'; class HomePage extends StatelessWidget { HomePage({Key? key, required this.title}) : super(key: key); @@ -13,16 +14,16 @@ class HomePage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: Text(title), - ), - body: Column( - children: [ - DroneInformation( - getDroneInformation: GetDroneInformation(comm: comm), - ), - ], - ), - ); + appBar: AppBar( + title: Text(title), + ), + body: Column( + children: [ + DroneInformation( + getDroneInformation: GetDroneInformation(comm: comm), + ), + ], + ), + bottomNavigationBar: const NavBar()); } } diff --git a/flutter_app/lib/widgets/nav_bar_widget.dart b/flutter_app/lib/widgets/nav_bar_widget.dart new file mode 100644 index 0000000..baaa5af --- /dev/null +++ b/flutter_app/lib/widgets/nav_bar_widget.dart @@ -0,0 +1,64 @@ +import 'package:flutter/material.dart'; + +class NavBar extends StatefulWidget { + const NavBar({super.key}); + + @override + NavBarState createState() => NavBarState(); +} + +class NavBarState extends State { + int _index = 0; + + void _onItemClicked(int index) { + setState(() { + _index = index; + }); + + switch (index) { + case 0: + Navigator.of(context).popUntil((route) => route.isFirst); + break; + case 1: + Navigator.pushNamed(context, '/logs'); + break; + case 2: + Navigator.pushNamed(context, '/camera'); + break; + default: + Navigator.pushNamed(context, '/sitl'); + break; + } + } + + @override + Widget build(BuildContext context) { + return BottomNavigationBar( + currentIndex: _index, + onTap: _onItemClicked, + items: const [ + BottomNavigationBarItem( + icon: Icon(Icons.home), + label: 'Home', + backgroundColor: Colors.black, + ), + BottomNavigationBarItem( + icon: Icon(Icons.format_list_bulleted_sharp), + label: 'Logs', + backgroundColor: Colors.black, + ), + BottomNavigationBarItem( + icon: Icon(Icons.camera_sharp), + label: 'Camera', + backgroundColor: Colors.black, + ), + BottomNavigationBarItem( + icon: Icon(Icons.check_box_sharp), + label: 'SITL', + backgroundColor: Colors.black, + ) + ], + showUnselectedLabels: true, + ); + } +} diff --git a/flutter_app/pubspec.lock b/flutter_app/pubspec.lock index df9b2af..3e0a02f 100644 --- a/flutter_app/pubspec.lock +++ b/flutter_app/pubspec.lock @@ -477,10 +477,10 @@ packages: dependency: transitive description: name: vm_service - sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "14.2.4" + version: "14.2.5" watcher: dependency: transitive description: diff --git a/flutter_app/test/widget_test.dart b/flutter_app/test/widget_test.dart new file mode 100644 index 0000000..be73888 --- /dev/null +++ b/flutter_app/test/widget_test.dart @@ -0,0 +1,30 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// 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 'package:flutter_test/flutter_test.dart'; + +import 'package:flutter_app/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (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); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} From 050e7c5754d04b069d60e4785a01d42b985dcd0f Mon Sep 17 00:00:00 2001 From: wdan31 Date: Sat, 12 Oct 2024 20:17:55 -0400 Subject: [PATCH 2/8] Removed widget_test.dart - not found in original repo --- flutter_app/test/widget_test.dart | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 flutter_app/test/widget_test.dart diff --git a/flutter_app/test/widget_test.dart b/flutter_app/test/widget_test.dart deleted file mode 100644 index be73888..0000000 --- a/flutter_app/test/widget_test.dart +++ /dev/null @@ -1,30 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility in the flutter_test package. For example, you can send tap and scroll -// 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 'package:flutter_test/flutter_test.dart'; - -import 'package:flutter_app/main.dart'; - -void main() { - testWidgets('Counter increments smoke test', (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); - - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); - await tester.pump(); - - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); - }); -} From a2b8421aa08fa16a8e0f428e595f72cb7da4b5ff Mon Sep 17 00:00:00 2001 From: wdan31 Date: Sat, 26 Oct 2024 12:16:00 -0400 Subject: [PATCH 3/8] Improved nav bar widget and placeholder screens --- flutter_app/lib/main.dart | 6 +- flutter_app/lib/widgets/nav_bar_widget.dart | 77 +++++++++++---------- 2 files changed, 43 insertions(+), 40 deletions(-) diff --git a/flutter_app/lib/main.dart b/flutter_app/lib/main.dart index da1e559..593d55f 100644 --- a/flutter_app/lib/main.dart +++ b/flutter_app/lib/main.dart @@ -18,9 +18,9 @@ class App extends StatelessWidget { ), routes: { '/': (BuildContext context) => HomePage(title: 'WARG IMACS'), - '/logs': (BuildContext context) => const Placeholder(child: NavBar()), - '/camera': (BuildContext context) => const Placeholder(child: NavBar()), - '/sitl': (BuildContext context) => const Placeholder(child: NavBar()), + '/logs': (BuildContext context) => const PlaceholderScreen(title: 'Logs'), + '/camera': (BuildContext context) => const PlaceholderScreen(title: 'Camera'), + '/sitl': (BuildContext context) => const PlaceholderScreen(title: 'SITL'), }, ); } diff --git a/flutter_app/lib/widgets/nav_bar_widget.dart b/flutter_app/lib/widgets/nav_bar_widget.dart index baaa5af..47fb92e 100644 --- a/flutter_app/lib/widgets/nav_bar_widget.dart +++ b/flutter_app/lib/widgets/nav_bar_widget.dart @@ -1,64 +1,67 @@ import 'package:flutter/material.dart'; -class NavBar extends StatefulWidget { - const NavBar({super.key}); - - @override - NavBarState createState() => NavBarState(); -} - -class NavBarState extends State { - int _index = 0; - - void _onItemClicked(int index) { - setState(() { - _index = index; - }); - - switch (index) { - case 0: - Navigator.of(context).popUntil((route) => route.isFirst); - break; - case 1: - Navigator.pushNamed(context, '/logs'); - break; - case 2: - Navigator.pushNamed(context, '/camera'); - break; - default: - Navigator.pushNamed(context, '/sitl'); - break; - } - } +/// Widget for navigating between different screens +/// +/// This widget displays the different sceeens in tabs along a bar at +/// the bottom of the screen. When clicked, each tab will navigate to +/// the corresponding screen. +class NavBar extends StatelessWidget { + /// @brief Constructs a NavBar widget. + const NavBar({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return BottomNavigationBar( - currentIndex: _index, - onTap: _onItemClicked, + onTap: (int index) { + switch (index) { + case 0: + Navigator.pushReplacementNamed(context, '/logs'); + break; + case 1: + Navigator.popAndPushNamed(context, '/logs'); + break; + case 2: + Navigator.popAndPushNamed(context, '/camera'); + break; + default: + Navigator.popAndPushNamed(context, '/sitl'); + break; + } + }, items: const [ BottomNavigationBarItem( - icon: Icon(Icons.home), + icon: Icon(Icons.home_sharp), label: 'Home', backgroundColor: Colors.black, ), BottomNavigationBarItem( icon: Icon(Icons.format_list_bulleted_sharp), label: 'Logs', - backgroundColor: Colors.black, ), BottomNavigationBarItem( icon: Icon(Icons.camera_sharp), label: 'Camera', - backgroundColor: Colors.black, ), BottomNavigationBarItem( icon: Icon(Icons.check_box_sharp), label: 'SITL', - backgroundColor: Colors.black, ) ], - showUnselectedLabels: true, ); } } + +class PlaceholderScreen extends StatelessWidget { + const PlaceholderScreen({Key? key, required this.title}) : super(key: key); + + final String title; + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(title), + ), + body: const Placeholder(), + bottomNavigationBar: const NavBar()); + } +} From f2a3fb43cb03d4a9b3751f83cb53e60f6d7a0718 Mon Sep 17 00:00:00 2001 From: wdan31 Date: Sat, 26 Oct 2024 16:11:17 -0400 Subject: [PATCH 4/8] Fixed nav bar widget destinations --- flutter_app/lib/widgets/nav_bar_widget.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flutter_app/lib/widgets/nav_bar_widget.dart b/flutter_app/lib/widgets/nav_bar_widget.dart index 47fb92e..349b4f8 100644 --- a/flutter_app/lib/widgets/nav_bar_widget.dart +++ b/flutter_app/lib/widgets/nav_bar_widget.dart @@ -15,7 +15,7 @@ class NavBar extends StatelessWidget { onTap: (int index) { switch (index) { case 0: - Navigator.pushReplacementNamed(context, '/logs'); + Navigator.pushReplacementNamed(context, '/'); break; case 1: Navigator.popAndPushNamed(context, '/logs'); From ccaa96ab8c15bd6d6158304e0023f08abfdf08cf Mon Sep 17 00:00:00 2001 From: wdan31 Date: Sat, 26 Oct 2024 16:13:42 -0400 Subject: [PATCH 5/8] Formatted dart --- flutter_app/lib/main.dart | 9 ++++++--- flutter_app/lib/widgets/nav_bar_widget.dart | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/flutter_app/lib/main.dart b/flutter_app/lib/main.dart index 593d55f..06ddaf0 100644 --- a/flutter_app/lib/main.dart +++ b/flutter_app/lib/main.dart @@ -18,9 +18,12 @@ class App extends StatelessWidget { ), routes: { '/': (BuildContext context) => HomePage(title: 'WARG IMACS'), - '/logs': (BuildContext context) => const PlaceholderScreen(title: 'Logs'), - '/camera': (BuildContext context) => const PlaceholderScreen(title: 'Camera'), - '/sitl': (BuildContext context) => const PlaceholderScreen(title: 'SITL'), + '/logs': (BuildContext context) => + const PlaceholderScreen(title: 'Logs'), + '/camera': (BuildContext context) => + const PlaceholderScreen(title: 'Camera'), + '/sitl': (BuildContext context) => + const PlaceholderScreen(title: 'SITL'), }, ); } diff --git a/flutter_app/lib/widgets/nav_bar_widget.dart b/flutter_app/lib/widgets/nav_bar_widget.dart index 349b4f8..8caacc0 100644 --- a/flutter_app/lib/widgets/nav_bar_widget.dart +++ b/flutter_app/lib/widgets/nav_bar_widget.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; /// Widget for navigating between different screens -/// +/// /// This widget displays the different sceeens in tabs along a bar at /// the bottom of the screen. When clicked, each tab will navigate to -/// the corresponding screen. +/// the corresponding screen. class NavBar extends StatelessWidget { /// @brief Constructs a NavBar widget. const NavBar({Key? key}) : super(key: key); From 1a032d33e0c2257f060e19c81461359e3dcfd5b5 Mon Sep 17 00:00:00 2001 From: wdan31 Date: Wed, 30 Oct 2024 14:25:58 -0400 Subject: [PATCH 6/8] Fixed navbar routing and added unit tests --- flutter_app/lib/widgets/nav_bar_widget.dart | 10 ++++--- .../test/widget/nav_bar_widget_test.dart | 29 +++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 flutter_app/test/widget/nav_bar_widget_test.dart diff --git a/flutter_app/lib/widgets/nav_bar_widget.dart b/flutter_app/lib/widgets/nav_bar_widget.dart index 8caacc0..193ad43 100644 --- a/flutter_app/lib/widgets/nav_bar_widget.dart +++ b/flutter_app/lib/widgets/nav_bar_widget.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; /// Widget for navigating between different screens @@ -18,13 +20,13 @@ class NavBar extends StatelessWidget { Navigator.pushReplacementNamed(context, '/'); break; case 1: - Navigator.popAndPushNamed(context, '/logs'); + Navigator.pushReplacementNamed(context, '/logs'); break; case 2: - Navigator.popAndPushNamed(context, '/camera'); + Navigator.pushReplacementNamed(context, '/camera'); break; default: - Navigator.popAndPushNamed(context, '/sitl'); + Navigator.pushReplacementNamed(context, '/sitl'); break; } }, @@ -39,7 +41,7 @@ class NavBar extends StatelessWidget { label: 'Logs', ), BottomNavigationBarItem( - icon: Icon(Icons.camera_sharp), + icon: Icon(Icons.camera), label: 'Camera', ), BottomNavigationBarItem( diff --git a/flutter_app/test/widget/nav_bar_widget_test.dart b/flutter_app/test/widget/nav_bar_widget_test.dart new file mode 100644 index 0000000..8516e90 --- /dev/null +++ b/flutter_app/test/widget/nav_bar_widget_test.dart @@ -0,0 +1,29 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:imacs/widgets/nav_bar_widget.dart'; + +void main() { + testWidgets('NavBar navigates to correct route on icon tap', (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + initialRoute: '/', + routes: { + '/': (context) => Scaffold(body: NavBar()), + '/logs': (context) => Scaffold(body: Text('Logs Page')), + '/camera': (context) => Scaffold(body: Text('Camera Page')), + '/sitl': (context) => Scaffold(body: Text('SITL Page')), + }, + ), + ); + + expect(find.byType(BottomNavigationBar), findsOneWidget); + + await tester.tap(find.byIcon(Icons.home_sharp)); + await tester.pumpAndSettle(); + expect(find.text('Home'), findsOneWidget); + + await tester.tap(find.byIcon(Icons.format_list_bulleted_sharp)); + await tester.pumpAndSettle(); + expect(find.text('Logs Page'), findsOneWidget); + }); +} From 89efae2c91c87516ff96d7f515fae6c7bc391d2f Mon Sep 17 00:00:00 2001 From: wdan31 Date: Wed, 30 Oct 2024 15:26:09 -0400 Subject: [PATCH 7/8] Fixed test cases --- flutter_app/lib/widgets/nav_bar_widget.dart | 20 +++++--- .../test/widget/nav_bar_widget_test.dart | 50 ++++++++++++------- 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/flutter_app/lib/widgets/nav_bar_widget.dart b/flutter_app/lib/widgets/nav_bar_widget.dart index 193ad43..e6f271e 100644 --- a/flutter_app/lib/widgets/nav_bar_widget.dart +++ b/flutter_app/lib/widgets/nav_bar_widget.dart @@ -1,5 +1,3 @@ -import 'dart:async'; - import 'package:flutter/material.dart'; /// Widget for navigating between different screens @@ -20,13 +18,13 @@ class NavBar extends StatelessWidget { Navigator.pushReplacementNamed(context, '/'); break; case 1: - Navigator.pushReplacementNamed(context, '/logs'); + Navigator.popAndPushNamed(context, '/logs'); break; case 2: - Navigator.pushReplacementNamed(context, '/camera'); + Navigator.popAndPushNamed(context, '/camera'); break; default: - Navigator.pushReplacementNamed(context, '/sitl'); + Navigator.popAndPushNamed(context, '/sitl'); break; } }, @@ -34,14 +32,13 @@ class NavBar extends StatelessWidget { BottomNavigationBarItem( icon: Icon(Icons.home_sharp), label: 'Home', - backgroundColor: Colors.black, ), BottomNavigationBarItem( icon: Icon(Icons.format_list_bulleted_sharp), label: 'Logs', ), BottomNavigationBarItem( - icon: Icon(Icons.camera), + icon: Icon(Icons.camera_sharp), label: 'Camera', ), BottomNavigationBarItem( @@ -49,11 +46,20 @@ class NavBar extends StatelessWidget { label: 'SITL', ) ], + unselectedItemColor: Colors.black, + selectedItemColor: Colors.black, + showUnselectedLabels: true, ); + } } +/// A placeholder screen with title text and the navigation bar +/// +/// This widget is a placeholder screen containing a title, +/// placeholder body, and the navigation bar. class PlaceholderScreen extends StatelessWidget { + /// @brief Constructs a PlaceholderScreen widget. const PlaceholderScreen({Key? key, required this.title}) : super(key: key); final String title; diff --git a/flutter_app/test/widget/nav_bar_widget_test.dart b/flutter_app/test/widget/nav_bar_widget_test.dart index 8516e90..ffeb841 100644 --- a/flutter_app/test/widget/nav_bar_widget_test.dart +++ b/flutter_app/test/widget/nav_bar_widget_test.dart @@ -3,27 +3,39 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:imacs/widgets/nav_bar_widget.dart'; void main() { - testWidgets('NavBar navigates to correct route on icon tap', (WidgetTester tester) async { - await tester.pumpWidget( - MaterialApp( - initialRoute: '/', - routes: { - '/': (context) => Scaffold(body: NavBar()), - '/logs': (context) => Scaffold(body: Text('Logs Page')), - '/camera': (context) => Scaffold(body: Text('Camera Page')), - '/sitl': (context) => Scaffold(body: Text('SITL Page')), - }, - ), - ); + group ( 'Navbar widget', + () { + testWidgets('NavBar navigates to correct route', (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + initialRoute: '/', + routes: { + '/': (context) => const Scaffold(body: Text('Home Page'), bottomNavigationBar: NavBar()), + '/logs': (context) => const Scaffold(body: Text('Logs Page'), bottomNavigationBar: NavBar()), + '/camera': (context) => const Scaffold(body: Text('Camera Page'), bottomNavigationBar: NavBar()), + '/sitl': (context) => const Scaffold(body: Text('SITL Page'), bottomNavigationBar: NavBar()), + }, + ), + ); - expect(find.byType(BottomNavigationBar), findsOneWidget); + expect(find.byType(BottomNavigationBar), findsOneWidget); - await tester.tap(find.byIcon(Icons.home_sharp)); - await tester.pumpAndSettle(); - expect(find.text('Home'), findsOneWidget); + // Test home icon tap + await tester.tap(find.text('Home')); + await tester.pumpAndSettle(); + expect(find.text('Home Page'), findsOneWidget); - await tester.tap(find.byIcon(Icons.format_list_bulleted_sharp)); - await tester.pumpAndSettle(); - expect(find.text('Logs Page'), findsOneWidget); + await tester.tap(find.text('Logs')); + await tester.pumpAndSettle(); + expect(find.text('Logs Page'), findsOneWidget); + + await tester.tap(find.text('Camera')); + await tester.pumpAndSettle(); + expect(find.text('Camera Page'), findsOneWidget); + + await tester.tap(find.text('SITL')); + await tester.pumpAndSettle(); + expect(find.text('SITL Page'), findsOneWidget); + }); }); } From 8ab451dcdd913c43f8bfebc6d06577f2081e192b Mon Sep 17 00:00:00 2001 From: wdan31 Date: Wed, 30 Oct 2024 15:27:05 -0400 Subject: [PATCH 8/8] Formatted dart --- flutter_app/lib/widgets/nav_bar_widget.dart | 3 +-- .../test/widget/nav_bar_widget_test.dart | 18 +++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/flutter_app/lib/widgets/nav_bar_widget.dart b/flutter_app/lib/widgets/nav_bar_widget.dart index e6f271e..6e42d93 100644 --- a/flutter_app/lib/widgets/nav_bar_widget.dart +++ b/flutter_app/lib/widgets/nav_bar_widget.dart @@ -50,12 +50,11 @@ class NavBar extends StatelessWidget { selectedItemColor: Colors.black, showUnselectedLabels: true, ); - } } /// A placeholder screen with title text and the navigation bar -/// +/// /// This widget is a placeholder screen containing a title, /// placeholder body, and the navigation bar. class PlaceholderScreen extends StatelessWidget { diff --git a/flutter_app/test/widget/nav_bar_widget_test.dart b/flutter_app/test/widget/nav_bar_widget_test.dart index ffeb841..8eff77a 100644 --- a/flutter_app/test/widget/nav_bar_widget_test.dart +++ b/flutter_app/test/widget/nav_bar_widget_test.dart @@ -3,17 +3,21 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:imacs/widgets/nav_bar_widget.dart'; void main() { - group ( 'Navbar widget', - () { - testWidgets('NavBar navigates to correct route', (WidgetTester tester) async { + group('Navbar widget', () { + testWidgets('NavBar navigates to correct route', + (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( initialRoute: '/', routes: { - '/': (context) => const Scaffold(body: Text('Home Page'), bottomNavigationBar: NavBar()), - '/logs': (context) => const Scaffold(body: Text('Logs Page'), bottomNavigationBar: NavBar()), - '/camera': (context) => const Scaffold(body: Text('Camera Page'), bottomNavigationBar: NavBar()), - '/sitl': (context) => const Scaffold(body: Text('SITL Page'), bottomNavigationBar: NavBar()), + '/': (context) => const Scaffold( + body: Text('Home Page'), bottomNavigationBar: NavBar()), + '/logs': (context) => const Scaffold( + body: Text('Logs Page'), bottomNavigationBar: NavBar()), + '/camera': (context) => const Scaffold( + body: Text('Camera Page'), bottomNavigationBar: NavBar()), + '/sitl': (context) => const Scaffold( + body: Text('SITL Page'), bottomNavigationBar: NavBar()), }, ), );