Browse Source

继续完成我的

liuyuqi-dellpc 2 years ago
parent
commit
a46644fbca

BIN
assets/images/about.png


BIN
assets/images/head.jpg


BIN
assets/images/setting.png


+ 2 - 2
lib/index_page.dart

@@ -13,8 +13,8 @@ class IndexPage extends StatefulWidget {
 class _IndexPageState extends State<IndexPage> {
   int navIndex = 0;
   List<Widget> pages = [
-    HomePage(url: "https://xw.qq.com/act/qgfeiyan"),
-    //http://m.look.360.cn/subject/400?sign=360_6aa05217&stab=0
+    HomePage(url: "http://m.look.360.cn/subject/400?sign=360_6aa05217&stab=0"),
+    //https://xw.qq.com/act/qgfeiyan
     // https://www.ipe.org.cn/MapGZBD/XQMap.html
     const TrackPage(),
     const MinePage(),

+ 1 - 2
lib/main.dart

@@ -35,8 +35,7 @@ class MyApp extends StatelessWidget {
           primarySwatch: Colors.blue,
         ),
         debugShowCheckedModeBanner: false,
-        // home: isLogin ? HomePage(url: "https://baidu.com") : LoginPage(),
-        home: isLogin ? IndexPage() : WelComePage(),
+        home: true ? IndexPage() : WelComePage(),
       ),
     );
   }

+ 4 - 3
lib/pages/home_page.dart

