|
|
@@ -21,8 +21,6 @@ class HomePage extends StatefulWidget {
|
|
|
_MineViewPageState createState() => _MineViewPageState();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
class _MineViewPageState extends State<HomePage> {
|
|
|
List items = [
|
|
|
{"name": "今日维保任务", "num": 0},
|
|
|
@@ -81,195 +79,218 @@ class _MineViewPageState extends State<HomePage> {
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- return Scaffold(
|
|
|
- extendBodyBehindAppBar: true,
|
|
|
- appBar: AppBar(
|
|
|
- shadowColor: Colors.transparent,
|
|
|
- backgroundColor: Colors.transparent,
|
|
|
- systemOverlayStyle: SystemUiOverlayStyle.light
|
|
|
- .copyWith(statusBarColor: Colors.transparent),
|
|
|
- // title: Text(user != null ? user["nickname"] : "",style:TextStyle(color: Colors.white),),
|
|
|
- centerTitle: true,
|
|
|
- elevation: 0.0,
|
|
|
- toolbarHeight: 0,
|
|
|
- ),
|
|
|
- backgroundColor: const Color(0xfff4f6ff),
|
|
|
- body: Column(
|
|
|
- children: [
|
|
|
- Container(
|
|
|
- padding: EdgeInsets.only(
|
|
|
- left: 15,
|
|
|
- right: 15,
|
|
|
- top: MediaQuery.of(context).padding.top + 10),
|
|
|
- height: MediaQuery.of(context).size.width * 0.53,
|
|
|
- decoration: BoxDecoration(
|
|
|
- image: DecorationImage(
|
|
|
- image: AssetImage("images/home_bg.jpg"), fit: BoxFit.cover),
|
|
|
- ),
|
|
|
- child: Column(
|
|
|
- children: [
|
|
|
- Row(
|
|
|
- mainAxisAlignment: MainAxisAlignment.end,
|
|
|
- children: [
|
|
|
- IconButton(
|
|
|
- icon: Icon(Icons.settings),
|
|
|
- color: Colors.white,
|
|
|
- onPressed: () => showToast("text"),
|
|
|
- ),
|
|
|
- ],
|
|
|
+
|
|
|
+
|
|
|
+ DateTime? _dateTime;//上次点击的时间
|
|
|
+
|
|
|
+ return WillPopScope(
|
|
|
+ child: Scaffold(
|
|
|
+ extendBodyBehindAppBar: true,
|
|
|
+ appBar: AppBar(
|
|
|
+ shadowColor: Colors.transparent,
|
|
|
+ backgroundColor: Colors.transparent,
|
|
|
+ systemOverlayStyle: SystemUiOverlayStyle.light
|
|
|
+ .copyWith(statusBarColor: Colors.transparent),
|
|
|
+ // title: Text(user != null ? user["nickname"] : "",style:TextStyle(color: Colors.white),),
|
|
|
+ centerTitle: true,
|
|
|
+ elevation: 0.0,
|
|
|
+ toolbarHeight: 0,
|
|
|
+ ),
|
|
|
+ backgroundColor: const Color(0xfff4f6ff),
|
|
|
+ body: Column(
|
|
|
+ children: [
|
|
|
+ Container(
|
|
|
+ padding: EdgeInsets.only(
|
|
|
+ left: 15,
|
|
|
+ right: 15,
|
|
|
+ top: MediaQuery.of(context).padding.top),
|
|
|
+ height: MediaQuery.of(context).size.width * 0.53,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ image: DecorationImage(
|
|
|
+ image: AssetImage("images/home_bg.jpg"),
|
|
|
+ fit: BoxFit.cover),
|
|
|
),
|
|
|
- Row(
|
|
|
+ child: Column(
|
|
|
children: [
|
|
|
- Image.asset(
|
|
|
- "images/head.png",
|
|
|
- width: 40,
|
|
|
- height: 40,
|
|
|
- ),
|
|
|
- SizedBox(width: 10),
|
|
|
- Text(
|
|
|
- StoreHelper.getStorage(ConstantString.name),
|
|
|
- style: TextStyle(
|
|
|
+ Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.end,
|
|
|
+ children: [
|
|
|
+ IconButton(
|
|
|
+ icon: Icon(Icons.settings),
|
|
|
color: Colors.white,
|
|
|
- fontWeight: FontWeight.bold,
|
|
|
- fontSize: 15),
|
|
|
- )
|
|
|
- ],
|
|
|
- ),
|
|
|
- SizedBox(height: 20),
|
|
|
- Row(
|
|
|
- children: [
|
|
|
- SizedBox(width: 50),
|
|
|
- Text(StoreHelper.getStorage(ConstantString.phone),
|
|
|
- style: TextStyle(
|
|
|
- color: Colors.white,
|
|
|
- fontWeight: FontWeight.bold,
|
|
|
- fontSize: 18))
|
|
|
- ],
|
|
|
- ),
|
|
|
- SizedBox(height: 10),
|
|
|
- Row(
|
|
|
- children: [
|
|
|
- SizedBox(width: 50),
|
|
|
- Text(StoreHelper.getStorage(ConstantString.orgName),
|
|
|
- style:
|
|
|
- TextStyle(color: Color(0xffaaaaaa), fontSize: 15))
|
|
|
- ],
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
- Container(
|
|
|
- padding: EdgeInsets.all(10),
|
|
|
- margin: EdgeInsets.all(15),
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: Colors.white, borderRadius: BorderRadius.circular(10)),
|
|
|
- child: Column(
|
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
- children: [
|
|
|
- SizedBox(height: 15),
|
|
|
- Container(
|
|
|
- width: double.infinity,
|
|
|
- height: 40,
|
|
|
- alignment: Alignment.center,
|
|
|
- decoration: BoxDecoration(
|
|
|
- color:
|
|
|
- alarmCount > 0 ? Colors.red : Color(0xff74b900),
|
|
|
- borderRadius: BorderRadius.circular(10)),
|
|
|
- child: Text(
|
|
|
- alarmCount > 0 ? '今日告警数量:$alarmCount' : "当前设备运行正常",
|
|
|
- style: TextStyle(
|
|
|
- color: Color(0xffffffff), fontSize: 15))),
|
|
|
- SizedBox(
|
|
|
- height: 20,
|
|
|
- ),
|
|
|
- Text("待办任务",
|
|
|
- style: TextStyle(color: Color(0xff000000), fontSize: 18)),
|
|
|
- SizedBox(
|
|
|
- height: 10,
|
|
|
- ),
|
|
|
- GridView.builder(
|
|
|
- shrinkWrap: true,
|
|
|
- padding: const EdgeInsets.only(
|
|
|
- top: 10,
|
|
|
- ),
|
|
|
- gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
- crossAxisCount: 1,
|
|
|
- mainAxisSpacing: 10,
|
|
|
- crossAxisSpacing: 10,
|
|
|
- childAspectRatio: MediaQuery.of(context).size.width / 30,
|
|
|
- ),
|
|
|
- itemBuilder: (context, index) {
|
|
|
- Map item = items[index];
|
|
|
- return Row(
|
|
|
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
+ onPressed: () => {},
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ SizedBox(width: 5),
|
|
|
+ Row(
|
|
|
children: [
|
|
|
- Text(item["name"],
|
|
|
+ Image.asset(
|
|
|
+ "images/head.png",
|
|
|
+ width: 35,
|
|
|
+ height: 35,
|
|
|
+ ),
|
|
|
+ SizedBox(width: 10),
|
|
|
+ Text(
|
|
|
+ StoreHelper.getStorage(ConstantString.name),
|
|
|
+ style: TextStyle(
|
|
|
+ color: Colors.white,
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
+ fontSize: 15),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ SizedBox(height: 5),
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ SizedBox(width: 45),
|
|
|
+ Text(StoreHelper.getStorage(ConstantString.phone),
|
|
|
style: TextStyle(
|
|
|
- color: Color(0xff000000), fontSize: 13)),
|
|
|
- Text(item["num"].toString(),
|
|
|
+ color: Colors.white,
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
+ fontSize: 20))
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ SizedBox(height: 6),
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ SizedBox(width: 45),
|
|
|
+ Text(StoreHelper.getStorage(ConstantString.orgName),
|
|
|
style: TextStyle(
|
|
|
- color: Color(0xff000000), fontSize: 13))
|
|
|
+ color: Color(0xFFB7CAFF), fontSize: 14))
|
|
|
],
|
|
|
- );
|
|
|
- },
|
|
|
- itemCount: items.length,
|
|
|
- )
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
- Container(
|
|
|
- margin: EdgeInsets.only(left: 15, right: 15),
|
|
|
- decoration:
|
|
|
- BoxDecoration(borderRadius: BorderRadius.circular(10)),
|
|
|
- child: Column(
|
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
- children: [
|
|
|
- GridView.builder(
|
|
|
- shrinkWrap: true,
|
|
|
- padding: const EdgeInsets.only(
|
|
|
- top: 0,
|
|
|
- ),
|
|
|
- gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
- crossAxisCount: 3,
|
|
|
- mainAxisSpacing: 10,
|
|
|
- crossAxisSpacing: 10,
|
|
|
- childAspectRatio:
|
|
|
- (MediaQuery.of(context).size.width / 3 - 60 / 3) /
|
|
|
- 120,
|
|
|
- ),
|
|
|
- itemBuilder: (context, index) {
|
|
|
- Map item = icons[index];
|
|
|
- return GestureDetector(
|
|
|
- onTap: () => Navigator.pushNamed(context, item['jump']),
|
|
|
- child: Container(
|
|
|
- padding: EdgeInsets.all(5),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ padding: EdgeInsets.all(10),
|
|
|
+ margin: EdgeInsets.all(15),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: Colors.white,
|
|
|
+ borderRadius: BorderRadius.circular(10)),
|
|
|
+ child: Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ SizedBox(height: 15),
|
|
|
+ Container(
|
|
|
+ width: double.infinity,
|
|
|
+ height: 40,
|
|
|
+ alignment: Alignment.center,
|
|
|
decoration: BoxDecoration(
|
|
|
- color: Color(0xffffffff),
|
|
|
+ color: alarmCount > 0
|
|
|
+ ? Colors.red
|
|
|
+ : Color(0xff74b900),
|
|
|
borderRadius: BorderRadius.circular(10)),
|
|
|
- child: Column(
|
|
|
- crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ child: Text(
|
|
|
+ alarmCount > 0
|
|
|
+ ? '今日告警数量:$alarmCount'
|
|
|
+ : "当前设备运行正常",
|
|
|
+ style: TextStyle(
|
|
|
+ color: Color(0xffffffff), fontSize: 15))),
|
|
|
+ SizedBox(
|
|
|
+ height: 20,
|
|
|
+ ),
|
|
|
+ Text("待办任务",
|
|
|
+ style: TextStyle(
|
|
|
+ color: Color(0xff000000), fontSize: 18)),
|
|
|
+ SizedBox(
|
|
|
+ height: 10,
|
|
|
+ ),
|
|
|
+ GridView.builder(
|
|
|
+ shrinkWrap: true,
|
|
|
+ padding: const EdgeInsets.only(
|
|
|
+ top: 10,
|
|
|
+ ),
|
|
|
+ gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
+ crossAxisCount: 1,
|
|
|
+ mainAxisSpacing: 10,
|
|
|
+ crossAxisSpacing: 10,
|
|
|
+ childAspectRatio:
|
|
|
+ MediaQuery.of(context).size.width / 30,
|
|
|
+ ),
|
|
|
+ itemBuilder: (context, index) {
|
|
|
+ Map item = items[index];
|
|
|
+ return Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
children: [
|
|
|
- Image.asset(
|
|
|
- item["image"],
|
|
|
- width: 60,
|
|
|
- height: 60,
|
|
|
- ),
|
|
|
- SizedBox(height: 10),
|
|
|
- Text(item["name"].toString(),
|
|
|
+ Text(item["name"],
|
|
|
+ style: TextStyle(
|
|
|
+ color: Color(0xff000000), fontSize: 13)),
|
|
|
+ Text(item["num"].toString(),
|
|
|
style: TextStyle(
|
|
|
color: Color(0xff000000), fontSize: 13))
|
|
|
],
|
|
|
- ),
|
|
|
+ );
|
|
|
+ },
|
|
|
+ itemCount: items.length,
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(left: 15, right: 15),
|
|
|
+ decoration:
|
|
|
+ BoxDecoration(borderRadius: BorderRadius.circular(10)),
|
|
|
+ child: Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ GridView.builder(
|
|
|
+ shrinkWrap: true,
|
|
|
+ padding: const EdgeInsets.only(
|
|
|
+ top: 0,
|
|
|
),
|
|
|
- );
|
|
|
- },
|
|
|
- itemCount: icons.length,
|
|
|
- )
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
- ],
|
|
|
- ));
|
|
|
+ gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
+ crossAxisCount: 3,
|
|
|
+ mainAxisSpacing: 10,
|
|
|
+ crossAxisSpacing: 10,
|
|
|
+ childAspectRatio:
|
|
|
+ (MediaQuery.of(context).size.width / 3 - 60 / 3) /
|
|
|
+ 120,
|
|
|
+ ),
|
|
|
+ itemBuilder: (context, index) {
|
|
|
+ Map item = icons[index];
|
|
|
+ return GestureDetector(
|
|
|
+ onTap: () =>
|
|
|
+ Navigator.pushNamed(context, item['jump']),
|
|
|
+ child: Container(
|
|
|
+ padding: EdgeInsets.all(5),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: Color(0xffffffff),
|
|
|
+ borderRadius: BorderRadius.circular(10)),
|
|
|
+ child: Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ children: [
|
|
|
+ Image.asset(
|
|
|
+ item["image"],
|
|
|
+ width: 60,
|
|
|
+ height: 60,
|
|
|
+ ),
|
|
|
+ SizedBox(height: 10),
|
|
|
+ Text(item["name"].toString(),
|
|
|
+ style: TextStyle(
|
|
|
+ color: Color(0xff000000),
|
|
|
+ fontSize: 13))
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ },
|
|
|
+ itemCount: icons.length,
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ )),
|
|
|
+ onWillPop: () async{
|
|
|
+ if(_dateTime == null || DateTime.now().difference(_dateTime!) > const Duration(seconds: 1)){
|
|
|
+ _dateTime = DateTime.now();
|
|
|
+ showToast('再按一次退出');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ });
|
|
|
}
|
|
|
}
|