liuyuqi-dellpc 4 years ago
parent
commit
1f46fd06d5

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

@@ -0,0 +1,74 @@
+name: CI
+on:
+  push:
+    branches: [ master, main ]
+  pull_request:
+    branches: [ master, main ]
+jobs:
+  build:
+    strategy:
+      matrix:
+        os: [ubuntu-latest]
+        # os: [ubuntu-latest, macos-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: Setup gradle
+        uses: eskatos/gradle-command-action@v1
+        with:
+          gradle-version: 6.5
+
+      - name: Flutter action
+        uses: subosito/flutter-action@v1.5.3
+        with:
+          channel: "stable"
+          flutter-version: "2.0.5"
+
+      - 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 clean
+          flutter build apk --release --split-per-abi
+
+      - name: Build Web
+        if: ${{runner.os == 'Linux'}}
+        run: |
+          flutter build web
+          cd build/web
+          zip -r web-app.zip .
+
+      # output some file:
+      - name: artifact
+        uses: actions/upload-artifact@v2
+        with:
+          name: ${{runner.OS}}-artifact
+          path: |
+            build/app/outputs/flutter-apk/**/*.apk
+            build/ios/**/*.ipa
+            build/web/web-app.zip

BIN
assets/xkcd-script.ttf


+ 13 - 0
lib/dao/user_dao.dart

@@ -0,0 +1,13 @@
+import 'package:flutter_clock/model/user_model.dart';
+
+class UserDao {
+  /// 登录
+  Future<UserModel> login(String username, String password) async {
+    return null;
+  }
+
+  /// 删除用户
+  Future<bool> delUser(String token, String userid) async {
+    return false;
+  }
+}

+ 0 - 1
lib/main.dart

@@ -3,7 +3,6 @@ import 'dart:io';
 import 'package:flutter/foundation.dart';
 import 'package:flutter/foundation.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter_clock/pages/main_page.dart';
 import 'package:flutter_clock/pages/main_page.dart';
