mirror of
https://github.com/Iconica-Development/flutter_date_time_picker.git
synced 2025-05-18 18:33:49 +02:00
feat: Added the feature to add the weekdays letters above the months
This commit is contained in:
parent
bd448daacc
commit
f0be7a5e36
5 changed files with 161 additions and 115 deletions
21
CHANGELOG.md
21
CHANGELOG.md
|
@ -1,18 +1,25 @@
|
||||||
|
## 2.2.0
|
||||||
|
|
||||||
|
- Added the abilty to add the weekday letters above the months
|
||||||
|
|
||||||
## 2.1.0
|
## 2.1.0
|
||||||
* Fixed internalization of the package
|
|
||||||
* Added dragcallback to the draggablesheet
|
- Fixed internalization of the package
|
||||||
|
- Added dragcallback to the draggablesheet
|
||||||
|
|
||||||
## 2.0.0
|
## 2.0.0
|
||||||
* Added overlay variant of datetimepicker
|
|
||||||
|
- Added overlay variant of datetimepicker
|
||||||
|
|
||||||
## 1.2.0
|
## 1.2.0
|
||||||
* Made date time picker height customizable
|
|
||||||
|
- Made date time picker height customizable
|
||||||
|
|
||||||
## 1.1.0
|
## 1.1.0
|
||||||
|
|
||||||
* Added option to change background color of date picker.
|
- Added option to change background color of date picker.
|
||||||
* Added option to style the bar at the bottom of the date picker.
|
- Added option to style the bar at the bottom of the date picker.
|
||||||
|
|
||||||
## 1.0.0
|
## 1.0.0
|
||||||
|
|
||||||
* TODO: Describe initial release.
|
- TODO: Describe initial release.
|
||||||
|
|
|
@ -36,6 +36,7 @@ class DateTimePickerTheme {
|
||||||
TextStyle(color: Colors.white),
|
TextStyle(color: Colors.white),
|
||||||
),
|
),
|
||||||
this.barTheme = const DateTimePickerBarTheme(),
|
this.barTheme = const DateTimePickerBarTheme(),
|
||||||
|
this.monthWeekDayHeaders = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// enum to define a shape dor the date. use [DateBoxShape.circle].
|
/// enum to define a shape dor the date. use [DateBoxShape.circle].
|
||||||
|
@ -83,4 +84,7 @@ class DateTimePickerTheme {
|
||||||
|
|
||||||
/// The shape of the border using a [ShapeBorder]
|
/// The shape of the border using a [ShapeBorder]
|
||||||
final ShapeBorder? shapeBorder;
|
final ShapeBorder? shapeBorder;
|
||||||
|
|
||||||
|
/// If true the first letters of the weekdays will be displayed above the days of the month
|
||||||
|
final bool monthWeekDayHeaders;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import 'package:flutter_date_time_picker/src/extensions/time_of_day.dart';
|
||||||
import 'package:flutter_date_time_picker/src/models/date_box_current_theme.dart';
|
import 'package:flutter_date_time_picker/src/models/date_box_current_theme.dart';
|
||||||
import 'package:flutter_date_time_picker/src/models/date_time_picker_theme.dart';
|
import 'package:flutter_date_time_picker/src/models/date_time_picker_theme.dart';
|
||||||
import 'package:flutter_date_time_picker/src/utils/date_time_picker_controller.dart';
|
import 'package:flutter_date_time_picker/src/utils/date_time_picker_controller.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
class MonthDateTimePicker extends StatelessWidget {
|
class MonthDateTimePicker extends StatelessWidget {
|
||||||
const MonthDateTimePicker({
|
const MonthDateTimePicker({
|
||||||
|
@ -35,6 +36,29 @@ class MonthDateTimePicker extends StatelessWidget {
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 30),
|
margin: const EdgeInsets.symmetric(horizontal: 30),
|
||||||
child: Center(
|
child: Center(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
if (dateTimePickerController.theme.monthWeekDayHeaders)
|
||||||
|
Row(
|
||||||
|
children: List.generate(
|
||||||
|
7,
|
||||||
|
(index) => Expanded(
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
DateFormat.E(Localizations.localeOf(context).toString())
|
||||||
|
.format(
|
||||||
|
date.daysOfWeek().elementAt(index),
|
||||||
|
)
|
||||||
|
.toUpperCase()[0],
|
||||||
|
style:
|
||||||
|
dateTimePickerController.theme.baseTheme.textStyle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: MediaQuery.of(context).size.height * 0.33,
|
||||||
child: GridView.count(
|
child: GridView.count(
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
crossAxisSpacing: 5,
|
crossAxisSpacing: 5,
|
||||||
|
@ -79,15 +103,18 @@ class MonthDateTimePicker extends StatelessWidget {
|
||||||
context, dateTimePickerController);
|
context, dateTimePickerController);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dateTimePickerController.wrongTimeDialog != null) {
|
if (dateTimePickerController.wrongTimeDialog !=
|
||||||
|
null) {
|
||||||
if (timeOfDay != null &&
|
if (timeOfDay != null &&
|
||||||
timeOfDay.containsAny(
|
timeOfDay.containsAny(
|
||||||
dateTimePickerController.disabledTimes ?? [],
|
dateTimePickerController.disabledTimes ??
|
||||||
|
[],
|
||||||
)) {
|
)) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) =>
|
builder: (context) =>
|
||||||
dateTimePickerController.wrongTimeDialog!);
|
dateTimePickerController
|
||||||
|
.wrongTimeDialog!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,11 +126,12 @@ class MonthDateTimePicker extends StatelessWidget {
|
||||||
timeOfDay.minute,
|
timeOfDay.minute,
|
||||||
);
|
);
|
||||||
|
|
||||||
dateTimePickerController.onTapDay(selectedDateTime);
|
dateTimePickerController
|
||||||
|
.onTapDay(selectedDateTime);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
margin:
|
margin: const EdgeInsets.symmetric(
|
||||||
const EdgeInsets.symmetric(vertical: 5, horizontal: 5),
|
vertical: 5, horizontal: 5),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: currentDateBoxTheme.backgroundColor,
|
color: currentDateBoxTheme.backgroundColor,
|
||||||
borderRadius:
|
borderRadius:
|
||||||
|
@ -114,7 +142,8 @@ class MonthDateTimePicker extends StatelessWidget {
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Center(
|
Center(
|
||||||
child: Text((addedIndex + 1 - daysToSkip).toString(),
|
child: Text(
|
||||||
|
(addedIndex + 1 - daysToSkip).toString(),
|
||||||
style: currentDateBoxTheme.textStyle),
|
style: currentDateBoxTheme.textStyle),
|
||||||
),
|
),
|
||||||
if (shouldMark(
|
if (shouldMark(
|
||||||
|
@ -146,6 +175,9 @@ class MonthDateTimePicker extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,10 @@ class MonthDateTimePickerSheet extends StatelessWidget {
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
height: MediaQuery.of(context).size.height * 0.33,
|
height: MediaQuery.of(context).size.height * 0.33 +
|
||||||
|
((theme.monthWeekDayHeaders)
|
||||||
|
? MediaQuery.of(context).size.height * 0.04
|
||||||
|
: 0),
|
||||||
child: PageView(
|
child: PageView(
|
||||||
controller: dateTimePickerController.pageController,
|
controller: dateTimePickerController.pageController,
|
||||||
onPageChanged: (i) {
|
onPageChanged: (i) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: flutter_date_time_picker
|
name: flutter_date_time_picker
|
||||||
description: A Flutter package for date and time picker.
|
description: A Flutter package for date and time picker.
|
||||||
version: 2.1.0
|
version: 2.2.0
|
||||||
homepage: https://iconica.nl/
|
homepage: https://iconica.nl/
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
|
Loading…
Reference in a new issue