Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"flutterSdkVersion": "3.0.0",
"flutterSdkVersion": "3.12.0",
"flavors": {}
}
4 changes: 4 additions & 0 deletions .fvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"flutter": "3.12.0",
"flavors": {}
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@ build/
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
.fvm/flutter_sdk
.fvm/
!.fvm/fvm_config.json
3 changes: 2 additions & 1 deletion .pubignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
sample_proj/
sample_proj/
.fvm/
2 changes: 1 addition & 1 deletion .run/main.dart.run.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="main.dart" type="FlutterRunConfigurationType" factoryName="Flutter">
<configuration default="false" name="main.dart" type="FlutterRunConfigurationType" factoryName="Flutter" nameIsGenerated="true">
<option name="filePath" value="$PROJECT_DIR$/sample_proj/lib/main.dart" />
<method v="2" />
</configuration>
Expand Down
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
## 1.0.2 - 18/7/2023

* Navigate to next year on reach last month of current year
* Update _intl_ to ^0.19.0

* ## 1.0.1 - 18/7/2023

* Fixed small Overflow issues from last build

## 1.0.0 - 10/7/2023

* Updated min dart version to 3.0.0
* Changed color scheme primaryVariant to outline
* Added implmentation to show weekday
* Added implementation to show weekday

### Bug Fixes

* Adjusted max height calculation for the picker
Expand Down
215 changes: 109 additions & 106 deletions lib/date_ranger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class DateRanger extends StatefulWidget {
this.showDoubleTapInfo = true,
this.minYear = 1940,
this.maxYear = 2100,
this.showWeekDay = true,
this.showWeekDay = false,
}) : super(key: key);

@override
Expand Down Expand Up @@ -189,119 +189,121 @@ class _DateRangerState extends State<DateRanger>
outline: widget.borderColors)),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
height: 55,
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
pickerOutput(),
if (widget.rangerType == DateRangerType.range) ...[
Center(
child: SizedBox(
width: 32,
child: Divider(
endIndent: 12,
indent: 12,
thickness: 2,
))),
pickerOutput(false)
],
],
),
),
ValueListenableBuilder<bool>(
valueListenable: showInfo,
builder: (context, value, child) => AnimatedOpacity(
duration: Duration(seconds: 2),
opacity: value ? 1 : 0,
child: Padding(
padding:
const EdgeInsets.symmetric(vertical: 6, horizontal: 4),
child: Text(
"Double tap to find date",
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
fontSize: 12),
),
)),
),
LayoutBuilder(
builder: (context, constraints) {
var sevenDaysWidth =
itemWidth * 7 + (widget.horizontalPadding * 2);
var width = widget.showWeekDay ? sevenDaysWidth : double.infinity;
var sevenDaysWidth = itemWidth * 7 + (widget.horizontalPadding * 2);
var width = widget.showWeekDay ? sevenDaysWidth : null;
return Container(
constraints: BoxConstraints(
maxHeight: calculateHeight(constraints),
/*maxWidth: width,
minWidth: width*/),
width: width,
margin: EdgeInsets.only(bottom: 26),
padding: EdgeInsets.symmetric(
horizontal: widget.horizontalPadding,
vertical: widget.verticalPadding)
.copyWith(top: 0),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(color: Colors.black12.withOpacity(0.6))
]),
child: InheritedRanger(
selectingStart: selectingStart,
activeYear: activeYear,
tabController: tabController,
rangerType: widget.rangerType,
activeTab: activeTab,
dateRange: dateRange,
navKey: navKey,
itemHeight: widget.itemHeight,
itemWidth: itemWidth,
runSpacing: widget.runSpacing,
activeDateBottomSpace: widget.activeDateBottomSpace,
activeDateFontSize: widget.activeDateFontSize,
minYear: widget.minYear,
maxYear: widget.maxYear,
showWeekday: widget.showWeekDay,
child: Navigator(
key: navKey,
onGenerateRoute: (settings) {
Widget widget;
if (settings.name == "/")
widget = PrimaryPage(
onNewDate: onNewDate,
onRangeChanged: onRangeChanged,
onError: onError,
);
else
widget = SecondaryPage(
dateTime: settings.arguments as DateTime);
return MaterialPageRoute(builder: (context) => widget);
},
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
pickerOutput(),
if (widget.rangerType == DateRangerType.range) ...[
SizedBox(
width: 32,
child: Divider(
endIndent: 12,
indent: 12,
thickness: 2,
)),
pickerOutput(false)
],
],
),
ValueListenableBuilder<bool>(
valueListenable: showInfo,
builder: (context, value, child) => AnimatedOpacity(
duration: Duration(seconds: 2),
opacity: value ? 1 : 0,
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 6, horizontal: 4),
child: Text(
"Double tap to find date",
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
fontSize: 12),
),
)),
),
Container(
constraints:
BoxConstraints(maxHeight: calculateHeight(constraints)),
margin: EdgeInsets.only(bottom: 26),
padding: EdgeInsets.symmetric(
horizontal: widget.horizontalPadding,
vertical: widget.verticalPadding)
.copyWith(top: 0),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(color: Colors.black12.withOpacity(0.6))
]),
child: InheritedRanger(
selectingStart: selectingStart,
activeYear: activeYear,
tabController: tabController,
rangerType: widget.rangerType,
activeTab: activeTab,
dateRange: dateRange,
navKey: navKey,
itemHeight: widget.itemHeight,
itemWidth: itemWidth,
runSpacing: widget.runSpacing,
activeDateBottomSpace: widget.activeDateBottomSpace,
activeDateFontSize: widget.activeDateFontSize,
minYear: widget.minYear,
maxYear: widget.maxYear,
showWeekday: widget.showWeekDay,
child: Navigator(
key: navKey,
onGenerateRoute: (settings) {
Widget widget;
if (settings.name == "/")
widget = PrimaryPage(
onNewDate: onNewDate,
onRangeChanged: onRangeChanged,
onError: onError,
);
else
widget = SecondaryPage(
dateTime: settings.arguments as DateTime);
return MaterialPageRoute(builder: (context) => widget);
},
),
),
),
ValueListenableBuilder<String>(
valueListenable: errorText,
builder: (context, value, child) => AnimatedSwitcher(
duration: Duration(milliseconds: 300),
reverseDuration: Duration(seconds: 2),
child: value.isEmpty
? SizedBox(
height: 16,
)
: Text(
value,
style: TextStyle(
color:
Theme.of(context).colorScheme.error,
fontSize: 14),
),
)),
],
),
);
},
),
ValueListenableBuilder<String>(
valueListenable: errorText,
builder: (context, value, child) => AnimatedSwitcher(
duration: Duration(milliseconds: 300),
reverseDuration: Duration(seconds: 2),
child: value.isEmpty
? SizedBox(
height: 16,
)
: Text(
value,
style: TextStyle(
color: Theme.of(context).colorScheme.error,
fontSize: 14),
),
)),
],
),
);
Expand All @@ -322,7 +324,7 @@ class _DateRangerState extends State<DateRanger>

