You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.1 KiB
80 lines
2.1 KiB
import 'package:flutter/material.dart';
|
|
import 'package:flutter_custom_calendar/calendar_view.dart';
|
|
import 'package:flutter_custom_calendar/controller.dart';
|
|
|
|
class DefaultStylePage extends StatefulWidget {
|
|
DefaultStylePage({Key key, this.title}) : super(key: key);
|
|
|
|
final String title;
|
|
|
|
@override
|
|
_DefaultStylePageState createState() => _DefaultStylePageState();
|
|
}
|
|
|
|
class _DefaultStylePageState extends State<DefaultStylePage> {
|
|
String text;
|
|
|
|
CalendarController controller;
|
|
|
|
@override
|
|
void initState() {
|
|
text = "${DateTime.now().year}年${DateTime.now().month}月";
|
|
|
|
controller = new CalendarController();
|
|
|
|
controller.addMonthChangeListener(
|
|
(year, month) {
|
|
setState(() {
|
|
text = "$year年$month月";
|
|
});
|
|
},
|
|
);
|
|
|
|
controller.addOnCalendarSelectListener((dateModel) {
|
|
//刷新选择的时间
|
|
setState(() {});
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text(widget.title),
|
|
),
|
|
body: new Container(
|
|
child: new Column(
|
|
children: <Widget>[
|
|
new Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
new IconButton(
|
|
icon: Icon(Icons.navigate_before),
|
|
onPressed: () {
|
|
controller.moveToPreviousMonth();
|
|
}),
|
|
new Text(text),
|
|
new IconButton(
|
|
icon: Icon(Icons.navigate_next),
|
|
onPressed: () {
|
|
controller.moveToNextMonth();
|
|
}),
|
|
],
|
|
),
|
|
CalendarViewWidget(
|
|
calendarController: controller,
|
|
),
|
|
new Text(
|
|
"单选模式\n选中的时间:\n${controller.getSingleSelectCalendar().toString()}"),
|
|
],
|
|
),
|
|
),
|
|
floatingActionButton: FloatingActionButton(
|
|
onPressed: () {},
|
|
tooltip: 'Increment',
|
|
child: Icon(Icons.add),
|
|
), // This trailing comma makes auto-formatting nicer for build methods.
|
|
);
|
|
}
|
|
}
|