@@ -19,6 +19,7 @@ class _HomePageState extends State<HomePage> {
       children: <Widget>[
         WebView(
           initialUrl: widget.url,
+          javascriptMode: JavascriptMode.unrestricted,
           onWebViewCreated: (WebViewController web) {
             web.canGoBack().then((res) {
 //                print(res); // 是否能返回上一级
@@ -46,11 +47,11 @@ class _HomePageState extends State<HomePage> {
   _loading() {
     return _isLoading == true
         ? Container(
-            decoration: BoxDecoration(color: Colors.white),
-            child: Center(
+            decoration: const BoxDecoration(color: Colors.white),
+            child: const Center(
               child: CircularProgressIndicator(),
             ),
           )
-        : Text('');
+        : const Text('');
   }
 }

+ 188 - 12
lib/pages/mine_page.dart

@@ -1,4 +1,9 @@
 import 'package:flutter/material.dart';
+import 'package:flutter_tracker/dio/login_dao.dart';
+import 'package:flutter_tracker/model/config.dart';
+import 'package:flutter_tracker/routes/routes.dart';
+import 'package:flutter_tracker/utils/app_util.dart';
+import 'package:shared_preferences/shared_preferences.dart';
 
 class MinePage extends StatefulWidget {
   const MinePage({Key key}) : super(key: key);
@@ -8,23 +13,194 @@ class MinePage extends StatefulWidget {
 }
 
 class _MinePageState extends State<MinePage> {
+  Size get _size => MediaQuery.of(context).size;
+
   @override
   Widget build(BuildContext context) {
     return Scaffold(
-      body: Column(
-        // mainAxisAlignment: MainAxisAlignment.center,
-        // crossAxisAlignment: CrossAxisAlignment.center,
-        // verticalDirection: VerticalDirection.down,
-        children: [
-          Image.asset(
-            "assets/images/home.jpg",
-            height: 50,
-            width: 50,
+      backgroundColor: Color(0xE6E4E4),
+      body: SizedBox(
+        width: _size.width,
+        child: SingleChildScrollView(
+          child: Column(
+            crossAxisAlignment: CrossAxisAlignment.center,
+            children: [
+              Container(
+                width: _size.width,
+                color: Colors.blue,
+                child: Column(
+                  crossAxisAlignment: CrossAxisAlignment.center,
+                  children: [
+                    const SizedBox(
+                      height: 50,
+                    ),
+                    // Container(
+                    //   height: 100,
+                    //   width: 100,
+                    //   decoration: BoxDecoration(
+                    //       borderRadius: BorderRadius.circular(50)),
+                    //   child: Image.asset(
+                    //     "assets/images/head.jpg",
+                    //   ),
+                    // ),
+
+                    const Text(
+                      "网小儿",
+                      style: TextStyle(fontSize: 25),
+                    ),
+                    const SizedBox(
+                      height: 10,
+                    ),
+                    const Text("2021-11-25 10:10:10"),
+                    const SizedBox(
+                      height: 10,
+                    )
+                  ],
+                ),
+              ),
+              const SizedBox(
+                height: 10,
+              ),
+              Image.asset(
+                "assets/images/head.jpg",
+                width: 150,
+                height: 150,
+              ),
+              const SizedBox(
+                height: 10,
+              ),
+              Container(
+                width: _size.width * 0.9,
+                height: _size.width * 0.4,
+                decoration: BoxDecoration(
+                    color: Colors.white,
+                    borderRadius: BorderRadius.circular(20)),
+                child: Column(
+                  crossAxisAlignment: CrossAxisAlignment.start,
+                  children: [
+                    Container(
+                      child: Text(
+                        "更多",
+                        style: TextStyle(
+                            fontSize: 20, fontWeight: FontWeight.bold),
+                      ),
+                      margin: EdgeInsets.only(left: 10, top: 5),
+                    ),
+                    Row(
+                      children: [
+                        Expanded(
+                          child: InkWell(
+                            onTap: () {
+                              goSetting();
+                            },
+                            child: Column(
+                              children: [
+                                SizedBox(
+                                  height: 10,
+                                ),
+                                Image.asset("assets/images/setting.png"),
+                                const SizedBox(
+                                  height: 10,
+                                ),
+                                const Text("设置")
+                              ],
+                            ),
+                          ),
+                        ),
+                        Expanded(
+                          child: InkWell(
+                            onTap: () {
+                              aboutUs();
+                            },
+                            child: Column(
+                              children: [
+                                SizedBox(
+                                  height: 10,
+                                ),
+                                Image.asset("assets/images/about.png"),
+                                const SizedBox(
+                                  height: 10,
+                                ),
+                                const Text("关于我们")
+                              ],
+                            ),
+                          ),
+                        ),
+                      ],
+                    ),
+                  ],
+                ),
+              ),
+              SizedBox(
+                height: 50,
+              ),
+              Container(
+                width: 150,
+                child: InkWell(
+                  onTap: () {
+                    logout();
+                  },
+                  child: Container(
+                    width: double.infinity,
+                    height: 50,
+                    padding: EdgeInsets.only(right: 20, left: 20),
+                    decoration: BoxDecoration(
+                        gradient: const LinearGradient(colors: [
+                          ThemeColor.loignColor,
+                          ThemeColor.loignColor
+                        ]),
+                        borderRadius: BorderRadius.circular(10),
+                        boxShadow: const [
+                          BoxShadow(
+                            offset: Offset(1.0, 5.0),
+                            color: ThemeColor.loignColor,
+                            blurRadius: 5.0,
+                          )
+                        ]),
+                    child: const Center(
+                      child: Text(
+                        "退出登录",
+                        style: TextStyle(fontSize: 20, color: Colors.white),
+                      ),
+                    ),
+                  ),
+                ),
+              ),
+            ],
           ),
-          Text("网小儿"),
-          Text("2021-11-25 10:10:10"),
-        ],
+        ),
       ),
     );
   }
+
+  @override
+  void initState() {
+    super.initState();
+  }
+
+  void getUserInfo(String token) {}
+
+  void logout() async {
+    var sharedPreferences = await SharedPreferences.getInstance();
+    String token = sharedPreferences.getString("token");
+    try {
+      bool logoutResult = await LoginDao.logout(token);
+      if (logoutResult) {
+        AppUtil.buildToast("退出成功!");
+        Navigator.of(context).pushNamed(Routes.loginPage);
+      } else {
+        AppUtil.buildToast("退出异常,检测网络");
+      }
+    } catch (e) {
+      AppUtil.buildToast("退出异常" + e.toString());
+    }
+  }
+
+  void aboutUs() {
+    AppUtil.buildToast("\"关于我们\"推出中..");
+  }
+
+  void goSetting() {
+    AppUtil.buildToast("\"设置\"推出中..");
+  }
 }

+ 3 - 1
lib/pages/settings_page.dart

@@ -10,6 +10,8 @@ class SettingsPage extends StatefulWidget {
 class _SettingsPageState extends State<SettingsPage> {
   @override
   Widget build(BuildContext context) {
-    return Container();
+    return Container(
+      child: Text("设置 "),
+    );
   }
 }

+ 7 - 0
lib/utils/app_util.dart

@@ -1,4 +1,5 @@
 import 'package:flutter_screenutil/flutter_screenutil.dart';
+import 'package:fluttertoast/fluttertoast.dart';
 
 class AppUtil {
   static double height(double value) {
@@ -12,4 +13,10 @@ class AppUtil {
   static double sp(double value) {
     return ScreenUtil().setSp(value);
   }
+
+  // 居中简单弹信息框
+  static void buildToast(String str) {
+    Fluttertoast.showToast(
+        fontSize: 25, gravity: ToastGravity.CENTER, msg: str);
+  }
 }