Commit 42ca4dee136a46434cc7a530fe9b5393109c69e1

Authored by wdn127929
2 parents 9d4f000c e72e0e92

年月日分开选择

... ... @@ -11,6 +11,7 @@ if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = "320"
if (flutterVersionCode == null) {
flutterVersionCode = '320'
... ... @@ -20,7 +21,6 @@ def flutterVersionName = "3.2.0"
if (flutterVersionName == null) {
flutterVersionName = '3.2.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
... ...
... ... @@ -38,7 +38,7 @@ class _FestivalEditPageState extends State<FestivalEditPage> {
itemBuilder: (BuildContext context, int index) {
return InkWell(
onTap: () {
DialogUtil.festivalAlertDialog(context, 'ggg', 700,
DialogUtil.festivalAlertDialog(context, 'ggg', 520,
rCallback: (name) {
// _addCookbookClass(name, showLoading: true);
});
... ...
import 'package:flutter/material.dart';
class MyColours {
static const Color color_d7d7d7 = Color(0xffD7D7D7);
static const Color color_F4FAFF = Color(0xffF4FAFF);
static const Color app_main = Color(0xFF24A4A8);
static const Color color_ffffff = Color(0xffffffff);
static const Color color_fefefe = Color(0xfffefefe);
static const Color color_f5f5f5 = Color(0xfff5f5f5);
static const Color color_199095 = Color(0xff199095);
static const Color color_afbcc4 = Color(0xffAFBCC4);
static const Color color_999999 = Color(0xff999999);
static const Color color_353535 = Color(0xff353535);
static const Color color_d8d8d8 = Color(0xffD8D8D8);
... ...
... ... @@ -18,6 +18,9 @@ import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/NumLengthInputFormatter.dart';
import 'package:one_key/utils/misc.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/pick_date_nonli_gongli/pick_calendar_day.dart';
import 'package:one_key/utils/pick_date_nonli_gongli/pick_calendar_month.dart';
import 'package:one_key/utils/pick_date_nonli_gongli/pick_calendar_year.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/common_button.dart';
... ... @@ -2342,215 +2345,404 @@ class DialogUtil {
static Future festivalAlertDialog(
BuildContext context, String name, double height,
{CustomCallBack rCallback, double fontSize = 28}) async {
String yearStr = '选填';
String monthStr = '';
String dayStr = '';
final action = await showDialog(
context: context,
barrierDismissible: true,
builder: (BuildContext context) {
TextEditingController controller = TextEditingController();
controller.text = name;
return Scaffold(
backgroundColor: Colors.transparent,
body: Center(
child: Container(
padding:
EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(72)),
height: ScreenUtil().setWidth(height),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(30))),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(30)))), //设置圆角
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40)),
child: Column(
children: [
// VEmptyView(60),
Stack(children: [
return StatefulBuilder(builder: (context, stateSetter) {
return Scaffold(
backgroundColor: Colors.transparent,
body: Center(
child: Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(72)),
height: ScreenUtil().setWidth(height),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(30))),
child: SingleChildScrollView(
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(30)))), //设置圆角
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40)),
child: Column(
children: [
// VEmptyView(60),
Stack(children: [
Container(
padding: EdgeInsets.only(
top: ScreenUtil().setWidth(60),
bottom: ScreenUtil().setWidth(40)),
// color: Colors.red,
alignment: Alignment.center,
child: Text('纪念日名称',
style: TextStyle(
fontSize: ScreenUtil().setSp(fontSize),
color: MyColours.color_353535)),
),
Positioned(
right: 0,
top: ScreenUtil().setWidth(36),
child: Text('删除',
style: TextStyle(
decoration: TextDecoration.underline,
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_199095)))
]),
Container(
height: ScreenUtil().setWidth(40),
// color: Colors.red,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(68)),
alignment: Alignment.center,
child: Material(
color: Colors.transparent,
child: TextField(
controller: controller,
maxLines: 1,
// //光标颜色
// cursorColor:
// widget.isSelect ? Colors.white : MyColours.color_199095,
// //输入文本的样式
// inputFormatters: lenghtLimit
// ? [
// LengthLimitingTextInputFormatter(10),
// ]
// : [],
textAlignVertical:
TextAlignVertical.bottom,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
),
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide.none),
hintText: '例:本人生日',
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(26),
),
enabledBorder:
new UnderlineInputBorder(
borderSide: BorderSide.none,
),
focusedBorder:
new UnderlineInputBorder(
borderSide: BorderSide.none,
),
),
onChanged: (value) {
name = value;
},
onEditingComplete: () {
FocusScope.of(context).requestFocus(
FocusNode()); //点击空白处隐藏键盘
},
keyboardType: TextInputType.text))),
// VEmptyView(28),
MyDivider(ScreenUtil().setWidth(280 * 2),
ScreenUtil().setWidth(2),
color: MyColours.color_efefef),
Container(
padding: EdgeInsets.only(
top: ScreenUtil().setWidth(60),
top: ScreenUtil().setWidth(40),
bottom: ScreenUtil().setWidth(50)),
// color: Colors.red,
alignment: Alignment.center,
child: Text('纪念日名称',
child: Text('纪念日日期',
style: TextStyle(
fontSize: ScreenUtil().setSp(fontSize),
color: MyColours.color_353535)),
),
Positioned(
right: 0,
top: ScreenUtil().setWidth(36),
child: Text('删除',
style: TextStyle(
decoration: TextDecoration.underline,
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_199095)))
]),
Container(
height: ScreenUtil().setWidth(40),
// color: Colors.red,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(68)),
alignment: Alignment.center,
child: Material(
color: Colors.transparent,
child: TextField(
controller: controller,
maxLines: 1,
// //光标颜色
// cursorColor:
// widget.isSelect ? Colors.white : MyColours.color_199095,
// //输入文本的样式
// inputFormatters: lenghtLimit
// ? [
// LengthLimitingTextInputFormatter(10),
// ]
// : [],
textAlignVertical:
TextAlignVertical.bottom,
textAlign: TextAlign.center,
Row(
children: [
InkWell(
child: Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(5),
vertical: ScreenUtil().setWidth(6)),
decoration: BoxDecoration(
color: true
? MyColours.color_199095
: MyColours.color_ffffff,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(
ScreenUtil().setWidth(10)),
bottomLeft: Radius.circular(
ScreenUtil().setWidth(10))),
border: Border.all(
color: MyColours.color_199095,
width: ScreenUtil().setWidth(2))),
child: Text('公历',
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
fontSize: ScreenUtil().setSp(28),
color: true
? MyColours.color_ffffff
: MyColours.color_333333)),
)),
InkWell(
child: Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(5),
vertical: ScreenUtil().setWidth(6)),
decoration: BoxDecoration(
color: false
? MyColours.color_199095
: MyColours.color_ffffff,
borderRadius: BorderRadius.only(
topRight: Radius.circular(
ScreenUtil().setWidth(10)),
bottomRight: Radius.circular(
ScreenUtil().setWidth(10))),
border: Border.all(
color: MyColours.color_199095,
width: ScreenUtil().setWidth(2))),
child: Text('农历',
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
color: false
? MyColours.color_ffffff
: MyColours.color_333333))),
),
HEmptyView(30),
InkWell(
onTap: () {
incrementCounterYear(
context,
true,
yearStr == '选填'
? DateTime.now().year.toString()
: yearStr, (year) {
print(year);
stateSetter(() {
yearStr = year;
});
});
},
child: Container(
padding: EdgeInsets.only(
bottom: ScreenUtil().setWidth(4)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: MyColours.color_E0E0E0,
width: ScreenUtil().setWidth(2)),
)),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Padding(
padding: EdgeInsets.zero,
child: Text(yearStr,
style: TextStyle(
fontSize:
ScreenUtil().setSp(26),
color: MyColours
.color_666666)),
),
HEmptyView(6),
Image.asset(
Utils.getImgPath(false
? 'c_arrow_up'
: 'c_arrow_down'),
width: ScreenUtil().setWidth(28),
// height: ScreenUtil().setWidth(10),
),
],
),
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide.none),
hintText: '例:本人生日',
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(26),
),
enabledBorder: new UnderlineInputBorder(
borderSide: BorderSide.none,
),
focusedBorder: new UnderlineInputBorder(
borderSide: BorderSide.none,
),
)),
Text('年',
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
color: MyColours.color_333333)),
HEmptyView(10),
InkWell(
onTap: () {
incrementCounterMonth(
context,
true,
yearStr == '选填'
? DateTime.now().year.toString()
: yearStr,
monthStr == ''
? DateTime.now().month.toString()
: monthStr, (month) {
print(month);
stateSetter(() {
monthStr = month;
});
if (dayStr != '') {
List dayList = updateDay(
true,
yearStr == '选填'
? DateTime.now()
.year
.toString()
: yearStr,
monthStr == ''
? DateTime.now()
.month
.toString()
: monthStr);
if (!dayList.contains(dayStr)) {
stateSetter(() {
dayStr = '';
});
}
}
});
},
child: Container(
padding: EdgeInsets.only(
bottom: ScreenUtil().setWidth(4)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: MyColours.color_E0E0E0,
width: ScreenUtil().setWidth(2)),
)),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Padding(
padding: EdgeInsets.zero,
child: Text(monthStr,
style: TextStyle(
fontSize:
ScreenUtil().setSp(26),
color: MyColours
.color_666666)),
),
HEmptyView(6),
Image.asset(
Utils.getImgPath(false
? 'c_arrow_up'
: 'c_arrow_down'),
width: ScreenUtil().setWidth(28),
// height: ScreenUtil().setWidth(10),
),
],
),
onChanged: (value) {
name = value;
},
onEditingComplete: () {
FocusScope.of(context).requestFocus(
FocusNode()); //点击空白处隐藏键盘
},
keyboardType: TextInputType.text))),
// VEmptyView(28),
MyDivider(ScreenUtil().setWidth(280 * 2),
ScreenUtil().setWidth(2),
color: MyColours.color_efefef),
Container(
padding: EdgeInsets.only(
top: ScreenUtil().setWidth(40),
bottom: ScreenUtil().setWidth(50)),
// color: Colors.red,
alignment: Alignment.center,
child: Text('纪念日日期',
style: TextStyle(
fontSize: ScreenUtil().setSp(fontSize),
color: MyColours.color_353535)),
),
Row(
children: [
InkWell(
child: Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(10),
vertical: ScreenUtil().setWidth(10)),
decoration: BoxDecoration(
color: true
? MyColours.color_199095
: MyColours.color_ffffff,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(
ScreenUtil().setWidth(10)),
bottomLeft: Radius.circular(
ScreenUtil().setWidth(10))),
border: Border.all(
color: MyColours.color_199095,
width: ScreenUtil().setWidth(2))),
child: Text('公历',
)),
Text('月',
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
color: true
? MyColours.color_ffffff
: MyColours.color_333333)),
)),
InkWell(
child: Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(10),
vertical: ScreenUtil().setWidth(10)),
decoration: BoxDecoration(
color: false
? MyColours.color_199095
: MyColours.color_ffffff,
borderRadius: BorderRadius.only(
topRight: Radius.circular(
ScreenUtil().setWidth(10)),
bottomRight: Radius.circular(
ScreenUtil().setWidth(10))),
border: Border.all(
color: MyColours.color_199095,
width: ScreenUtil().setWidth(2))),
child: Text('农历',
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
color: false
? MyColours.color_ffffff
: MyColours.color_333333))),
),
],
),
Row(
children: [
InkWell(
child: Container(
height: ScreenUtil().setWidth(47 * 2),
alignment: Alignment.center,
child: Text(
'取消',
color: MyColours.color_333333)),
HEmptyView(10),
InkWell(
onTap: () {
incrementCounterDay(
context,
true,
yearStr == '选填'
? DateTime.now().year.toString()
: yearStr,
monthStr == ''
? DateTime.now().month.toString()
: monthStr,
dayStr == ''
? DateTime.now().day.toString()
: dayStr, (day) {
print(dayStr);
stateSetter(() {
dayStr = day;
});
});
},
child: Container(
padding: EdgeInsets.only(
bottom: ScreenUtil().setWidth(4)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: MyColours.color_E0E0E0,
width: ScreenUtil().setWidth(2)),
)),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Padding(
padding: EdgeInsets.zero,
child: Text(dayStr,
style: TextStyle(
fontSize:
ScreenUtil().setSp(26),
color: MyColours
.color_666666)),
),
HEmptyView(6),
Image.asset(
Utils.getImgPath(false
? 'c_arrow_up'
: 'c_arrow_down'),
width: ScreenUtil().setWidth(28),
// height: ScreenUtil().setWidth(10),
),
],
),
)),
Text('日',
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setWidth(34)),
),
fontSize: ScreenUtil().setSp(28),
color: MyColours.color_333333)),
],
),
VEmptyView(60),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
RoundButton(
width: ScreenUtil().setWidth(200),
height: ScreenUtil().setWidth(70),
radius: ScreenUtil().setWidth(10),
text: '取消',
fontSize: 28,
borderColor: MyColours.color_199095,
textColor: MyColours.color_199095,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
onPressed: () {
Navigator.of(context).pop();
},
),
onTap: () {
Navigator.of(context).pop();
},
),
InkWell(
child: Container(
height: ScreenUtil().setWidth(47 * 2),
alignment: Alignment.center,
child: Text(
'保存',
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setWidth(34)),
),
RoundButton(
width: ScreenUtil().setWidth(200),
height: ScreenUtil().setWidth(70),
radius: ScreenUtil().setWidth(10),
text: '保存',
fontSize: 28,
onPressed: () {
if (name == '' || name.trim().length == 0) {
Utils.showToast('请输入纪念日名称');
return;
}
Navigator.of(context).pop();
rCallback(name);
},
),
onTap: () {
if (name == '' || name.trim().length == 0) {
Utils.showToast('请输入纪念日名称');
return;
}
Navigator.of(context).pop();
rCallback(name);
},
)
],
)
],
)),
],
),
VEmptyView(20),
],
)),
)),
),
),
));
));
});
},
);
}
... ...
// 计算阳历的这个年份这个月份,天数有几天
getYangliDay(year, month) {
int count = 0;
//判断大月份
if (month == 1 ||
month == 3 ||
month == 5 ||
month == 7 ||
month == 8 ||
month == 10 ||
month == 12) {
count = 31;
}
//判断小月
if (month == 4 || month == 6 || month == 9 || month == 11) {
count = 30;
}
//判断平年与闰年
if (month == 2) {
if (isLeapYear(year)) {
count = 29;
} else {
count = 28;
}
}
return count;
}
/**
* 是否是闰年
*/
bool isLeapYear(int year) {
return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
}
// 计算阳历的这个年份这个月份,天数有几天
int getNongliDay(int year, int month) {
if ((LUNAR_INFO[year - 1900] & (0x100000 >> month)) == 0)
return 29;
else
return 30;
}
/**
* 用来表示1900年到2099年间农历年份的相关信息,共24位bit的16进制表示,其中:
* 1. 前4位表示该年闰哪个月;
* 2. 5-17位表示农历年份13个月的大小月分布,0表示小,1表示大;
* 3. 最后7位表示农历年首(正月初一)对应的公历日期。
* <p/>
* 以2014年的数据0x955ABF为例说明:
* 1001 0101 0101 1010 1011 1111
* 闰九月 农历正月初一对应公历1月31号
*/
final List<int> LUNAR_INFO = [
0x84B6BF,
/*1900*/
0x04AE53,
0x0A5748,
0x5526BD,
0x0D2650,
0x0D9544,
0x46AAB9,
0x056A4D,
0x09AD42,
0x24AEB6,
0x04AE4A,
/*1901-1910*/
0x6A4DBE,
0x0A4D52,
0x0D2546,
0x5D52BA,
0x0B544E,
0x0D6A43,
0x296D37,
0x095B4B,
0x749BC1,
0x049754,
/*1911-1920*/
0x0A4B48,
0x5B25BC,
0x06A550,
0x06D445,
0x4ADAB8,
0x02B64D,
0x095742,
0x2497B7,
0x04974A,
0x664B3E,
/*1921-1930*/
0x0D4A51,
0x0EA546,
0x56D4BA,
0x05AD4E,
0x02B644,
0x393738,
0x092E4B,
0x7C96BF,
0x0C9553,
0x0D4A48,
/*1931-1940*/
0x6DA53B,
0x0B554F,
0x056A45,
0x4AADB9,
0x025D4D,
0x092D42,
0x2C95B6,
0x0A954A,
0x7B4ABD,
0x06CA51,
/*1941-1950*/
0x0B5546,
0x555ABB,
0x04DA4E,
0x0A5B43,
0x352BB8,
0x052B4C,
0x8A953F,
0x0E9552,
0x06AA48,
0x6AD53C,
/*1951-1960*/
0x0AB54F,
0x04B645,
0x4A5739,
0x0A574D,
0x052642,
0x3E9335,
0x0D9549,
0x75AABE,
0x056A51,
0x096D46,
/*1961-1970*/
0x54AEBB,
0x04AD4F,
0x0A4D43,
0x4D26B7,
0x0D254B,
0x8D52BF,
0x0B5452,
0x0B6A47,
0x696D3C,
0x095B50,
/*1971-1980*/
0x049B45,
0x4A4BB9,
0x0A4B4D,
0xAB25C2,
0x06A554,
0x06D449,
0x6ADA3D,
0x0AB651,
0x095746,
0x5497BB,
/*1981-1990*/
0x04974F,
0x064B44,
0x36A537,
0x0EA54A,
0x86B2BF,
0x05AC53,
0x0AB647,
0x5936BC,
0x092E50,
0x0C9645,
/*1991-2000*/
0x4D4AB8,
0x0D4A4C,
0x0DA541,
0x25AAB6,
0x056A49,
0x7AADBD,
0x025D52,
0x092D47,
0x5C95BA,
0x0A954E,
/*2001-2010*/
0x0B4A43,
0x4B5537,
0x0AD54A,
0x955ABF,
0x04BA53,
0x0A5B48,
0x652BBC,
0x052B50,
0x0A9345,
0x474AB9,
/*2011-2020*/
0x06AA4C,
0x0AD541,
0x24DAB6,
0x04B64A,
0x6a573D,
0x0A4E51,
0x0D2646,
0x5E933A,
0x0D534D,
0x05AA43,
/*2021-2030*/
0x36B537,
0x096D4B,
0xB4AEBF,
0x04AD53,
0x0A4D48,
0x6D25BC,
0x0D254F,
0x0D5244,
0x5DAA38,
0x0B5A4C,
/*2031-2040*/
0x056D41,
0x24ADB6,
0x049B4A,
0x7A4BBE,
0x0A4B51,
0x0AA546,
0x5B52BA,
0x06D24E,
0x0ADA42,
0x355B37,
/*2041-2050*/
0x09374B,
0x8497C1,
0x049753,
0x064B48,
0x66A53C,
0x0EA54F,
0x06AA44,
0x4AB638,
0x0AAE4C,
0x092E42,
/*2051-2060*/
0x3C9735,
0x0C9649,
0x7D4ABD,
0x0D4A51,
0x0DA545,
0x55AABA,
0x056A4E,
0x0A6D43,
0x452EB7,
0x052D4B,
/*2061-2070*/
0x8A95BF,
0x0A9553,
0x0B4A47,
0x6B553B,
0x0AD54F,
0x055A45,
0x4A5D38,
0x0A5B4C,
0x052B42,
0x3A93B6,
/*2071-2080*/
0x069349,
0x7729BD,
0x06AA51,
0x0AD546,
0x54DABA,
0x04B64E,
0x0A5743,
0x452738,
0x0D264A,
0x8E933E,
/*2081-2090*/
0x0D5252,
0x0DAA47,
0x66B53B,
0x056D4F,
0x04AE45,
0x4A4EB9,
0x0A4D4C,
0x0D1541,
0x2D92B5 /*2091-2099*/
];
... ...
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/res/colors.dart';
import 'change_nongli_yangli.dart';
typedef CustomCallBack = void Function(Object object);
void incrementCounterDay(
context,
bool gongli,
String year,
String month,
String day,
CustomCallBack callBack,
) {
showDialog(
barrierDismissible: true,
context: context,
builder: (context) {
// 用Scaffold返回显示的内容,能跟随主题
return GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: Scaffold(
backgroundColor: Colors.transparent, // 设置透明背影
body: Stack(children: <Widget>[
PickBodyDay(
gongli: gongli,
callBack: callBack,
year: year,
month: month,
day: day)
])));
},
);
}
class PickBodyDay extends StatefulWidget {
final bool gongli;
final CustomCallBack callBack;
final String year;
final String month;
final String day;
PickBodyDay(
{Key key, this.gongli, this.callBack, this.year, this.month, this.day})
: super(key: key);
@override
_PickBodyDayState createState() => _PickBodyDayState();
}
class _PickBodyDayState extends State<PickBodyDay> {
// String sYear = "2000";
// String sMonth = '6';
String sDay = '15';
List day = [], yday = [];
List nday = [
'初一',
'初二',
'初三',
'初四',
'初五',
'初六',
'初七',
'初八',
'初九',
'初十',
'十一',
'十二',
'十三',
'十四',
'十五',
'十六',
'十七',
'十八',
'十九',
'二十',
'廿一',
'廿二',
'廿三',
'廿四',
'廿五',
'廿六',
'廿七',
'廿八',
'廿九',
'三十',
'三十一'
];
FixedExtentScrollController dayController =
new FixedExtentScrollController(initialItem: 14);
@override
void initState() {
// TODO: implement initState
super.initState();
// 获取当天的日期,年份默认选择的是2000年,月份默认是6月,日期默认是15日,时间默认是不详
dayController =
new FixedExtentScrollController(initialItem: int.parse(widget.day) - 1);
sDay = widget.day;
DateTime today = DateTime.now();
// 请空之前的数据
// 获取默认年份和月份之下的天数
int count = getYangliDay(int.parse(widget.year), int.parse(widget.month));
print('count---$count');
yday = [];
for (int m = 1; m < count + 1; m++) {
yday.add('$m');
}
// updateDay();
}
@override
Widget build(BuildContext context) {
// 切换农历和阳历的时候更换月份和天的称呼
if (widget.gongli) {
day = yday;
} else {
int count = getNongliDay(int.parse(widget.year), int.parse(widget.month));
print('农历的天数==${count}');
List old = nday;
List newDay = old.sublist(0, count);
// 初始化当前的选中的月份的天数
day = newDay;
}
return Positioned(
left: 0,
right: 0,
bottom: 0,
child: Container(
// height: 300,
decoration: BoxDecoration(color: Colors.white),
// padding: EdgeInsets.all(10),
child: Column(children: <Widget>[
Container(
// padding: EdgeInsets.symmetric(hori ScreenUtil().setWidth(30)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: ScreenUtil().setWidth(1),
color: MyColours.color_E0E0E0))),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
flex: 1,
child: GestureDetector(
child: Container(
color: Colors.white,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40)),
alignment: Alignment.centerLeft,
height: ScreenUtil().setWidth(90),
child: Text('取消',
style: TextStyle(
color: MyColours.color_333333))),
onTap: () {
print('关闭弹框');
Navigator.pop(context);
},
)),
Expanded(
flex: 1,
child: GestureDetector(
child: Container(
color: Colors.white,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40)),
alignment: Alignment.centerRight,
height: ScreenUtil().setWidth(90),
child: Text('确定',
style:
TextStyle(color: MyColours.color_199095)),
),
onTap: () {
print('确定 关闭弹框');
// print(sMonth);
// print(sMonth);
print(sDay);
// print(sTime);
widget.callBack(sDay);
Navigator.pop(context);
},
)),
],
)),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
// Expanded(
// flex: 1,
// child: Container(
// height: 200,
// child: CupertinoPicker(
// useMagnifier: true,
// magnification: 1.2,
// squeeze: 1,
// diameterRatio: 1.5,
// looping: false,
// backgroundColor: Colors.transparent, //选择器背景色
// itemExtent: 35, //item的高度
// onSelectedItemChanged: (index) {
// print('index === $index');
// int selectYear = 1980 + index;
// // 更改年的时候,查询选中的年和月的天数
// print("选中年 = ${selectYear}");
// setState(() {
// sYear = '$selectYear';
// // 更换年的时候检测是阳历还是农历
// updateDay();
// // monthController.jumpToItem(3);
// });
// },
// scrollController: yearController,
// children: XZItem(year, '年'),
// ))),
// Expanded(
// flex: 1,
// child: Container(
// height: 200,
// child: CupertinoPicker(
// useMagnifier: true,
// magnification: 1.2,
// squeeze: 1,
// diameterRatio: 1.5,
// looping: false,
// backgroundColor: Colors.transparent, //选择器背景色
// itemExtent: 35, //item的高度
// onSelectedItemChanged: (index) {
// //选中item的位置索引
// print("月index = $index}");
// setState(() {
// sMonth = '${index + 1}';
// });
// sMonth = '${index + 1}';
// updateDay();
// },
// scrollController: monthController,
// children: XZItem(month, '月'),
// ))),
Expanded(
flex: 1,
child: Container(
height: 200,
child: CupertinoPicker(
useMagnifier: true,
magnification: 1.3,
squeeze: 1,
diameterRatio: 1.5,
looping: false,
backgroundColor: Colors.transparent, //选择器背景色
itemExtent: ScreenUtil().setWidth(70), //item的高度
selectionOverlay: SizedBox(),
onSelectedItemChanged: (index) {
//选中item的位置索引
print("日index = $index}");
setState(() {
sDay = '${index + 1}';
});
sDay = '${index + 1}';
},
scrollController: dayController,
children: XZItem(day, '日'),
))),
// Expanded(
// flex: 1,
// child: Container(
// height: 200,
// child: CupertinoPicker(
// useMagnifier: true,
// magnification: 1.2,
// squeeze: 1,
// diameterRatio: 1.5,
// looping: false,
// backgroundColor: Colors.transparent, //选择器背景色
// itemExtent: 35, //item的高度
// onSelectedItemChanged: (index) {
// //选中item的位置索引
// print("index = $index}");
// setState(() {
// if (index == 0) {
// sTime = '24';
// } else {
// sTime = '${index - 1}';
// }
// });
// },
// scrollController: timeController,
// children: XZItem(time, ''),
// ))),
])
])));
}
List<Widget> XZItem(_data, type) {
List<Widget> list = new List();
for (var i = 0; i < _data.length; i++) {
list.add(Text('${_data[i]}$type',
style: TextStyle(color: Colors.black, fontSize: 14)));
}
return list;
}
}
... ...
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/res/colors.dart';
import 'change_nongli_yangli.dart';
typedef CustomCallBack = void Function(Object object);
List updateDay(bool gongli, String year, String month) {
if (gongli) {
// 公历// 截取天数
// print('widget.sYear ==== ${sYear}');
// print('widget.sMonth ==== ${sMonth}');
// print('widget.sDay ==== ${sDay}');
int count = getYangliDay(int.parse(year), int.parse(month));
print('count---$count');
List yday = [];
for (int m = 1; m < count + 1; m++) {
yday.add('$m');
}
return yday;
} else {
int count1 = getYangliDay(int.parse(year), int.parse(month));
print('count---$count1');
List yday = [];
for (int m = 1; m < count1 + 1; m++) {
yday.add('$m');
}
int count = getNongliDay(int.parse(year), int.parse(month));
print('农历的天数==${count}');
List old = yday;
List newDay = old.sublist(0, count);
print(old);
print(newDay);
yday = newDay;
return yday;
}
}
void incrementCounterMonth(
context,
bool gongli,
String year,
String month,
CustomCallBack callBack,
) {
showDialog(
barrierDismissible: true,
context: context,
builder: (context) {
// 用Scaffold返回显示的内容,能跟随主题
return GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: Scaffold(
backgroundColor: Colors.transparent, // 设置透明背影
body: Stack(children: <Widget>[
PickBodyMonth(
gongli: gongli,
callBack: callBack,
year: year,
month: month)
])));
},
);
}
class PickBodyMonth extends StatefulWidget {
final bool gongli;
final CustomCallBack callBack;
final String year;
final String month;
PickBodyMonth({Key key, this.gongli, this.callBack, this.month, this.year})
: super(key: key);
@override
_PickBodyMonthState createState() => _PickBodyMonthState();
}
class _PickBodyMonthState extends State<PickBodyMonth> {
String sYear = "2000";
String sMonth = '6';
List month = [], yMonth = [];
List nMonth = ['正', '二', '三', '四', '五', '六', '七', '八', '九', '十', '冬', '腊'];
FixedExtentScrollController monthController =
new FixedExtentScrollController(initialItem: 5);
@override
void initState() {
// TODO: implement initState
super.initState();
// 获取当天的日期,年份默认选择的是2000年,月份默认是6月,日期默认是15日,时间默认是不详
monthController = new FixedExtentScrollController(
initialItem: int.parse(widget.month) - 1);
DateTime today = DateTime.now();
// 请空之前的数据
yMonth = [];
for (int m = 1; m < 13; m++) {
yMonth.add('$m');
}
// 获取默认年份和月份之下的天数
// updateDay();
}
@override
Widget build(BuildContext context) {
// 切换农历和阳历的时候更换月份和天的称呼
if (widget.gongli) {
month = yMonth;
} else {
month = nMonth;
}
return Positioned(
left: 0,
right: 0,
bottom: 0,
child: Container(
// height: 300,
decoration: BoxDecoration(color: Colors.white),
// padding: EdgeInsets.all(10),
child: Column(children: <Widget>[
Container(
// padding: EdgeInsets.symmetric(hori ScreenUtil().setWidth(30)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: ScreenUtil().setWidth(1),
color: MyColours.color_E0E0E0))),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
flex: 1,
child: GestureDetector(
child: Container(
color: Colors.white,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40)),
alignment: Alignment.centerLeft,
height: ScreenUtil().setWidth(90),
child: Text('取消',
style: TextStyle(
color: MyColours.color_333333))),
onTap: () {
print('关闭弹框');
Navigator.pop(context);
},
)),
Expanded(
flex: 1,
child: GestureDetector(
child: Container(
color: Colors.white,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40)),
alignment: Alignment.centerRight,
height: ScreenUtil().setWidth(90),
child: Text('确定',
style:
TextStyle(color: MyColours.color_199095)),
),
onTap: () {
print('确定 关闭弹框');
print(sMonth);
// print(sMonth);
// print(sDay);
// print(sTime);
widget.callBack(sMonth);
Navigator.pop(context);
},
)),
],
)),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
// Expanded(
// flex: 1,
// child: Container(
// height: 200,
// child: CupertinoPicker(
// useMagnifier: true,
// magnification: 1.2,
// squeeze: 1,
// diameterRatio: 1.5,
// looping: false,
// backgroundColor: Colors.transparent, //选择器背景色
// itemExtent: 35, //item的高度
// onSelectedItemChanged: (index) {
// print('index === $index');
// int selectYear = 1980 + index;
// // 更改年的时候,查询选中的年和月的天数
// print("选中年 = ${selectYear}");
// setState(() {
// sYear = '$selectYear';
// // 更换年的时候检测是阳历还是农历
// updateDay();
// // monthController.jumpToItem(3);
// });
// },
// scrollController: yearController,
// children: XZItem(year, '年'),
// ))),
Expanded(
flex: 1,
child: Container(
height: ScreenUtil().setWidth(360),
child: CupertinoPicker(
useMagnifier: true,
magnification: 1.3,
squeeze: 1,
diameterRatio: 1.5,
looping: false,
backgroundColor: Colors.transparent, //选择器背景色
itemExtent: ScreenUtil().setWidth(70), //item的高度
selectionOverlay: SizedBox(),
onSelectedItemChanged: (index) {
//选中item的位置索引
print("月index = $index}");
setState(() {
sMonth = '${index + 1}';
});
sMonth = '${index + 1}';
// updateDay();
},
scrollController: monthController,
children: XZItem(month, '月'),
))),
// Expanded(
// flex: 1,
// child: Container(
// height: 200,
// child: CupertinoPicker(
// useMagnifier: true,
// magnification: 1.2,
// squeeze: 1,
// diameterRatio: 1.5,
// looping: false,
// backgroundColor: Colors.transparent, //选择器背景色
// itemExtent: 35, //item的高度
// onSelectedItemChanged: (index) {
// //选中item的位置索引
// print("日index = $index}");
// setState(() {
// sDay = '${index + 1}';
// });
// sDay = '${index + 1}';
// },
// scrollController: dayController,
// children: XZItem(day, '日'),
// ))),
// Expanded(
// flex: 1,
// child: Container(
// height: 200,
// child: CupertinoPicker(
// useMagnifier: true,
// magnification: 1.2,
// squeeze: 1,
// diameterRatio: 1.5,
// looping: false,
// backgroundColor: Colors.transparent, //选择器背景色
// itemExtent: 35, //item的高度
// onSelectedItemChanged: (index) {
// //选中item的位置索引
// print("index = $index}");
// setState(() {
// if (index == 0) {
// sTime = '24';
// } else {
// sTime = '${index - 1}';
// }
// });
// },
// scrollController: timeController,
// children: XZItem(time, ''),
// ))),
])
])));
}
// updateDay() {
// if (widget.gongli) {
// // 公历// 截取天数
// print('widget.sYear ==== ${sYear}');
// print('widget.sMonth ==== ${sMonth}');
// print('widget.sDay ==== ${sDay}');
// int count = getYangliDay(int.parse(sYear), int.parse(sMonth));
// print('count---$count');
// yday = [];
// for (int m = 1; m < count + 1; m++) {
// yday.add('$m');
// }
// } else {
// int count = getNongliDay(int.parse(sYear), int.parse(sMonth));
// print('农历的天数==${count}');
// List old = day;
// List newDay = old.sublist(0, count);
// print(old);
// print(newDay);
// day = newDay;
// }
// }
List<Widget> XZItem(_data, type) {
List<Widget> list = new List();
for (var i = 0; i < _data.length; i++) {
list.add(Text('${_data[i]}$type',
style: TextStyle(color: Colors.black, fontSize: 14)));
}
return list;
}
}
... ...
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'change_nongli_yangli.dart';
typedef CustomCallBack = void Function(Object object);
void incrementCounterYear(
context,
bool gongli,
String year,
CustomCallBack callBack,
) {
showDialog(
barrierDismissible: true,
context: context,
builder: (context) {
// 用Scaffold返回显示的内容,能跟随主题
return Scaffold(
backgroundColor: Colors.transparent, // 设置透明背影
body: Stack(children: <Widget>[
PickBodyYear(gongli: gongli, callBack: callBack, year: year)
]));
},
);
}
class PickBodyYear extends StatefulWidget {
final bool gongli;
final CustomCallBack callBack;
final String year;
PickBodyYear({Key key, this.gongli, this.callBack, this.year})
: super(key: key);
@override
_PickBodyYearState createState() => _PickBodyYearState();
}
class _PickBodyYearState extends State<PickBodyYear> {
String sYear = "2000";
// String sMonth = '6';
// String sDay = '15';
// String sTime = '24';
List yearList = [];
// List nMonth = ['正', '二', '三', '四', '五', '六', '七', '八', '九', '十', '冬', '腊'];
// List time = [
// '时辰未知',
// '0时子',
// '1时丑',
// '2时丑',
// '3时寅',
// '4时寅',
// '5时',
// '6时',
// '7时',
// '8时',
// '9时',
// '10时',
// '11时',
// '12时',
// '13时丑',
// '14时丑',
// '15时寅',
// '16时寅',
// '17时',
// '18时',
// '19时',
// '20时',
// '21时',
// '22时',
// '23时'
// ];
// List nday = [
// '初一',
// '初二',
// '初三',
// '初四',
// '初五',
// '初六',
// '初七',
// '初八',
// '初九',
// '初十',
// '十一',
// '十二',
// '十三',
// '十四',
// '十五',
// '十六',
// '十七',
// '十八',
// '十九',
// '二十',
// '廿一',
// '廿二',
// '廿三',
// '廿四',
// '廿五',
// '廿六',
// '廿七',
// '廿八',
// '廿九',
// '三十',
// '三十一'
// ];
FixedExtentScrollController yearController =
new FixedExtentScrollController(initialItem: 20);
// FixedExtentScrollController monthController =
// new FixedExtentScrollController(initialItem: 5);
// FixedExtentScrollController dayController =
// new FixedExtentScrollController(initialItem: 14);
// FixedExtentScrollController timeController =
// new FixedExtentScrollController();
@override
void initState() {
// TODO: implement initState
super.initState();
// 获取当天的日期,年份默认选择的是2000年,月份默认是6月,日期默认是15日,时间默认是不详
yearController = new FixedExtentScrollController(
initialItem: int.parse(widget.year) - 1900);
DateTime today = DateTime.now();
// 请空之前的数据
sYear = widget.year;
for (var y = 1900; y < today.year + 50; y++) {
yearList.add('$y');
}
// yMonth = [];
// for (int m = 1; m < 13; m++) {
// yMonth.add('$m');
// }
// 获取默认年份和月份之下的天数
// int count = getYangliDay(int.parse(sYear), int.parse(sMonth));
// print('count---$count');
// yday = [];
// for (int m = 1; m < count + 1; m++) {
// yday.add('$m');
// }
// updateDay();
}
@override
Widget build(BuildContext context) {
// 切换农历和阳历的时候更换月份和天的称呼
// if (widget.gongli) {
// month = yMonth;
// day = yday;
// } else {
// month = nMonth;
// int count = getNongliDay(int.parse(sYear), int.parse(sMonth));
// print('农历的天数==${count}');
// List old = nday;
// List newDay = old.sublist(0, count);
// // 初始化当前的选中的月份的天数
// day = newDay;
// }
return Positioned(
left: 0,
right: 0,
bottom: 0,
child: Container(
// height: ScreenUtil().setWidth(380+100),
decoration: BoxDecoration(color: Colors.white),
// padding: EdgeInsets.all(10),
child: Column(children: <Widget>[
// VEmptyView(10),
Container(
// padding: EdgeInsets.symmetric(hori ScreenUtil().setWidth(30)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: ScreenUtil().setWidth(1),
color: MyColours.color_E0E0E0))),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
flex: 1,
child: GestureDetector(
child: Container(
color: Colors.white,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40)),
alignment: Alignment.centerLeft,
height: ScreenUtil().setWidth(90),
child: Text('取消',
style: TextStyle(
color: MyColours.color_333333))),
onTap: () {
print('关闭弹框');
Navigator.pop(context);
},
)),
Expanded(
flex: 1,
child: GestureDetector(
child: Container(
color: Colors.white,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40)),
alignment: Alignment.centerRight,
height: ScreenUtil().setWidth(90),
child: Text('确定',
style:
TextStyle(color: MyColours.color_199095)),
),
onTap: () {
print('确定 关闭弹框');
print(sYear);
// print(sMonth);
// print(sDay);
// print(sTime);
widget.callBack(sYear);
Navigator.pop(context);
},
)),
],
)),
VEmptyView(30),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
flex: 1,
child: Container(
height: ScreenUtil().setWidth(360),
child: CupertinoPicker(
useMagnifier: true,
magnification: 1.3,
squeeze: 1,
diameterRatio: 1.5,
looping: false,
backgroundColor: Colors.transparent, //选择器背景色
itemExtent: ScreenUtil().setWidth(70), //item的高度
selectionOverlay: SizedBox(),
onSelectedItemChanged: (index) {
print('index === $index');
int selectYear = 1900 + index;
// 更改年的时候,查询选中的年和月的天数
print("选中年 = ${selectYear}");
setState(() {
sYear = '$selectYear';
// 更换年的时候检测是阳历还是农历
// updateDay();
// monthController.jumpToItem(3);
});
},
scrollController: yearController,
children: XZItem(yearList, '年'),
))),
]),
VEmptyView(30),
])));
}
// updateDay() {
// if (widget.gongli) {
// // 公历// 截取天数
// print('widget.sYear ==== ${sYear}');
// print('widget.sMonth ==== ${sMonth}');
// print('widget.sDay ==== ${sDay}');
// int count = getYangliDay(int.parse(sYear), int.parse(sMonth));
// print('count---$count');
// yday = [];
// for (int m = 1; m < count + 1; m++) {
// yday.add('$m');
// }
// } else {
// int count = getNongliDay(int.parse(sYear), int.parse(sMonth));
// print('农历的天数==${count}');
// List old = day;
// List newDay = old.sublist(0, count);
// print(old);
// print(newDay);
// day = newDay;
// }
// }
List<Widget> XZItem(_data, type) {
List<Widget> list = new List();
for (var i = 0; i < _data.length; i++) {
list.add(Container(
alignment: Alignment.center,
child: Text('${_data[i]}$type',
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(28))),
));
}
return list;
}
}
... ...
... ... @@ -121,7 +121,7 @@ class FTableItemState extends State<FTableItem> {
// margin: EdgeInsets.all(ScreenUtil().setWidth(9)),
decoration: BoxDecoration(
color: widget.need && signStr == '已预订' && !isSelf
? Color.fromRGBO(154, 23, 45, 1)
? MyColours.color_afbcc4
: widget.canSelected && table.selected
? MyColours.color_199095
: MyColours.color_ffffff,
... ... @@ -152,13 +152,13 @@ class FTableItemState extends State<FTableItem> {
table.name,
maxLines: 1,
style: TextStyle(
color: (widget.need &&
signStr == '已预订' &&
!isSelf) ||
(widget.canSelected && table.selected)
? MyColours.color_ffffff
: MyColours.color_333333,
fontSize: ScreenUtil().setSp(36),
color:
(widget.need && signStr == '已预订' && !isSelf)
? MyColours.color_333333
: (widget.canSelected && table.selected)
? MyColours.color_ffffff
: MyColours.color_333333,
fontSize: ScreenUtil().setSp(34),
decoration: TextDecoration.none,
fontWeight: FontWeight.bold),
overflow: TextOverflow.ellipsis,
... ... @@ -199,10 +199,11 @@ class FTableItemState extends State<FTableItem> {
: '')
: table.tableNum,
style: TextStyle(
color: signStr == '已预订' && !isSelf ||
(widget.canSelected && table.selected)
? MyColours.color_ffffff
: MyColours.color_353535,
color: signStr == '已预订' && !isSelf
? MyColours.color_353535
: (widget.canSelected && table.selected)
? MyColours.color_ffffff
: MyColours.color_353535,
fontSize: ScreenUtil().setSp(22),
decoration: TextDecoration.none,
fontWeight: FontWeight.normal),
... ... @@ -220,7 +221,7 @@ class FTableItemState extends State<FTableItem> {
? '${table.nickName}订'
: '',
style: TextStyle(
color: MyColours.color_ffffff,
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(22),
decoration: TextDecoration.none,
fontWeight: FontWeight.normal),
... ... @@ -237,12 +238,12 @@ class FTableItemState extends State<FTableItem> {
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(10)),
decoration: BoxDecoration(
color: Color.fromRGBO(232, 141, 164, 1),
color: MyColours.color_d7d7d7,
),
child: Text(
'新客',
style: TextStyle(
color: MyColours.color_ffffff,
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(24),
decoration: TextDecoration.none,
fontWeight: FontWeight.normal),
... ...