lyq.me@qq.com 2 years ago
parent
commit
dc176f11fb
7 changed files with 152 additions and 248 deletions
  1. 61 0
      .github/workflows/build.yml
  2. 15 14
      lib/bean/bean.dart
  3. 0 86
      lib/main.dart
  4. 4 1
      lib/ui/CanteenDishListView.dart
  5. 35 41
      lib/ui/CanteenMain.dart
  6. 37 37
      pubspec.lock
  7. 0 69
      pubspec.yaml

+ 61 - 0
.github/workflows/build.yml

@@ -0,0 +1,61 @@
+name: CI
+on:
+  push:
+    branches: [ master , main]
+  pull_request:
+    branches: [ master , main]
+jobs:
+  build:
+    strategy:
+      matrix:
+        os: [ubuntu-latest]
+    runs-on: ${{matrix.os}}
+    steps:
+      - uses: actions/checkout@v2
+
+      - name: Setup Java JDK
+        uses: actions/setup-java@v2
+        with:
+          distribution: 'adopt'
+          java-version: "8.x"
+
+      - name: Flutter action
+        uses: subosito/flutter-action@v1.5.3
+        with:
+          channel: "stable"
+          flutter-version: "2.5.2"
+
+      - name: Cache Dependencies
+        id: cache
+        uses: actions/cache@v2
+        with:
+          path: |
+            ~/.gradle/caches
+            ~/.gradle/wrapper
+            Pods
+          key: |
+            ${{runner.OS}}-gradle-caches-${{ hashFiles('pubspec.lock') }}
+            ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
+          restore-keys: |
+            ${{ runner.os }}-pods-
+            ${{ runner.os }}-gradle-
+
+      - name: Install Dependencies
+        if: steps.cache.outputs.cache-hit != 'true'
+        run: flutter pub get
+
+      - name: Build apk
+        if: ${{ runner.os == 'Linux' }}
+        run: flutter build apk --debug --no-sound-null-safety
+
+      # output some file:
+      - name: artifact
+        uses: actions/upload-artifact@v2
+        with:
+          name: ${{runner.OS}}-artifact
+          path: |
+            # build/app/outputs/flutter-apk/**/*.apk
+            build/app/outputs/flutter-apk/app.apk
+            build/ios/**/*.ipa
+            build/web/web-app.zip
+            build/windows/runner/Release/

+ 15 - 14
lib/bean/bean.dart

@@ -4,33 +4,34 @@ import 'package:flutter/cupertino.dart';
 //   String name;
 //   late int id;
 //   static int _id_count=0;
-//   Map<String,Canteen>canteens=new Map();
+//   Map<String,Canteen>canteens=Map();
 //   Campus(this.name){id=++_id_count;}
 //   Canteen addCanteen(String name){
-//     canteens[name]=new Canteen(name);
+//     canteens[name]=Canteen(name);
 //     return canteens[name]!;
 //   }
 // }
 // class Canteen{
 //   String name;
-//   Dishes daily=new Dishes();  //当日菜品(固定)
-//   Dishes special=new Dishes();//特色菜品
-//   Dishes nowaday=new Dishes();//当日新菜
+//   Dishes daily=Dishes();  //当日菜品(固定)
+//   Dishes special=Dishes();//特色菜品
+//   Dishes nowaday=Dishes();//当日新菜
 //   Canteen(this.name);
 // }
