Skip to content

making the route settings available #265

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

Open
wants to merge 3 commits 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
13 changes: 5 additions & 8 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/liuyanbo/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/liuyanbo/Documents/GitHub/flutter_datetime_picker/example"
export "FLUTTER_TARGET=/Users/liuyanbo/Documents/GitHub/flutter_datetime_picker/example/lib/main.dart"
export "FLUTTER_ROOT=/home/alex/flutter"
export "FLUTTER_APPLICATION_PATH=/storage2/code/flutter_datetime_picker/example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
export "FLUTTER_FRAMEWORK_DIR=/Users/liuyanbo/flutter/bin/cache/artifacts/engine/ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_DEFINES=flutter.inspector.structuredErrors%3Dtrue"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=true"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.packages"
export "PACKAGE_CONFIG=.dart_tool/package_config.json"
100 changes: 50 additions & 50 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/material.dart' as material;
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';

void main() => runApp(new MyApp());
void main() => material.runApp(new MyApp());

class CustomPicker extends CommonPickerModel {
String digits(int value, int length) {
Expand Down Expand Up @@ -78,57 +78,57 @@ class CustomPicker extends CommonPickerModel {
}
}

class MyApp extends StatelessWidget {
class MyApp extends material.StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
material.Widget build(material.BuildContext context) {
return new material.MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
theme: new material.ThemeData(
primarySwatch: material.Colors.blue,
),
home: new HomePage(),
);
}
}

