import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:hyzp_ybqx/components/commonFun.dart';

import 'LoginTabsWidget.dart';

const pageData = {
  "discountStatus": 2,
  "subscribeStatus": "0",
  "title": "限时免费",
  "subTitle": "活动时间9月1日-9月30日",
  "packageList": [
    {"id": 23, "desc": "月度订阅", "dealPrice": 10, "originPrice": 50, "recommand": 1},
    {"id": 33, "desc": "半年订阅", "dealPrice": 56, "originPrice": 280, "recommand": 0},
    {"id": 56, "desc": "年度订阅", "dealPrice": 108, "originPrice": 540, "recommand": 0}
  ]
};

class LoginTabs2 extends StatefulWidget {
  @override
  createState() => new LoginTabs2State();
}

// ScreenUtil().statusBarHeight + ScreenUtil().setHeight(144) + ScreenUtil().setHeight(348)
// + ScreenUtil().setHeight(36) + height: ScreenUtil().setHeight(166) + ScreenUtil().setHeight(17)
// + ScreenUtil().setHeight(826)
class LoginTabs2State extends State<LoginTabs2> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: PreferredSize(child: AppBar(), preferredSize: Size.fromHeight(0)),
      //使用 SingleChildScrollView 包装一下，否则键盘弹出时会报错空间溢出
      body: SingleChildScrollView(
        child: Column(
          children: <Widget>[
            Container(
              height: ScreenUtil().screenHeight -
                  ScreenUtil().statusBarHeight -
                  (Platform.isAndroid ? ScreenUtil().bottomBarHeight : 0),
              width: ScreenUtil().screenWidth,
              decoration: BoxDecoration(
                  image: DecorationImage(
                      image: AssetImage("assets/images/背景图.png"), fit: BoxFit.cover)),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.start,
                // alignment: WrapAlignment.center,
                // crossAxisAlignment: WrapCrossAlignment.center,
                // runSpacing: 9.0,
                children: <Widget>[
                  Container(
                    height: ScreenUtil().setHeight(144),
                    //padding: EdgeInsets.only(top: ScreenUtil().setHeight(10)),
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      mainAxisAlignment: MainAxisAlignment.start,
                      children: (() {
                        if (Platform.isAndroid) {
                          return [
                            IconButton(
                              onPressed: () {
                                //Navigator.pop(context);
                                SystemNavigator.pop(); //退出App
                              },
                              icon:
                                  const Icon(Icons.close, color: Colors.white),
                            )
                          ];
                        }
                        return <Widget>[];
                      })(),
                    ),
                  ),
                  Center(
                    child: Container(
                      margin: EdgeInsets.only(top: ScreenUtil().setHeight(0)),
                      width: ScreenUtil().setWidth(490), //单位px，
                      height: ScreenUtil().setHeight(348),
                      //child: Image.asset('assets/images/user.png', fit: BoxFit.cover),
                      child: Image.asset('assets/images/图层 2.png', fit: BoxFit.fitHeight),
                    ),
                  ),
                  SizedBox(height: ScreenUtil().setHeight(36)),
                  Container(
                    height: ScreenUtil().setHeight(166),
                    margin: EdgeInsets.all(0),
                    child: RichText(
                      maxLines: 2,
                      textAlign: TextAlign.center,
                      text: TextSpan(children: [
                        TextSpan(
                            // text: '宜宾市翠屏黑烟车',
                            text: qx_name_long + '黑烟车',
                            style: TextStyle(
                                fontSize: 26.0, color: Colors.white, fontWeight: FontWeight.bold)),
                        TextSpan(
                            text: '抓拍系统',
                            style: TextStyle(
                                fontSize: 26.0,
                                color: Color.fromRGBO(49, 216, 123, 1),
                                fontWeight: FontWeight.bold)),
                        TextSpan(
                            // text: '\n' + copyright_info_PinYin,
                            text: copyright_info_PinYin.isEmpty
                                ? '\nBLACK SMOKE CAR CAPTURE SYSTEM'
                                : ('\n' + copyright_info_PinYin),
                            style:
                                TextStyle(fontSize: 11.0, color: Color.fromRGBO(101, 117, 142, 1))),
                      ]),
                    ),
                  ),
                  SizedBox(height: ScreenUtil().setHeight(17)),
                  Container(
                    height: ScreenUtil().setHeight(945),
                    child: LoginTabsWidget(),
                  ),
                  Container(color: Colors.transparent, height: ScreenUtil().setHeight(30)),
                  Container(
                    color: Colors.transparent,
                    height: ScreenUtil().setHeight(130), //不能超过133，否则有些手机会越界
                    child: Text(
                      copyright_info,
                      maxLines: 2,
                      textAlign: TextAlign.center,
                      style: TextStyle(
                          fontSize: 16.0,
                          color: Color.fromRGBO(106, 144, 204, 1),
                          fontWeight: FontWeight.bold),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
