Browse Source

初步完成

Rice 2 years ago
parent
commit
4a66194ae7
46 changed files with 1460 additions and 150 deletions
  1. 13 0
      .vscode/launch.json
  2. 9 0
      assets/icons/add_to_cart.svg
  3. 7 0
      assets/icons/back.svg
  4. 3 0
      assets/icons/bag_1.svg
  5. 5 0
      assets/icons/cart.svg
  6. 5 0
      assets/icons/heart.svg
  7. 3 0
      assets/icons/search.svg
  8. BIN
      assets/images/bag_1.png
  9. BIN
      assets/images/bag_1_1.png
  10. BIN
      assets/images/bag_2.png
  11. BIN
      assets/images/bag_2_1.png
  12. BIN
      assets/images/bag_3.png
  13. BIN
      assets/images/bag_3_1.png
  14. BIN
      assets/images/bag_4.png
  15. BIN
      assets/images/bag_4_1.png
  16. BIN
      assets/images/bag_5.png
  17. BIN
      assets/images/bag_6.png
  18. BIN
      assets/images/qc_code.png
  19. 0 27
      lib/Staff.dart
  20. 6 0
      lib/constants.dart
  21. 17 7
      lib/main.dart
  22. 134 0
      lib/models/product.dart
  23. 9 2
      lib/models/table.dart
  24. 81 0
      lib/models/tableDetail.dart
  25. 0 86
      lib/order/order.dart
  26. 52 0
      lib/screen/Staff.dart
  27. 2 2
      lib/screen/Welcome.dart
  28. 146 0
      lib/screen/cart.dart
  29. 97 0
      lib/screen/check_out.dart
  30. 71 0
      lib/screen/details/components/add_to_cart.dart
  31. 66 0
      lib/screen/details/components/body.dart
  32. 82 0
      lib/screen/details/components/cart_counter.dart
  33. 91 0
      lib/screen/details/components/color_and_size.dart
  34. 38 0
      lib/screen/details/components/counter_with_fav_btn.dart
  35. 23 0
      lib/screen/details/components/description.dart
  36. 63 0
      lib/screen/details/components/product_title_with_image copy.dart
  37. 62 0
      lib/screen/details/components/product_title_with_image.dart
  38. 49 0
      lib/screen/details/detail_screen.dart
  39. 2 4
      lib/screen/login.dart
  40. 53 0
      lib/screen/order/components/body.dart
  41. 58 0
      lib/screen/order/components/categories.dart
  42. 54 0
      lib/screen/order/components/item-card.dart
  43. 111 0
      lib/screen/order/order_home_screen.dart
  44. 10 6
      lib/screen/table.dart
  45. 34 13
      pubspec.lock
  46. 4 3
      pubspec.yaml

+ 13 - 0
.vscode/launch.json

@@ -0,0 +1,13 @@
+{
+    // 使用 IntelliSense 了解相关属性。 
+    // 悬停以查看现有属性的描述。
+    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
+    "version": "0.2.0",
+    "configurations": [
+        {
+            "name": "Flutter",
+            "request": "launch",
+            "type": "dart"
+        }
+    ]
+}

+ 9 - 0
assets/icons/add_to_cart.svg

@@ -0,0 +1,9 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="26.342" height="25.415" viewBox="0 0 26.342 25.415">
+  <g id="add_to_cart" data-name="add to cart" transform="translate(0.063 -3.8)">
+    <path id="Path_10" data-name="Path 10" d="M98.936,335.2a3.137,3.137,0,1,0,3.136,3.137A3.136,3.136,0,0,0,98.936,335.2Zm0,5.118a1.981,1.981,0,1,1,1.981-1.981A1.981,1.981,0,0,1,98.936,340.318Z" transform="translate(-90.326 -312.258)" fill="#4f97c4"/>
+    <path id="Path_11" data-name="Path 11" d="M26.17,19.366a.586.586,0,0,0-.462-.231H20.746a4.59,4.59,0,0,1-.248,1.149h4.436l-2.49,8.243a1.723,1.723,0,0,1-1.658,1.23H8.68a1.729,1.729,0,0,1-1.7-1.432l-1.421-8.04H8.322a.7.7,0,0,1-.029-.1l-.139-1.045H5.347l-.416-2.322a3.459,3.459,0,0,0-2.807-2.8L.616,13.746a.578.578,0,1,0-.2,1.138l1.513.266a2.3,2.3,0,0,1,1.866,1.866L5.832,28.533a2.87,2.87,0,0,0,2.836,2.38H20.781a2.875,2.875,0,0,0,2.761-2.045l2.709-8.982A.593.593,0,0,0,26.17,19.366Z" transform="translate(0 -9.363)" fill="#4f97c4"/>
+    <path id="Path_12" data-name="Path 12" d="M308.637,335.2a3.137,3.137,0,1,0,3.136,3.137A3.136,3.136,0,0,0,308.637,335.2Zm0,5.118a1.981,1.981,0,1,1,1.981-1.981A1.981,1.981,0,0,1,308.637,340.318Z" transform="translate(-287.913 -312.258)" fill="#4f97c4"/>
+    <path id="Path_13" data-name="Path 13" d="M195.93,43.716h1.155v-2.83h2.83V39.73h-2.83V36.9H195.93v2.83H193.1v1.155h2.83Z" transform="translate(-182.006 -31.188)" fill="#4f97c4"/>
+    <path id="Path_14" data-name="Path 14" d="M165.32,14.44A5.32,5.32,0,1,0,160,9.12,5.325,5.325,0,0,0,165.32,14.44Zm0-9.49a4.168,4.168,0,1,1-4.165,4.17A4.17,4.17,0,0,1,165.32,4.949Z" transform="translate(-150.818 0)" fill="#4f97c4"/>
+  </g>
+</svg>

+ 7 - 0
assets/icons/back.svg

@@ -0,0 +1,7 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="25" height="16.667" viewBox="0 0 25 16.667">
+  <g id="back_1_" data-name="back (1)" transform="translate(-0.001 -85.333)">
+    <g id="Group_3" data-name="Group 3" transform="translate(0.001 85.333)">
+      <path id="Path_5" data-name="Path 5" d="M24.48,93.145H1.779L8.7,86.222a.521.521,0,0,0-.736-.736L.153,93.3a.521.521,0,0,0,0,.736l7.812,7.812a.521.521,0,1,0,.737-.736L1.779,94.187h22.7a.521.521,0,1,0,0-1.042Z" transform="translate(-0.001 -85.333)" fill="#535353"/>
+    </g>
+  </g>
+</svg>

File diff suppressed because it is too large
+ 3 - 0
assets/icons/bag_1.svg


+ 5 - 0
assets/icons/cart.svg

@@ -0,0 +1,5 @@
+<svg id="cart" xmlns="http://www.w3.org/2000/svg" width="25.615" height="24.156" viewBox="0 0 25.615 24.156">
+  <path id="Path_2" data-name="Path 2" d="M99,322.332a3.051,3.051,0,1,0,3.051,3.051A3.051,3.051,0,0,0,99,322.332Zm0,4.98a1.929,1.929,0,1,1,1.929-1.929A1.929,1.929,0,0,1,99,327.312Zm0,0" transform="translate(-90.572 -304.277)" fill="#fff"/>
+  <path id="Path_3" data-name="Path 3" d="M25.055,5.631H5.254l-.4-2.26A3.37,3.37,0,0,0,2.119.645L.655.387a.561.561,0,1,0-.2,1.1l1.469.258A2.243,2.243,0,0,1,3.745,3.567l1.985,11.2a2.8,2.8,0,0,0,2.759,2.316H20.266a2.8,2.8,0,0,0,2.686-1.991l2.636-8.737a.586.586,0,0,0-.084-.5.568.568,0,0,0-.449-.224ZM21.881,14.76a1.671,1.671,0,0,1-1.609,1.195H8.5a1.674,1.674,0,0,1-1.654-1.391L5.456,6.747H24.3Zm0,0" transform="translate(0.004 -0.379)" fill="#fff"/>
+  <path id="Path_4" data-name="Path 4" d="M309,322.332a3.051,3.051,0,1,0,3.051,3.051A3.051,3.051,0,0,0,309,322.332Zm0,4.98a1.929,1.929,0,1,1,1.929-1.929A1.929,1.929,0,0,1,309,327.312Zm0,0" transform="translate(-288.795 -304.277)" fill="#fff"/>
+</svg>