-import 'package:flutter_clock/pages/user_page.dart';
 
 
 void setOverrideForDesktop() {
 void setOverrideForDesktop() {
   if (kIsWeb) return;
   if (kIsWeb) return;

+ 6 - 0
lib/model/clock_model.dart

@@ -0,0 +1,6 @@
+class ClockModel {
+  String clockName;
+  String location;
+  DateTime dateTime;
+  
+}

+ 8 - 0
lib/model/config.dart

@@ -0,0 +1,8 @@
+
+class Config {
+  // 默认字体
+  static String defaultFontFamily =
+      '-apple-system,BlinkMacSystemFont,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Segoe UI","PingFang SC","Hiragino Sans GB","Microsoft YaHei","Helvetica Neue",Helvetica,Arial,sans-serif';
+
+
+}

+ 12 - 0
lib/model/constants.dart

@@ -0,0 +1,12 @@
+  import 'package:flutter/material.dart';
+
+  const Color kPrimaryColor = Color(0xFF366CF6);
+  const Color kSecondaryColor = Color(0xFFF5F6FC);
+  const Color kBgLightColor = Color(0xFFF2F4FC);
+  const Color kBgDarkColor = Color(0xFFEBEDFA);
+  const Color kBadgeColor = Color(0xFFEE376E);
+  const Color kGrayColor = Color(0xFF8793B2);
+  const Color kTitleTextColor = Color(0xFF30384D);
+  const Color kTextColor = Color(0xFF4D5875);
+
+  const double kDefaultPadding = 20.0;

+ 5 - 0
lib/model/user_model.dart

@@ -0,0 +1,5 @@
+class UserModel {
+  String userid;
+  String password;
+  String logo;
+}

+ 54 - 24
lib/pages/main_page.dart

@@ -1,13 +1,14 @@
-import 'package:flutter/material.dart';
 import 'dart:async';
 import 'dart:async';
 import 'dart:math' as math;
 import 'dart:math' as math;
+
+import 'package:flutter/material.dart';
+import 'package:flutter_clock/model/config.dart';
 import 'package:intl/intl.dart';
 import 'package:intl/intl.dart';
 
 
 class MainPage extends StatefulWidget {
 class MainPage extends StatefulWidget {
   @override
   @override
   State<StatefulWidget> createState() {
   State<StatefulWidget> createState() {
-    @override
-    _MainPageState createState() => _MainPageState();
+    return _MainPageState();
   }
   }
 }
 }
 
 
@@ -24,35 +25,64 @@ class _MainPageState extends State<MainPage> {
   }
   }
 
 
   @override
   @override
-  Widget build(BuildContext context) => Scaffold(
+  Widget build(BuildContext context) {
+    return Scaffold(
         backgroundColor: Colors.white,
         backgroundColor: Colors.white,
-        appBar: AppBar(title: Text('xkcd clock')),
-        body: Column(
-          children: [
-            Stack(
+        body: SingleChildScrollView(
+          child: Center(
+            child: Column(
               children: [
               children: [
-                Image.asset('assets/face.png'),
-                Transform.rotate(
-                  angle: -(radiansFromTime(_localTime.toUtc()) +
-                      _utcMidnightRadiansOffset),
-                  child: ClipOval(
-                    clipper: InnerFaceClipper(),
-                    child: Image.asset('assets/face.png'),
+                Text(
+                  "Clock",
+                  style: TextStyle(
+                    fontSize: 30,
+                    color: Colors.red,
                   ),
                   ),
                 ),
                 ),
+                Text(
+                  "author: 天问",
+                  style: TextStyle(fontFamily: Config.defaultFontFamily),
+                ),
+                Text(
+                  "contact: liuyuqi.gov@msn.cn",
+                  style: TextStyle(fontFamily: Config.defaultFontFamily),
+                ),
+                SizedBox(
+                  height: 5,
+                ),
+                Stack(
+                  children: [
+                    Image.asset(
+                      'assets/face.png',
+                      width: 350,
+                    ),
+                    Transform.rotate(
+                      angle: -(radiansFromTime(_localTime.toUtc()) +
+                          _utcMidnightRadiansOffset),
+                      child: ClipOval(
+                        clipper: InnerFaceClipper(),
+                        child: Image.asset(
+                          'assets/face.png',
+                          width: 350,
+                        ),
+                      ),
+                    ),
+                  ],
+                ),
+                Text(DateFormat.EEEE().format(_localTime),
+                    style: TextStyle(fontSize: 48)),
+                Text(DateFormat.yMMMMd().format(_localTime),
+                    style: TextStyle(fontSize: 20)),
+                Text(DateFormat.jms().format(_localTime),
+                    style: TextStyle(fontSize: 42)),
               ],
               ],
             ),
             ),
-            Text(DateFormat.EEEE().format(_localTime),
-                style: TextStyle(fontSize: 48)),
-            Text(DateFormat.yMMMMd().format(_localTime),
-                style: TextStyle(fontSize: 20)),
-            Text(DateFormat.jm().format(_localTime),
-                style: TextStyle(fontSize: 42)),
-          ],
-        ),
-      );
+          ),
+        ));
+  }
 
 
   static double radiansFromDegrees(double degrees) => degrees * math.pi / 180;
   static double radiansFromDegrees(double degrees) => degrees * math.pi / 180;
+
   static double radiansFromTime(DateTime time) {
   static double radiansFromTime(DateTime time) {
     final midnightToday = DateTime(time.year, time.month, time.day);
     final midnightToday = DateTime(time.year, time.month, time.day);
     final secondsSinceMidnight = midnightToday.difference(time).inSeconds;
     final secondsSinceMidnight = midnightToday.difference(time).inSeconds;

+ 24 - 0
lib/pages/splash_page.dart

@@ -0,0 +1,24 @@
+import 'package:flutter/cupertino.dart';
+import 'package:flutter/material.dart';
+
+/// 闪屏页 3s之后进入主页
+class SplashPage extends StatefulWidget {
+  @override
+  State<StatefulWidget> createState() {
+    return _SplashPageState();
+  }
+}
+
+class _SplashPageState extends State<SplashPage> {
+  @override
+  Widget build(BuildContext context) {
+    return Scaffold(
+      appBar: AppBar(
+        title: Text("Splash"),
+      ),
+      body: Container(
+        alignment: Alignment.topCenter,
+      ),
+    );
+  }
+}

+ 0 - 10
lib/pages/user_page.dart

@@ -1,10 +0,0 @@
-import 'package:flutter/cupertino.dart';
-
-class UserPage extends StatelessWidget {
-  @override
-  Widget build(BuildContext context) {
-    return Container(
-      child: Text("nihao"),
-    );
-  }
-}

+ 3 - 0
lib/utils/app_utils.dart

@@ -0,0 +1,3 @@
+class AppUtils{
+  
+}

+ 66 - 0
lib/views/side_menu.dart

@@ -0,0 +1,66 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_clock/model/constants.dart';
+import 'package:flutter_clock/views/side_menu_item.dart';
+
+/// 左侧滑动菜单
+class SideMenu extends StatelessWidget {
+  const SideMenu({
+    Key key,
+  }) : super(key: key);
+
+  @override
+  Widget build(BuildContext context) {
+    return Container(
+      height: double.infinity,
+      padding: EdgeInsets.only(top: kDefaultPadding),
+      color: kBgLightColor,
+      child: SafeArea(
+        child: SingleChildScrollView(
+          padding: EdgeInsets.symmetric(horizontal: kDefaultPadding),
+          child: Column(
+            children: [
+              Row(
+                children: [
+                  Image.asset(
+                    "assets/images/Logo Outlook.png",
+                    width: 46,
+                  ),
+                  Spacer(),
+                ],
+              ),
+              SizedBox(height: kDefaultPadding * 2),
+              // Menu Items
+              SideMenuItem(
+                press: () {},
+                title: "Inbox",
+                iconSrc: "assets/Icons/Inbox.svg",
+                isActive: true,
+                itemCount: 3,
+              ),
+              SideMenuItem(
+                press: () {},
+                title: "Sent",
+                iconSrc: "assets/Icons/Send.svg",
+                isActive: false,
+              ),
+              SideMenuItem(
+                press: () {},
+                title: "Drafts",
+                iconSrc: "assets/Icons/File.svg",
+                isActive: false,
+              ),
+              SideMenuItem(
+                press: () {},
+                title: "Deleted",
+                iconSrc: "assets/Icons/Trash.svg",
+                isActive: false,
+                showBorder: false,
+              ),
+
+            ],
+          ),
+        ),
+      ),
+    );
+  }
+}

+ 59 - 0
lib/views/side_menu_item.dart

@@ -0,0 +1,59 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_clock/model/constants.dart';
+
+class SideMenuItem extends StatelessWidget {
+  const SideMenuItem({
+    Key key,
+    this.isActive,
+    this.isHover = false,
+    this.itemCount,
+    this.showBorder = true,
+    @required this.iconSrc,
+    @required this.title,
+    @required this.press,
+  }) : super(key: key);
+
+  final bool isActive, isHover, showBorder;
+  final int itemCount;
+  final String iconSrc, title;
+  final VoidCallback press;
+
+  @override
+  Widget build(BuildContext context) {
+    return Padding(
+      padding: const EdgeInsets.only(top: kDefaultPadding),
+      child: InkWell(
+        onTap: press,
+        child: Row(
+          children: [
+            SizedBox(width: kDefaultPadding / 4),
+            Expanded(
+              child: Container(
+                padding: EdgeInsets.only(bottom: 15, right: 5),
+                decoration: showBorder
+                    ? BoxDecoration(
+                        border: Border(
+                          bottom: BorderSide(color: Color(0xFFDFE2EF)),
+                        ),
+                      )
+                    : null,
+                child: Row(
+                  children: [
+                    SizedBox(width: kDefaultPadding * 0.75),
+                    Text(
+                      title,
+                      style: Theme.of(context).textTheme.button.copyWith(
+                            color:
+                                (isActive || isHover) ? kTextColor : kGrayColor,
+                          ),
+                    ),
+                  ],
+                ),
+              ),
+            ),
+          ],
+        ),
+      ),
+    );
+  }
+}