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

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_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 {
@ -23,6 +21,7 @@ class _BlueStylePageState extends State<BlueStylePage> {
@override
void initState() {
super.initState();
controller = new CalendarController(
showMode: CalendarConstants.MODE_SHOW_MONTH_AND_WEEK,
@ -81,8 +80,7 @@ class _BlueStylePageState extends State<BlueStylePage> {
height: 20,
),
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Container(
height: 100,
@ -146,7 +144,7 @@ class _BlueStylePageState extends State<BlueStylePage> {
}
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
@override
@ -183,10 +181,10 @@ class CustomStyleWeekBarItem extends BaseWeekBar {
class CustomStyleDayWidget extends BaseCombineDayWidget {
CustomStyleDayWidget(DateModel dateModel) : super(dateModel);
TextStyle normalTextStyle =
final TextStyle normalTextStyle =
TextStyle(fontWeight: FontWeight.w700, color: Colors.black);
TextStyle noIsCurrentMonthTextStyle =
final TextStyle noIsCurrentMonthTextStyle =
TextStyle(fontWeight: FontWeight.w700, color: Colors.grey);
@override

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

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

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

@ -1,7 +1,7 @@
import 'package:example/only_week_page.dart';
import 'package:example/red_style_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'blue_style_page.dart';
import 'custom_sign_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
void initState() {
super.initState();
controller = new CalendarController(
selectMode: CalendarConstants.MODE_MULTI_SELECT,
maxMultiSelectCount: 5,
@ -102,7 +103,7 @@ class _MultiSelectStylePageState extends State<MultiSelectStylePage> {
}
class CustomStyleWeekBarItem extends BaseWeekBar {
List<String> weekList = ["", "", "", "", "", "", ""];
final List<String> weekList = ["", "", "", "", "", "", ""];
@override
Widget getWeekBarItem(int index) {
@ -119,7 +120,6 @@ class CustomStyleDayWidget extends BaseCustomDayWidget {
@override
void drawNormal(DateModel dateModel, Canvas canvas, Size size) {
bool isWeekend = dateModel.isWeekend;
bool isInRange = dateModel.isInRange;
//

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

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

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

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

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

@ -1,10 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_custom_calendar/calendar_provider.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/utils/LogUtil.dart';
import 'package:flutter_custom_calendar/utils/date_util.dart';
import 'package:flutter_custom_calendar/widget/month_view.dart';
import 'package:provider/provider.dart';
@ -21,6 +19,7 @@ class _MonthViewPagerState extends State<MonthViewPager>
@override
void initState() {
super.initState();
LogUtil.log(TAG: this.runtimeType, message: "MonthViewPager initState");
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/configuration.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/utils/date_util.dart';
import 'package:flutter_custom_calendar/widget/month_view.dart';

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

Loading…
Cancel
Save