代码格式优化,删掉没用的代码

develop^2
LXD312569496 5 years ago committed by xiaodong
parent 8879b04fa7
commit fdcb1c2c85

@ -1,7 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_custom_calendar/flutter_custom_calendar.dart'; import 'package:flutter_custom_calendar/flutter_custom_calendar.dart';
import 'package:flutter_custom_calendar/style/style.dart';
import 'package:random_pk/random_pk.dart';
class BlueStylePage extends StatefulWidget { class BlueStylePage extends StatefulWidget {
@ -23,6 +21,7 @@ class _BlueStylePageState extends State<BlueStylePage> {
@override @override
void initState() { void initState() {
super.initState();
controller = new CalendarController( controller = new CalendarController(
showMode: CalendarConstants.MODE_SHOW_MONTH_AND_WEEK, showMode: CalendarConstants.MODE_SHOW_MONTH_AND_WEEK,
@ -81,8 +80,7 @@ class _BlueStylePageState extends State<BlueStylePage> {
height: 20, height: 20,
), ),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.max,
mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
Container( Container(
height: 100, height: 100,
@ -146,7 +144,7 @@ class _BlueStylePageState extends State<BlueStylePage> {
} }
class CustomStyleWeekBarItem extends BaseWeekBar { class CustomStyleWeekBarItem extends BaseWeekBar {
List<String> weekList = ["mo", "tu", "we", "th", "fr", "sa", "su"]; final List<String> weekList = ["mo", "tu", "we", "th", "fr", "sa", "su"];
//build //build
@override @override
@ -183,10 +181,10 @@ class CustomStyleWeekBarItem extends BaseWeekBar {
class CustomStyleDayWidget extends BaseCombineDayWidget { class CustomStyleDayWidget extends BaseCombineDayWidget {
CustomStyleDayWidget(DateModel dateModel) : super(dateModel); CustomStyleDayWidget(DateModel dateModel) : super(dateModel);
TextStyle normalTextStyle = final TextStyle normalTextStyle =
TextStyle(fontWeight: FontWeight.w700, color: Colors.black); TextStyle(fontWeight: FontWeight.w700, color: Colors.black);
TextStyle noIsCurrentMonthTextStyle = final TextStyle noIsCurrentMonthTextStyle =
TextStyle(fontWeight: FontWeight.w700, color: Colors.grey); TextStyle(fontWeight: FontWeight.w700, color: Colors.grey);
@override @override

@ -43,6 +43,7 @@ class _CustomSignPageState extends State<CustomSignPage> {
@override @override
void initState() { void initState() {
super.initState();
controller = new CalendarController( controller = new CalendarController(
extraDataMap: customExtraData); extraDataMap: customExtraData);
@ -124,7 +125,7 @@ class _CustomSignPageState extends State<CustomSignPage> {
} }
class CustomStyleWeekBarItem extends BaseWeekBar { class CustomStyleWeekBarItem extends BaseWeekBar {
List<String> weekList = ["", "", "", "", "", "", ""]; final List<String> weekList = ["", "", "", "", "", "", ""];
@override @override
Widget getWeekBarItem(int index) { Widget getWeekBarItem(int index) {

@ -21,6 +21,7 @@ class _CustomStylePageState extends State<CustomStylePage> {
@override @override
void initState() { void initState() {
super.initState();
controller = new CalendarController(); controller = new CalendarController();
controller.addMonthChangeListener( controller.addMonthChangeListener(
@ -96,7 +97,7 @@ class _CustomStylePageState extends State<CustomStylePage> {
} }
class CustomStyleWeekBarItem extends BaseWeekBar { class CustomStyleWeekBarItem extends BaseWeekBar {
List<String> weekList = ["", "", "", "", "", "", ""]; final List<String> weekList = ["", "", "", "", "", "", ""];
@override @override
Widget getWeekBarItem(int index) { Widget getWeekBarItem(int index) {

@ -21,12 +21,13 @@ class _DefaultStylePageState extends State<DefaultStylePage> {
@override @override
void initState() { void initState() {
super.initState();
DateTime now = DateTime.now(); DateTime now = DateTime.now();
controller = new CalendarController( controller = new CalendarController(
minYear: now.year, minYear: now.year-1,
minYearMonth: now.month - 5, minYearMonth: 1,
maxYear: now.year, maxYear: now.year+1,
maxYearMonth: now.month + 5, maxYearMonth: 12,
showMode: CalendarConstants.MODE_SHOW_MONTH_AND_WEEK); showMode: CalendarConstants.MODE_SHOW_MONTH_AND_WEEK);
controller.addMonthChangeListener( controller.addMonthChangeListener(

@ -1,7 +1,7 @@
import 'package:example/only_week_page.dart'; import 'package:example/only_week_page.dart';
import 'package:example/red_style_page.dart'; import 'package:example/red_style_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'blue_style_page.dart'; import 'blue_style_page.dart';
import 'custom_sign_page.dart'; import 'custom_sign_page.dart';
import 'custom_style_page.dart'; import 'custom_style_page.dart';
@ -114,64 +114,3 @@ class HomePage extends StatelessWidget {
} }
} }
//
//# Desktop Flutter Example
//
//This is the standard Flutter template application, modified to run on desktop.
//
//The `linux` and `windows` directories serve as early prototypes of
//what will eventually become the `flutter create` templates for desktop, and will
//be evolving over time to better reflect that goal. The `macos` directory has
//now become a `flutter create` template, so is largely identical to what that
//command creates.
//
//## Building and Running
//
//See [the main project README](../README.md).
//
//To build without running, use `flutter build macos`/`windows`/`linux` rather than `flutter run`, as with
//a standard Flutter project.
//
//## Dart Differences from Flutter Template
//
//The `main.dart` and `pubspec.yaml` have minor changes to support desktop:
//* `debugDefaultTargetPlatformOverride` is set to avoid 'Unknown platform'
//exceptions.
//* The font is explicitly set to Roboto, and Roboto is bundled via
//`pubspec.yaml`, to ensure that text displays on all platforms.
//
//See the [Flutter Application Requirements section of the Flutter page on
//desktop support](https://github.com/flutter/flutter/wiki/Desktop-shells#flutter-application-requirements)
//for more information.
//
//## Adapting for Another Project
//
//Since `flutter create` is not yet supported for Windows and Linux, the easiest
//way to try out desktop support with an existing Flutter application on those
//platforms is to copy the platform directories from this example; see below for
//details. For macOS, just run `flutter create --macos .` in your project.
//
//Be sure to read the [Flutter page on desktop
//support](https://github.com/flutter/flutter/wiki/Desktop-shells) before trying to
//run an existing project on desktop, especially the [Flutter Application Requirements
//section](https://github.com/flutter/flutter/wiki/Desktop-shells#flutter-application-requirements).
//
//### Coping the Desktop Runners
//
//The 'linux' and 'windows' directories are self-contained, and can be copied to
//an existing Flutter project, enabling `flutter run` for those platforms.
//
//**Be aware that neither the API surface of the Flutter desktop libraries nor the
//interaction between the `flutter` tool and the platform directories is stable,
//and no attempt will be made to provide supported migration paths as things
//change.** You should expect that every time you update Flutter you may have
//to delete your copies of the platform directories and re-copy them from an
//updated version of flutter-desktop-embedding.
//
//### Customizing the Runners
//
//See [Application Customization](App-Customization.md) for premilinary
//documenation on modifying basic application information like name and icon.
//
//If you are building for macOS, you should also read about [managing macOS
//security configurations](../macOS-Security.md).

@ -21,6 +21,7 @@ class _MultiSelectStylePageState extends State<MultiSelectStylePage> {
@override @override
void initState() { void initState() {
super.initState();
controller = new CalendarController( controller = new CalendarController(
selectMode: CalendarConstants.MODE_MULTI_SELECT, selectMode: CalendarConstants.MODE_MULTI_SELECT,
maxMultiSelectCount: 5, maxMultiSelectCount: 5,
@ -102,7 +103,7 @@ class _MultiSelectStylePageState extends State<MultiSelectStylePage> {
} }
class CustomStyleWeekBarItem extends BaseWeekBar { class CustomStyleWeekBarItem extends BaseWeekBar {
List<String> weekList = ["", "", "", "", "", "", ""]; final List<String> weekList = ["", "", "", "", "", "", ""];
@override @override
Widget getWeekBarItem(int index) { Widget getWeekBarItem(int index) {
@ -119,7 +120,6 @@ class CustomStyleDayWidget extends BaseCustomDayWidget {
@override @override
void drawNormal(DateModel dateModel, Canvas canvas, Size size) { void drawNormal(DateModel dateModel, Canvas canvas, Size size) {
bool isWeekend = dateModel.isWeekend;
bool isInRange = dateModel.isInRange; bool isInRange = dateModel.isInRange;
// //

@ -21,6 +21,7 @@ class _OnlyWeekPageState extends State<OnlyWeekPage> {
@override @override
void initState() { void initState() {
super.initState();
DateTime now = DateTime.now(); DateTime now = DateTime.now();
controller = new CalendarController( controller = new CalendarController(
minYear: now.year, minYear: now.year,

@ -22,6 +22,7 @@ class _ProgressStylePageState extends State<ProgressStylePage> {
@override @override
void initState() { void initState() {
super.initState();
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);
@ -117,7 +118,7 @@ class _ProgressStylePageState extends State<ProgressStylePage> {
} }
class CustomStyleWeekBarItem extends BaseWeekBar { class CustomStyleWeekBarItem extends BaseWeekBar {
List<String> weekList = ["", "", "", "", "", "", ""]; final List<String> weekList = ["", "", "", "", "", "", ""];
@override @override
Widget getWeekBarItem(int index) { Widget getWeekBarItem(int index) {

@ -22,6 +22,8 @@ class _RedStylePageState extends State<RedStylePage> {
@override @override
void initState() { void initState() {
super.initState();
controller = new CalendarController( controller = new CalendarController(
showMode: CalendarConstants.MODE_SHOW_MONTH_AND_WEEK, showMode: CalendarConstants.MODE_SHOW_MONTH_AND_WEEK,
extraDataMap: customExtraData); extraDataMap: customExtraData);
@ -47,6 +49,7 @@ class _RedStylePageState extends State<RedStylePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var calendarWidget = CalendarViewWidget( var calendarWidget = CalendarViewWidget(
itemSize: 40,
calendarController: controller, calendarController: controller,
margin: EdgeInsets.only(top: 20), margin: EdgeInsets.only(top: 20),
weekBarItemWidgetBuilder: () { weekBarItemWidgetBuilder: () {
@ -64,7 +67,7 @@ class _RedStylePageState extends State<RedStylePage> {
color: Colors.white, color: Colors.white,
padding: EdgeInsets.symmetric(horizontal: 20), padding: EdgeInsets.symmetric(horizontal: 20),
child: new Column( child: new Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment:CrossAxisAlignment.stretch ,
children: <Widget>[ children: <Widget>[
SizedBox( SizedBox(
height: 20, height: 20,
@ -131,7 +134,7 @@ class _RedStylePageState extends State<RedStylePage> {
} }
class CustomStyleWeekBarItem extends BaseWeekBar { class CustomStyleWeekBarItem extends BaseWeekBar {
List<String> weekList = ["M", "T", "W", "T", "F", "S", "S"]; final List<String> weekList = ["M", "T", "W", "T", "F", "S", "S"];
//build //build
@override @override
@ -168,10 +171,10 @@ class CustomStyleWeekBarItem extends BaseWeekBar {
class CustomStyleDayWidget extends BaseCombineDayWidget { class CustomStyleDayWidget extends BaseCombineDayWidget {
CustomStyleDayWidget(DateModel dateModel) : super(dateModel); CustomStyleDayWidget(DateModel dateModel) : super(dateModel);
TextStyle normalTextStyle = final TextStyle normalTextStyle =
TextStyle(fontWeight: FontWeight.w700, color: Colors.black); TextStyle(fontWeight: FontWeight.w700, color: Colors.black);
TextStyle noIsCurrentMonthTextStyle = final TextStyle noIsCurrentMonthTextStyle =
TextStyle(fontWeight: FontWeight.w700, color: Colors.grey); TextStyle(fontWeight: FontWeight.w700, color: Colors.grey);
@override @override

@ -1,6 +1,3 @@
import 'dart:developer';
import 'dart:math';
import 'package:flutter_custom_calendar/model/date_model.dart'; import 'package:flutter_custom_calendar/model/date_model.dart';
import 'package:flutter_custom_calendar/utils/LogUtil.dart'; import 'package:flutter_custom_calendar/utils/LogUtil.dart';

@ -56,7 +56,7 @@ class CustomDayWidgetPainter extends CustomPainter {
* widgetitem * widgetitem
*/ */
abstract class BaseCombineDayWidget extends StatelessWidget { abstract class BaseCombineDayWidget extends StatelessWidget {
DateModel dateModel; final DateModel dateModel;
BaseCombineDayWidget(this.dateModel); BaseCombineDayWidget(this.dateModel);

@ -16,20 +16,20 @@ import 'package:provider/provider.dart';
//StatefulWidgetStatelessWidget //StatefulWidgetStatelessWidget
class CalendarViewWidget extends StatefulWidget { class CalendarViewWidget extends StatefulWidget {
// //
BoxDecoration boxDecoration; final BoxDecoration boxDecoration;
//paddingmargin //paddingmargin
EdgeInsetsGeometry padding; final EdgeInsetsGeometry padding;
EdgeInsetsGeometry margin; final EdgeInsetsGeometry margin;
///7 ///7
double itemSize; final double itemSize;
//item10 //item10
double verticalSpacing; final double verticalSpacing;
DayWidgetBuilder dayWidgetBuilder; final DayWidgetBuilder dayWidgetBuilder;
WeekBarItemWidgetBuilder weekBarItemWidgetBuilder; final WeekBarItemWidgetBuilder weekBarItemWidgetBuilder;
// //
final CalendarController calendarController; final CalendarController calendarController;
@ -111,6 +111,7 @@ class CalendarContainerState extends State<CalendarContainer>
@override @override
void initState() { void initState() {
super.initState();
calendarProvider = Provider.of<CalendarProvider>(context, listen: false); calendarProvider = Provider.of<CalendarProvider>(context, listen: false);
expand = calendarProvider.expandStatus.value; expand = calendarProvider.expandStatus.value;

@ -1,32 +0,0 @@
import 'package:flutter/material.dart';
/**
*
*/
class FastClickWidget extends StatelessWidget {
final int between_time = 500; //500ms
Function onTap;
Widget child;
FastClickWidget({@required this.onTap, @required this.child});
int lastClickTime = 0;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
if (lastClickTime == 0 ||
DateTime.now().millisecondsSinceEpoch - lastClickTime >
between_time) {
onTap();
lastClickTime = DateTime.now().millisecondsSinceEpoch;
} else {
//500ms
}
},
child: child,
);
}
}

@ -1,5 +1,3 @@
import 'dart:developer';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_custom_calendar/cache_data.dart'; import 'package:flutter_custom_calendar/cache_data.dart';

@ -1,10 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_custom_calendar/calendar_provider.dart'; import 'package:flutter_custom_calendar/calendar_provider.dart';
import 'package:flutter_custom_calendar/configuration.dart'; import 'package:flutter_custom_calendar/configuration.dart';
import 'package:flutter_custom_calendar/constants/constants.dart';
import 'package:flutter_custom_calendar/model/date_model.dart'; import 'package:flutter_custom_calendar/model/date_model.dart';
import 'package:flutter_custom_calendar/utils/LogUtil.dart'; import 'package:flutter_custom_calendar/utils/LogUtil.dart';
import 'package:flutter_custom_calendar/utils/date_util.dart';
import 'package:flutter_custom_calendar/widget/month_view.dart'; import 'package:flutter_custom_calendar/widget/month_view.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -21,6 +19,7 @@ class _MonthViewPagerState extends State<MonthViewPager>
@override @override
void initState() { void initState() {
super.initState();
LogUtil.log(TAG: this.runtimeType, message: "MonthViewPager initState"); LogUtil.log(TAG: this.runtimeType, message: "MonthViewPager initState");
calendarProvider = Provider.of<CalendarProvider>(context, listen: false); calendarProvider = Provider.of<CalendarProvider>(context, listen: false);

@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_custom_calendar/calendar_provider.dart'; import 'package:flutter_custom_calendar/calendar_provider.dart';
import 'package:flutter_custom_calendar/configuration.dart'; import 'package:flutter_custom_calendar/configuration.dart';
import 'package:flutter_custom_calendar/constants/constants.dart'; import 'package:flutter_custom_calendar/constants/constants.dart';
import 'package:flutter_custom_calendar/controller.dart';
import 'package:flutter_custom_calendar/model/date_model.dart'; import 'package:flutter_custom_calendar/model/date_model.dart';
import 'package:flutter_custom_calendar/utils/date_util.dart'; import 'package:flutter_custom_calendar/utils/date_util.dart';
import 'package:flutter_custom_calendar/widget/month_view.dart'; import 'package:flutter_custom_calendar/widget/month_view.dart';

@ -1,7 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_custom_calendar/calendar_provider.dart'; import 'package:flutter_custom_calendar/calendar_provider.dart';
import 'package:flutter_custom_calendar/configuration.dart'; import 'package:flutter_custom_calendar/configuration.dart';
import 'package:flutter_custom_calendar/controller.dart';
import 'package:flutter_custom_calendar/model/date_model.dart'; import 'package:flutter_custom_calendar/model/date_model.dart';
import 'package:flutter_custom_calendar/utils/LogUtil.dart'; import 'package:flutter_custom_calendar/utils/LogUtil.dart';
import 'package:flutter_custom_calendar/widget/week_view.dart'; import 'package:flutter_custom_calendar/widget/week_view.dart';
@ -23,6 +22,7 @@ class _WeekViewPagerState extends State<WeekViewPager>
@override @override
void initState() { void initState() {
super.initState();
LogUtil.log(TAG: this.runtimeType, message: "WeekViewPager initState"); LogUtil.log(TAG: this.runtimeType, message: "WeekViewPager initState");
calendarProvider = Provider.of<CalendarProvider>(context, listen: false); calendarProvider = Provider.of<CalendarProvider>(context, listen: false);
@ -56,7 +56,8 @@ class _WeekViewPagerState extends State<WeekViewPager>
} }
LogUtil.log( LogUtil.log(
TAG: this.runtimeType, TAG: this.runtimeType,
message: "WeekViewPager PageView onPageChanged:${position}"); message:
"WeekViewPager PageView onPageChanged,position:$position");
// //
DateModel firstDayOfWeek = configuration.weekList[position]; DateModel firstDayOfWeek = configuration.weekList[position];
int currentMonth = firstDayOfWeek.month; int currentMonth = firstDayOfWeek.month;
@ -64,7 +65,7 @@ class _WeekViewPagerState extends State<WeekViewPager>
LogUtil.log( LogUtil.log(
TAG: this.runtimeType, TAG: this.runtimeType,
message: message:
"WeekViewPager PageView monthChange:currentMonth:${currentMonth}"); "WeekViewPager PageView monthChange:currentMonth:$currentMonth");
configuration.monthChangeListeners.forEach((listener) { configuration.monthChangeListeners.forEach((listener) {
listener(firstDayOfWeek.year, firstDayOfWeek.month); listener(firstDayOfWeek.year, firstDayOfWeek.month);
}); });

Loading…
Cancel
Save