diff --git a/mobile/lib/pages/all_products_page.dart b/mobile/lib/pages/all_products_page.dart index 06041be..5022533 100644 --- a/mobile/lib/pages/all_products_page.dart +++ b/mobile/lib/pages/all_products_page.dart @@ -65,14 +65,16 @@ class AllProductsPage extends StatelessWidget { children: [ Expanded( child: Column(children: [ - const Row( + Row( children: [ - BackButton(), Expanded( - child: TextField( - decoration: InputDecoration( - label: Text("Search"), - contentPadding: EdgeInsets.only(top: 20))), + child: Container( + margin: const EdgeInsets.only(left: 10, right: 10), + child: const TextField( + decoration: InputDecoration( + label: Text("Search"), + contentPadding: EdgeInsets.only(top: 20))), + ), ), ], ), diff --git a/mobile/lib/pages/cart_page.dart b/mobile/lib/pages/cart_page.dart index 96818a6..0e1647d 100644 --- a/mobile/lib/pages/cart_page.dart +++ b/mobile/lib/pages/cart_page.dart @@ -135,76 +135,80 @@ class CartPage extends StatelessWidget { @override Widget build(BuildContext context) { - return Column( - children: [ - Expanded( - child: Consumer( - builder: (_, cartRepo, __) { - final cart = cartRepo.allCartItems(); - return ListView.builder( - shrinkWrap: true, - itemBuilder: (_, idx) => CartItemView( - cartRepo: cartRepo, - productId: cart[idx].product.id, - name: cart[idx].product.name, - price: cart[idx].product.price, - imagePath: "assets/boykisser.png", - amount: cart[idx].amount), - itemCount: cart.length, - ); - }, + return SafeArea( + child: Column( + children: [ + Expanded( + child: Consumer( + builder: (_, cartRepo, __) { + final cart = cartRepo.allCartItems(); + return ListView.builder( + shrinkWrap: true, + itemBuilder: (_, idx) => CartItemView( + cartRepo: cartRepo, + productId: cart[idx].product.id, + name: cart[idx].product.name, + price: cart[idx].product.price, + imagePath: "assets/boykisser.png", + amount: cart[idx].amount), + itemCount: cart.length, + ); + }, + ), ), - ), - Container( - decoration: const BoxDecoration(color: Color(0xFFFFFFFF), boxShadow: [ - BoxShadow( - blurRadius: 10, - spreadRadius: -4, - ) - ]), - padding: const EdgeInsets.all(10), - child: Column( - children: [ - Row( - children: [ - Expanded( - child: Container( - margin: const EdgeInsets.only(right: 10), - child: PrimaryButton( - onPressed: () {}, child: const Text("Indtast vare")), + Container( + decoration: + const BoxDecoration(color: Color(0xFFFFFFFF), boxShadow: [ + BoxShadow( + blurRadius: 10, + spreadRadius: -4, + ) + ]), + padding: const EdgeInsets.all(10), + child: Column( + children: [ + Row( + children: [ + Expanded( + child: Container( + margin: const EdgeInsets.only(right: 10), + child: PrimaryButton( + onPressed: () {}, + child: const Text("Indtast vare")), + ), ), - ), - Expanded( - child: Container( - margin: const EdgeInsets.only(left: 10), - child: PrimaryButton( - onPressed: () {}, child: const Text("Skan vare")), + Expanded( + child: Container( + margin: const EdgeInsets.only(left: 10), + child: PrimaryButton( + onPressed: () {}, child: const Text("Skan vare")), + ), ), - ), - ], - ), - Row( - children: [ - Expanded( - child: Container( - margin: const EdgeInsets.only(top: 10), - child: PrimaryButton( - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - const FinishShoppingPage())); - }, - child: const Text("Afslut indkøb")), + ], + ), + Row( + children: [ + Expanded( + child: Container( + margin: const EdgeInsets.only(top: 10), + child: PrimaryButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + const FinishShoppingPage())); + }, + child: const Text("Afslut indkøb")), + ), ), - ), - ], - ), - ], + ], + ), + ], + ), ), - ), - ], + ], + ), ); } } diff --git a/mobile/lib/pages/dashboard.dart b/mobile/lib/pages/dashboard.dart index d92cccd..7f0e5b6 100644 --- a/mobile/lib/pages/dashboard.dart +++ b/mobile/lib/pages/dashboard.dart @@ -5,17 +5,24 @@ import 'package:mobile/pages/all_receipts_page.dart'; import 'package:mobile/pages/home_page.dart'; import 'package:mobile/repos/bottom_navigation_bar.dart'; import 'package:mobile/repos/cart.dart'; +import 'package:mobile/repos/user.dart'; import 'package:provider/provider.dart'; class Dashboard extends StatelessWidget { - final List pages = [ - const HomePage(), - const AllProductsPage(), - const CartPage(), - const AllReceiptsPage(), - ]; + final User user; - Dashboard({super.key}); + final List pages = []; + + Dashboard({super.key, required this.user}) { + pages.addAll([ + HomePage( + user: user, + ), + const AllProductsPage(), + const CartPage(), + const AllReceiptsPage(), + ]); + } @override Widget build(BuildContext context) { diff --git a/mobile/lib/pages/home_page.dart b/mobile/lib/pages/home_page.dart index 519735d..3672d58 100644 --- a/mobile/lib/pages/home_page.dart +++ b/mobile/lib/pages/home_page.dart @@ -1,10 +1,72 @@ import 'package:flutter/material.dart'; +import 'package:mobile/repos/user.dart'; class HomePage extends StatelessWidget { - const HomePage({super.key}); + final User user; + const HomePage({super.key, required this.user}); @override Widget build(BuildContext context) { - return const Column(); + return SafeArea( + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Container( + margin: const EdgeInsets.only(right: 10), + child: const SettingsMenu()), + ], + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text("Velkommen ${user.name}"), + ], + ), + ), + ], + ), + ); + } +} + +class SettingsMenu extends StatefulWidget { + const SettingsMenu({super.key}); + + @override + State createState() => SettingsMenuState(); +} + +class SettingsMenuState extends State { + final FocusNode buttonFocusNode = FocusNode(debugLabel: 'Menu Button'); + + @override + Widget build(BuildContext context) { + return MenuAnchor( + childFocusNode: buttonFocusNode, + menuChildren: [ + MenuItemButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: const Text('Log ud'), + ), + ], + builder: (_, MenuController controller, Widget? child) { + return IconButton( + focusNode: buttonFocusNode, + onPressed: () { + if (controller.isOpen) { + controller.close(); + } else { + controller.open(); + } + }, + icon: const Icon(Icons.settings), + ); + }, + ); } } diff --git a/mobile/lib/pages/log_in_page.dart b/mobile/lib/pages/log_in_page.dart index 20f879e..39aadc5 100644 --- a/mobile/lib/pages/log_in_page.dart +++ b/mobile/lib/pages/log_in_page.dart @@ -64,8 +64,9 @@ class LogInFormState extends State { final loginResult = usersRepo.login(mailController.text, passwordController.text); if (loginResult is Ok) { - Navigator.of(context) - .push(MaterialPageRoute(builder: (context) => Dashboard())); + Navigator.of(context).push(MaterialPageRoute( + builder: (context) => + Dashboard(user: (loginResult as Ok).value))); } else { setState(() { loginError = true;