更新日历样式

This commit is contained in:
czz
2025-07-11 16:48:25 +08:00
parent 092267ae3a
commit de5bacb553
11 changed files with 271 additions and 89 deletions

View File

@@ -271,6 +271,153 @@ Future showDateSelectionDialog(BuildContext context,
);
}
Future showMonthSelectionDialog(
BuildContext context, {
required DateTime checkDate,
Function(DateTime)? checkChange,
String title = "选择月份",
}) {
ThemeController themeController = Get.find();
final List<int> years = List.generate(100, (i) => DateTime.now().year - i)
..sort();
final List<int> months = List.generate(12, (i) => i + 1);
final RxInt yearIndex = years.indexOf(checkDate.year).obs;
final RxInt monthIndex = months.indexOf(checkDate.month).obs;
return showDialog(
context: context,
barrierDismissible: true,
builder: (BuildContext context) {
return Stack(
children: [
Positioned(
bottom: 0,
left: 0,
right: 0,
child: Material(
color: Colors.transparent,
child: Dialog(
backgroundColor: const Color(0xFF003058),
insetPadding: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0),
),
child: Container(
width: double.infinity,
padding: EdgeInsets.fromLTRB(30.rpx, 10.rpx, 30.rpx, 90.rpx),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: Colors.transparent,
padding: EdgeInsets.zero,
onTap: () => Navigator.of(context).pop(),
child: Container(
width: 100.rpx,
height: 60.rpx,
alignment: Alignment.center,
child: Text("取消",
style: TextStyle(
fontSize: 30.rpx, color: Colors.white)),
),
),
Text(
title,
style: TextStyle(
fontFamily: 'Readex Pro',
color: themeController.currentColor.sc3,
fontSize: 30.rpx,
),
),
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: Colors.transparent,
padding: EdgeInsets.zero,
onTap: () {
final selectedDate = DateTime(
years[yearIndex.value],
months[monthIndex.value],
);
Navigator.of(context).pop();
checkChange?.call(selectedDate);
},
child: Container(
width: 100.rpx,
height: 60.rpx,
alignment: Alignment.center,
child: Text("确定",
style: TextStyle(
fontSize: 30.rpx,
color: stringToColor("#84F5FF"))),
),
),
],
),
SizedBox(height: 20.rpx),
Stack(
children: [
Positioned.fill(
child: IgnorePointer(
child: Center(
child: Container(
height: 90.rpx,
margin:
EdgeInsets.symmetric(horizontal: 95.rpx),
decoration: BoxDecoration(
color: const Color(0xFF84F5FF),
borderRadius: BorderRadius.circular(16.rpx),
),
),
),
),
),
SizedBox(
height: 240.rpx,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 95.rpx),
child: Row(
children: [
Expanded(
child: getOnePickers(
context,
years,
yearIndex,
unit: "",
),
),
Expanded(
child: getOnePickers(
context,
months,
monthIndex,
unit: "",
),
),
],
),
),
),
],
),
],
),
),
),
),
),
],
);
},
);
}
Future<void> showWeightPickerDialog(
BuildContext context, {
required String initialWeight, // 初始体重单位kg