-
Notifications
You must be signed in to change notification settings - Fork 217
add option for edge fading #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,13 @@ packages: | |
| relative: true | ||
| source: path | ||
| version: "1.1.3" | ||
| fading_edge_scrollview: | ||
| dependency: transitive | ||
| description: | ||
| name: fading_edge_scrollview | ||
| url: "https://pub.dartlang.org" | ||
| source: hosted | ||
| version: "1.0.2" | ||
|
Comment on lines
+46
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add edgefading package |
||
| flutter: | ||
| dependency: "direct main" | ||
| description: flutter | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import 'package:date_picker_timeline/date_widget.dart'; | |
| import 'package:date_picker_timeline/extra/color.dart'; | ||
| import 'package:date_picker_timeline/extra/style.dart'; | ||
| import 'package:date_picker_timeline/gestures/tap.dart'; | ||
| import 'package:fading_edge_scrollview/fading_edge_scrollview.dart'; | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:intl/date_symbol_data_local.dart'; | ||
|
|
||
|
|
@@ -17,6 +18,7 @@ class DatePickerTimeline extends StatefulWidget { | |
| DateChangeListener onDateChange; | ||
| int daysCount; | ||
| String locale; | ||
| bool isEdgeFadding; | ||
|
|
||
| // Creates the DatePickerTimeline Widget | ||
| DatePickerTimeline( | ||
|
|
@@ -31,15 +33,16 @@ class DatePickerTimeline extends StatefulWidget { | |
| this.daysCount = 50000, | ||
| this.onDateChange, | ||
| this.locale = "en_US", | ||
| this.isEdgeFadding = false, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New parameter to enable EdgeFadding |
||
| }) : super(key: key); | ||
|
|
||
| @override | ||
| State<StatefulWidget> createState() => new _DatePickerState(); | ||
| } | ||
|
|
||
| class _DatePickerState extends State<DatePickerTimeline> { | ||
|
|
||
| @override void initState() { | ||
| @override | ||
| void initState() { | ||
| super.initState(); | ||
|
|
||
| initializeDateFormatting(widget.locale, null); | ||
|
|
@@ -48,37 +51,43 @@ class _DatePickerState extends State<DatePickerTimeline> { | |
| @override | ||
| Widget build(BuildContext context) { | ||
| return Container( | ||
| width: widget.width, | ||
| height: widget.height, | ||
| child: ListView.builder( | ||
| itemCount: widget.daysCount, | ||
| scrollDirection: Axis.horizontal, | ||
| itemBuilder: (context, index) { | ||
| // Return the Date Widget | ||
| DateTime _date = DateTime.now().add(Duration(days: index)); | ||
| DateTime date = new DateTime(_date.year, _date.month, _date.day); | ||
| bool isSelected = compareDate(date, widget.currentDate); | ||
| width: widget.width, | ||
| height: widget.height, | ||
| child: widget.isEdgeFadding | ||
| ? (FadingEdgeScrollView.fromScrollView(child: buildList(context))) | ||
| : buildList(context)); | ||
| } | ||
|
|
||
| Widget buildList(BuildContext context) { | ||
| return ListView.builder( | ||
| itemCount: widget.daysCount, | ||
| scrollDirection: Axis.horizontal, | ||
| controller: new ScrollController(), | ||
| itemBuilder: (context, index) { | ||
| // Return the Date Widget | ||
| DateTime _date = DateTime.now().add(Duration(days: index)); | ||
| DateTime date = new DateTime(_date.year, _date.month, _date.day); | ||
| bool isSelected = compareDate(date, widget.currentDate); | ||
|
Comment on lines
+61
to
+70
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create buildList to avoid code diplucation |
||
|
|
||
| return DateWidget( | ||
| date: date, | ||
| monthTextStyle: widget.monthTextStyle, | ||
| dateTextStyle: widget.dateTextStyle, | ||
| dayTextStyle: widget.dayTextStyle, | ||
| locale: widget.locale, | ||
| selectionColor: | ||
| isSelected ? widget.selectionColor : Colors.transparent, | ||
| onDateSelected: (selectedDate) { | ||
| // A date is selected | ||
| if (widget.onDateChange != null) { | ||
| widget.onDateChange(selectedDate); | ||
| } | ||
| setState(() { | ||
| widget.currentDate = selectedDate; | ||
| }); | ||
| }, | ||
| ); | ||
| }, | ||
| ), | ||
| return DateWidget( | ||
| date: date, | ||
| monthTextStyle: widget.monthTextStyle, | ||
| dateTextStyle: widget.dateTextStyle, | ||
| dayTextStyle: widget.dayTextStyle, | ||
| locale: widget.locale, | ||
| selectionColor: | ||
| isSelected ? widget.selectionColor : Colors.transparent, | ||
| onDateSelected: (selectedDate) { | ||
| // A date is selected | ||
| if (widget.onDateChange != null) { | ||
| widget.onDateChange(selectedDate); | ||
| } | ||
| setState(() { | ||
| widget.currentDate = selectedDate; | ||
| }); | ||
| }, | ||
| ); | ||
| }, | ||
|
Comment on lines
+72
to
+90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just format code for the DateWidget |
||
| ); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2nd example, with EdgeFadding