1
0
Fork 0

Add cart screen

main
Jonas Franz 3 years ago
parent 0b69d37074
commit f23481e4bd
  1. 27
      lib/screens/cart/cart_item_list.dart
  2. 10
      lib/screens/cart/cart_screen.dart
  3. 18
      lib/screens/cart/total_price_text.dart
  4. 2
      lib/screens/product_list/cart_button.dart

@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
class CartItemList extends StatelessWidget {
const CartItemList({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return DefaultTextStyle.merge(
style: const TextStyle(fontSize: 16, height: 2.5),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Table(
columnWidths: const {
0: FlexColumnWidth(),
1: FixedColumnWidth(128),
2: IntrinsicColumnWidth(),
},
children: const [
TableRow(children: [Text('Äpfel'), Text('3x3€'), Text('9€')]),
TableRow(children: [Text('Äpfel'), Text('3x3€'), Text('9€')]),
TableRow(children: [Text('Äpfel'), Text('3x3€'), Text('9€')])
],
),
),
);
}
}

@ -1,6 +1,9 @@
import 'package:flutter/material.dart';
import 'package:thesis_shop/screens/cart/total_price_text.dart';
import 'package:thesis_shop/widgets/user_switch.dart';
import 'cart_item_list.dart';
class CartScreen extends StatelessWidget {
const CartScreen({Key? key}) : super(key: key);
@ -11,6 +14,13 @@ class CartScreen extends StatelessWidget {
title: const Text('Warenkorb'),
actions: [UserSwitch(isOn: true, onChanged: (_) {})],
),
body: Column(
mainAxisSize: MainAxisSize.max,
children: const [
Expanded(child: CartItemList()),
TotalPriceText(),
],
),
);
}
}

@ -0,0 +1,18 @@
import 'package:flutter/material.dart';
class TotalPriceText extends StatelessWidget {
const TotalPriceText({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return SafeArea(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Gesamtpreis: 27€',
style: Theme.of(context).textTheme.labelLarge?.copyWith(fontSize: 24),
),
),
);
}
}

@ -9,7 +9,7 @@ class CartButton extends StatelessWidget {
return ElevatedButton.icon(
onPressed: () => Navigator.of(context).pushRouteKey(RouteKey.cart),
icon: const Icon(Icons.shopping_basket),
label: const Text('Warenkorb (2 Produkte)'),
label: const Text('Warenkorb (3 Produkte)'),
);
}
}

Loading…
Cancel
Save