admin
2021-11-25 70a344485bd0c9b68ac91f72ed23ec5bfa998b09
lib/ui/mine/settings.dart
@@ -2,12 +2,18 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:locations/api/http.dart';
import 'package:locations/ui/widget/nav.dart';
import 'package:locations/utils/event_bus_util.dart';
import 'package:locations/utils/push_util.dart';
import 'package:locations/utils/ui_constant.dart';
import 'package:locations/utils/ui_utils.dart';
import 'package:locations/utils/user_util.dart';
void main() {
  runApp(MyApp());
}
class MyApp extends StatelessWidget {
  // This widget is the root of your application.
@@ -15,7 +21,7 @@
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '设置',
      theme: ThemeData(primaryColor: Color(0xFFF5F5F5)),
      theme: ThemeData(primaryColor: const Color(0xFFF5F5F5)),
      home: SettingPage(title: ''),
    );
  }
@@ -44,97 +50,120 @@
  bool msg = false;
  bool ad = false;
  bool login = false;
  @override
  void initState() {
    super.initState();
    UserUtil.isLogin().then((value) {
      setState(() {
        login = value;
      });
    });
  }
  Future logout() async {
    var uid = await UserUtil.getUid();
    Map<String, dynamic>? map = await UserApiUtil.logout(context, uid);
    if (map!["code"] == 0) {
      await UserUtil.logout();
      await PushUtil.removeAlias();
      eventBus.fire(LoginEventBus(false));
      setState(() {
        login = false;
      });
    } else {
      ToastUtil.toast(map["msg"]);
    }
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Color(0xFFF5F5F5),
        body: Container(
          child: Flex(
            direction: Axis.vertical,
            children: [
              TopNavBar(title: "设置"),
              getBigItemView(
                  title: "推送免打扰",
                  content: "关闭后,21:00-09:00不接受任何推送",
                  marginTop: 14,
                  marginBottom: 1,
                  checked: msg,
                  changed: (bool value) {
                    print(value);
                    setState(() {
                      msg = value;
                    });
                  }),
              getBigItemView(
                  title: "个性化广告推荐",
                  content: "关闭后,广告数量将不变,但内容相关度会降低",
                  marginTop: 0,
                  marginBottom: 16,
                  checked: ad,
                  changed: (bool value) {
                    print(value);
                    setState(() {
                      ad = value;
                    });
                  }),
              getCommonItemView(
                  title: "清理缓存",
                  content: "551.4MB",
                  onClick: () {
                    print("清理缓存");
                  }),
              getCommonItemView(
                  title: "检查更新",
                  content: "版本号2.0.0",
                  onClick: () {
                    print("检查更新");
                  }),
              getCommonItemView(
                  title: "账户注销",
                  content: "",
                  onClick: () {
                    print("账户注销");
                  }),
              getCommonItemView(
                  title: "隐私投诉",
                  content: "",
                  onClick: () {
                    print("隐私投诉");
                  }),
              getCommonItemView(
                  title: "第三方SDK列表",
                  content: "",
                  onClick: () {
                    print("第三方SDK列表");
                  }),
              Expanded(
                child: Container(),
              ),
              Container(
                  child: Stack(
                children: [
                  InkWell(
                      onTap: () {
                        print("退出登录");
                      },
                      child: Container(
                          alignment: Alignment.center,
                          height: 48,
                          color: Colors.white,
                          child: Text(
                            "退出登录",
                            style: TextStyle(
                                color: ColorConstant.theme, fontSize: 16),
                          )))
                ],
              )),
            ],
          ),
        backgroundColor: const Color(0xFFF5F5F5),
        body: Flex(
          direction: Axis.vertical,
          children: [
            TopNavBar(title: "设置"),
            getBigItemView(
                title: "推送免打扰",
                content: "关闭后,21:00-09:00不接受任何推送",
                marginTop: 14,
                marginBottom: 1,
                checked: msg,
                changed: (bool value) {
                  print(value);
                  setState(() {
                    msg = value;
                  });
                }),
            getBigItemView(
                title: "个性化广告推荐",
                content: "关闭后,广告数量将不变,但内容相关度会降低",
                marginTop: 0,
                marginBottom: 16,
                checked: ad,
                changed: (bool value) {
                  print(value);
                  setState(() {
                    ad = value;
                  });
                }),
            getCommonItemView(
                title: "清理缓存",
                content: "551.4MB",
                onClick: () {
                  print("清理缓存");
                }),
            getCommonItemView(
                title: "检查更新",
                content: "版本号2.0.0",
                onClick: () {
                  print("检查更新");
                }),
            getCommonItemView(
                title: "账户注销",
                content: "",
                onClick: () {
                  print("账户注销");
                }),
            getCommonItemView(
                title: "隐私投诉",
                content: "",
                onClick: () {
                  print("隐私投诉");
                }),
            getCommonItemView(
                title: "第三方SDK列表",
                content: "",
                onClick: () {
                  print("第三方SDK列表");
                }),
            Expanded(
              child: Container(),
            ),
            login
                ? Container(
                    child: Stack(
                    children: [
                      InkWell(
                          onTap: () {
                            print("退出登录");
                            logout();
                          },
                          child: Container(
                              alignment: Alignment.center,
                              height: 48,
                              color: Colors.white,
                              child: const Text(
                                "退出登录",
                                style: TextStyle(
                                    color: ColorConstant.theme, fontSize: 16),
                              )))
                    ],
                  ))
                : Container(),
          ],
        ));
  }
@@ -144,21 +173,22 @@
      required GestureTapCallback onClick}) {
    return Container(
      height: 53,
      margin: EdgeInsets.fromLTRB(0, 0, 0, 1),
      margin: const EdgeInsets.fromLTRB(0, 0, 0, 1),
      color: Colors.white,
      child: InkWell(
        onTap: () {
          onClick();
        },
        child: Container(
            padding: EdgeInsets.fromLTRB(20, 0, 20, 0),
            padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
            child: Flex(
              crossAxisAlignment: CrossAxisAlignment.center,
              direction: Axis.horizontal,
              children: [
                Text(
                  title,
                  style: TextStyle(fontSize: 16, color: Color(0xFF333333)),
                  style:
                      const TextStyle(fontSize: 16, color: Color(0xFF333333)),
                ),
                Expanded(
                    child: Flex(
@@ -167,9 +197,9 @@
                  children: [
                    Container(
                      child: Text(content,
                          style: TextStyle(
                          style: const TextStyle(
                              fontSize: 14, color: Color(0xFF959595))),
                      margin: EdgeInsets.fromLTRB(0, 0, 13.5, 0),
                      margin: const EdgeInsets.fromLTRB(0, 0, 13.5, 0),
                    ),
                    Image.asset(
                      "assets/images/common/icon_array_right.png",
@@ -195,7 +225,7 @@
      margin: EdgeInsets.fromLTRB(0, marginTop, 0, marginBottom),
      color: Colors.white,
      child: Container(
          padding: EdgeInsets.fromLTRB(20, 0, 20, 0),
          padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
          child: Stack(children: [
            Flex(
              crossAxisAlignment: CrossAxisAlignment.start,
@@ -208,8 +238,9 @@
                ),
                Container(
                  child: Text(content,
                      style: TextStyle(fontSize: 9, color: Color(0xFF959595))),
                  margin: EdgeInsets.fromLTRB(0, 5, 0, 0),
                      style: const TextStyle(
                          fontSize: 9, color: Color(0xFF959595))),
                  margin: const EdgeInsets.fromLTRB(0, 5, 0, 0),
                )
              ],
            ),