final sumRowsHeight = (numRows * widget.itemHeight) + sumRunSpace;

final height = widget.activeDateFontSize +
final height = (widget.activeDateFontSize * 1.5) +
widget.activeDateBottomSpace +
sumRowsHeight +
(widget.verticalPadding * 2);
Expand Down Expand Up @@ -384,6 +386,7 @@ class _DateRangerState extends State<DateRanger>
? CrossAxisAlignment.start
: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Text(
isRange ? "${start ? "Start" : "End"} date" : "Date",
Expand Down
32 changes: 25 additions & 7 deletions lib/src/primary_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ class _PrimaryPageState extends State<PrimaryPage> {
var tabDate = DateTime(ranger.activeYear, value + 1);
return Row(
children: [
chevron(active: value > 0),
chevron(
active: tabDate.year >= ranger.minYear,
onTap: () {
if (value > 0) {
ranger.tabController
.animateTo(ranger.tabController.index + -1);
} else {
widget.onNewDate
.call(tabDate.subtract(Duration(days: 1)));
}
}),
InkWell(
onTap: () async {
var newDate = await ranger.navKey.currentState!
Expand All @@ -55,7 +65,17 @@ class _PrimaryPageState extends State<PrimaryPage> {
),
),
),
chevron(left: false, active: value < 11)
chevron(
left: false,
active: tabDate.year <= ranger.maxYear,
onTap: () {
if (value < 11) {
ranger.tabController
.animateTo(ranger.tabController.index + 1);
} else {
widget.onNewDate.call(tabDate.add(Duration(days: 31)));
}
})
],
);
},
Expand All @@ -73,16 +93,14 @@ class _PrimaryPageState extends State<PrimaryPage> {
);
}

Widget chevron({bool left = true, bool active = true}) {
Widget chevron(
{bool left = true, bool active = true, required VoidCallback onTap}) {
return Expanded(
child: AnimatedOpacity(
opacity: active ? 1 : 0.2,
duration: Duration(milliseconds: 100),
child: InkWell(
onTap: active
? () => ranger.tabController
.animateTo(ranger.tabController.index + (left ? -1 : 1))
: null,
onTap: active ? onTap : null,
child: Padding(
padding: const EdgeInsets.only(top: 24),
child: Align(
Expand Down
Loading