mirror of
https://github.com/Mercantec-GHC/h4-projekt-gruppe-0-sm.git
synced 2025-04-27 16:24:07 +02:00
home page
This commit is contained in:
parent
55b87419be
commit
11c6e9cad3
@ -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))),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -135,76 +135,80 @@ class CartPage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Consumer<CartRepo>(
|
||||
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<CartRepo>(
|
||||
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")),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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<StatelessWidget> pages = [
|
||||
const HomePage(),
|
||||
const AllProductsPage(),
|
||||
const CartPage(),
|
||||
const AllReceiptsPage(),
|
||||
];
|
||||
final User user;
|
||||
|
||||
Dashboard({super.key});
|
||||
final List<StatelessWidget> pages = [];
|
||||
|
||||
Dashboard({super.key, required this.user}) {
|
||||
pages.addAll([
|
||||
HomePage(
|
||||
user: user,
|
||||
),
|
||||
const AllProductsPage(),
|
||||
const CartPage(),
|
||||
const AllReceiptsPage(),
|
||||
]);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -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<StatefulWidget> createState() => SettingsMenuState();
|
||||
}
|
||||
|
||||
class SettingsMenuState extends State<SettingsMenu> {
|
||||
final FocusNode buttonFocusNode = FocusNode(debugLabel: 'Menu Button');
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MenuAnchor(
|
||||
childFocusNode: buttonFocusNode,
|
||||
menuChildren: <Widget>[
|
||||
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),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -64,8 +64,9 @@ class LogInFormState extends State<LogInForm> {
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user