时间日期选择器
This commit is contained in:
BIN
assets/images/compass_rotated.png
Normal file
BIN
assets/images/compass_rotated.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 987 KiB |
@ -19,11 +19,11 @@ class MyPainter extends CustomPainter {
|
|||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
// 创建画笔
|
// 创建画笔
|
||||||
final Paint paintLine = Paint()
|
final Paint paintLine = Paint()
|
||||||
..color = Colors.grey
|
..color = Colors.white
|
||||||
..strokeWidth = 2;
|
..strokeWidth = 2;
|
||||||
// 绘制线
|
// 绘制线
|
||||||
canvas.drawLine(Offset(-400, 0), Offset(400, 0), paintLine);
|
canvas.drawLine(const Offset(-400, 0), const Offset(400, 0), paintLine);
|
||||||
canvas.drawLine(Offset(0, 500), Offset(0, -440), paintLine);
|
canvas.drawLine(const Offset(0, 500), const Offset(0, -440), paintLine);
|
||||||
// 创建画笔
|
// 创建画笔
|
||||||
// final Paint paintPoint = Paint()..color = Colors.red;
|
// final Paint paintPoint = Paint()..color = Colors.red;
|
||||||
// 绘制圆点
|
// 绘制圆点
|
||||||
|
@ -12,7 +12,6 @@ class RegionSelector extends StatelessWidget {
|
|||||||
if (pname == '') return '未选择城市';
|
if (pname == '') return '未选择城市';
|
||||||
StringBuffer sb = StringBuffer();
|
StringBuffer sb = StringBuffer();
|
||||||
sb.write(pname);
|
sb.write(pname);
|
||||||
// if (cname == '') return sb.toString();
|
|
||||||
if (cname == '') return '未选择城市';
|
if (cname == '') return '未选择城市';
|
||||||
sb.write(' - ');
|
sb.write(' - ');
|
||||||
sb.write(cname);
|
sb.write(cname);
|
||||||
@ -31,8 +30,8 @@ class RegionSelector extends StatelessWidget {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
Pickers.showAddressPicker(context,
|
Pickers.showAddressPicker(context,
|
||||||
addAllItem: false,
|
addAllItem: false,
|
||||||
initProvince: regionProvider.provinceName,
|
initProvince: regionProvider.tempProvinceName,
|
||||||
initCity: regionProvider.cityName,
|
initCity: regionProvider.tempCityName,
|
||||||
onConfirm: (p, c, t) {
|
onConfirm: (p, c, t) {
|
||||||
regionProvider.updateRegion(p, c);
|
regionProvider.updateRegion(p, c);
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:fengshui_compass/components/my_icon.dart';
|
||||||
import 'package:fengshui_compass/models/et_date.dart';
|
import 'package:fengshui_compass/models/et_date.dart';
|
||||||
import 'package:fengshui_compass/pages/pan_page.dart';
|
import 'package:fengshui_compass/pages/pan_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:fengshui_compass/components/my_icon.dart';
|
|
||||||
import 'package:flutter_localizations/flutter_localizations.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:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:webview_flutter/webview_flutter.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() {
|
calLunar() {
|
||||||
if (_controllerWebView != null) {
|
if (_controllerWebView != null) {
|
||||||
@ -150,7 +175,7 @@ class _BirthCalState extends State<BirthCalPage> {
|
|||||||
|
|
||||||
calPan() {
|
calPan() {
|
||||||
if (_controllerWebView != null) {
|
if (_controllerWebView != null) {
|
||||||
if(qmType == 0) {
|
if (qmType == 0) {
|
||||||
_controllerWebView
|
_controllerWebView
|
||||||
.runJavascriptReturningResult(
|
.runJavascriptReturningResult(
|
||||||
"flutterCallPaiPan($year, $month, $day, $hour, $minute)")
|
"flutterCallPaiPan($year, $month, $day, $hour, $minute)")
|
||||||
@ -191,8 +216,7 @@ class _BirthCalState extends State<BirthCalPage> {
|
|||||||
zhishi: qm.zhishi,
|
zhishi: qm.zhishi,
|
||||||
zhifu: qm.zhifu,
|
zhifu: qm.zhifu,
|
||||||
kong: qm.kong,
|
kong: qm.kong,
|
||||||
qimenResult: qm.qimenResult
|
qimenResult: qm.qimenResult)));
|
||||||
)));
|
|
||||||
});
|
});
|
||||||
} else if (qmType == 1) {
|
} else if (qmType == 1) {
|
||||||
_controllerWebView
|
_controllerWebView
|
||||||
@ -235,8 +259,7 @@ class _BirthCalState extends State<BirthCalPage> {
|
|||||||
zhishi: qm.zhishi,
|
zhishi: qm.zhishi,
|
||||||
zhifu: qm.zhifu,
|
zhifu: qm.zhifu,
|
||||||
kong: qm.kong,
|
kong: qm.kong,
|
||||||
qimenResult: qm.qimenResult
|
qimenResult: qm.qimenResult)));
|
||||||
)));
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
_controllerWebView
|
_controllerWebView
|
||||||
@ -279,8 +302,7 @@ class _BirthCalState extends State<BirthCalPage> {
|
|||||||
zhishi: qm.zhishi,
|
zhishi: qm.zhishi,
|
||||||
zhifu: qm.zhifu,
|
zhifu: qm.zhifu,
|
||||||
kong: qm.kong,
|
kong: qm.kong,
|
||||||
qimenResult: qm.qimenResult
|
qimenResult: qm.qimenResult)));
|
||||||
)));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -357,7 +379,7 @@ class _BirthCalState extends State<BirthCalPage> {
|
|||||||
lunar_day = json.decode(tmp)['lDay'];
|
lunar_day = json.decode(tmp)['lDay'];
|
||||||
|
|
||||||
_controllerDate.text =
|
_controllerDate.text =
|
||||||
"${year}年${month}月${day}日";
|
"${year}年${month}月${day}日 $hour时$minute分";
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -410,7 +432,7 @@ class _BirthCalState extends State<BirthCalPage> {
|
|||||||
day = json.decode(tmp)['cDay'];
|
day = json.decode(tmp)['cDay'];
|
||||||
|
|
||||||
_controllerDate.text =
|
_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(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
const Padding(
|
const Padding(
|
||||||
@ -455,45 +477,50 @@ class _BirthCalState extends State<BirthCalPage> {
|
|||||||
readOnly: true,
|
readOnly: true,
|
||||||
)),
|
)),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: _showDatePicker,
|
// onPressed: _showDatePicker,
|
||||||
|
onPressed: _showDateTimePicker,
|
||||||
icon: Icon(MyIcons.icon_rili))
|
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(
|
Row(
|
||||||
children: [
|
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: 40)),
|
|
||||||
// 切换奇门类型,单选框
|
|
||||||
Row(children: [
|
|
||||||
Row(
|
Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Radio(value: 0, groupValue: qmType, onChanged: (v){
|
Radio(
|
||||||
|
value: 0,
|
||||||
|
groupValue: qmType,
|
||||||
|
onChanged: (v) {
|
||||||
setState(() {
|
setState(() {
|
||||||
qmType = v;
|
qmType = v;
|
||||||
});
|
});
|
||||||
@ -504,7 +531,10 @@ class _BirthCalState extends State<BirthCalPage> {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Radio(value: 1, groupValue: qmType, onChanged: (v){
|
Radio(
|
||||||
|
value: 1,
|
||||||
|
groupValue: qmType,
|
||||||
|
onChanged: (v) {
|
||||||
setState(() {
|
setState(() {
|
||||||
qmType = v;
|
qmType = v;
|
||||||
});
|
});
|
||||||
@ -512,7 +542,8 @@ class _BirthCalState extends State<BirthCalPage> {
|
|||||||
const Text("阴盘")
|
const Text("阴盘")
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
],),
|
],
|
||||||
|
),
|
||||||
Row(
|
Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
|
@ -327,7 +327,9 @@ class _CompassState extends State<CompassPage> {
|
|||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: const BoxConstraints(minHeight: 600),
|
constraints: const BoxConstraints(minHeight: 600),
|
||||||
child: Stack(
|
child: Consumer<RegionProvider>(
|
||||||
|
builder: (builder, regionProvider, child) {
|
||||||
|
return Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
// 罗盘
|
// 罗盘
|
||||||
@ -343,16 +345,18 @@ class _CompassState extends State<CompassPage> {
|
|||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Transform.rotate(
|
Transform.rotate(
|
||||||
angle: myaw * pi / 360,
|
angle: myaw * pi / 360 +
|
||||||
|
regionProvider.declination,
|
||||||
child: const Image(
|
child: const Image(
|
||||||
image:
|
image: AssetImage(
|
||||||
AssetImage("assets/images/compass.png"),
|
"assets/images/compass_rotated.png"),
|
||||||
fit: BoxFit.fill),
|
fit: BoxFit.fill),
|
||||||
),
|
),
|
||||||
Align(
|
Align(
|
||||||
alignment: FractionalOffset(w_x, w_y),
|
alignment: FractionalOffset(w_x, w_y),
|
||||||
child: const Image(
|
child: const Image(
|
||||||
image: AssetImage("assets/images/water.png"),
|
image:
|
||||||
|
AssetImage("assets/images/water.png"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
CrossPaint(),
|
CrossPaint(),
|
||||||
@ -377,12 +381,14 @@ class _CompassState extends State<CompassPage> {
|
|||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
// "${azimuth.toStringAsFixed(2)}",
|
// "${azimuth.toStringAsFixed(2)}",
|
||||||
myaw.toStringAsFixed(2),
|
(myaw + regionProvider.declination)
|
||||||
style:
|
.toStringAsFixed(2),
|
||||||
const TextStyle(color: Colors.amber, fontSize: 36),
|
style: const TextStyle(
|
||||||
|
color: Colors.amber, fontSize: 36),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
|
//磁偏角调整按钮
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 5,
|
top: 5,
|
||||||
right: 8,
|
right: 8,
|
||||||
@ -390,6 +396,13 @@ class _CompassState extends State<CompassPage> {
|
|||||||
onPressed: () => selectRegion(),
|
onPressed: () => selectRegion(),
|
||||||
icon: const Icon(Icons.settings, color: Colors.amber),
|
icon: const Icon(Icons.settings, color: Colors.amber),
|
||||||
)),
|
)),
|
||||||
|
Positioned(
|
||||||
|
top: 45,
|
||||||
|
right: 8,
|
||||||
|
child: IconButton(
|
||||||
|
onPressed: () => selectRegion(),
|
||||||
|
icon: const Icon(Icons.photo, color: Colors.amber),
|
||||||
|
)),
|
||||||
// 最下面一行,ranging value openlaser
|
// 最下面一行,ranging value openlaser
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 80,
|
bottom: 80,
|
||||||
@ -419,8 +432,8 @@ class _CompassState extends State<CompassPage> {
|
|||||||
padding: const EdgeInsets.only(right: 15),
|
padding: const EdgeInsets.only(right: 15),
|
||||||
child: Text(
|
child: Text(
|
||||||
"${distance} m",
|
"${distance} m",
|
||||||
style:
|
style: const TextStyle(
|
||||||
const TextStyle(color: Colors.amber, fontSize: 28),
|
color: Colors.amber, fontSize: 28),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
@ -473,6 +486,8 @@ class _CompassState extends State<CompassPage> {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
|
@ -4,7 +4,6 @@ import 'package:provider/provider.dart';
|
|||||||
|
|
||||||
import '../bottom_navigation_widget.dart';
|
import '../bottom_navigation_widget.dart';
|
||||||
import '../states/token.dart';
|
import '../states/token.dart';
|
||||||
import '../utils/token_helper.dart';
|
|
||||||
|
|
||||||
// 用户未登录页面
|
// 用户未登录页面
|
||||||
class PersonalLoginPage extends StatefulWidget {
|
class PersonalLoginPage extends StatefulWidget {
|
||||||
@ -17,7 +16,7 @@ class PersonalLoginPage extends StatefulWidget {
|
|||||||
class _PersonalLoginPageState extends State<PersonalLoginPage> {
|
class _PersonalLoginPageState extends State<PersonalLoginPage> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
bool isLogin = TokenHelper.getInstance.isLogin;
|
// bool isLogin = TokenHelper.getInstance.isLogin;
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
Reference in New Issue
Block a user