Skip to content

Commit e01b680

Browse files
Fixed Bug where slider was sliding past the selected date close #37, #29
1 parent 5d94712 commit e01b680

File tree

8 files changed

+86
-148
lines changed

8 files changed

+86
-148
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## [1.2.1] - 15/08/2020
2+
3+
* Added option to activate/deactivate certain dates
4+
* Fixed bug where slider was going past the selected date
5+
16
## [1.2.0] - 31/03/2020
27

38
* This version is breaking backward compatibility

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,19 @@ Column(
4848
DatePicker(
4949
this.startDate, {
5050
Key key,
51-
this.width = 60,
52-
this.height = 80,
51+
this.width,
52+
this.height,
5353
this.controller,
54-
this.monthTextStyle = defaultMonthTextStyle,
55-
this.dayTextStyle = defaultDayTextStyle,
56-
this.dateTextStyle = defaultDateTextStyle,
57-
this.selectedTextColor = Colors.white,
58-
this.selectionColor = AppColors.defaultSelectionColor,
54+
this.monthTextStyle,
55+
this.dayTextStyle,
56+
this.dateTextStyle,
57+
this.selectedTextColor,
58+
this.selectionColor,
59+
this.deactivatedColor,
5960
this.initialSelectedDate,
60-
this.daysCount = 500,
61+
this.activeDates,
62+
this.inactiveDates,
63+
this.daysCount,
6164
this.onDateChange,
6265
this.locale = "en_US",
6366
}) : super(key: key);
@@ -66,7 +69,7 @@ DatePicker(
6669
Author
6770
------
6871

69-
* [Vivek Kaushik](http://github.com/iamvivekkaushik/)
72+
* [Vivek Kaushik](https://github.com/iamvivekkaushik/)
7073

7174

7275
Contributors
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
#!/bin/sh
22
# This is a generated file; do not edit or check into version control.
33
export "FLUTTER_ROOT=/Users/vivek/development/flutter"
4-
export "FLUTTER_APPLICATION_PATH=/Users/vivek/StudioProjects/date_picker_timeline_flutter/example"
5-
export "FLUTTER_TARGET=/Users/vivek/StudioProjects/date_picker_timeline_flutter/example/lib/main.dart"
4+
export "FLUTTER_APPLICATION_PATH=/Users/vivek/StudioProjects/DatePickerTimelineFlutter/example"
5+
export "FLUTTER_TARGET=lib/main.dart"
66
export "FLUTTER_BUILD_DIR=build"
77
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
88
export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
99
export "FLUTTER_FRAMEWORK_DIR=/Users/vivek/development/flutter/bin/cache/artifacts/engine/ios"
1010
export "FLUTTER_BUILD_NAME=1.0.0"
1111
export "FLUTTER_BUILD_NUMBER=1"
12-
export "TRACK_WIDGET_CREATION=true"
12+
export "DART_OBFUSCATION=false"
13+
export "TRACK_WIDGET_CREATION=false"
14+
export "TREE_SHAKE_ICONS=false"
15+
export "PACKAGE_CONFIG=.packages"

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class _MyHomePageState extends State<MyHomePage> {
7070
initialSelectedDate: DateTime.now(),
7171
selectionColor: Colors.black,
7272
selectedTextColor: Colors.white,
73-
activeDates: [
73+
inactiveDates: [
7474
DateTime.now().add(Duration(days: 3)),
7575
DateTime.now().add(Duration(days: 4)),
7676
DateTime.now().add(Duration(days: 7))

example/pubspec.lock

Lines changed: 28 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,69 @@
11
# Generated by pub
22
# See https://dart.dev/tools/pub/glossary#lockfile
33
packages:
4-
archive:
5-
dependency: transitive
6-
description:
7-
name: archive
8-
url: "https://pub.dartlang.org"
9-
source: hosted
10-
version: "2.0.13"
11-
args:
12-
dependency: transitive
13-
description:
14-
name: args
15-
url: "https://pub.dartlang.org"
16-
source: hosted
17-
version: "1.6.0"
184
async:
195
dependency: transitive
206
description:
217
name: async
228
url: "https://pub.dartlang.org"
239
source: hosted
24-
version: "2.4.1"
10+
version: "2.4.2"
2511
boolean_selector:
2612
dependency: transitive
2713
description:
2814
name: boolean_selector
2915
url: "https://pub.dartlang.org"
3016
source: hosted
3117
version: "2.0.0"
32-
charcode:
18+
characters:
3319
dependency: transitive
3420
description:
35-
name: charcode
21+
name: characters
3622
url: "https://pub.dartlang.org"
3723
source: hosted
38-
version: "1.1.3"
39-
collection:
24+
version: "1.0.0"
25+
charcode:
4026
dependency: transitive
4127
description:
42-
name: collection
28+
name: charcode
4329
url: "https://pub.dartlang.org"
4430
source: hosted
45-
version: "1.14.12"
46-
convert:
31+
version: "1.1.3"
32+
clock:
4733
dependency: transitive
4834
description:
49-
name: convert
35+
name: clock
5036
url: "https://pub.dartlang.org"
5137
source: hosted
52-
version: "2.1.1"
53-
crypto:
38+
version: "1.0.1"
39+
collection:
5440
dependency: transitive
5541
description:
56-
name: crypto
42+
name: collection
5743
url: "https://pub.dartlang.org"
5844
source: hosted
59-
version: "2.1.4"
45+
version: "1.14.13"
6046
cupertino_icons:
6147
dependency: "direct main"
6248
description:
6349
name: cupertino_icons
6450
url: "https://pub.dartlang.org"
6551
source: hosted
66-
version: "0.1.2"
52+
version: "0.1.3"
6753
date_picker_timeline:
6854
dependency: "direct main"
6955
description:
7056
path: ".."
7157
relative: true
7258
source: path
7359
version: "1.2.0"
60+
fake_async:
61+
dependency: transitive
62+
description:
63+
name: fake_async
64+
url: "https://pub.dartlang.org"
65+
source: hosted
66+
version: "1.1.0"
7467
flutter:
7568
dependency: "direct main"
7669
description: flutter
@@ -81,27 +74,20 @@ packages:
8174
description: flutter
8275
source: sdk
8376
version: "0.0.0"
84-
image:
85-
dependency: transitive
86-
description:
87-
name: image
88-
url: "https://pub.dartlang.org"
89-
source: hosted
90-
version: "2.1.12"
9177
intl:
9278
dependency: transitive
9379
description:
9480
name: intl
9581
url: "https://pub.dartlang.org"
9682
source: hosted
97-
version: "0.16.0"
83+
version: "0.16.1"
9884
matcher:
9985
dependency: transitive
10086
description:
10187
name: matcher
10288
url: "https://pub.dartlang.org"
10389
source: hosted
104-
version: "0.12.6"
90+
version: "0.12.8"
10591
meta:
10692
dependency: transitive
10793
description:
@@ -115,21 +101,7 @@ packages:
115101
name: path
116102
url: "https://pub.dartlang.org"
117103
source: hosted
118-
version: "1.6.4"
119-
petitparser:
120-
dependency: transitive
121-
description:
122-
name: petitparser
123-
url: "https://pub.dartlang.org"
124-
source: hosted
125-
version: "2.4.0"
126-
quiver:
127-
dependency: transitive
128-
description:
129-
name: quiver
130-
url: "https://pub.dartlang.org"
131-
source: hosted
132-
version: "2.1.3"
104+
version: "1.7.0"
133105
sky_engine:
134106
dependency: transitive
135107
description: flutter
@@ -148,7 +120,7 @@ packages:
148120
name: stack_trace
149121
url: "https://pub.dartlang.org"
150122
source: hosted
151-
version: "1.9.3"
123+
version: "1.9.5"
152124
stream_channel:
153125
dependency: transitive
154126
description:
@@ -176,27 +148,20 @@ packages:
176148
name: test_api
177149
url: "https://pub.dartlang.org"
178150
source: hosted
179-
version: "0.2.15"
151+
version: "0.2.17"
180152
typed_data:
181153
dependency: transitive
182154
description:
183155
name: typed_data
184156
url: "https://pub.dartlang.org"
185157
source: hosted
186-
version: "1.1.6"
158+
version: "1.2.0"
187159
vector_math:
188160
dependency: transitive
189161
description:
190162
name: vector_math
191163
url: "https://pub.dartlang.org"
192164
source: hosted
193165
version: "2.0.8"
194-
xml:
195-
dependency: transitive
196-
description:
197-
name: xml
198-
url: "https://pub.dartlang.org"
199-
source: hosted
200-
version: "3.6.1"
201166
sdks:
202-
dart: ">=2.6.0 <3.0.0"
167+
dart: ">=2.9.0-14.0.dev <3.0.0"

lib/date_picker_widget.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,12 @@ class DatePickerController {
272272
/// Calculate the number of pixels that needs to be scrolled to go to the
273273
/// date provided in the argument
274274
double _calculateDateOffset(DateTime date) {
275-
int offset = date.difference(_datePickerState.widget.startDate).inDays + 1;
276-
print(offset);
275+
final startDate = new DateTime(
276+
_datePickerState.widget.startDate.year,
277+
_datePickerState.widget.startDate.month,
278+
_datePickerState.widget.startDate.day);
279+
280+
int offset = date.difference(startDate).inDays;
277281
return (offset * _datePickerState.widget.width) + (offset * 6);
278282
}
279283
}

0 commit comments

Comments
 (0)