class HomePage extends StatelessWidget {
class HomePage extends material.StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Datetime Picker'),
material.Widget build(material.BuildContext context) {
return material.Scaffold(
appBar: material.AppBar(
title: material.Text('Datetime Picker'),
),
body: Center(
child: Column(
children: <Widget>[
TextButton(
body: material.Center(
child: material.Column(
children: <material.Widget>[
material.TextButton(
onPressed: () {
DatePicker.showDatePicker(context,
showTitleActions: true,
minTime: DateTime(2018, 3, 5),
maxTime: DateTime(2019, 6, 7),
theme: DatePickerTheme(
headerColor: Colors.orange,
backgroundColor: Colors.blue,
itemStyle: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
headerColor: material.Colors.orange,
backgroundColor: material.Colors.blue,
itemStyle: material.TextStyle(
color: material.Colors.white,
fontWeight: material.FontWeight.bold,
fontSize: 18),
doneStyle:
TextStyle(color: Colors.white, fontSize: 16)),
onChanged: (date) {
doneStyle: material.TextStyle(
color: material.Colors.white,
fontSize: 16)), onChanged: (date) {
print('change $date in time zone ' +
date.timeZoneOffset.inHours.toString());
}, onConfirm: (date) {
print('confirm $date');
}, currentTime: DateTime.now(), locale: LocaleType.en);
},
child: Text(
child: material.Text(
'show date picker(custom theme &date time range)',
style: TextStyle(color: Colors.blue),
style: material.TextStyle(color: material.Colors.blue),
)),
TextButton(
material.TextButton(
onPressed: () {
DatePicker.showTimePicker(context, showTitleActions: true,
onChanged: (date) {
Expand All @@ -138,11 +138,11 @@ class HomePage extends StatelessWidget {
print('confirm $date');
}, currentTime: DateTime.now());
},
child: Text(
child: material.Text(
'show time picker',
style: TextStyle(color: Colors.blue),
style: material.TextStyle(color: material.Colors.blue),
)),
TextButton(
material.TextButton(
onPressed: () {
DatePicker.showTime12hPicker(context, showTitleActions: true,
onChanged: (date) {
Expand All @@ -152,11 +152,11 @@ class HomePage extends StatelessWidget {
print('confirm $date');
}, currentTime: DateTime.now());
},
child: Text(
child: material.Text(
'show 12H time picker with AM/PM',
style: TextStyle(color: Colors.blue),
style: material.TextStyle(color: material.Colors.blue),
)),
TextButton(
material.TextButton(
onPressed: () {
DatePicker.showDateTimePicker(context,
showTitleActions: true,
Expand All @@ -168,11 +168,11 @@ class HomePage extends StatelessWidget {
print('confirm $date');
}, locale: LocaleType.zh);
},
child: Text(
child: material.Text(
'show date time picker (Chinese)',
style: TextStyle(color: Colors.blue),
style: material.TextStyle(color: material.Colors.blue),
)),
TextButton(
material.TextButton(
onPressed: () {
DatePicker.showDateTimePicker(context, showTitleActions: true,
onChanged: (date) {
Expand All @@ -182,11 +182,11 @@ class HomePage extends StatelessWidget {
print('confirm $date');
}, currentTime: DateTime(2008, 12, 31, 23, 12, 34));
},
child: Text(
child: material.Text(
'show date time picker (English-America)',
style: TextStyle(color: Colors.blue),
style: material.TextStyle(color: material.Colors.blue),
)),
TextButton(
material.TextButton(
onPressed: () {
DatePicker.showDateTimePicker(context, showTitleActions: true,
onChanged: (date) {
Expand All @@ -198,11 +198,11 @@ class HomePage extends StatelessWidget {
currentTime: DateTime(2008, 12, 31, 23, 12, 34),
locale: LocaleType.nl);
},
child: Text(
child: material.Text(
'show date time picker (Dutch)',
style: TextStyle(color: Colors.blue),
style: material.TextStyle(color: material.Colors.blue),
)),
TextButton(
material.TextButton(
onPressed: () {
DatePicker.showDateTimePicker(context, showTitleActions: true,
onChanged: (date) {
Expand All @@ -214,11 +214,11 @@ class HomePage extends StatelessWidget {
currentTime: DateTime(2008, 12, 31, 23, 12, 34),
locale: LocaleType.ru);
},
child: Text(
child: material.Text(
'show date time picker (Russian)',
style: TextStyle(color: Colors.blue),
style: material.TextStyle(color: material.Colors.blue),
)),
TextButton(
material.TextButton(
onPressed: () {
DatePicker.showDateTimePicker(context, showTitleActions: true,
onChanged: (date) {
Expand All @@ -230,11 +230,11 @@ class HomePage extends StatelessWidget {
currentTime: DateTime.utc(2019, 12, 31, 23, 12, 34),
locale: LocaleType.de);
},
child: Text(
child: material.Text(
'show date time picker in UTC (German)',
style: TextStyle(color: Colors.blue),
style: material.TextStyle(color: material.Colors.blue),
)),
TextButton(
material.TextButton(
onPressed: () {
DatePicker.showPicker(context, showTitleActions: true,
onChanged: (date) {
Expand All @@ -246,9 +246,9 @@ class HomePage extends StatelessWidget {
pickerModel: CustomPicker(currentTime: DateTime.now()),
locale: LocaleType.en);
},
child: Text(
child: material.Text(
'show custom time picker,\nyou can custom picker model like this',
style: TextStyle(color: Colors.blue),
style: material.TextStyle(color: material.Colors.blue),
)),
],
),
Expand Down
42 changes: 26 additions & 16 deletions lib/flutter_datetime_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ 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/datetime_picker_theme.dart'
as picker;
import 'package:flutter_datetime_picker/src/date_model.dart';
import 'package:flutter_datetime_picker/src/i18n_model.dart';

Expand All @@ -30,11 +30,13 @@ class DatePicker {
DateCancelledCallback? onCancel,
locale: LocaleType.en,
DateTime? currentTime,
DatePickerTheme? theme,
picker.DatePickerTheme? theme,
RouteSettings? settings,
}) async {
return await Navigator.push(
context,
_DatePickerRoute(
settings: settings,
showTitleActions: showTitleActions,
onChanged: onChanged,
onConfirm: onConfirm,
Expand Down Expand Up @@ -65,11 +67,13 @@ class DatePicker {
DateCancelledCallback? onCancel,
locale: LocaleType.en,
DateTime? currentTime,
DatePickerTheme? theme,
picker.DatePickerTheme? theme,
RouteSettings? settings,
}) async {
return await Navigator.push(
context,
_DatePickerRoute(
settings: settings,
showTitleActions: showTitleActions,
onChanged: onChanged,
onConfirm: onConfirm,
Expand Down Expand Up @@ -98,11 +102,13 @@ class DatePicker {
DateCancelledCallback? onCancel,
locale: LocaleType.en,
DateTime? currentTime,
DatePickerTheme? theme,
picker.DatePickerTheme? theme,
RouteSettings? settings,
}) async {
return await Navigator.push(
context,
_DatePickerRoute(
settings: settings,
showTitleActions: showTitleActions,
onChanged: onChanged,
onConfirm: onConfirm,
Expand Down Expand Up @@ -132,11 +138,13 @@ class DatePicker {
DateCancelledCallback? onCancel,
locale: LocaleType.en,
DateTime? currentTime,
DatePickerTheme? theme,
picker.DatePickerTheme? theme,
RouteSettings? settings,
}) async {
return await Navigator.push(
context,
_DatePickerRoute(
settings: settings,
showTitleActions: showTitleActions,
onChanged: onChanged,
onConfirm: onConfirm,
Expand Down Expand Up @@ -166,11 +174,13 @@ class DatePicker {
DateCancelledCallback? onCancel,
locale: LocaleType.en,
BasePickerModel? pickerModel,
DatePickerTheme? theme,
picker.DatePickerTheme? theme,
RouteSettings? settings,
}) async {
return await Navigator.push(
context,
_DatePickerRoute(
settings: settings,
showTitleActions: showTitleActions,
onChanged: onChanged,
onConfirm: onConfirm,
Expand All @@ -191,21 +201,21 @@ class _DatePickerRoute<T> extends PopupRoute<T> {
this.onChanged,
this.onConfirm,
this.onCancel,
DatePickerTheme? theme,
picker.DatePickerTheme? theme,
this.barrierLabel,
this.locale,
RouteSettings? settings,
BasePickerModel? pickerModel,
}) : this.pickerModel = pickerModel ?? DatePickerModel(),
this.theme = theme ?? DatePickerTheme(),
this.theme = theme ?? picker.DatePickerTheme(),
super(settings: settings);

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

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

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

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

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

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

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

Expand Down Expand Up @@ -543,7 +553,7 @@ class _BottomPickerLayout extends SingleChildLayoutDelegate {
final double progress;
final int? itemCount;
final bool? showTitleActions;
final DatePickerTheme theme;
final picker.DatePickerTheme theme;
final double bottomPadding;

@override
Expand Down