-class Dish{
+class Dish {
   String name;
-  String cost;      //价格
-  String time;      //供应时间
+  String cost; //价格
+  String time; //供应时间
   //String category;  //菜品分类:当日菜品(固定),特色菜品,当日新菜
   //String campus;    //校区
-  String canteen;   //食堂
-  bool star=false,like=false;
+  String canteen; //食堂
+  bool star = false, like = false;
   //DateTime? star_time=null;
 
-  Dish(this.name,this.cost,this.time,this.canteen,{bool like=false,bool star=false,DateTime? star_time}){
-    this.like=like;
-    this.star=star;
+  Dish(this.name, this.cost, this.time, this.canteen,
+      {bool like = false, bool star = false, DateTime? star_time}) {
+    this.like = like;
+    this.star = star;
     //if(star_time!=null)this.star_time=star_time;
   }
-}
+}

+ 0 - 86
lib/main.dart

@@ -1,9 +1,7 @@
-import 'package:canteen/ui/CanteenDishListView.dart';
 import 'package:flutter/material.dart';
 import 'package:canteen/ui/CanteenMain.dart';
 import 'package:canteen/bean/themes.dart';
 
-import 'bean/bean.dart';
 
 void main() {
   runApp(const MyApp());
@@ -24,87 +22,3 @@ class MyApp extends StatelessWidget {
   }
 }
 
-class MyHomePage extends StatefulWidget {
-  const MyHomePage({Key? key, required this.title}) : super(key: key);
-
-  // This widget is the home page of your application. It is stateful, meaning
-  // that it has a State object (defined below) that contains fields that affect
-  // how it looks.
-
-  // This class is the configuration for the state. It holds the values (in this
-  // case the title) provided by the parent (in this case the App widget) and
-  // used by the build method of the State. Fields in a Widget subclass are
-  // always marked "final".
-
-  final String title;
-
-  @override
-  State<MyHomePage> createState() => _MyHomePageState();
-}
-
-class _MyHomePageState extends State<MyHomePage> {
-  int _counter = 0;
-
-  void _incrementCounter() {
-    setState(() {
-      // This call to setState tells the Flutter framework that something has
-      // changed in this State, which causes it to rerun the build method below
-      // so that the display can reflect the updated values. If we changed
-      // _counter without calling setState(), then the build method would not be
-      // called again, and so nothing would appear to happen.
-      _counter++;
-    });
-  }
-
-  @override
-  Widget build(BuildContext context) {
-    // This method is rerun every time setState is called, for instance as done
-    // by the _incrementCounter method above.
-    //
-    // The Flutter framework has been optimized to make rerunning build methods
-    // fast, so that you can just rebuild anything that needs updating rather
-    // than having to individually change instances of widgets.
-    return Scaffold(
-      appBar: AppBar(
-        // Here we take the value from the MyHomePage object that was created by
-        // the App.build method, and use it to set our appbar title.
-        title: Text(widget.title),
-      ),
-      body: Center(
-        // Center is a layout widget. It takes a single child and positions it
-        // in the middle of the parent.
-        child: Column(
-          // Column is also a layout widget. It takes a list of children and
-          // arranges them vertically. By default, it sizes itself to fit its
-          // children horizontally, and tries to be as tall as its parent.
-          //
-          // Invoke "debug painting" (press "p" in the console, choose the
-          // "Toggle Debug Paint" action from the Flutter Inspector in Android
-          // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
-          // to see the wireframe for each widget.
-          //
-          // Column has various properties to control how it sizes itself and
-          // how it positions its children. Here we use mainAxisAlignment to
-          // center the children vertically; the main axis here is the vertical
-          // axis because Columns are vertical (the cross axis would be
-          // horizontal).
-          mainAxisAlignment: MainAxisAlignment.center,
-          children: <Widget>[
-            const Text(
-              'You have pushed the button this many times:',
-            ),
-            Text(
-              '$_counter',
-              style: Theme.of(context).textTheme.headline4,
-            ),
-          ],
-        ),
-      ),
-      floatingActionButton: FloatingActionButton(
-        onPressed: _incrementCounter,
-        tooltip: 'Increment',
-        child: const Icon(Icons.add),
-      ), // This trailing comma makes auto-formatting nicer for build methods.
-    );
-  }
-}

+ 4 - 1
lib/ui/CanteenDishListView.dart

@@ -6,6 +6,7 @@ class CanteenDishListView extends StatelessWidget{
   final void Function(int index)?onLikePressed;
   final void Function(int index)?onStarPressed;
   CanteenDishListView(this.dishes,{this.onLikePressed=null,this.onStarPressed=null});
+  
   @override
   Widget build(BuildContext context) {
     return ListView.separated(
@@ -29,7 +30,9 @@ class _DishListViewItem extends StatelessWidget{
   final Dish dish;
   final void Function(int index)?onLikePressed;
   final void Function(int index)?onStarPressed;
-  _DishListViewItem(this.id,this.dish,this.onLikePressed,this.onStarPressed);
+
+  const _DishListViewItem(this.id,this.dish,this.onLikePressed,this.onStarPressed);
+
   @override
   //5:3=20:12
   //4:3=12:9

+ 35 - 41
lib/ui/CanteenMain.dart

@@ -3,6 +3,8 @@ import 'package:canteen/widget/ChznExpansionPanelList.dart';
 import 'package:flutter/material.dart';
 
 class CanteenMain extends StatefulWidget {
+  const CanteenMain({Key? key}) : super(key: key);
+
   @override
   State<CanteenMain> createState() => CanteenMainState();
 }
@@ -65,17 +67,11 @@ class CanteenMainState extends State<CanteenMain> {
                 icon: Icon(Icons.star_border,
                     color: Theme.of(context).primaryColor),
                 onPressed: () {
-
-
                   //此处应当跳转至收藏页面
-
-
-                  Navigator.of(context).push(MaterialPageRoute(
-                    builder: (context){
-                      return listviewexpamle();
-                    }
-                  ));
-
+                  Navigator.of(context)
+                      .push(MaterialPageRoute(builder: (context) {
+                    return listviewexpamle();
+                  }));
                 },
               )
             ]),
@@ -113,37 +109,35 @@ class _CampusListViewState extends State<_CampusListView> {
   @override
   Widget build(BuildContext context) {
     return Expanded(
-        child: SingleChildScrollView(child:
-      ChznExpansionPanelList(
-        expansionCallback: (int index, bool isExpanded) {
-          setState(() {
-            if (!isExpanded) {
-              if (select != -1) widget._campusList[select].isExpanded = false;
-              select = index;
-              widget._campusList[select].isExpanded = true;
-            } else {
-              widget._campusList[index].isExpanded = false;
-              select = -1;
-            }
-            _selectCampus = select;
-          });
-        },
-        children:
-            widget._campusList.map<ExpansionPanel>((_CampusViewItem item) {
-          return ExpansionPanel(
-              headerBuilder: (BuildContext context, bool isExpanded) {
-                return item.header;
-              },
-              body: item.body,
-              isExpanded: item.isExpanded,
-              canTapOnHeader: true,
-              backgroundColor:
-                  item.isExpanded ? const Color(0xFFF0F0F0) : Colors.white);
-        }).toList(),
-        expandedHeaderPadding: const EdgeInsets.all(0),
-        elevation: 0,
-      )
-    ));
+        child: SingleChildScrollView(
+            child: ChznExpansionPanelList(
+      expansionCallback: (int index, bool isExpanded) {
+        setState(() {
+          if (!isExpanded) {
+            if (select != -1) widget._campusList[select].isExpanded = false;
+            select = index;
+            widget._campusList[select].isExpanded = true;
+          } else {
+            widget._campusList[index].isExpanded = false;
+            select = -1;
+          }
+          _selectCampus = select;
+        });
+      },
+      children: widget._campusList.map<ExpansionPanel>((_CampusViewItem item) {
+        return ExpansionPanel(
+            headerBuilder: (BuildContext context, bool isExpanded) {
+              return item.header;
+            },
+            body: item.body,
+            isExpanded: item.isExpanded,
+            canTapOnHeader: true,
+            backgroundColor:
+                item.isExpanded ? const Color(0xFFF0F0F0) : Colors.white);
+      }).toList(),
+      expandedHeaderPadding: const EdgeInsets.all(0),
+      elevation: 0,
+    )));
   }
 }
 

+ 37 - 37
pubspec.lock

@@ -5,58 +5,58 @@ packages:
     dependency: transitive
     description:
       name: async
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
-    version: "2.8.1"
+    version: "2.8.2"
   boolean_selector:
     dependency: transitive
     description:
       name: boolean_selector
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "2.1.0"
   characters:
     dependency: transitive
     description:
       name: characters
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.1.0"
+    version: "1.2.0"
   charcode:
     dependency: transitive
     description:
       name: charcode
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.3.1"
   clock:
     dependency: transitive
     description:
       name: clock
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.1.0"
   collection:
     dependency: transitive
     description:
       name: collection
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.15.0"
+    version: "1.16.0"
   cupertino_icons:
     dependency: "direct main"
     description:
       name: cupertino_icons
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.0.4"
   fake_async:
     dependency: transitive
     description:
       name: fake_async
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.2.0"
+    version: "1.3.0"
   flutter:
     dependency: "direct main"
     description: flutter
@@ -66,7 +66,7 @@ packages:
     dependency: "direct dev"
     description:
       name: flutter_lints
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.0.4"
   flutter_test:
@@ -78,30 +78,37 @@ packages:
     dependency: transitive
     description:
       name: lints
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.0.1"
   matcher:
     dependency: transitive
     description:
       name: matcher
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
+    source: hosted
+    version: "0.12.11"
+  material_color_utilities:
+    dependency: transitive
+    description:
+      name: material_color_utilities
+      url: "https://pub.dartlang.org"
     source: hosted
-    version: "0.12.10"
+    version: "0.1.4"
   meta:
     dependency: transitive
     description:
       name: meta
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.7.0"
   path:
     dependency: transitive
     description:
       name: path
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.8.0"
+    version: "1.8.1"
   sky_engine:
     dependency: transitive
     description: flutter
@@ -111,57 +118,50 @@ packages:
     dependency: transitive
     description:
       name: source_span
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.8.1"
+    version: "1.8.2"
   stack_trace:
     dependency: transitive
     description:
       name: stack_trace
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.10.0"
   stream_channel:
     dependency: transitive
     description:
       name: stream_channel
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "2.1.0"
   string_scanner:
     dependency: transitive
     description:
       name: string_scanner
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.1.0"
   term_glyph:
     dependency: transitive
     description:
       name: term_glyph
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.2.0"
   test_api:
     dependency: transitive
     description:
       name: test_api
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
-    version: "0.4.2"
-  typed_data:
-    dependency: transitive
-    description:
-      name: typed_data
-      url: "https://pub.flutter-io.cn"
-    source: hosted
-    version: "1.3.0"
+    version: "0.4.9"
   vector_math:
     dependency: transitive
     description:
       name: vector_math
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
-    version: "2.1.0"
+    version: "2.1.2"
 sdks:
-  dart: ">=2.12.0 <3.0.0"
+  dart: ">=2.14.0 <3.0.0"

+ 0 - 69
pubspec.yaml

@@ -1,90 +1,21 @@
 name: canteen
 description: 食堂信息
-
-# The following line prevents the package from being accidentally published to
-# pub.dev using `flutter pub publish`. This is preferred for private packages.
 publish_to: 'none' # Remove this line if you wish to publish to pub.dev
-
-# The following defines the version and build number for your application.
-# A version number is three numbers separated by dots, like 1.2.43
-# followed by an optional build number separated by a +.
-# Both the version and the builder number may be overridden in flutter
-# build by specifying --build-name and --build-number, respectively.
-# In Android, build-name is used as versionName while build-number used as versionCode.
-# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
-# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
-# Read more about iOS versioning at
-# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
 version: 1.0.0+1
 
 environment:
   sdk: ">=2.12.0 <3.0.0"
-
-# Dependencies specify other packages that your package needs in order to work.
-# To automatically upgrade your package dependencies to the latest versions
-# consider running `flutter pub upgrade --major-versions`. Alternatively,
-# dependencies can be manually updated by changing the version numbers below to
-# the latest version available on pub.dev. To see which dependencies have newer
-# versions available, run `flutter pub outdated`.
 dependencies:
   flutter:
     sdk: flutter
-
-
-  # The following adds the Cupertino Icons font to your application.
-  # Use with the CupertinoIcons class for iOS style icons.
   cupertino_icons: ^1.0.3
 
 dev_dependencies:
   flutter_test:
     sdk: flutter
-
-  # The "flutter_lints" package below contains a set of recommended lints to
-  # encourage good coding practices. The lint set provided by the package is
-  # activated in the `analysis_options.yaml` file located at the root of your
-  # package. See that file for information about deactivating specific lint
-  # rules and activating additional ones.
   flutter_lints: ^1.0.0
-
-# For information on the generic Dart part of this file, see the
-# following page: https://dart.dev/tools/pub/pubspec
-
-# The following section is specific to Flutter.
 flutter:
-
-  # The following line ensures that the Material Icons font is
-  # included with your application, so that you can use the icons in
-  # the material Icons class.
   uses-material-design: true
 
-  # To add assets to your application, add an assets section, like this:
   assets:
     - assets/
-  #   - images/a_dot_burr.jpeg
-  #   - images/a_dot_ham.jpeg
-
-  # An image asset can refer to one or more resolution-specific "variants", see
-  # https://flutter.dev/assets-and-images/#resolution-aware.
-
-  # For details regarding adding assets from package dependencies, see
-  # https://flutter.dev/assets-and-images/#from-packages
-
-  # To add custom fonts to your application, add a fonts section here,
-  # in this "flutter" section. Each entry in this list should have a
-  # "family" key with the font family name, and a "fonts" key with a
-  # list giving the asset and other descriptors for the font. For
-  # example:
-  # fonts:
-  #   - family: Schyler
-  #     fonts:
-  #       - asset: fonts/Schyler-Regular.ttf
-  #       - asset: fonts/Schyler-Italic.ttf
-  #         style: italic
-  #   - family: Trajan Pro
-  #     fonts:
-  #       - asset: fonts/TrajanPro.ttf
-  #       - asset: fonts/TrajanPro_Bold.ttf
-  #         weight: 700
-  #
-  # For details regarding fonts from package dependencies,
-  # see https://flutter.dev/custom-fonts/#from-packages