1
0
Fork 0

Add user switch

main
Jonas Franz 2 years ago
parent 476dff1499
commit 0b69d37074
  1. 6
      lib/screens/cart/cart_screen.dart
  2. 6
      lib/screens/product_list/product_list_screen.dart
  3. 26
      lib/widgets/user_switch.dart

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:thesis_shop/widgets/user_switch.dart';
class CartScreen extends StatelessWidget {
const CartScreen({Key? key}) : super(key: key);
@ -6,7 +7,10 @@ class CartScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Warenkorb')),
appBar: AppBar(
title: const Text('Warenkorb'),
actions: [UserSwitch(isOn: true, onChanged: (_) {})],
),
);
}
}

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:thesis_shop/models/product.dart';
import 'package:thesis_shop/widgets/user_switch.dart';
import 'cart_button_overlay.dart';
import 'product_list.dart';
@ -18,7 +19,10 @@ class ProductListScreen extends StatelessWidget {
Widget build(BuildContext context) {
const products = _productPlaceholder;
return Scaffold(
appBar: AppBar(title: const Text('Thesis Shop')),
appBar: AppBar(
title: const Text('Thesis Shop'),
actions: [UserSwitch(isOn: true, onChanged: (_) {})],
),
body: const CartButtonOverlay(
child: ProductList(products: _productPlaceholder),
),

@ -0,0 +1,26 @@
import 'package:flutter/material.dart';
class UserSwitch extends StatelessWidget {
final bool isOn;
final ValueChanged<bool> onChanged;
const UserSwitch({
Key? key,
required this.isOn,
required this.onChanged,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.account_circle),
Switch(
value: isOn,
onChanged: onChanged,
activeColor: Colors.green,
)
],
);
}
}
Loading…
Cancel
Save