diff --git a/lib/Component/bottom_navigation_bar.dart b/lib/Component/bottom_navigation_bar.dart index 21a1b96c315f7b4de003b051298f4024656948da..3e6554269ea28e6aa8edad4c409864b2795e4f1d 100644 --- a/lib/Component/bottom_navigation_bar.dart +++ b/lib/Component/bottom_navigation_bar.dart @@ -6,6 +6,8 @@ import 'package:home_industry/Pages/Home/home_page.dart'; import 'package:home_industry/Pages/Profile/profile.dart'; import 'package:home_industry/Pages/Transactions/my_orders.dart'; +import 'modal_bottom_admin_info.dart'; + class BottomNavigation extends StatefulWidget { const BottomNavigation({Key key}) : super(key: key); @@ -47,7 +49,25 @@ class _BottomNavigationState extends State<BottomNavigation> { }) ]; } - return const <Widget>[CartIcon()]; + return <Widget>[ + CartIcon(), + if (_selectedIndex == 0) + IconButton( + icon: Icon(Icons.info_outline), + onPressed: () { + showModalInfoAdmin(context); + }) + ]; + } + + void showModalInfoAdmin(BuildContext context) { + showModalBottomSheet( + context: context, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(25))), + builder: (BuildContext context) { + return const AdminInfo(); + }); } Widget _dynamicAppBar(BuildContext context) { @@ -70,11 +90,9 @@ class _BottomNavigationState extends State<BottomNavigation> { return Scaffold( resizeToAvoidBottomInset: false, appBar: _dynamicAppBar(context), - body: Center( - child: AnimatedSwitcher( - duration: const Duration(milliseconds: 220), - child: _widgetOptions.elementAt(_selectedIndex)), - ), + body: AnimatedSwitcher( + duration: const Duration(milliseconds: 220), + child: _widgetOptions.elementAt(_selectedIndex)), bottomNavigationBar: BottomNavigationBar( items: const <BottomNavigationBarItem>[ BottomNavigationBarItem( diff --git a/test/bottom_navigation_bar_test.dart b/test/bottom_navigation_bar_test.dart index 0c2fc4cff2f654b771fc62fe7fad2f7f974397d8..6c45d589a2380e1ec6dc6838ee2dc7b8018c28de 100644 --- a/test/bottom_navigation_bar_test.dart +++ b/test/bottom_navigation_bar_test.dart @@ -6,6 +6,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:home_industry/Component/bottom_navigation_bar.dart'; import 'package:home_industry/Component/custom_circular.dart'; +import 'package:home_industry/Component/modal_bottom_admin_info.dart'; import 'package:home_industry/Component/router.dart'; import 'package:home_industry/Pages/Cart/bloc/bloc.dart'; import 'package:home_industry/Pages/Profile/bloc/bloc.dart'; @@ -102,6 +103,24 @@ void main() { expect(find.text('Keranjang', skipOffstage: false), findsOneWidget); }); + testWidgets('Test initial to home info admin tap', + (WidgetTester tester) async { + when(dio.get('/configs/help-contact/')).thenAnswer((_) async => + Response<Map<String, dynamic>>( + statusCode: 200, data: {'email': 'pilarjakarta@gmail.com'})); + when(bloc.state).thenAnswer((_) => ProfileLoaded(profile: profile)); + when(cartBloc.state).thenAnswer((_) => CartLoaded([], '10000', 1)); + await tester.pumpWidget(testWidget); + expect(find.text('SELAMAT DATANG'), findsOneWidget); + expect(find.text(test), findsOneWidget); + expect(find.byType(FlatButton), findsNWidgets(2)); + await tester.tap(find.byIcon(Icons.info_outline).first); + await tester.pump(Duration(seconds: 3)); + expect(find.byType(AdminInfo), findsOneWidget); + await tester.pump(Duration(seconds: 1)); + expect(find.text('pilarjakarta@gmail.com'), findsOneWidget); + }); + testWidgets('Test initial to home loading', (WidgetTester tester) async { when(bloc.state).thenAnswer((_) => const ProfileLoading()); await tester.pumpWidget(testWidget);