parent
7f32ef4bf1
commit
476dff1499
@ -0,0 +1,7 @@ |
||||
import 'package:flutter/widgets.dart'; |
||||
|
||||
enum RouteKey { products, cart } |
||||
|
||||
extension NavigatorHelper on NavigatorState { |
||||
pushRouteKey(RouteKey key) => pushNamed(key.name); |
||||
} |
@ -0,0 +1,12 @@ |
||||
import 'package:flutter/material.dart'; |
||||
|
||||
class CartScreen extends StatelessWidget { |
||||
const CartScreen({Key? key}) : super(key: key); |
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return Scaffold( |
||||
appBar: AppBar(title: const Text('Warenkorb')), |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,15 @@ |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:thesis_shop/route_key.dart'; |
||||
|
||||
class CartButton extends StatelessWidget { |
||||
const CartButton({Key? key}) : super(key: key); |
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return ElevatedButton.icon( |
||||
onPressed: () => Navigator.of(context).pushRouteKey(RouteKey.cart), |
||||
icon: const Icon(Icons.shopping_basket), |
||||
label: const Text('Warenkorb (2 Produkte)'), |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,23 @@ |
||||
import 'package:flutter/material.dart'; |
||||
|
||||
import 'cart_button.dart'; |
||||
|
||||
class CartButtonOverlay extends StatelessWidget { |
||||
final Widget child; |
||||
const CartButtonOverlay({Key? key, required this.child}) : super(key: key); |
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return Stack( |
||||
children: [ |
||||
Positioned.fill(child: child), |
||||
const Positioned( |
||||
left: 8, |
||||
bottom: 8, |
||||
right: 8, |
||||
child: SafeArea(child: CartButton()), |
||||
) |
||||
], |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,18 @@ |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:thesis_shop/models/product.dart'; |
||||
|
||||
import 'product_item.dart'; |
||||
|
||||
class ProductList extends StatelessWidget { |
||||
final List<Product> products; |
||||
const ProductList({Key? key, required this.products}) : super(key: key); |
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return ListView.separated( |
||||
itemCount: products.length, |
||||
itemBuilder: (context, index) => ProductItem(product: products[index]), |
||||
separatorBuilder: (context, _) => const Divider(), |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,6 @@ |
||||
typedef MapFunction<T, K> = T Function(K key); |
||||
|
||||
extension MapKeysExtension<K, V> on Map<K, V> { |
||||
Map<T, V> mapKeys<T>(MapFunction<T, K> keyMapper) => |
||||
map((key, value) => MapEntry(keyMapper(key), value)); |
||||
} |
Loading…
Reference in new issue