Skip to content
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

Fix some minor bugs #334

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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 example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class HomePage extends StatelessWidget {
showTitleActions: true,
minTime: DateTime(2018, 3, 5),
maxTime: DateTime(2019, 6, 7),
theme: DatePickerTheme(
theme: DateTimePickerTheme(
headerColor: Colors.orange,
backgroundColor: Colors.blue,
itemStyle: TextStyle(
Expand Down
53 changes: 25 additions & 28 deletions lib/flutter_datetime_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ library flutter_datetime_picker;
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
import 'package:flutter_datetime_picker/src/datetime_picker_theme.dart';
import 'package:flutter_datetime_picker/src/date_model.dart';
import 'package:flutter_datetime_picker/src/i18n_model.dart';
Expand All @@ -22,15 +21,15 @@ class DatePicker {
///
static Future<DateTime?> showDatePicker(
BuildContext context, {
bool showTitleActions: true,
bool showTitleActions = true,
DateTime? minTime,
DateTime? maxTime,
DateChangedCallback? onChanged,
DateChangedCallback? onConfirm,
DateCancelledCallback? onCancel,
locale: LocaleType.en,
locale = LocaleType.en,
DateTime? currentTime,
DatePickerTheme? theme,
DateTimePickerTheme? theme,
}) async {
return await Navigator.push(
context,
Expand Down Expand Up @@ -58,14 +57,14 @@ class DatePicker {
///
static Future<DateTime?> showTimePicker(
BuildContext context, {
bool showTitleActions: true,
bool showSecondsColumn: true,
bool showTitleActions = true,
bool showSecondsColumn = true,
DateChangedCallback? onChanged,
DateChangedCallback? onConfirm,
DateCancelledCallback? onCancel,
locale: LocaleType.en,
locale = LocaleType.en,
DateTime? currentTime,
DatePickerTheme? theme,
DateTimePickerTheme? theme,
}) async {
return await Navigator.push(
context,
Expand All @@ -92,13 +91,13 @@ class DatePicker {
///
static Future<DateTime?> showTime12hPicker(
BuildContext context, {
bool showTitleActions: true,
bool showTitleActions = true,
DateChangedCallback? onChanged,
DateChangedCallback? onConfirm,
DateCancelledCallback? onCancel,
locale: LocaleType.en,
locale = LocaleType.en,
DateTime? currentTime,
DatePickerTheme? theme,
DateTimePickerTheme? theme,
}) async {
return await Navigator.push(
context,
Expand All @@ -124,15 +123,15 @@ class DatePicker {
///
static Future<DateTime?> showDateTimePicker(
BuildContext context, {
bool showTitleActions: true,
bool showTitleActions = true,
DateTime? minTime,
DateTime? maxTime,
DateChangedCallback? onChanged,
DateChangedCallback? onConfirm,
DateCancelledCallback? onCancel,
locale: LocaleType.en,
locale = LocaleType.en,
DateTime? currentTime,
DatePickerTheme? theme,
DateTimePickerTheme? theme,
}) async {
return await Navigator.push(
context,
Expand Down Expand Up @@ -160,13 +159,13 @@ class DatePicker {
///
static Future<DateTime?> showPicker(
BuildContext context, {
bool showTitleActions: true,
bool showTitleActions = true,
DateChangedCallback? onChanged,
DateChangedCallback? onConfirm,
DateCancelledCallback? onCancel,
locale: LocaleType.en,
locale = LocaleType.en,
BasePickerModel? pickerModel,
DatePickerTheme? theme,
DateTimePickerTheme? theme,
}) async {
return await Navigator.push(
context,
Expand All @@ -191,21 +190,21 @@ class _DatePickerRoute<T> extends PopupRoute<T> {
this.onChanged,
this.onConfirm,
this.onCancel,
DatePickerTheme? theme,
DateTimePickerTheme? theme,
this.barrierLabel,
this.locale,
RouteSettings? settings,
BasePickerModel? pickerModel,
}) : this.pickerModel = pickerModel ?? DatePickerModel(),
this.theme = theme ?? DatePickerTheme(),
this.theme = theme ?? DateTimePickerTheme(),
super(settings: settings);

final bool? showTitleActions;
final DateChangedCallback? onChanged;
final DateChangedCallback? onConfirm;
final DateCancelledCallback? onCancel;
final LocaleType? locale;
final DatePickerTheme theme;
final DateTimePickerTheme theme;
final BasePickerModel pickerModel;

@override
Expand Down Expand Up @@ -293,7 +292,7 @@ class _DatePickerState extends State<_DatePickerComponent> {

@override
Widget build(BuildContext context) {
DatePickerTheme theme = widget.route.theme;
DateTimePickerTheme theme = widget.route.theme;
return GestureDetector(
child: AnimatedBuilder(
animation: widget.route.animation!,
Expand Down Expand Up @@ -326,7 +325,7 @@ class _DatePickerState extends State<_DatePickerComponent> {
}
}

Widget _renderPickerView(DatePickerTheme theme) {
Widget _renderPickerView(DateTimePickerTheme theme) {
Widget itemView = _renderItemView(theme);
if (widget.route.showTitleActions == true) {
return Column(
Expand All @@ -341,7 +340,7 @@ class _DatePickerState extends State<_DatePickerComponent> {

Widget _renderColumnView(
ValueKey key,
DatePickerTheme theme,
DateTimePickerTheme theme,
StringAtIndexCallBack stringAtIndexCB,
ScrollController scrollController,
int layoutProportion,
Expand Down Expand Up @@ -396,7 +395,7 @@ class _DatePickerState extends State<_DatePickerComponent> {
);
}

Widget _renderItemView(DatePickerTheme theme) {
Widget _renderItemView(DateTimePickerTheme theme) {
return Container(
color: theme.backgroundColor,
child: Directionality(
Expand Down Expand Up @@ -471,7 +470,7 @@ class _DatePickerState extends State<_DatePickerComponent> {
}

// Title View
Widget _renderTitleActionsView(DatePickerTheme theme) {
Widget _renderTitleActionsView(DateTimePickerTheme theme) {
final done = _localeDone();
final cancel = _localeCancel();

Expand Down Expand Up @@ -535,15 +534,13 @@ class _BottomPickerLayout extends SingleChildLayoutDelegate {
_BottomPickerLayout(
this.progress,
this.theme, {
this.itemCount,
this.showTitleActions,
this.bottomPadding = 0,
});

final double progress;
final int? itemCount;
final bool? showTitleActions;
final DatePickerTheme theme;
final DateTimePickerTheme theme;
final double bottomPadding;

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/src/date_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class TimePickerModel extends CommonPickerModel {
bool showSecondsColumn;

TimePickerModel(
{DateTime? currentTime, LocaleType? locale, this.showSecondsColumn: true})
{DateTime? currentTime, LocaleType? locale, this.showSecondsColumn = true})
: super(locale: locale) {
this.currentTime = currentTime ?? DateTime.now();

Expand Down
4 changes: 2 additions & 2 deletions lib/src/datetime_picker_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/material.dart';

// Migrate DiagnosticableMixin to Diagnosticable until
// https://github.com/flutter/flutter/pull/51495 makes it into stable (v1.15.21)
class DatePickerTheme with DiagnosticableTreeMixin {
class DateTimePickerTheme with DiagnosticableTreeMixin {
final TextStyle cancelStyle;
final TextStyle doneStyle;
final TextStyle itemStyle;
Expand All @@ -14,7 +14,7 @@ class DatePickerTheme with DiagnosticableTreeMixin {
final double titleHeight;
final double itemHeight;

const DatePickerTheme({
const DateTimePickerTheme({
this.cancelStyle = const TextStyle(color: Colors.black54, fontSize: 16),
this.doneStyle = const TextStyle(color: Colors.blue, fontSize: 16),
this.itemStyle = const TextStyle(color: Color(0xFF000046), fontSize: 18),
Expand Down