Skip to content
Merged
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
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ To add bottom picker to your project add this line to your pubspec.yaml file

```yaml
dependencies:
bottom_picker: ^3.2.1
bottom_picker: ^3.2.1
```

## Parameters
Expand Down Expand Up @@ -323,8 +323,8 @@ dependencies:

```dart
BottomPicker(
items: items,
title: Text("Choose your country", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15)),
items: items,
title: Text("Choose your country", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15)),
).show(context);
```

Expand All @@ -334,7 +334,7 @@ BottomPicker(

```dart
BottomPicker.date(
pickerTitle: Text(
pickerTitle: Text(
'Set your Birthday',
style: TextStyle(
fontWeight: FontWeight.bold,
Expand Down Expand Up @@ -430,7 +430,7 @@ BottomPicker.timer(

```dart
BottomPicker.dateTime(
pickerTitle: Text(
pickerTitle: Text(
'Set the event exact time and date',
style: TextStyle(
fontWeight: FontWeight.bold,
Expand Down Expand Up @@ -476,7 +476,7 @@ BottomPicker.monthYear(

```dart
BottomPicker(
items: [
items: [
Center(
child: Text('Leonardo DiCaprio'),
),
Expand Down Expand Up @@ -517,7 +517,7 @@ BottomPicker(

```dart
BottomPicker.range(
pickerTitle: Text(
pickerTitle: Text(
'Set date range',
style: TextStyle(
fontWeight: FontWeight.bold,
Expand Down Expand Up @@ -555,7 +555,7 @@ BottomPicker.range(

```dart
BottomPicker.rangeTime(
pickerTitle: Text(
pickerTitle: Text(
'Set Time range',
style: TextStyle(
fontWeight: FontWeight.bold,
Expand Down Expand Up @@ -598,11 +598,11 @@ We warmly welcome contributions to the `bottom_picker` package! Your help in mak
- **Found a bug?** Please [open a new issue](https://github.com/koukibadr/Bottom-Picker/issues/new?assignees=&labels=bug&template=bug_report.md&title=) with clear steps to reproduce the problem. The more detail you provide, the easier it will be to fix.
- **Have a great idea for a new feature?** We'd love to hear it! Please [open a new issue](https://github.com/koukibadr/Bottom-Picker/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=) to discuss your suggestion. Explain the use case and how it would benefit users.
- **Want to get your hands dirty and contribute code?** Fantastic! Here's how:
1. Fork the [repository](https://github.com/koukibadr/Bottom-Picker).
2. Create a new branch for your feature or bug fix.
3. Make your changes, ensuring you follow the project's coding style and conventions.
4. Write clear and concise commit messages.
5. Submit a [pull request](https://github.com/koukibadr/Bottom-Picker/pulls) with a detailed description of your changes and why they should be merged.
1. Fork the [repository](https://github.com/koukibadr/Bottom-Picker).
2. Create a new branch for your feature or bug fix.
3. Make your changes, ensuring you follow the project's coding style and conventions.
4. Write clear and concise commit messages.
5. Submit a [pull request](https://github.com/koukibadr/Bottom-Picker/pulls) with a detailed description of your changes and why they should be merged.

We'll review your contributions and provide feedback as soon as possible. Thank you for your interest in improving `bottom_picker`!

Expand Down
34 changes: 32 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// ignore_for_file: avoid_print

import 'package:bottom_picker/bottom_picker.dart';
import 'package:bottom_picker/cupertino/cupertino_date_picker.dart';
import 'package:bottom_picker/resources/arrays.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -169,11 +170,38 @@ class ExampleApp extends StatelessWidget {
width: buttonWidth,
child: ElevatedButton(
onPressed: () {
_openDateTimePicker(context);
_openDateTimePicker(
context,
CupertinoDatePickerCalendarType.fullWeek,
);
},
child: Text('Date and Time Picker', textAlign: TextAlign.center),
),
),
SizedBox(
width: buttonWidth,
child: ElevatedButton(
onPressed: () {
_openDateTimePicker(
context,
CupertinoDatePickerCalendarType.workDays,
);
},
child: Text('Workday Picker', textAlign: TextAlign.center),
),
),
SizedBox(
width: buttonWidth,
child: ElevatedButton(
onPressed: () {
_openDateTimePicker(
context,
CupertinoDatePickerCalendarType.weekend,
);
},
child: Text('Weekend Day Picker', textAlign: TextAlign.center),
),
),
],
),
);
Expand Down Expand Up @@ -558,7 +586,8 @@ class ExampleApp extends StatelessWidget {
).show(context);
}

void _openDateTimePicker(BuildContext context) {
void _openDateTimePicker(
BuildContext context, CupertinoDatePickerCalendarType calendarType,) {
BottomPicker.dateTime(
minuteInterval: 2,
headerBuilder: (context) {
Expand Down Expand Up @@ -598,6 +627,7 @@ class ExampleApp extends StatelessWidget {
Color(0xfffdcbf1),
Color(0xffe6dee9),
],
calendarType: calendarType,
).show(context);
}
}
42 changes: 33 additions & 9 deletions lib/bottom_picker.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:io';

import 'package:bottom_picker/cupertino/cupertino_date_picker.dart';
import 'package:bottom_picker/resources/arrays.dart';
import 'package:bottom_picker/resources/context_extension.dart';
import 'package:bottom_picker/resources/time.dart';
Expand Down Expand Up @@ -38,7 +39,8 @@ class BottomPicker extends StatefulWidget {
@Deprecated('should use headerBuilder instead') this.pickerDescription,
required this.items,
@Deprecated('should use headerBuilder instead') this.titleAlignment,
@Deprecated('should use headerBuilder instead') this.titlePadding = const EdgeInsets.all(0),
@Deprecated('should use headerBuilder instead')
this.titlePadding = const EdgeInsets.all(0),
this.dismissable = false,
this.onChange,
this.onSubmit,
Expand Down Expand Up @@ -71,6 +73,7 @@ class BottomPicker extends StatefulWidget {
@Deprecated('should use headerBuilder instead') this.closeWidget,
this.closeOnSubmit = true,
this.headerBuilder,
this.calendarType = CupertinoDatePickerCalendarType.fullWeek,
}) {
dateOrder = null;
onRangeDateSubmitPressed = null;
Expand All @@ -86,7 +89,8 @@ class BottomPicker extends StatefulWidget {
super.key,
@Deprecated('should use headerBuilder instead') this.pickerTitle,
@Deprecated('should use headerBuilder instead') this.pickerDescription,
@Deprecated('should use headerBuilder instead') this.titlePadding = const EdgeInsets.all(0),
@Deprecated('should use headerBuilder instead')
this.titlePadding = const EdgeInsets.all(0),
@Deprecated('should use headerBuilder instead') this.titleAlignment,
this.dismissable = false,
this.onChange,
Expand Down Expand Up @@ -122,6 +126,7 @@ class BottomPicker extends StatefulWidget {
@Deprecated('should use headerBuilder instead') this.closeWidget,
this.closeOnSubmit = true,
this.headerBuilder,
this.calendarType = CupertinoDatePickerCalendarType.fullWeek,
}) {
datePickerMode = CupertinoDatePickerMode.date;
bottomPickerType = BottomPickerType.dateTime;
Expand All @@ -134,7 +139,8 @@ class BottomPicker extends StatefulWidget {
super.key,
@Deprecated('should use headerBuilder instead') this.pickerTitle,
@Deprecated('should use headerBuilder instead') this.pickerDescription,
@Deprecated('should use headerBuilder instead') this.titlePadding = const EdgeInsets.all(0),
@Deprecated('should use headerBuilder instead')
this.titlePadding = const EdgeInsets.all(0),
@Deprecated('should use headerBuilder instead') this.titleAlignment,
this.dismissable = false,
this.onChange,
Expand Down Expand Up @@ -169,6 +175,7 @@ class BottomPicker extends StatefulWidget {
@Deprecated('should use headerBuilder instead') this.closeWidget,
this.closeOnSubmit = true,
this.headerBuilder,
this.calendarType = CupertinoDatePickerCalendarType.fullWeek,
}) {
datePickerMode = CupertinoDatePickerMode.monthYear;
bottomPickerType = BottomPickerType.dateTime;
Expand All @@ -182,7 +189,8 @@ class BottomPicker extends StatefulWidget {
super.key,
@Deprecated('should use headerBuilder instead') this.pickerTitle,
@Deprecated('should use headerBuilder instead') this.pickerDescription,
@Deprecated('should use headerBuilder instead') this.titlePadding = const EdgeInsets.all(0),
@Deprecated('should use headerBuilder instead')
this.titlePadding = const EdgeInsets.all(0),
@Deprecated('should use headerBuilder instead') this.titleAlignment,
this.dismissable = false,
this.onChange,
Expand Down Expand Up @@ -221,6 +229,7 @@ class BottomPicker extends StatefulWidget {
@Deprecated('should use headerBuilder instead') this.closeWidget,
this.closeOnSubmit = true,
this.headerBuilder,
this.calendarType = CupertinoDatePickerCalendarType.fullWeek,
}) {
datePickerMode = CupertinoDatePickerMode.dateAndTime;
bottomPickerType = BottomPickerType.dateTime;
Expand All @@ -235,7 +244,8 @@ class BottomPicker extends StatefulWidget {
required this.initialTime,
this.maxTime,
this.minTime,
@Deprecated('should use headerBuilder instead') this.titlePadding = const EdgeInsets.all(0),
@Deprecated('should use headerBuilder instead')
this.titlePadding = const EdgeInsets.all(0),
@Deprecated('should use headerBuilder instead') this.titleAlignment,
this.dismissable = false,
this.onChange,
Expand Down Expand Up @@ -270,6 +280,7 @@ class BottomPicker extends StatefulWidget {
@Deprecated('should use headerBuilder instead') this.closeWidget,
this.closeOnSubmit = true,
this.headerBuilder,
this.calendarType = CupertinoDatePickerCalendarType.fullWeek,
}) {
datePickerMode = CupertinoDatePickerMode.time;
bottomPickerType = BottomPickerType.time;
Expand All @@ -286,7 +297,8 @@ class BottomPicker extends StatefulWidget {
this.timerSecondsInterval = 1,
@Deprecated('should use headerBuilder instead') this.pickerDescription,
this.initialTimerDuration,
@Deprecated('should use headerBuilder instead') this.titlePadding = const EdgeInsets.all(0),
@Deprecated('should use headerBuilder instead')
this.titlePadding = const EdgeInsets.all(0),
@Deprecated('should use headerBuilder instead') this.titleAlignment,
this.dismissable = false,
this.onChange,
Expand Down Expand Up @@ -319,6 +331,7 @@ class BottomPicker extends StatefulWidget {
@Deprecated('should use headerBuilder instead') this.closeWidget,
this.closeOnSubmit = true,
this.headerBuilder,
this.calendarType = CupertinoDatePickerCalendarType.fullWeek,
}) {
dateOrder = null;
onRangeDateSubmitPressed = null;
Expand All @@ -334,7 +347,8 @@ class BottomPicker extends StatefulWidget {
@Deprecated('should use headerBuilder instead') this.pickerDescription,
required this.onRangeDateSubmitPressed,
this.onRangePickerDismissed,
@Deprecated('should use headerBuilder instead') this.titlePadding = const EdgeInsets.all(0),
@Deprecated('should use headerBuilder instead')
this.titlePadding = const EdgeInsets.all(0),
@Deprecated('should use headerBuilder instead') this.titleAlignment,
this.dismissable = false,
@Deprecated('should use headerBuilder instead') this.onCloseButtonPressed,
Expand Down Expand Up @@ -369,6 +383,7 @@ class BottomPicker extends StatefulWidget {
@Deprecated('should use headerBuilder instead') this.closeWidget,
this.closeOnSubmit = true,
this.headerBuilder,
this.calendarType = CupertinoDatePickerCalendarType.fullWeek,
}) {
datePickerMode = CupertinoDatePickerMode.date;
bottomPickerType = BottomPickerType.rangeDate;
Expand Down Expand Up @@ -399,7 +414,8 @@ class BottomPicker extends StatefulWidget {
required this.onRangeTimeSubmitPressed,
this.onRangePickerDismissed,
this.use24hFormat = true,
@Deprecated('should use headerBuilder instead') this.titlePadding = const EdgeInsets.all(0),
@Deprecated('should use headerBuilder instead')
this.titlePadding = const EdgeInsets.all(0),
@Deprecated('should use headerBuilder instead') this.titleAlignment,
this.dismissable = false,
@Deprecated('should use headerBuilder instead') this.onCloseButtonPressed,
Expand Down Expand Up @@ -435,6 +451,7 @@ class BottomPicker extends StatefulWidget {
@Deprecated('should use headerBuilder instead') this.closeWidget,
this.closeOnSubmit = true,
this.headerBuilder,
this.calendarType = CupertinoDatePickerCalendarType.fullWeek,
}) {
datePickerMode = CupertinoDatePickerMode.time;
bottomPickerType = BottomPickerType.rangeTime;
Expand Down Expand Up @@ -726,6 +743,9 @@ class BottomPicker extends StatefulWidget {
/// By default closeOnSubmit = true.
final bool closeOnSubmit;

/// The datepicker calendar type
final CupertinoDatePickerCalendarType calendarType;

///display the bottom picker popup
///[context] the app context to display the popup
void show(BuildContext context) {
Expand Down Expand Up @@ -839,7 +859,9 @@ class BottomPickerState extends State<BottomPicker> {
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: widget.headerBuilder == null ? widget.titlePadding : EdgeInsetsGeometry.zero,
padding: widget.headerBuilder == null
? widget.titlePadding
: EdgeInsetsGeometry.zero,
child: Row(
children: [
if (widget.headerBuilder != null)
Expand Down Expand Up @@ -911,6 +933,7 @@ class BottomPickerState extends State<BottomPicker> {
textStyle: widget.pickerTextStyle,
itemExtent: widget.itemExtent,
showTimeSeparator: widget.showTimeSeparator,
calendarType: widget.calendarType,
)
: widget.bottomPickerType == BottomPickerType.dateTime
? DatePicker(
Expand All @@ -928,6 +951,7 @@ class BottomPickerState extends State<BottomPicker> {
textStyle: widget.pickerTextStyle,
itemExtent: widget.itemExtent,
showTimeSeparator: widget.showTimeSeparator,
calendarType: widget.calendarType,
)
: widget.bottomPickerType ==
BottomPickerType.rangeTime
Expand Down
Loading