+ 5 - 0
assets/icons/heart.svg

@@ -0,0 +1,5 @@
+<svg id="heart" xmlns="http://www.w3.org/2000/svg" width="15.3" height="13.507" viewBox="0 0 15.3 13.507">
+  <g id="Group_6" data-name="Group 6">
+    <path id="Path_9" data-name="Path 9" d="M11.236,30a3.622,3.622,0,0,0-2.262.782A5.153,5.153,0,0,0,7.65,32.374a5.153,5.153,0,0,0-1.324-1.592A3.622,3.622,0,0,0,4.064,30,4.153,4.153,0,0,0,0,34.408c0,2.715,2.18,4.572,5.48,7.385.56.478,1.2,1.019,1.856,1.6a.478.478,0,0,0,.629,0c.66-.577,1.3-1.119,1.856-1.6,3.3-2.812,5.479-4.669,5.479-7.384A4.153,4.153,0,0,0,11.236,30Z" transform="translate(0 -30)" fill="#fff"/>
+  </g>
+</svg>

+ 3 - 0
assets/icons/search.svg

@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="22.191" height="22.191" viewBox="0 0 22.191 22.191">
+  <path id="search_2_" data-name="search (2)" d="M22.191,21.211,14.67,13.69a8.341,8.341,0,1,0-.981.981l7.521,7.521ZM8.322,15.257a6.935,6.935,0,1,1,6.935-6.935A6.943,6.943,0,0,1,8.322,15.257Z" fill="#fff"/>
+</svg>

BIN
assets/images/bag_1.png


BIN
assets/images/bag_1_1.png


BIN
assets/images/bag_2.png


BIN
assets/images/bag_2_1.png


BIN
assets/images/bag_3.png


BIN
assets/images/bag_3_1.png


BIN
assets/images/bag_4.png


BIN
assets/images/bag_4_1.png


BIN
assets/images/bag_5.png


BIN
assets/images/bag_6.png


BIN
assets/images/qc_code.png


+ 0 - 27
lib/Staff.dart

@@ -1,27 +0,0 @@
-import 'package:flutter/material.dart';
-
-///STAFF START
-class StaffInfoPage extends StatefulWidget {
-  static const routeName = '/staff';
-
-  @override
-  State<StatefulWidget> createState() => _StaffInfoState();
-}
-
-class _StaffInfoState extends State<StaffInfoPage> {
-  @override
-  Widget build(BuildContext context) {
-    return Scaffold(
-      appBar: AppBar(
-        title: Text("员工信息"),
-      ),
-      body: Container(
-        child: Center(
-          child: Text("STAFF INFORMATION"),
-        ),
-      ),
-    );
-  }
-}
-
-/// STAFF END

+ 6 - 0
lib/constants.dart

@@ -0,0 +1,6 @@
+import 'package:flutter/material.dart';
+
+const kTextColor = Color(0xFF535353);
+const kTextLightColor = Color(0xFFACACAC);
+
+const kDefaultPaddin = 20.0;

+ 17 - 7
lib/main.dart

@@ -1,13 +1,15 @@
 import 'package:flutter/material.dart';
-import 'package:fooddeliveryapp/login.dart';
-import 'package:fooddeliveryapp/table.dart';
+import 'package:fooddeliveryapp/screen/cart.dart';
+import 'package:fooddeliveryapp/screen/check_out.dart';
+import 'package:fooddeliveryapp/screen/login.dart';
+import 'package:fooddeliveryapp/models/tableDetail.dart';
+import 'package:fooddeliveryapp/screen/table.dart';
 import 'package:provider/provider.dart';
 
-import 'Staff.dart';
-import 'Welcome.dart';
+import 'screen/Staff.dart';
+import 'screen/Welcome.dart';
 import 'models/table.dart';
 import 'models/user.dart';
-import 'order/order.dart';
 
 void main() => runApp(MyApp());
 
