Files
fengshui_compass/lib/pages/pan_page.dart
2022-06-27 09:51:30 +08:00

1037 lines
34 KiB
Dart

import 'package:flutter/material.dart';
import '../models/qimen_result.dart';
class PanPage extends StatelessWidget {
final String solarDate;
final String lunarDate;
final String jieqi;
final String dunju;
final String bazi;
final String zhishi;
final String zhifu;
final List<String> kong;
final List<QimenResult> qimenResult;
const PanPage(
{Key key,
this.solarDate,
this.lunarDate,
this.jieqi,
this.dunju,
this.bazi,
this.zhishi,
this.zhifu,
this.kong,
this.qimenResult})
: super(key: key);
List<Widget> getWidgetList() {
return qimenResult
.asMap()
.entries
.map((entry) => getItemContainer(entry))
.toList();
}
Widget getItemContainer(MapEntry<int, QimenResult> entry) {
// 3行2列 放入天地星门神, 中间什么都不放
// 颜色计算 8*5 一共有40个位置要设置颜色
// key
// 0 1 2
// 3 _ 5
// 6 7 8
Color skyColor = Colors.black;
Color earthColor = Colors.black;
Color starColor = Colors.black;
Color gateColor = Colors.black;
Color godColor = Colors.black;
if (entry.key == 0) {
if (entry.value.sky == '' ||
entry.value.sky == '' ||
entry.value.sky == '') {
skyColor = Colors.red[900];
} else if (entry.value.sky == '' ||
entry.value.sky == '' ||
entry.value.sky == '') {
skyColor = Colors.green[300];
} else {
skyColor = Colors.black;
}
if (entry.value.earth == '' ||
entry.value.earth == '' ||
entry.value.earth == '') {
earthColor = Colors.red[900];
} else if (entry.value.earth == '' ||
entry.value.earth == '' ||
entry.value.earth == '') {
earthColor = Colors.green[300];
} else {
earthColor = Colors.black;
}
if (entry.value.god == '') {
godColor = Colors.yellow[600];
} else {
godColor = Colors.blue;
}
if (entry.value.gate == '' || entry.value.gate == '') {
gateColor = Colors.brown;
} else if (entry.value.gate == zhishi[2]) {
gateColor = Colors.red;
} else {
gateColor = Colors.purple;
}
if (entry.value.star == zhifu[3]) {
starColor = Colors.red;
} else {
starColor = Colors.black;
}
return Container(
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
entry.value.god,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: godColor),
),
Text(
entry.value.star,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: starColor),
),
Text(
entry.value.gate,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: gateColor),
)
],
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
const Text(' '),
Text(
entry.value.sky,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: skyColor),
),
Text(
entry.value.earth,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: earthColor),
)
],
)
],
));
} else if (entry.key == 1) {
if (entry.value.sky == '') {
skyColor = Colors.red[900];
} else if (entry.value.sky == '' ||
entry.value.sky == '' ||
entry.value.sky == '') {
skyColor = Colors.green[300];
} else {
skyColor = Colors.black;
}
if (entry.value.earth == '') {
earthColor = Colors.red[900];
} else if (entry.value.earth == '' ||
entry.value.earth == '' ||
entry.value.earth == '') {
earthColor = Colors.green[300];
} else {
earthColor = Colors.black;
}
if (entry.value.god == '') {
godColor = Colors.yellow[600];
} else {
godColor = Colors.blue;
}
if (entry.value.gate == '') {
gateColor = Colors.brown;
} else if (entry.value.gate == zhishi[2]) {
gateColor = Colors.red;
} else {
gateColor = Colors.purple;
}
if (entry.value.star == zhifu[3]) {
starColor = Colors.red;
} else {
starColor = Colors.black;
}
return Container(
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
entry.value.god,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: godColor),
),
Text(
entry.value.star,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: starColor),
),
Text(
entry.value.gate,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: gateColor),
)
],
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
const Text(' '),
Text(
entry.value.sky,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: skyColor),
),
Text(
entry.value.earth,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: earthColor),
)
],
)
],
));
} else if (entry.key == 2) {
if (entry.value.sky == '' ||
entry.value.sky == '' ||
entry.value.sky == '') {
skyColor = Colors.red[900];
} else if (entry.value.sky == '' ||
entry.value.sky == '') {
skyColor = Colors.green[300];
} else {
skyColor = Colors.black;
}
if (entry.value.earth == '' ||
entry.value.earth == '' ||
entry.value.earth == '') {
earthColor = Colors.red[900];
} else if (entry.value.earth == '' ||
entry.value.earth == '') {
earthColor = Colors.green[300];
} else {
earthColor = Colors.black;
}
if (entry.value.god == '') {
godColor = Colors.yellow[600];
} else {
godColor = Colors.blue;
}
if (entry.value.gate == '' || entry.value.gate == '') {
gateColor = Colors.brown;
} else if (entry.value.gate == zhishi[2]) {
gateColor = Colors.red;
} else {
gateColor = Colors.purple;
}
if (entry.value.star == zhifu[3]) {
starColor = Colors.red;
} else {
starColor = Colors.black;
}
return Container(
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
entry.value.god,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: godColor),
),
Text(
entry.value.star,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: starColor),
),
Text(
entry.value.gate,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: gateColor),
)
],
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
const Text(' '),
Text(
entry.value.sky,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: skyColor),
),
Text(
entry.value.earth,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: earthColor),
)
],
)
],
));
} else if (entry.key == 3) {
if (entry.value.sky == '') {
skyColor = Colors.red[900];
} else if (entry.value.sky == '' ||
entry.value.sky == '') {
skyColor = Colors.green[300];
} else {
skyColor = Colors.black;
}
if (entry.value.earth == '') {
earthColor = Colors.red[900];
} else if (entry.value.earth == '' ||
entry.value.earth == '') {
earthColor = Colors.green[300];
} else {
earthColor = Colors.black;
}
if (entry.value.god == '') {
godColor = Colors.yellow[600];
} else {
godColor = Colors.blue;
}
if (entry.value.gate == '' || entry.value.gate == '') {
gateColor = Colors.brown;
} else if (entry.value.gate == zhishi[2]) {
gateColor = Colors.red;
} else {
gateColor = Colors.purple;
}
if (entry.value.star == zhifu[3]) {
starColor = Colors.red;
} else {
starColor = Colors.black;
}
return Container(
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
entry.value.god,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: godColor),
),
Text(
entry.value.star,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: starColor),
),
Text(
entry.value.gate,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: gateColor),
)
],
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
const Text(' '),
Text(
entry.value.sky,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: skyColor),
),
Text(
entry.value.earth,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: earthColor),
)
],
)
],
));
} else if (entry.key == 4) {
return Container(
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: const [Text(' '), Text(' '), Text(' ')],
),
Column(
children: const [Text(' '), Text(' '), Text(' ')],
)
],
));
} else if (entry.key == 5) {
if (entry.value.sky == '' ||
entry.value.sky == '' ||
entry.value.sky == '') {
skyColor = Colors.green[300];
} else {
skyColor = Colors.black;
}
if (entry.value.earth == '' ||
entry.value.earth == '' ||
entry.value.earth == '') {
earthColor = Colors.green[300];
} else {
earthColor = Colors.black;
}
if (entry.value.god == '') {
godColor = Colors.yellow[600];
} else {
godColor = Colors.blue;
}
if (entry.value.gate == '') {
gateColor = Colors.brown;
} else if (entry.value.gate == zhishi[2]) {
gateColor = Colors.red;
} else {
gateColor = Colors.purple;
}
if (entry.value.star == zhifu[3]) {
starColor = Colors.red;
} else {
starColor = Colors.black;
}
return Container(
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
entry.value.god,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: godColor),
),
Text(
entry.value.star,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: starColor),
),
Text(
entry.value.gate,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: gateColor),
)
],
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
const Text(' '),
Text(
entry.value.sky,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: skyColor),
),
Text(
entry.value.earth,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: earthColor),
)
],
)
],
));
} else if (entry.key == 6) {
if (entry.value.sky == '' || entry.value.sky == ''||entry.value.sky == '') {
skyColor = Colors.red[900];
} else if (entry.value.sky == '' ||
entry.value.sky == '' || entry.value.sky == '') {
skyColor = Colors.green[300];
} else {
skyColor = Colors.black;
}
if (entry.value.earth == ''||entry.value.earth == ''||entry.value.earth == '') {
earthColor = Colors.red[900];
} else if (entry.value.earth == '' ||
entry.value.earth == '' || entry.value.earth == '') {
earthColor = Colors.green[300];
} else {
earthColor = Colors.black;
}
if (entry.value.god == '') {
godColor = Colors.yellow[600];
} else {
godColor = Colors.blue;
}
if (entry.value.gate == '' || entry.value.gate == '') {
gateColor = Colors.brown;
} else if (entry.value.gate == zhishi[2]) {
gateColor = Colors.red;
} else {
gateColor = Colors.purple;
}
if (entry.value.star == zhifu[3]) {
starColor = Colors.red;
} else {
starColor = Colors.black;
}
return Container(
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
entry.value.god,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: godColor),
),
Text(
entry.value.star,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: starColor),
),
Text(
entry.value.gate,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: gateColor),
)
],
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
const Text(' '),
Text(
entry.value.sky,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: skyColor),
),
Text(
entry.value.earth,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: earthColor),
)
],
)
],
));
} else if (entry.key == 7) {
if (entry.value.sky == '' ||
entry.value.sky == '') {
skyColor = Colors.green[300];
} else {
skyColor = Colors.black;
}
if (entry.value.earth == '' ||
entry.value.earth == '') {
earthColor = Colors.green[300];
} else {
earthColor = Colors.black;
}
if (entry.value.god == '') {
godColor = Colors.yellow[600];
} else {
godColor = Colors.blue;
}
if (entry.value.gate == '' || entry.value.gate == '') {
gateColor = Colors.brown;
} else if (entry.value.gate == zhishi[2]) {
gateColor = Colors.red;
} else {
gateColor = Colors.purple;
}
if (entry.value.star == zhifu[3]) {
starColor = Colors.red;
} else {
starColor = Colors.black;
}
return Container(
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
entry.value.god,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: godColor),
),
Text(
entry.value.star,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: starColor),
),
Text(
entry.value.gate,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: gateColor),
)
],
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
const Text(' '),
Text(
entry.value.sky,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: skyColor),
),
Text(
entry.value.earth,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: earthColor),
)
],
)
],
));
} else if (entry.key == 8) {
if (entry.value.sky == ''||entry.value.sky == ''||entry.value.sky == '') {
skyColor = Colors.red[900];
} else if (entry.value.sky == '' ||
entry.value.sky == '') {
skyColor = Colors.green[300];
} else {
skyColor = Colors.black;
}
if (entry.value.earth == ''||entry.value.earth == ''||entry.value.earth == '') {
earthColor = Colors.red[900];
} else if (entry.value.earth == '' ||
entry.value.earth == '') {
earthColor = Colors.green[300];
} else {
earthColor = Colors.black;
}
if (entry.value.god == '') {
godColor = Colors.yellow[600];
} else {
godColor = Colors.blue;
}
if (entry.value.gate == '') {
gateColor = Colors.brown;
} else if (entry.value.gate == zhishi[2]) {
gateColor = Colors.red;
} else {
gateColor = Colors.purple;
}
if (entry.value.star == zhifu[3]) {
starColor = Colors.red;
} else {
starColor = Colors.black;
}
return Container(
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
entry.value.god,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: godColor),
),
Text(
entry.value.star,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: starColor),
),
Text(
entry.value.gate,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: gateColor),
)
],
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
const Text(' '),
Text(
entry.value.sky,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: skyColor),
),
Text(
entry.value.earth,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: earthColor),
)
],
)
],
));
}
}
@override
Widget build(BuildContext context) {
return Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/bg1.png"), fit: BoxFit.cover)),
child: Scaffold(
// backgroundColor: Colors.transparent,
appBar: AppBar(
// backgroundColor: Colors.transparent,
// elevation: 0,
centerTitle: true,
title: const Text(
'在线起局',
style: TextStyle(color: Colors.white),
),
),
body: SafeArea(
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(top: 45, left: 60, bottom: 60),
child: Column(
children: [
Row(
children: [
const Padding(
child: Text(
"公历:",
style: TextStyle(fontSize: 22),
),
padding:
EdgeInsets.only(left: 15, right: 15)),
Expanded(
child: Text(solarDate,
style: const TextStyle(fontSize: 22)))
],
),
Row(
children: [
const Padding(
child: Text(
"农历:",
style: TextStyle(fontSize: 22),
),
padding:
EdgeInsets.only(left: 15, right: 15)),
Expanded(
child: Text(lunarDate,
style: const TextStyle(fontSize: 22)))
],
),
Row(
children: [
const Padding(
child: Text(
"节气:",
style: TextStyle(fontSize: 22),
),
padding:
EdgeInsets.only(left: 15, right: 15)),
Expanded(
child: Text(jieqi,
style: const TextStyle(fontSize: 22)))
],
),
Row(
children: [
const Padding(
child: Text("遁局:",
style: TextStyle(fontSize: 22)),
padding:
EdgeInsets.only(left: 15, right: 15)),
Expanded(
child: Text(dunju,
style: const TextStyle(fontSize: 22)))
],
),
Row(
children: [
const Padding(
child: Text("干支:",
style: TextStyle(fontSize: 22)),
padding:
EdgeInsets.only(left: 15, right: 15)),
Expanded(
child: Text(bazi,
style: const TextStyle(fontSize: 22)))
],
),
Row(
children: [
const Padding(
child: Text("值符:",
style: TextStyle(fontSize: 22)),
padding:
EdgeInsets.only(left: 15, right: 15)),
Expanded(
child: Text(zhifu,
style: const TextStyle(fontSize: 22)))
],
),
Row(
children: [
const Padding(
child: Text("值使:",
style: TextStyle(fontSize: 22)),
padding:
EdgeInsets.only(left: 15, right: 15)),
Expanded(
child: Text(zhishi,
style: const TextStyle(fontSize: 22)))
],
),
],
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Spacer(),
Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 185,
child: Center(
child: Text(kong[5]),
)),
Container(
width: 185,
child: Center(
child: Text(kong[6]),
)),
Container(
width: 185,
child: Center(
child: Text(kong[7]),
)),
],
),
Row(
children: [
Container(
height: 550,
child: Column(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
Text(kong[4]),
Text(kong[3]),
Text(kong[2]),
],
),
),
Container(
width: 550,
height: 550,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
"assets/images/pan.png"),
fit: BoxFit.contain)),
child: GridView.count(
//水平子Widget之间间距
crossAxisSpacing: 10.0,
//垂直子Widget之间间距
mainAxisSpacing: 10.0,
//GridView内边距
padding: EdgeInsets.all(10.0),
//一行的Widget数量
crossAxisCount: 3,
//子Widget宽高比例
childAspectRatio: 1.0,
//子Widget列表
children: getWidgetList(),
),
),
Container(
height: 550,
child: Column(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
Text(kong[8]),
Text(kong[9]),
Text(kong[10]),
],
),
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 185,
child: Center(
child: Text(kong[1]),
)),
Container(
width: 185,
child: Center(
child: Text(kong[0]),
)),
Container(
width: 185,
child: Center(
child: Text(kong[11]),
)),
],
)
],
),
Spacer(),
],
)
],
),
),
)));
}
}