mirror of
https://github.com/Mercantec-GHC/h4-projekt-gruppe-0-sm.git
synced 2025-04-28 00:34:06 +02:00
home page
This commit is contained in:
parent
55b87419be
commit
11c6e9cad3
@ -65,14 +65,16 @@ class AllProductsPage extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(children: [
|
child: Column(children: [
|
||||||
const Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
BackButton(),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: Container(
|
||||||
decoration: InputDecoration(
|
margin: const EdgeInsets.only(left: 10, right: 10),
|
||||||
label: Text("Search"),
|
child: const TextField(
|
||||||
contentPadding: EdgeInsets.only(top: 20))),
|
decoration: InputDecoration(
|
||||||
|
label: Text("Search"),
|
||||||
|
contentPadding: EdgeInsets.only(top: 20))),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -135,76 +135,80 @@ class CartPage extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return SafeArea(
|
||||||
children: [
|
child: Column(
|
||||||
Expanded(
|
children: [
|
||||||
child: Consumer<CartRepo>(
|
Expanded(
|
||||||
builder: (_, cartRepo, __) {
|
child: Consumer<CartRepo>(
|
||||||
final cart = cartRepo.allCartItems();
|
builder: (_, cartRepo, __) {
|
||||||
return ListView.builder(
|
final cart = cartRepo.allCartItems();
|
||||||
shrinkWrap: true,
|
return ListView.builder(
|
||||||
itemBuilder: (_, idx) => CartItemView(
|
shrinkWrap: true,
|
||||||
cartRepo: cartRepo,
|
itemBuilder: (_, idx) => CartItemView(
|
||||||
productId: cart[idx].product.id,
|
cartRepo: cartRepo,
|
||||||
name: cart[idx].product.name,
|
productId: cart[idx].product.id,
|
||||||
price: cart[idx].product.price,
|
name: cart[idx].product.name,
|
||||||
imagePath: "assets/boykisser.png",
|
price: cart[idx].product.price,
|
||||||
amount: cart[idx].amount),
|
imagePath: "assets/boykisser.png",
|
||||||
itemCount: cart.length,
|
amount: cart[idx].amount),
|
||||||
);
|
itemCount: cart.length,
|
||||||
},
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
Container(
|
||||||
Container(
|
decoration:
|
||||||
decoration: const BoxDecoration(color: Color(0xFFFFFFFF), boxShadow: [
|
const BoxDecoration(color: Color(0xFFFFFFFF), boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
blurRadius: 10,
|
blurRadius: 10,
|
||||||
spreadRadius: -4,
|
spreadRadius: -4,
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: const EdgeInsets.only(right: 10),
|
margin: const EdgeInsets.only(right: 10),
|
||||||
child: PrimaryButton(
|
child: PrimaryButton(
|
||||||
onPressed: () {}, child: const Text("Indtast vare")),
|
onPressed: () {},
|
||||||
|
child: const Text("Indtast vare")),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
Expanded(
|
||||||
Expanded(
|
child: Container(
|
||||||
child: Container(
|
margin: const EdgeInsets.only(left: 10),
|
||||||
margin: const EdgeInsets.only(left: 10),
|
child: PrimaryButton(
|
||||||
child: PrimaryButton(
|
onPressed: () {}, child: const Text("Skan vare")),
|
||||||
onPressed: () {}, child: const Text("Skan vare")),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
Row(
|
||||||
Row(
|
children: [
|
||||||
children: [
|
Expanded(
|
||||||
Expanded(
|
child: Container(
|
||||||
child: Container(
|
margin: const EdgeInsets.only(top: 10),
|
||||||
margin: const EdgeInsets.only(top: 10),
|
child: PrimaryButton(
|
||||||
child: PrimaryButton(
|
onPressed: () {
|
||||||
onPressed: () {
|
Navigator.push(
|
||||||
Navigator.push(
|
context,
|
||||||
context,
|
MaterialPageRoute(
|
||||||
MaterialPageRoute(
|
builder: (context) =>
|
||||||
builder: (context) =>
|
const FinishShoppingPage()));
|
||||||
const FinishShoppingPage()));
|
},
|
||||||
},
|
child: const Text("Afslut indkøb")),
|
||||||
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/pages/home_page.dart';
|
||||||
import 'package:mobile/repos/bottom_navigation_bar.dart';
|
import 'package:mobile/repos/bottom_navigation_bar.dart';
|
||||||
import 'package:mobile/repos/cart.dart';
|
import 'package:mobile/repos/cart.dart';
|
||||||
|
import 'package:mobile/repos/user.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class Dashboard extends StatelessWidget {
|
class Dashboard extends StatelessWidget {
|
||||||
final List<StatelessWidget> pages = [
|
final User user;
|
||||||
const HomePage(),
|
|
||||||
const AllProductsPage(),
|
|
||||||
const CartPage(),
|
|
||||||
const AllReceiptsPage(),
|
|
||||||
];
|
|
||||||
|
|
||||||
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -1,10 +1,72 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mobile/repos/user.dart';
|
||||||
|
|
||||||
class HomePage extends StatelessWidget {
|
class HomePage extends StatelessWidget {
|
||||||
const HomePage({super.key});
|
final User user;
|
||||||
|
const HomePage({super.key, required this.user});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
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 =
|
final loginResult =
|
||||||
usersRepo.login(mailController.text, passwordController.text);
|
usersRepo.login(mailController.text, passwordController.text);
|
||||||
if (loginResult is Ok) {
|
if (loginResult is Ok) {
|
||||||
Navigator.of(context)
|
Navigator.of(context).push(MaterialPageRoute(
|
||||||
.push(MaterialPageRoute(builder: (context) => Dashboard()));
|
builder: (context) =>
|
||||||
|
Dashboard(user: (loginResult as Ok).value)));
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
loginError = true;
|
loginError = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user