时间日期选择器
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:fengshui_compass/components/my_icon.dart';
|
||||
import 'package:fengshui_compass/models/et_date.dart';
|
||||
import 'package:fengshui_compass/pages/pan_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fengshui_compass/components/my_icon.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
@ -96,6 +98,29 @@ class _BirthCalState extends State<BirthCalPage> {
|
||||
});
|
||||
}
|
||||
|
||||
_showDateTimePicker() {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHMS, onConfirm: (p) {
|
||||
setState(() {
|
||||
hour = p.hour;
|
||||
minute = p.minute;
|
||||
if (isLunar) {
|
||||
lunar_year = p.year;
|
||||
lunar_month = p.month;
|
||||
lunar_day = p.day;
|
||||
|
||||
_controllerDate.text =
|
||||
"${lunar_year}年${lunar_month}月${lunar_day}日 $hour时$minute分";
|
||||
} else {
|
||||
year = p.year;
|
||||
month = p.month;
|
||||
day = p.day;
|
||||
|
||||
_controllerDate.text = "${year}年${month}月${day}日 $hour时$minute分";
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 通过公历算农历
|
||||
calLunar() {
|
||||
if (_controllerWebView != null) {
|
||||
@ -150,10 +175,10 @@ class _BirthCalState extends State<BirthCalPage> {
|
||||
|
||||
calPan() {
|
||||
if (_controllerWebView != null) {
|
||||
if(qmType == 0) {
|
||||
if (qmType == 0) {
|
||||
_controllerWebView
|
||||
.runJavascriptReturningResult(
|
||||
"flutterCallPaiPan($year, $month, $day, $hour, $minute)")
|
||||
"flutterCallPaiPan($year, $month, $day, $hour, $minute)")
|
||||
.then((value) {
|
||||
String tmp = value
|
||||
.replaceAll(r'\"', '"')
|
||||
@ -166,24 +191,24 @@ class _BirthCalState extends State<BirthCalPage> {
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PanPage(
|
||||
solarDate: EtDate(
|
||||
cYear: year,
|
||||
cMonth: month,
|
||||
cDay: day,
|
||||
lYear: lunar_year,
|
||||
lMonth: lunar_month,
|
||||
lDay: lunar_day,
|
||||
hour: hour,
|
||||
minute: minute)
|
||||
cYear: year,
|
||||
cMonth: month,
|
||||
cDay: day,
|
||||
lYear: lunar_year,
|
||||
lMonth: lunar_month,
|
||||
lDay: lunar_day,
|
||||
hour: hour,
|
||||
minute: minute)
|
||||
.getSolar(),
|
||||
lunarDate: EtDate(
|
||||
cYear: year,
|
||||
cMonth: month,
|
||||
cDay: day,
|
||||
lYear: lunar_year,
|
||||
lMonth: lunar_month,
|
||||
lDay: lunar_day,
|
||||
hour: hour,
|
||||
minute: minute)
|
||||
cYear: year,
|
||||
cMonth: month,
|
||||
cDay: day,
|
||||
lYear: lunar_year,
|
||||
lMonth: lunar_month,
|
||||
lDay: lunar_day,
|
||||
hour: hour,
|
||||
minute: minute)
|
||||
.getLunar(),
|
||||
jieqi: qm.jieqi,
|
||||
dunju: qm.dunju,
|
||||
@ -191,13 +216,12 @@ class _BirthCalState extends State<BirthCalPage> {
|
||||
zhishi: qm.zhishi,
|
||||
zhifu: qm.zhifu,
|
||||
kong: qm.kong,
|
||||
qimenResult: qm.qimenResult
|
||||
)));
|
||||
qimenResult: qm.qimenResult)));
|
||||
});
|
||||
} else if (qmType == 1) {
|
||||
_controllerWebView
|
||||
.runJavascriptReturningResult(
|
||||
"flutterCallYinPan($year, $month, $day, $hour, $minute)")
|
||||
"flutterCallYinPan($year, $month, $day, $hour, $minute)")
|
||||
.then((value) {
|
||||
String tmp = value
|
||||
.replaceAll(r'\"', '"')
|
||||
@ -210,24 +234,24 @@ class _BirthCalState extends State<BirthCalPage> {
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PanPage(
|
||||
solarDate: EtDate(
|
||||
cYear: year,
|
||||
cMonth: month,
|
||||
cDay: day,
|
||||
lYear: lunar_year,
|
||||
lMonth: lunar_month,
|
||||
lDay: lunar_day,
|
||||
hour: hour,
|
||||
minute: minute)
|
||||
cYear: year,
|
||||
cMonth: month,
|
||||
cDay: day,
|
||||
lYear: lunar_year,
|
||||
lMonth: lunar_month,
|
||||
lDay: lunar_day,
|
||||
hour: hour,
|
||||
minute: minute)
|
||||
.getSolar(),
|
||||
lunarDate: EtDate(
|
||||
cYear: year,
|
||||
cMonth: month,
|
||||
cDay: day,
|
||||
lYear: lunar_year,
|
||||
lMonth: lunar_month,
|
||||
lDay: lunar_day,
|
||||
hour: hour,
|
||||
minute: minute)
|
||||
cYear: year,
|
||||
cMonth: month,
|
||||
cDay: day,
|
||||
lYear: lunar_year,
|
||||
lMonth: lunar_month,
|
||||
lDay: lunar_day,
|
||||
hour: hour,
|
||||
minute: minute)
|
||||
.getLunar(),
|
||||
jieqi: qm.jieqi,
|
||||
dunju: qm.dunju,
|
||||
@ -235,13 +259,12 @@ class _BirthCalState extends State<BirthCalPage> {
|
||||
zhishi: qm.zhishi,
|
||||
zhifu: qm.zhifu,
|
||||
kong: qm.kong,
|
||||
qimenResult: qm.qimenResult
|
||||
)));
|
||||
qimenResult: qm.qimenResult)));
|
||||
});
|
||||
} else {
|
||||
_controllerWebView
|
||||
.runJavascriptReturningResult(
|
||||
"flutterCallPaiPan($year, $month, $day, $hour, $minute)")
|
||||
"flutterCallPaiPan($year, $month, $day, $hour, $minute)")
|
||||
.then((value) {
|
||||
String tmp = value
|
||||
.replaceAll(r'\"', '"')
|
||||
@ -254,24 +277,24 @@ class _BirthCalState extends State<BirthCalPage> {
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PanPage(
|
||||
solarDate: EtDate(
|
||||
cYear: year,
|
||||
cMonth: month,
|
||||
cDay: day,
|
||||
lYear: lunar_year,
|
||||
lMonth: lunar_month,
|
||||
lDay: lunar_day,
|
||||
hour: hour,
|
||||
minute: minute)
|
||||
cYear: year,
|
||||
cMonth: month,
|
||||
cDay: day,
|
||||
lYear: lunar_year,
|
||||
lMonth: lunar_month,
|
||||
lDay: lunar_day,
|
||||
hour: hour,
|
||||
minute: minute)
|
||||
.getSolar(),
|
||||
lunarDate: EtDate(
|
||||
cYear: year,
|
||||
cMonth: month,
|
||||
cDay: day,
|
||||
lYear: lunar_year,
|
||||
lMonth: lunar_month,
|
||||
lDay: lunar_day,
|
||||
hour: hour,
|
||||
minute: minute)
|
||||
cYear: year,
|
||||
cMonth: month,
|
||||
cDay: day,
|
||||
lYear: lunar_year,
|
||||
lMonth: lunar_month,
|
||||
lDay: lunar_day,
|
||||
hour: hour,
|
||||
minute: minute)
|
||||
.getLunar(),
|
||||
jieqi: qm.jieqi,
|
||||
dunju: qm.dunju,
|
||||
@ -279,8 +302,7 @@ class _BirthCalState extends State<BirthCalPage> {
|
||||
zhishi: qm.zhishi,
|
||||
zhifu: qm.zhifu,
|
||||
kong: qm.kong,
|
||||
qimenResult: qm.qimenResult
|
||||
)));
|
||||
qimenResult: qm.qimenResult)));
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -357,7 +379,7 @@ class _BirthCalState extends State<BirthCalPage> {
|
||||
lunar_day = json.decode(tmp)['lDay'];
|
||||
|
||||
_controllerDate.text =
|
||||
"${year}年${month}月${day}日";
|
||||
"${year}年${month}月${day}日 $hour时$minute分";
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -410,7 +432,7 @@ class _BirthCalState extends State<BirthCalPage> {
|
||||
day = json.decode(tmp)['cDay'];
|
||||
|
||||
_controllerDate.text =
|
||||
"${lunar_year}年${lunar_month}月${lunar_day}日";
|
||||
"${lunar_year}年${lunar_month}月${lunar_day}日 $hour时$minute分";
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -434,7 +456,7 @@ class _BirthCalState extends State<BirthCalPage> {
|
||||
))
|
||||
],
|
||||
),
|
||||
const Padding(padding: EdgeInsets.only(top: 40)),
|
||||
const Padding(padding: EdgeInsets.only(top: 80)),
|
||||
Row(
|
||||
children: [
|
||||
const Padding(
|
||||
@ -455,64 +477,73 @@ class _BirthCalState extends State<BirthCalPage> {
|
||||
readOnly: true,
|
||||
)),
|
||||
IconButton(
|
||||
onPressed: _showDatePicker,
|
||||
// onPressed: _showDatePicker,
|
||||
onPressed: _showDateTimePicker,
|
||||
icon: Icon(MyIcons.icon_rili))
|
||||
],
|
||||
),
|
||||
const Padding(padding: EdgeInsets.only(top: 40)),
|
||||
// const Padding(padding: EdgeInsets.only(top: 40)),
|
||||
// Row(
|
||||
// children: [
|
||||
// const Padding(
|
||||
// padding: EdgeInsets.only(
|
||||
// left: 10,
|
||||
// right: 10,
|
||||
// ),
|
||||
// child: Text(
|
||||
// "出生时间:",
|
||||
// style: TextStyle(fontSize: 18),
|
||||
// ),
|
||||
// ),
|
||||
// Expanded(
|
||||
// child: TextField(
|
||||
// controller: _controllerTime,
|
||||
// decoration: InputDecoration(
|
||||
// contentPadding: const EdgeInsets.all(10.0),
|
||||
// border: OutlineInputBorder(
|
||||
// borderRadius: BorderRadius.circular(10.0),
|
||||
// )),
|
||||
// readOnly: true,
|
||||
// )),
|
||||
// IconButton(
|
||||
// onPressed: _showTimePicker,
|
||||
// icon: Icon(Icons.timelapse_outlined))
|
||||
// ],
|
||||
// ),
|
||||
Padding(padding: EdgeInsets.only(top: 80)),
|
||||
// 切换奇门类型,单选框
|
||||
Row(
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: Text(
|
||||
"出生时间:",
|
||||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Radio(
|
||||
value: 0,
|
||||
groupValue: qmType,
|
||||
onChanged: (v) {
|
||||
setState(() {
|
||||
qmType = v;
|
||||
});
|
||||
}),
|
||||
const Text("拆补法")
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _controllerTime,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: const EdgeInsets.all(10.0),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
)),
|
||||
readOnly: true,
|
||||
)),
|
||||
IconButton(
|
||||
onPressed: _showTimePicker,
|
||||
icon: Icon(Icons.timelapse_outlined))
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Radio(
|
||||
value: 1,
|
||||
groupValue: qmType,
|
||||
onChanged: (v) {
|
||||
setState(() {
|
||||
qmType = v;
|
||||
});
|
||||
}),
|
||||
const Text("阴盘")
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
Padding(padding: EdgeInsets.only(top: 40)),
|
||||
// 切换奇门类型,单选框
|
||||
Row(children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Radio(value: 0, groupValue: qmType, onChanged: (v){
|
||||
setState(() {
|
||||
qmType = v;
|
||||
});
|
||||
}),
|
||||
const Text("拆补法")
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Radio(value: 1, groupValue: qmType, onChanged: (v){
|
||||
setState(() {
|
||||
qmType = v;
|
||||
});
|
||||
}),
|
||||
const Text("阴盘")
|
||||
],
|
||||
)
|
||||
],),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
|
Reference in New Issue
Block a user