@@ -15,6 +17,7 @@ class MyApp extends StatelessWidget {
   // This widget is the root of your application.
   @override
   Widget build(BuildContext context) {
+    // var cart = OrderCart;
     return MultiProvider(
       providers: [
         ChangeNotifierProvider(
@@ -22,6 +25,9 @@ class MyApp extends StatelessWidget {
         ),
         ChangeNotifierProvider(
           create: (context) => TableStatusList(),
+        ),
+        ChangeNotifierProvider(
+          create: (context) => TableDetail(),
         )
       ],
       child: MaterialApp(
@@ -31,11 +37,15 @@ class MyApp extends StatelessWidget {
           //登录后的首页
           WelcomePage.routeName: (context) => WelcomePage(),
           //订单页面
-          OrderPage.routeName: (context) => OrderPage(),
+          // OrderPage.routeName: (context) => OrderPage(),
           //员工信息页面
           StaffInfoPage.routeName: (context) => StaffInfoPage(),
           //开台页面
-          TablePage.routeName: (context) => TablePage()
+          TablePage.routeName: (context) => TablePage(),
+          //购物车页面
+          OrderCart.routeName: (context) => OrderCart(),
+          //结账页面
+          CheckOut.routeName: (context) => CheckOut()
         },
         title: '点餐软件demo',
         theme: ThemeData(

+ 134 - 0
lib/models/product.dart

@@ -0,0 +1,134 @@
+import 'package:flutter/material.dart';
+
+class Product {
+  final String image, title, description;
+  final int price, size, id;
+  final Color color;
+  bool status;
+  Product(
+      {this.id,
+      this.image,
+      this.title,
+      this.price,
+      this.description,
+      this.size,
+      this.color,
+      this.status});
+}
+
+List<Product> products2 = [
+  Product(
+      id: 1,
+      title: "小炒肉",
+      price: 23,
+      size: 12,
+      description: dummyText,
+      image: "assets/images/bag_2_1.png",
+      color: Color(0xFF3D82AE),
+      status: true),
+  Product(
+      id: 2,
+      title: "炖牛骨",
+      price: 44,
+      size: 8,
+      description: dummyText,
+      image: "assets/images/bag_3_1.png",
+      color: Color(0xFFD3A984),
+      status: false),
+  Product(
+      id: 3,
+      title: "番茄炒蛋",
+      price: 16,
+      size: 10,
+      description: dummyText,
+      image: "assets/images/bag_1_1.png",
+      color: Color(0xFF989493),
+      status: true),
+  Product(
+      id: 4,
+      title: "鲜骨浓汤锅",
+      price: 34,
+      size: 11,
+      description: dummyText,
+      image: "assets/images/bag_2_1.png",
+      color: Color(0xFFE6B398),
+      status: false),
+  Product(
+      id: 5,
+      title: "Office Code",
+      price: 24,
+      size: 12,
+      description: dummyText,
+      image: "assets/images/bag_2_1.png",
+      color: Color(0xFFFB7883),
+      status: true),
+  Product(
+      id: 6,
+      title: "Office Code",
+      price: 26,
+      size: 12,
+      description: dummyText,
+      image: "assets/images/bag_6.png",
+      color: Color(0xFFAEAEAE),
+      status: true),
+];
+
+List<Product> products = [
+  Product(
+      id: 1,
+      title: "牛油菌汤锅",
+      price: 55,
+      size: 12,
+      description: dummyText,
+      image: "assets/images/bag_1_1.png",
+      color: Color(0xFF3D82AE),
+      status: true),
+  Product(
+      id: 2,
+      title: "番茄清汤锅",
+      price: 34,
+      size: 8,
+      description: dummyText,
+      image: "assets/images/bag_2_1.png",
+      color: Color(0xFFD3A984),
+      status: false),
+  Product(
+      id: 3,
+      title: "嫩羊肉卷",
+      price: 33,
+      size: 10,
+      description: dummyText,
+      image: "assets/images/bag_3_1.png",
+      color: Color(0xFF989493),
+      status: true),
+  Product(
+      id: 4,
+      title: "菌汤牛油鸳鸯锅",
+      price: 24,
+      size: 11,
+      description: dummyText,
+      image: "assets/images/bag_1_1.png",
+      color: Color(0xFFE6B398),
+      status: false),
+  Product(
+      id: 5,
+      title: "Office Code",
+      price: 24,
+      size: 12,
+      description: dummyText,
+      image: "assets/images/bag_2_1.png",
+      color: Color(0xFFFB7883),
+      status: true),
+  Product(
+      id: 6,
+      title: "Office Code",
+      price: 24,
+      size: 12,
+      description: dummyText,
+      image: "assets/images/bag_1_1.png",
+      color: Color(0xFFAEAEAE),
+      status: true),
+];
+
+String dummyText =
+    "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since. When an unknown printer took a galley.";

+ 9 - 2
lib/models/table.dart

@@ -21,9 +21,18 @@ class TableStatusList with ChangeNotifier {
   }
 
   deletetable(int index) {
+    print("[删除桌号]" + index.toString());
     _tableStatusMap.remove(index);
     notifyListeners();
   }
+
+  changetable(int before, TableStatus tableStatus) {
+    if (!isopen(tableStatus.id)) {
+      print("[更换桌号]" + before.toString());
+      deletetable(before);
+      addtable(tableStatus);
+    }
+  }
 }
 
 //桌状态
@@ -33,8 +42,6 @@ class TableStatus {
   int id;
 
   bool isopen = false;
-
-  double amount = 0;
 }
 
 // class OrderDetails {}

+ 81 - 0
lib/models/tableDetail.dart

@@ -0,0 +1,81 @@
+import 'package:flutter/cupertino.dart';
+import 'package:fooddeliveryapp/models/product.dart';
+
+class Item {
+  int count;
+  Product product;
+
+  Item(int i, Product p) {
+    this.count = i;
+    product = p;
+  }
+}
+
+class TableDetail with ChangeNotifier {
+  //记录当前使用台号
+  int _tableId;
+
+  DateTime openTime;
+
+  TableDetail({int id}) {
+    this._tableId = id;
+    notifyListeners();
+  }
+
+  List<Item> _items = [];
+
+  List<Item> get items => _items;
+
+  int getTableId() => _tableId;
+
+  DateTime getOpenTime() => openTime;
+
+  setTableId(int id) {
+    print("[tabledetails]设置桌号id" + id.toString());
+    this._tableId = id;
+    this.openTime = DateTime.now();
+    notifyListeners();
+  }
+
+  addItem(Product p) {
+    Item item = _items.firstWhere((i) => i.product == p, orElse: () => null);
+    if (item == null) {
+      item = Item(0, p);
+      _items.add(item);
+    }
+    item.count++;
+    notifyListeners();
+  }
+
+  // 从购物车移除商品,判断数量,通知
+  removeItem(Product p) {
+    Item item = _items.firstWhere((i) => i.product == p, orElse: () => null);
+    if (item == null) {
+      return;
+    }
+    item.count--;
+    if (item.count == 0) {
+      _items.remove(item);
+    }
+    notifyListeners();
+  }
+
+  endCart() {
+    _items = [];
+  }
+
+  // 获取购物车中指定商品数量,不存在返回0
+  int getItemCount(Product p) {
+    Item item = _items.firstWhere((i) => i.product == p, orElse: () => null);
+    return item == null ? 0 : item.count;
+  }
+
+  // 计算总总额。取小数点2位转字符串
+  String getTotalPrices() {
+    double total = 0;
+    for (var item in _items) {
+      total += item.product.price * item.count;
+    }
+    return total.toStringAsFixed(2);
+  }
+}

+ 0 - 86
lib/order/order.dart

@@ -1,86 +0,0 @@
-import 'package:flutter/material.dart';
-
-///Order START
-class OrderPage extends StatefulWidget {
-  static const routeName = '/order';
-  final int index;
-  //构造函数 同时传入桌号
-  OrderPage({Key key, @required this.index}) : super(key: key);
-
-  @override
-  State<StatefulWidget> createState() {
-    print("[桌点餐详情]" + index.toString());
-    return _OrderPageState();
-  }
-}
-
-class _OrderPageState extends State<OrderPage> {
-  @override
-  Widget build(BuildContext context) {
-    return Scaffold(
-      appBar: AppBar(title: Text("点单页面")),
-      drawer: Drawer(
-        // Add a ListView to the drawer. This ensures the user can scroll
-        // through the options in the drawer if there isn't enough vertical
-        // space to fit everything.
-        child: ListView(
-          // Important: Remove any padding from the ListView.
-          padding: EdgeInsets.zero,
-          children: <Widget>[
-            DrawerHeader(
-              child: Column(
-                children: <Widget>[
-                  Padding(
-                    padding: const EdgeInsets.fromLTRB(0,60,0,0),
-                    child: Text(
-                      "口之福火锅店",
-                      style: TextStyle(
-                          fontSize: 30,
-                          color: Colors.white,
-                          fontStyle: FontStyle.italic,
-                          fontWeight: FontWeight.bold),
-                    ),
-                  )
-                ],
-              ),
-              decoration: BoxDecoration(
-                color: Colors.red,
-                image: new DecorationImage(
-                  // image: new ExactAssetImage('images/drawer.jpg'),
-                  image: new NetworkImage(
-                      "http://test.ricemarch.com:9000/images/timg.jpg"),
-                  fit: BoxFit.cover,
-                ),
-              ),
-            ),
-            ListTile(
-              title: Text('Item 1'),
-              onTap: () {
-                // Update the state of the app
-                // ...
-                // Then close the drawer
-                Navigator.pop(context);
-              },
-            ),
-            ListTile(
-              title: Text('Item 2'),
-              onTap: () {
-                // Update the state of the app
-                // ...
-                // Then close the drawer
-                Navigator.pop(context);
-              },
-            ),
-          ],
-        ),
-      ),
-      body: Center(
-        child: Column(
-          children: <Widget>[Text("order页面")],
-        ),
-      ),
-    );
-  }
-}
-
-/// order END

+ 52 - 0
lib/screen/Staff.dart

@@ -0,0 +1,52 @@
+import 'package:flutter/material.dart';
+
+///STAFF START
+class StaffInfoPage extends StatefulWidget {
+  static const routeName = '/staff';
+
+  @override
+  State<StatefulWidget> createState() => _StaffInfoState();
+}
+
+class _StaffInfoState extends State<StaffInfoPage> {
+  @override
+  Widget build(BuildContext context) {
+    return Scaffold(
+      appBar: AppBar(
+        title: Text("员工信息"),
+      ),
+      body: Card(
+        child: Row(
+          children: <Widget>[
+            Column(
+              mainAxisSize: MainAxisSize.min,
+              crossAxisAlignment: CrossAxisAlignment.start,
+              children: <Widget>[
+                Padding(
+                  padding: const EdgeInsets.all(8.0),
+                  child: Text(
+                    "员工号:" + 8.toString(),
+                    style: TextStyle(fontSize: 15),
+                  ),
+                ),
+                Padding(
+                  padding: const EdgeInsets.all(8.0),
+                  child: Text("员工姓名:" + "谭武略"),
+                ),
+                Padding(
+                  padding: const EdgeInsets.all(8.0),
+                  child: Text("本次上岗时间:" +
+                      DateTime.now().toIso8601String().split("T")[0] +
+                      " " +
+                      DateTime.now().toIso8601String().split("T")[1]),
+                )
+              ],
+            )
+          ],
+        ),
+      ),
+    );
+  }
+}
+
+/// STAFF END

+ 2 - 2
lib/Welcome.dart → lib/screen/Welcome.dart

@@ -1,10 +1,10 @@
 import 'package:flutter/material.dart';
-import 'package:fooddeliveryapp/table.dart';
+import 'package:fooddeliveryapp/screen/table.dart';
 import 'package:provider/provider.dart';
 
 import 'Staff.dart';
 import 'login.dart';
-import 'models/user.dart';
+import '../models/user.dart';
 
 class WelcomePage extends StatelessWidget {
   static const routeName = '/welcome';

+ 146 - 0
lib/screen/cart.dart

@@ -0,0 +1,146 @@
+import 'package:flutter/cupertino.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_svg/svg.dart';
+import 'package:fooddeliveryapp/constants.dart';
+import 'package:fooddeliveryapp/models/tableDetail.dart';
+import 'package:fooddeliveryapp/screen/check_out.dart';
+import 'package:fooddeliveryapp/screen/details/components/add_to_cart.dart';
+import 'package:fooddeliveryapp/screen/table.dart';
+import 'package:provider/provider.dart';
+
+class OrderCart extends StatelessWidget {
+  static const routeName = "/cart";
+  @override
+  Widget build(BuildContext context) {
+    int index = ModalRoute.of(context).settings.arguments;
+    return Scaffold(
+      // appBar: AppBar(
+      //   title: Text('购物车'),
+      // ),
+      appBar: buildAppBar(context),
+      body: ItemList(
+        index: index,
+      ),
+    );
+  }
+}
+
+class ItemList extends StatelessWidget {
+  final int index;
+
+  const ItemList({Key key, this.index}) : super(key: key);
+  @override
+  Widget build(BuildContext context) {
+    return Column(
+      children: <Widget>[
+        Expanded(child: CartList()),
+        // TotalPrice(),
+        Padding(
+          padding: const EdgeInsets.symmetric(horizontal: kDefaultPaddin / 2),
+          child: AddToCart(pressButton: () {
+            //进行路由跳转  直接删除栈中元素 跳转到tablepage
+            Navigator.of(context).pushNamedAndRemoveUntil(
+                CheckOut.routeName, ModalRoute.withName(TablePage.routeName),
+                arguments: index);
+          }),
+        )
+      ],
+    );
+  }
+}
+
+class CartList extends StatelessWidget {
+  const CartList({
+    Key key,
+  }) : super(key: key);
+
+  @override
+  Widget build(BuildContext context) {
+    return Consumer<TableDetail>(
+      builder: (c, cart, child) {
+        return ListView.separated(
+          itemBuilder: (c, index) {
+            return Row(
+              mainAxisAlignment: MainAxisAlignment.start,
+              children: <Widget>[
+                Expanded(
+                  flex: 1,
+                  child: Container(
+                    constraints: BoxConstraints(maxHeight: kDefaultPaddin * 3),
+                    child: Image.asset(
+                      cart.items[index].product.image,
+                      fit: BoxFit.contain,
+                    ),
+                  ),
+                ),
+                Expanded(
+                  flex: 2,
+                  child: Text(
+                    '${cart.items[index].product.title}',
+                    style: TextStyle(fontSize: 25),
+                  ),
+                ),
+                Expanded(flex: 1, child: Text('数量:${cart.items[index].count}')),
+                Expanded(
+                  flex: 1,
+                  child: cart.items[index].product.status == true
+                      ? Text("已制作")
+                      : FlatButton(
+                          color: cart.items[index].product.color,
+                          child: Text("退菜"),
+                          onPressed: () {
+                            print("退菜");
+                            cart.removeItem(cart.items[index].product);
+                          },
+                        ),
+                )
+              ],
+            );
+          },
+          separatorBuilder: (_, __) => Divider(),
+          itemCount: cart.items.length,
+        );
+      },
+    );
+  }
+}
+
+AppBar buildAppBar(BuildContext context) {
+  return AppBar(
+    elevation: 0,
+    // backgroundColor: product.color,
+    leading: IconButton(
+      icon: SvgPicture.asset(
+        'assets/icons/back.svg',
+        color: Colors.white,
+      ),
+      onPressed: () => Navigator.pop(context),
+    ),
+    title: TotalPrice(),
+    actions: <Widget>[
+      IconButton(
+        icon: SvgPicture.asset("assets/icons/search.svg"),
+        onPressed: () {},
+      ),
+      // IconButton(
+      //   icon: SvgPicture.asset("assets/icons/cart.svg"),
+      //   onPressed: () {
+      //     Navigator.pushNamed(context, OrderCart.routeName);
+      //   },
+      // ),
+      SizedBox(width: kDefaultPaddin / 2)
+    ],
+  );
+}
+
+class TotalPrice extends StatelessWidget {
+  @override
+  Widget build(BuildContext context) {
+    return Consumer<TableDetail>(
+      builder: (context, cart, widget) {
+        return Text('总额:${cart.getTotalPrices()}',
+            style: TextStyle(color: Colors.white, fontSize: 20));
+      },
+    );
+  }
+}

+ 97 - 0
lib/screen/check_out.dart

@@ -0,0 +1,97 @@
+import 'package:flutter/material.dart';
+import 'package:fooddeliveryapp/constants.dart';
+import 'package:fooddeliveryapp/models/table.dart';
+import 'package:fooddeliveryapp/models/tableDetail.dart';
+import 'package:provider/provider.dart';
+
+class CheckOut extends StatelessWidget {
+  final int index;
+
+  static final routeName = "/checkout";
+
+  const CheckOut({Key key, this.index}) : super(key: key);
+
+  @override
+  Widget build(BuildContext context) {
+    TableStatusList myTableStatusList = Provider.of<TableStatusList>(context);
+    TableDetail myTableDetail = Provider.of<TableDetail>(context);
+    return Scaffold(
+      backgroundColor: Colors.green,
+      body: Container(
+        margin: EdgeInsets.fromLTRB(
+            kDefaultPaddin, kDefaultPaddin * 2, kDefaultPaddin, kDefaultPaddin),
+        padding: EdgeInsets.all(kDefaultPaddin),
+        decoration: BoxDecoration(
+            color: Colors.white,
+            borderRadius: BorderRadius.all(Radius.circular(24))),
+        child: Column(
+          children: <Widget>[
+            Text(
+              "订单支付页面",
+              style: Theme.of(context)
+                  .textTheme
+                  .headline4
+                  .copyWith(color: Colors.black, fontWeight: FontWeight.normal),
+            ),
+            Container(
+                decoration: BoxDecoration(
+                  // shape: BoxShape.circle,
+                  border: Border.all(color: Colors.white),
+                ),
+                child: Padding(
+                  padding: const EdgeInsets.all(8.0),
+                  child: Image.asset("assets/images/qc_code.png"),
+                )),
+            TotalPrices(),
+            Text(
+              "开台时间:" +
+                  myTableDetail
+                      .getOpenTime()
+                      .toIso8601String()
+                      .split("T")[1]
+                      .substring(0, 8),
+            ),
+            Text("闭台时间:" +
+                DateTime.now().toIso8601String().split("T")[1].substring(0, 8)),
+            Text("服务工号:" + 8.toString()),
+            FlatButton(
+              shape: RoundedRectangleBorder(
+                  borderRadius: BorderRadius.circular(18)),
+              // color: product.color,
+              color: Colors.red,
+              onPressed: () {
+                ///加入购物车
+                print("支付完成");
+                myTableStatusList.deletetable(myTableDetail.getTableId());
+                print("订单cart清空");
+                myTableDetail.endCart();
+                Navigator.pop(context);
+              },
+              child: Text(
+                "支付完成".toUpperCase(),
+                style: TextStyle(
+                  fontSize: 17,
+                  fontWeight: FontWeight.bold,
+                  color: Colors.white,
+                ),
+              ),
+            ),
+          ],
+        ),
+      ),
+    );
+  }
+}
+
+class TotalPrices extends StatelessWidget {
+  const TotalPrices({
+    Key key,
+  }) : super(key: key);
+
+  @override
+  Widget build(BuildContext context) {
+    return Consumer<TableDetail>(builder: (context, cart, child) {
+      return Center(child: Text("¥${cart.getTotalPrices()}"));
+    });
+  }
+}

+ 71 - 0
lib/screen/details/components/add_to_cart.dart

@@ -0,0 +1,71 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_svg/flutter_svg.dart';
+import 'package:fooddeliveryapp/constants.dart';
+
+class AddToCart extends StatelessWidget {
+  final Function pressButton;
+  const AddToCart({
+    Key key,
+    // @required this.product,
+    this.count,
+    this.pressButton,
+  }) : super(key: key);
+
+  // final Product product;
+  final int count;
+
+  @override
+  Widget build(BuildContext context) {
+    return Padding(
+      padding: const EdgeInsets.symmetric(vertical: kDefaultPaddin),
+      child: Row(
+        children: <Widget>[
+          Container(
+            margin: EdgeInsets.only(right: kDefaultPaddin),
+            height: 50,
+            width: 58,
+            decoration: BoxDecoration(
+              borderRadius: BorderRadius.circular(18),
+              border: Border.all(
+                // color: product.color,
+                color: Colors.red,
+              ),
+            ),
+            child: IconButton(
+              icon: SvgPicture.asset(
+                "assets/icons/add_to_cart.svg",
+                // color: product.color,
+                color: Colors.red,
+              ),
+              onPressed: () {},
+            ),
+          ),
+          Expanded(
+            child: SizedBox(
+              height: 50,
+              child: FlatButton(
+                shape: RoundedRectangleBorder(
+                    borderRadius: BorderRadius.circular(18)),
+                // color: product.color,
+                color: Colors.red,
+                onPressed: () {
+                  ///加入购物车
+                  print("数量:" + count.toString());
+                  pressButton();
+                },
+                child: Text(
+                  "结账".toUpperCase(),
+                  style: TextStyle(
+                    fontSize: 17,
+                    fontWeight: FontWeight.bold,
+                    color: Colors.white,
+                  ),
+                ),
+              ),
+            ),
+          ),
+        ],
+      ),
+    );
+  }
+}

+ 66 - 0
lib/screen/details/components/body.dart

@@ -0,0 +1,66 @@
+import 'package:flutter/material.dart';
+import 'package:fooddeliveryapp/constants.dart';
+import 'package:fooddeliveryapp/models/product.dart';
+// import 'package:fooddeliveryapp/models/tableDetail.dart';
+// import 'package:provider/provider.dart';
+
+// import 'add_to_cart.dart';
+// import 'color_and_size.dart';
+import 'counter_with_fav_btn.dart';
+import 'description.dart';
+import 'product_title_with_image.dart';
+
+class DetailsBody extends StatelessWidget {
+  final Product product;
+
+  const DetailsBody({Key key, this.product}) : super(key: key);
+  @override
+  Widget build(BuildContext context) {
+    // It provide us total height and width
+    Size size = MediaQuery.of(context).size;
+
+    return SingleChildScrollView(
+      child: Column(
+        children: <Widget>[
+          SizedBox(
+            height: size.height * 1.2,
+            child: Stack(
+              children: <Widget>[
+                Container(
+                  margin: EdgeInsets.only(top: size.height * 0.4),
+                  padding: EdgeInsets.only(
+                    top: size.height * 0.12,
+                    left: kDefaultPaddin,
+                    right: kDefaultPaddin,
+                  ),
+                  // height: 500,
+                  decoration: BoxDecoration(
+                    color: Colors.white,
+                    borderRadius: BorderRadius.only(
+                      topLeft: Radius.circular(24),
+                      topRight: Radius.circular(24),
+                    ),
+                  ),
+                  child: Column(
+                    children: <Widget>[
+                      // ColorAndSize(product: product),
+                      // SizedBox(height: kDefaultPaddin / 2),
+                      Description(product: product),
+                      SizedBox(height: kDefaultPaddin / 2),
+                      CounterWithFavBtn(
+                        product: product,
+                      ),
+                      SizedBox(height: kDefaultPaddin / 2),
+                      // AddToCart(product: product)
+                    ],
+                  ),
+                ),
+                ProductTitleWithImage(product: product)
+              ],
+            ),
+          )
+        ],
+      ),
+    );
+  }
+}

+ 82 - 0
lib/screen/details/components/cart_counter.dart

@@ -0,0 +1,82 @@
+import 'package:flutter/material.dart';
+import 'package:fooddeliveryapp/constants.dart';
+import 'package:fooddeliveryapp/models/product.dart';
+import 'package:fooddeliveryapp/models/tableDetail.dart';
+import 'package:provider/provider.dart';
+
+class CartCounter extends StatefulWidget {
+  final Product product;
+  // final TableDetail myTableDetail;
+
+  const CartCounter({
+    Key key,
+    @required this.product,
+  }) : super(key: key);
+  @override
+  _CartCounterState createState() => _CartCounterState(product);
+}
+
+class _CartCounterState extends State<CartCounter> {
+  final Product product;
+
+  _CartCounterState(this.product);
+  @override
+  Widget build(BuildContext context) {
+    final myTableDetail = Provider.of<TableDetail>(context);
+    int numOfItems = myTableDetail.getItemCount(product);
+    return Row(
+      children: <Widget>[
+        buildOutlineButton(
+          icon: Icons.remove,
+          press: () {
+            if (numOfItems > 0) {
+              setState(() {
+                numOfItems--;
+                myTableDetail.removeItem(product);
+                print("[通知]减少商品" +
+                    product.id.toString() +
+                    "NUMS:" +
+                    myTableDetail.getItemCount(product).toString());
+              });
+            }
+          },
+        ),
+        Padding(
+          padding: const EdgeInsets.symmetric(horizontal: kDefaultPaddin / 2),
+          child: Text(
+            // if our item is less  then 10 then  it shows 01 02 like that
+            numOfItems.toString().padLeft(2, "0"),
+            style: Theme.of(context).textTheme.headline6,
+          ),
+        ),
+        buildOutlineButton(
+            icon: Icons.add,
+            press: () {
+              setState(() {
+                numOfItems++;
+                myTableDetail.addItem(product);
+                print("[通知]添加商品" +
+                    product.id.toString() +
+                    "NUMS:" +
+                    myTableDetail.getItemCount(product).toString());
+              });
+            }),
+      ],
+    );
+  }
+
+  SizedBox buildOutlineButton({IconData icon, Function press}) {
+    return SizedBox(
+      width: 40,
+      height: 32,
+      child: OutlineButton(
+        padding: EdgeInsets.zero,
+        shape: RoundedRectangleBorder(
+          borderRadius: BorderRadius.circular(13),
+        ),
+        onPressed: press,
+        child: Icon(icon),
+      ),
+    );
+  }
+}

+ 91 - 0
lib/screen/details/components/color_and_size.dart

@@ -0,0 +1,91 @@
+import 'package:flutter/material.dart';
+import 'package:fooddeliveryapp/constants.dart';
+import 'package:fooddeliveryapp/models/product.dart';
+
+class ColorAndSize extends StatelessWidget {
+  const ColorAndSize({
+    Key key,
+    @required this.product,
+  }) : super(key: key);
+
+  final Product product;
+
+  @override
+  Widget build(BuildContext context) {
+    return Row(
+      children: <Widget>[
+        Expanded(
+          child: Column(
+            crossAxisAlignment: CrossAxisAlignment.start,
+            children: <Widget>[
+              Text("Color"),
+              Row(
+                children: <Widget>[
+                  ColorDot(
+                    color: Color(0xFF356C95),
+                    isSelected: true,
+                  ),
+                  ColorDot(color: Color(0xFFF8C078)),
+                  ColorDot(color: Color(0xFFA29B9B)),
+                ],
+              ),
+            ],
+          ),
+        ),
+        Expanded(
+          child: RichText(
+            text: TextSpan(
+              style: TextStyle(color: kTextColor),
+              children: [
+                TextSpan(text: "Size\n"),
+                TextSpan(
+                  text: "${product.size} cm",
+                  style: Theme.of(context)
+                      .textTheme
+                      .headline5
+                      .copyWith(fontWeight: FontWeight.bold),
+                )
+              ],
+            ),
+          ),
+        ),
+      ],
+    );
+  }
+}
+
+class ColorDot extends StatelessWidget {
+  final Color color;
+  final bool isSelected;
+  const ColorDot({
+    Key key,
+    this.color,
+    // by default isSelected is false
+    this.isSelected = false,
+  }) : super(key: key);
+
+  @override
+  Widget build(BuildContext context) {
+    return Container(
+      margin: EdgeInsets.only(
+        top: kDefaultPaddin / 4,
+        right: kDefaultPaddin / 2,
+      ),
+      padding: EdgeInsets.all(2.5),
+      height: 24,
+      width: 24,
+      decoration: BoxDecoration(
+        shape: BoxShape.circle,
+        border: Border.all(
+          color: isSelected ? color : Colors.transparent,
+        ),
+      ),
+      child: DecoratedBox(
+        decoration: BoxDecoration(
+          color: color,
+          shape: BoxShape.circle,
+        ),
+      ),
+    );
+  }
+}

+ 38 - 0
lib/screen/details/components/counter_with_fav_btn.dart

@@ -0,0 +1,38 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_svg/flutter_svg.dart';
+import 'package:fooddeliveryapp/models/product.dart';
+// import 'package:fooddeliveryapp/models/tableDetail.dart';
+
+import 'cart_counter.dart';
+
+class CounterWithFavBtn extends StatelessWidget {
+  final Product product;
+  // final TableDetail myTableDetail;
+  const CounterWithFavBtn({
+    Key key,
+    @required this.product,
+    // @required this.myTableDetail,
+  }) : super(key: key);
+
+  @override
+  Widget build(BuildContext context) {
+    return Row(
+      mainAxisAlignment: MainAxisAlignment.spaceBetween,
+      children: <Widget>[
+        CartCounter(
+          product: product,
+        ),
+        Container(
+          padding: EdgeInsets.all(8),
+          height: 32,
+          width: 32,
+          decoration: BoxDecoration(
+            color: Color(0xFFFF6464),
+            shape: BoxShape.circle,
+          ),
+          child: SvgPicture.asset("assets/icons/heart.svg"),
+        )
+      ],
+    );
+  }
+}

+ 23 - 0
lib/screen/details/components/description.dart

@@ -0,0 +1,23 @@
+import 'package:flutter/material.dart';
+import 'package:fooddeliveryapp/constants.dart';
+import 'package:fooddeliveryapp/models/product.dart';
+
+class Description extends StatelessWidget {
+  const Description({
+    Key key,
+    @required this.product,
+  }) : super(key: key);
+
+  final Product product;
+
+  @override
+  Widget build(BuildContext context) {
+    return Padding(
+      padding: const EdgeInsets.symmetric(vertical: kDefaultPaddin),
+      child: Text(
+        product.description,
+        style: TextStyle(height: 1.5),
+      ),
+    );
+  }
+}

+ 63 - 0
lib/screen/details/components/product_title_with_image copy.dart

@@ -0,0 +1,63 @@
+import 'package:flutter/material.dart';
+import 'package:shop_app/models/Product.dart';
+
+import '../../../constants.dart';
+
+class ProductTitleWithImage extends StatelessWidget {
+  const ProductTitleWithImage({
+    Key key,
+    @required this.product,
+  }) : super(key: key);
+
+  final Product product;
+
+  @override
+  Widget build(BuildContext context) {
+    return Padding(
+      padding: const EdgeInsets.symmetric(horizontal: kDefaultPaddin),
+      child: Column(
+        crossAxisAlignment: CrossAxisAlignment.start,
+        children: <Widget>[
+          Text(
+            "Aristocratic Hand Bag",
+            style: TextStyle(color: Colors.white),
+          ),
+          Text(
+            product.title,
+            style: Theme.of(context)
+                .textTheme
+                .headline4
+                .copyWith(color: Colors.white, fontWeight: FontWeight.bold),
+          ),
+          SizedBox(height: kDefaultPaddin),
+          Row(
+            children: <Widget>[
+              RichText(
+                text: TextSpan(
+                  children: [
+                    TextSpan(text: "Price\n"),
+                    TextSpan(
+                      text: "\$${product.price}",
+                      style: Theme.of(context).textTheme.headline4.copyWith(
+                          color: Colors.white, fontWeight: FontWeight.bold),
+                    ),
+                  ],
+                ),
+              ),
+              SizedBox(width: kDefaultPaddin),
+              Expanded(
+                child: Hero(
+                  tag: "${product.id}",
+                  child: Image.asset(
+                    product.image,
+                    fit: BoxFit.fill,
+                  ),
+                ),
+              )
+            ],
+          )
+        ],
+      ),
+    );
+  }
+}

+ 62 - 0
lib/screen/details/components/product_title_with_image.dart

@@ -0,0 +1,62 @@
+import 'package:flutter/material.dart';
+import 'package:fooddeliveryapp/constants.dart';
+import 'package:fooddeliveryapp/models/product.dart';
+
+class ProductTitleWithImage extends StatelessWidget {
+  const ProductTitleWithImage({
+    Key key,
+    @required this.product,
+  }) : super(key: key);
+
+  final Product product;
+
+  @override
+  Widget build(BuildContext context) {
+    return Padding(
+      padding: const EdgeInsets.symmetric(horizontal: kDefaultPaddin),
+      child: Column(
+        crossAxisAlignment: CrossAxisAlignment.start,
+        children: <Widget>[
+          Text(
+            "最最美味的菜品来自口之福",
+            style: TextStyle(color: Colors.white),
+          ),
+          Text(
+            product.title,
+            style: Theme.of(context)
+                .textTheme
+                .headline4
+                .copyWith(color: Colors.white, fontWeight: FontWeight.bold),
+          ),
+          SizedBox(height: kDefaultPaddin),
+          Row(
+            children: <Widget>[
+              RichText(
+                text: TextSpan(
+                  children: [
+                    TextSpan(text: "Price\n"),
+                    TextSpan(
+                      text: "\$${product.price}",
+                      style: Theme.of(context).textTheme.headline4.copyWith(
+                          color: Colors.white, fontWeight: FontWeight.bold),
+                    ),
+                  ],
+                ),
+              ),
+              SizedBox(width: kDefaultPaddin),
+              Expanded(
+                child: Hero(
+                  tag: "${product.id}",
+                  child: Image.asset(
+                    product.image,
+                    fit: BoxFit.fill,
+                  ),
+                ),
+              )
+            ],
+          )
+        ],
+      ),
+    );
+  }
+}

+ 49 - 0
lib/screen/details/detail_screen.dart

@@ -0,0 +1,49 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_svg/svg.dart';
+import 'package:fooddeliveryapp/screen/cart.dart';
+import 'package:fooddeliveryapp/constants.dart';
+import 'package:fooddeliveryapp/models/product.dart';
+import 'package:fooddeliveryapp/screen/details/components/body.dart';
+
+class DetailsScreen extends StatelessWidget {
+  final Product product;
+
+  const DetailsScreen({Key key, this.product}) : super(key: key);
+  @override
+  Widget build(BuildContext context) {
+    return Scaffold(
+      appBar: buildAppBar(context),
+      backgroundColor: product.color,
+      body: DetailsBody(
+        product: product,
+      ),
+    );
+  }
+
+  AppBar buildAppBar(BuildContext context) {
+    return AppBar(
+      elevation: 0,
+      backgroundColor: product.color,
+      leading: IconButton(
+        icon: SvgPicture.asset(
+          'assets/icons/back.svg',
+          color: Colors.white,
+        ),
+        onPressed: () => Navigator.pop(context),
+      ),
+      actions: <Widget>[
+        IconButton(
+          icon: SvgPicture.asset("assets/icons/search.svg"),
+          onPressed: () {},
+        ),
+        IconButton(
+          icon: SvgPicture.asset("assets/icons/cart.svg"),
+          onPressed: () {
+            Navigator.pushNamed(context, OrderCart.routeName);
+          },
+        ),
+        SizedBox(width: kDefaultPaddin / 2)
+      ],
+    );
+  }
+}

+ 2 - 4
lib/login.dart → lib/screen/login.dart

@@ -3,7 +3,7 @@ import 'package:fluttertoast/fluttertoast.dart';
 import 'package:provider/provider.dart';
 
 import 'Welcome.dart';
-import 'models/user.dart';
+import '../models/user.dart';
 
 class LoginPage extends StatefulWidget {
   static const routeName = "/";
@@ -87,8 +87,7 @@ class _LoginPageState extends State<LoginPage> {
                 ///图片
                 image: DecorationImage(
                   fit: BoxFit.cover,
-                  image: NetworkImage(
-                     'https://picsum.photos/id/1/150'),
+                  image: NetworkImage('https://picsum.photos/id/1/150'),
                 ),
               ),
             ),
@@ -267,4 +266,3 @@ class _LoginPageState extends State<LoginPage> {
         _pwdEditController.text == '1001';
   }
 }
-

+ 53 - 0
lib/screen/order/components/body.dart

@@ -0,0 +1,53 @@
+import 'package:flutter/material.dart';
+import 'package:fooddeliveryapp/constants.dart';
+import 'package:fooddeliveryapp/models/product.dart';
+import 'package:fooddeliveryapp/screen/details/detail_screen.dart';
+import 'package:fooddeliveryapp/screen/order/order_home_screen.dart';
+
+import 'item-card.dart';
+
+/// order页面中body体内容
+class Body extends StatelessWidget {
+  @override
+  Widget build(BuildContext context) {
+    return TabBarView(
+      children: getMyTabs().map((t) => t.body).toList(),
+    );
+  }
+}
+
+class Menu extends StatelessWidget {
+  const Menu({
+    Key key,
+    @required this.productsList,
+  }) : super(key: key);
+
+  final List<Product> productsList;
+
+  @override
+  Widget build(BuildContext context) {
+    return Expanded(
+      flex: 1,
+      child: Padding(
+        padding: const EdgeInsets.symmetric(horizontal: kDefaultPaddin),
+        child: GridView.builder(
+            itemCount: productsList.length,
+            gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
+                crossAxisCount: 2,
+                mainAxisSpacing: kDefaultPaddin,
+                crossAxisSpacing: kDefaultPaddin,
+                childAspectRatio: 0.75),
+            itemBuilder: (context, index) => ItemCard(
+                  product: productsList[index],
+                  press: () => Navigator.push(
+                      context,
+                      MaterialPageRoute(
+                        builder: (context) => DetailsScreen(
+                          product: productsList[index],
+                        ),
+                      )),
+                )),
+      ),
+    );
+  }
+}

+ 58 - 0
lib/screen/order/components/categories.dart

@@ -0,0 +1,58 @@
+import 'package:flutter/material.dart';
+import 'package:fooddeliveryapp/constants.dart';
+
+class Categories extends StatefulWidget {
+  @override
+  _CategoriesState createState() => _CategoriesState();
+}
+
+class _CategoriesState extends State<Categories> {
+  List<String> categories = ["功夫锅底", "飘香卤味", "安心肉品", "招牌菜"];
+
+  int selectedIndex = 0;
+
+  @override
+  Widget build(BuildContext context) {
+    return Padding(
+      padding: EdgeInsets.symmetric(vertical: kDefaultPaddin),
+      child: SizedBox(
+        height: 35,
+        child: ListView.builder(
+            itemCount: categories.length,
+            scrollDirection: Axis.horizontal,
+            itemBuilder: (context, index) => buildCategory(index)),
+      ),
+    );
+  }
+
+  Widget buildCategory(int index) {
+    return GestureDetector(
+      onTap: () {
+        setState(() {
+          selectedIndex = index;
+          print("[order页面]选择了第" + index.toString() + "个菜单页面");
+        });
+      },
+      child: Padding(
+        padding: const EdgeInsets.symmetric(horizontal: kDefaultPaddin),
+        child: Column(
+          crossAxisAlignment: CrossAxisAlignment.start,
+          children: <Widget>[
+            Text(
+              categories[index],
+              style: TextStyle(
+                  fontWeight: FontWeight.bold,
+                  color: selectedIndex == index ? kTextColor : kTextLightColor),
+            ),
+            Container(
+              margin: EdgeInsets.only(top: kDefaultPaddin / 4),
+              height: 2,
+              width: 30,
+              color: selectedIndex == index ? Colors.black : Colors.transparent,
+            )
+          ],
+        ),
+      ),
+    );
+  }
+}

+ 54 - 0
lib/screen/order/components/item-card.dart

@@ -0,0 +1,54 @@
+import 'package:flutter/material.dart';
+import 'package:fooddeliveryapp/constants.dart';
+import 'package:fooddeliveryapp/models/product.dart';
+
+class ItemCard extends StatelessWidget {
+  final Product product;
+  final Function press;
+  const ItemCard({
+    Key key,
+    this.product,
+    this.press,
+  }) : super(key: key);
+
+  @override
+  Widget build(BuildContext context) {
+    return GestureDetector(
+      onTap: press,
+      child: Column(
+        crossAxisAlignment: CrossAxisAlignment.start,
+        children: <Widget>[
+          Expanded(
+            child: Container(
+              padding: EdgeInsets.all(kDefaultPaddin),
+              // For  demo we use fixed height  and width
+              // Now we dont need them
+              // height: 180,
+              // width: 160,
+              decoration: BoxDecoration(
+                color: product.color,
+                borderRadius: BorderRadius.circular(16),
+              ),
+              child: Hero(
+                tag: "${product.id}",
+                child: Image.asset(product.image),
+              ),
+            ),
+          ),
+          Padding(
+            padding: const EdgeInsets.symmetric(vertical: kDefaultPaddin / 4),
+            child: Text(
+              // products is out demo list
+              product.title,
+              style: TextStyle(color: kTextLightColor),
+            ),
+          ),
+          Text(
+            "\$${product.price}",
+            style: TextStyle(fontWeight: FontWeight.bold),
+          )
+        ],
+      ),
+    );
+  }
+}

+ 111 - 0
lib/screen/order/order_home_screen.dart

@@ -0,0 +1,111 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_svg/svg.dart';
+import 'package:fooddeliveryapp/models/product.dart';
+import 'package:fooddeliveryapp/screen/cart.dart';
+import 'package:fooddeliveryapp/constants.dart';
+import 'package:fooddeliveryapp/screen/order/components/body.dart';
+
+class HomeSrcreen extends StatelessWidget {
+  static const routeName = '/order';
+  final int index;
+  //构造函数 同时传入桌号
+  HomeSrcreen({Key key, @required this.index}) : super(key: key);
+
+  @override
+  Widget build(BuildContext context) {
+    return DefaultTabController(
+      length: getMyTabs().length,
+      child: Scaffold(
+        appBar: buildAppBar(context),
+        body: Body(),
+      ),
+    );
+  }
+
+  AppBar buildAppBar(BuildContext context) {
+    return AppBar(
+      backgroundColor: Colors.white,
+      elevation: 0,
+      title: Padding(
+        padding: const EdgeInsets.symmetric(horizontal: kDefaultPaddin),
+        child: Text(
+          "口之福火锅",
+          style: Theme.of(context)
+              .textTheme
+              .headline5
+              .copyWith(fontWeight: FontWeight.bold),
+        ),
+      ),
+      leading: IconButton(
+        icon: SvgPicture.asset("assets/icons/back.svg"),
+        onPressed: () {},
+      ),
+      actions: <Widget>[
+        IconButton(
+          icon: SvgPicture.asset(
+            "assets/icons/search.svg",
+            // By default our  icon color is white
+            color: kTextColor,
+          ),
+          onPressed: () {},
+        ),
+        IconButton(
+          icon: SvgPicture.asset(
+            "assets/icons/cart.svg",
+            // By default our  icon color is white
+            color: kTextColor,
+          ),
+          onPressed: () {
+            Navigator.pushNamed(context, OrderCart.routeName, arguments: index);
+          },
+        ),
+        SizedBox(width: kDefaultPaddin / 2)
+      ],
+      bottom: TabBar(tabs: getMyTabs().map((e) => e.tab).toList()),
+    );
+  }
+}
+
+List<MyTab> getMyTabs() {
+  return [
+    MyTab(
+      Tab(
+        child: Text(
+          "功夫锅底",
+          style: TextStyle(color: Colors.black),
+        ),
+      ),
+      Menu(
+        productsList: products,
+      ),
+    ),
+    MyTab(
+      Tab(
+        child: Text(
+          "飘香卤味",
+          style: TextStyle(color: Colors.black),
+        ),
+      ),
+      // Icon(Icons.directions_transit, color: Colors.pink, size: 60),
+      Menu(productsList: products),
+    ),
+    MyTab(
+      Tab(
+        child: Text(
+          "安心肉品",
+          style: TextStyle(color: Colors.black),
+        ),
+      ),
+      // Icon(Icons.directions_bike, color: Colors.pink, size: 60),
+      Menu(productsList: products2),
+    )
+  ];
+}
+
+/// 因此抽象成独立的类
+class MyTab {
+  Tab tab;
+  Widget body;
+
+  MyTab(this.tab, this.body);
+}

+ 10 - 6
lib/table.dart → lib/screen/table.dart

@@ -1,8 +1,9 @@
 import 'package:flutter/material.dart';
-import 'package:fooddeliveryapp/order/order.dart';
+import 'package:fooddeliveryapp/models/tableDetail.dart';
+import 'package:fooddeliveryapp/screen/order/order_home_screen.dart';
 import 'package:provider/provider.dart';
 
-import 'models/table.dart';
+import '../models/table.dart';
 
 class TablePage extends StatefulWidget {
   static const String routeName = '/table';
@@ -73,6 +74,8 @@ class _TableState extends State<TablePage> {
       int count, TableStatusList tableStatusList, BuildContext context) {
     List<Widget> containers = [];
     final statusList = Provider.of<TableStatusList>(context);
+    final myTableDetail = Provider.of<TableDetail>(context);
+
     for (var i = 0; i < count; i++) {
       // var image = Image.network('https://picsum.photos/id/$i/150');
       // containers.add(image);
@@ -81,13 +84,14 @@ class _TableState extends State<TablePage> {
         onTap: () {
           if (tableStatusList.isopen(i)) {
             print("点击该台已开台,台号为=> " + "$i");
-            Navigator.push(
-                context, MaterialPageRoute(builder: (context) => OrderPage(index: i)));
+            Navigator.push(context,
+                MaterialPageRoute(builder: (context) => HomeSrcreen(index: i)));
           } else {
             print("点击该台号为=> " + "$i");
             statusList.addtable(TableStatus(i));
-            Navigator.push(
-                context, MaterialPageRoute(builder: (context) => OrderPage(index: i)));
+            myTableDetail.setTableId(i);
+            Navigator.push(context,
+                MaterialPageRoute(builder: (context) => HomeSrcreen(index: i)));
           }
         },
       ));

+ 34 - 13
pubspec.lock

@@ -7,42 +7,42 @@ packages:
       name: archive
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "2.0.11"
+    version: "2.0.13"
   args:
     dependency: transitive
     description:
       name: args
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "1.5.2"
+    version: "1.6.0"
   async:
     dependency: transitive
     description:
       name: async
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "2.4.0"
+    version: "2.4.1"
   boolean_selector:
     dependency: transitive
     description:
       name: boolean_selector
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "1.0.5"
+    version: "2.0.0"
   charcode:
     dependency: transitive
     description:
       name: charcode
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "1.1.2"
+    version: "1.1.3"
   collection:
     dependency: transitive
     description:
       name: collection
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "1.14.11"
+    version: "1.14.12"
   convert:
     dependency: transitive
     description:
@@ -56,7 +56,7 @@ packages:
       name: crypto
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "2.1.3"
+    version: "2.1.4"
   cupertino_icons:
     dependency: "direct main"
     description:
@@ -69,6 +69,13 @@ packages:
     description: flutter
     source: sdk
     version: "0.0.0"
+  flutter_svg:
+    dependency: "direct main"
+    description:
+      name: flutter_svg
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "0.17.4"
   flutter_test:
     dependency: "direct dev"
     description: flutter
@@ -106,7 +113,7 @@ packages:
       name: image
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "2.1.4"
+    version: "2.1.12"
   matcher:
     dependency: transitive
     description:
@@ -135,6 +142,20 @@ packages:
       url: "https://pub.flutter-io.cn"
     source: hosted
     version: "1.6.4"
+  path_drawing:
+    dependency: transitive
+    description:
+      name: path_drawing
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "0.4.1"
+  path_parsing:
+    dependency: transitive
+    description:
+      name: path_parsing
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "0.1.4"
   pedantic:
     dependency: transitive
     description:
@@ -162,7 +183,7 @@ packages:
       name: quiver
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "2.0.5"
+    version: "2.1.3"
   shared_preferences:
     dependency: "direct main"
     description:
@@ -202,7 +223,7 @@ packages:
       name: source_span
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "1.5.5"
+    version: "1.7.0"
   stack_trace:
     dependency: transitive
     description:
@@ -237,7 +258,7 @@ packages:
       name: test_api
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "0.2.11"
+    version: "0.2.15"
   typed_data:
     dependency: transitive
     description:
@@ -258,7 +279,7 @@ packages:
       name: xml
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "3.5.0"
+    version: "3.6.1"
 sdks:
-  dart: ">=2.4.0 <3.0.0"
+  dart: ">=2.6.0 <3.0.0"
   flutter: ">=1.12.13+hotfix.5 <2.0.0"

+ 4 - 3
pubspec.yaml

@@ -27,6 +27,7 @@ dependencies:
   http: ^0.12.1
   shared_preferences: ^0.5.7+2
   fluttertoast: ^3.0.3
+  flutter_svg: ^0.17.4 # it help us to use SVG in our app
 
 dev_dependencies:
   flutter_test:
@@ -45,9 +46,9 @@ flutter:
   uses-material-design: true
 
   # To add assets to your application, add an assets section, like this:
-  # assets:
-  #  - images/a_dot_burr.jpeg
-  #  - images/a_dot_ham.jpeg
+  assets:
+    - assets/images/
+    - assets/icons/
 
   # An image asset can refer to one or more resolution-specific "variants", see
   # https://flutter.dev/assets-and-images/#resolution-aware.

Some files were not shown because too many files changed in this diff