|
|
@ -2,6 +2,9 @@ import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_custom_calendar/flutter_custom_calendar.dart';
|
|
|
|
import 'package:flutter_custom_calendar/flutter_custom_calendar.dart';
|
|
|
|
import 'dart:math';
|
|
|
|
import 'dart:math';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 进度条风格+单选
|
|
|
|
|
|
|
|
*/
|
|
|
|
class ProgressStylePage extends StatefulWidget {
|
|
|
|
class ProgressStylePage extends StatefulWidget {
|
|
|
|
ProgressStylePage({Key key, this.title}) : super(key: key);
|
|
|
|
ProgressStylePage({Key key, this.title}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
|
@ -12,18 +15,23 @@ class ProgressStylePage extends StatefulWidget {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _ProgressStylePageState extends State<ProgressStylePage> {
|
|
|
|
class _ProgressStylePageState extends State<ProgressStylePage> {
|
|
|
|
String text;
|
|
|
|
ValueNotifier<String> text;
|
|
|
|
|
|
|
|
ValueNotifier<String> selectText;
|
|
|
|
|
|
|
|
|
|
|
|
CalendarController controller;
|
|
|
|
CalendarController controller;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
text = "${DateTime.now().year}年${DateTime.now().month}月";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DateTime now = DateTime.now();
|
|
|
|
DateTime now = DateTime.now();
|
|
|
|
DateTime temp = DateTime(now.year, now.month, now.day);
|
|
|
|
DateTime temp = DateTime(now.year, now.month, now.day);
|
|
|
|
|
|
|
|
|
|
|
|
Map<DateModel, int> progressMap = {
|
|
|
|
Map<DateModel, int> progressMap = {
|
|
|
|
|
|
|
|
DateModel.fromDateTime(temp.add(Duration(days: -1))): 0,
|
|
|
|
|
|
|
|
DateModel.fromDateTime(temp.add(Duration(days: -2))): 20,
|
|
|
|
|
|
|
|
DateModel.fromDateTime(temp.add(Duration(days: -3))): 40,
|
|
|
|
|
|
|
|
DateModel.fromDateTime(temp.add(Duration(days: -4))): 60,
|
|
|
|
|
|
|
|
DateModel.fromDateTime(temp.add(Duration(days: -5))): 80,
|
|
|
|
|
|
|
|
DateModel.fromDateTime(temp.add(Duration(days: -6))): 100,
|
|
|
|
DateModel.fromDateTime(temp.add(Duration(days: 1))): 0,
|
|
|
|
DateModel.fromDateTime(temp.add(Duration(days: 1))): 0,
|
|
|
|
DateModel.fromDateTime(temp.add(Duration(days: 2))): 20,
|
|
|
|
DateModel.fromDateTime(temp.add(Duration(days: 2))): 20,
|
|
|
|
DateModel.fromDateTime(temp.add(Duration(days: 3))): 40,
|
|
|
|
DateModel.fromDateTime(temp.add(Duration(days: 3))): 40,
|
|
|
@ -43,23 +51,20 @@ class _ProgressStylePageState extends State<ProgressStylePage> {
|
|
|
|
|
|
|
|
|
|
|
|
controller.addMonthChangeListener(
|
|
|
|
controller.addMonthChangeListener(
|
|
|
|
(year, month) {
|
|
|
|
(year, month) {
|
|
|
|
setState(() {
|
|
|
|
text.value = "$year年$month月";
|
|
|
|
text = "$year年$month月";
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
controller.addOnCalendarSelectListener((dateModel) {
|
|
|
|
controller.addOnCalendarSelectListener((dateModel) {
|
|
|
|
//刷新选择的时间
|
|
|
|
//刷新选择的时间
|
|
|
|
setState(() {});
|
|
|
|
selectText.value =
|
|
|
|
|
|
|
|
"单选模式\n选中的时间:\n${controller.getSingleSelectCalendar()}";
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
controller.addOnMultiSelectOutOfSizeListener(() {
|
|
|
|
text = new ValueNotifier("${DateTime.now().year}年${DateTime.now().month}月");
|
|
|
|
print("超出限制个数");
|
|
|
|
|
|
|
|
});
|
|
|
|
selectText = new ValueNotifier(
|
|
|
|
controller.addOnMultiSelectOutOfRangeListener(() {
|
|
|
|
"单选模式\n选中的时间:\n${controller.getSingleSelectCalendar()}");
|
|
|
|
print("超出范围限制");
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
@ -79,7 +84,11 @@ class _ProgressStylePageState extends State<ProgressStylePage> {
|
|
|
|
onPressed: () {
|
|
|
|
onPressed: () {
|
|
|
|
controller.moveToPreviousMonth();
|
|
|
|
controller.moveToPreviousMonth();
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
new Text(text),
|
|
|
|
ValueListenableBuilder(
|
|
|
|
|
|
|
|
valueListenable: text,
|
|
|
|
|
|
|
|
builder: (context, value, child) {
|
|
|
|
|
|
|
|
return new Text(text.value);
|
|
|
|
|
|
|
|
}),
|
|
|
|
new IconButton(
|
|
|
|
new IconButton(
|
|
|
|
icon: Icon(Icons.navigate_next),
|
|
|
|
icon: Icon(Icons.navigate_next),
|
|
|
|
onPressed: () {
|
|
|
|
onPressed: () {
|
|
|
@ -90,8 +99,11 @@ class _ProgressStylePageState extends State<ProgressStylePage> {
|
|
|
|
CalendarViewWidget(
|
|
|
|
CalendarViewWidget(
|
|
|
|
calendarController: controller,
|
|
|
|
calendarController: controller,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
// new Text(
|
|
|
|
ValueListenableBuilder(
|
|
|
|
// "单选模式\n选中的时间:\n${controller.getSingleSelectCalendar().toString()}"),
|
|
|
|
valueListenable: selectText,
|
|
|
|
|
|
|
|
builder: (context, value, child) {
|
|
|
|
|
|
|
|
return new Text(selectText.value);
|
|
|
|
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|