diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 7c56964..391a902 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -20,7 +20,5 @@ ???? CFBundleVersion 1.0 - MinimumOSVersion - 12.0 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 1f6541e..db9bdcf 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -275,7 +275,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -349,7 +349,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -398,7 +398,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 4f74653..fc5ae03 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -26,6 +26,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit" shouldUseLaunchSchemeArgsEnv = "YES"> @@ -45,6 +46,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift index b636303..c30b367 100644 --- a/example/ios/Runner/AppDelegate.swift +++ b/example/ios/Runner/AppDelegate.swift @@ -1,13 +1,16 @@ -import UIKit import Flutter +import UIKit @main -@objc class AppDelegate: FlutterAppDelegate { +@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate { override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { - GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } + + func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) { + GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry) + } } diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index 4f68a2c..288ad41 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -2,6 +2,8 @@ + CADisableMinimumFrameDurationOnPhone + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable @@ -22,6 +24,29 @@ $(FLUTTER_BUILD_NUMBER) LSRequiresIPhoneOS + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneClassName + UIWindowScene + UISceneConfigurationName + flutter + UISceneDelegateClassName + FlutterSceneDelegate + UISceneStoryboardFile + Main + + + + + UIApplicationSupportsIndirectInputEvents + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile @@ -41,9 +66,5 @@ UIViewControllerBasedStatusBarAppearance - CADisableMinimumFrameDurationOnPhone - - UIApplicationSupportsIndirectInputEvents - diff --git a/example/pubspec.lock b/example/pubspec.lock index 29ed256..c015a85 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -28,10 +28,10 @@ packages: dependency: transitive description: name: characters - sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.4.1" clock: dependency: transitive description: @@ -115,18 +115,18 @@ packages: dependency: transitive description: name: matcher - sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861 url: "https://pub.dev" source: hosted - version: "0.12.17" + version: "0.12.19" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" url: "https://pub.dev" source: hosted - version: "0.11.1" + version: "0.13.0" meta: dependency: transitive description: @@ -192,10 +192,10 @@ packages: dependency: transitive description: name: test_api - sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 + sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a" url: "https://pub.dev" source: hosted - version: "0.7.7" + version: "0.7.10" vector_math: dependency: transitive description: @@ -213,5 +213,5 @@ packages: source: hosted version: "15.0.0" sdks: - dart: ">=3.8.0-0 <4.0.0" + dart: ">=3.9.0-0 <4.0.0" flutter: ">=3.18.0-18.0.pre.54" diff --git a/lib/bottom_picker.dart b/lib/bottom_picker.dart index 5f80e5f..8fd38bd 100644 --- a/lib/bottom_picker.dart +++ b/lib/bottom_picker.dart @@ -37,17 +37,11 @@ class BottomPicker extends StatefulWidget { BottomPicker({ super.key, - @Deprecated('should use headerBuilder instead') this.pickerTitle, - @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), this.dismissable = false, this.onChange, this.onSubmit, this.onDismiss, - @Deprecated('should use headerBuilder instead') this.onCloseButtonPressed, this.bottomPickerTheme = BottomPickerTheme.blue, this.gradientColors, this.selectedItemIndex = 0, @@ -56,17 +50,7 @@ class BottomPicker extends StatefulWidget { this.buttonSingleColor, this.backgroundColor = Colors.white, this.pickerThemeData, - @Deprecated('should use pickerThemeData instead') - this.pickerTextStyle = const TextStyle( - fontSize: 14, - color: Colors.black, - ), this.itemExtent = 35.0, - @Deprecated('should use headerBuilder instead') - this.displayCloseIcon = true, - @Deprecated('should use headerBuilder instead') - this.closeIconColor = Colors.black, - @Deprecated('should use headerBuilder instead') this.closeIconSize = 20, this.layoutOrientation = TextDirection.ltr, this.buttonAlignment = MainAxisAlignment.center, this.height, @@ -74,7 +58,6 @@ class BottomPicker extends StatefulWidget { this.selectionOverlay, this.buttonContent, this.buttonStyle, - @Deprecated('should use headerBuilder instead') this.closeWidget, this.closeOnSubmit = true, this.headerBuilder, this.diameterRatio = 1.1, @@ -92,16 +75,10 @@ class BottomPicker extends StatefulWidget { BottomPicker.date({ 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.titleAlignment, this.dismissable = false, this.onChange, this.onSubmit, this.onDismiss, - @Deprecated('should use headerBuilder instead') this.onCloseButtonPressed, this.bottomPickerTheme = BottomPickerTheme.blue, this.gradientColors, this.initialDateTime, @@ -113,16 +90,6 @@ class BottomPicker extends StatefulWidget { this.backgroundColor = Colors.white, this.dateOrder = DatePickerDateOrder.ymd, this.pickerThemeData, - @Deprecated('should use pickerThemeData instead') - this.pickerTextStyle = const TextStyle( - fontSize: 14, - color: Colors.black, - ), - @Deprecated('should use headerBuilder instead') - this.displayCloseIcon = true, - @Deprecated('should use headerBuilder instead') - this.closeIconColor = Colors.black, - @Deprecated('should use headerBuilder instead') this.closeIconSize = 20, this.layoutOrientation = TextDirection.ltr, this.buttonAlignment = MainAxisAlignment.center, this.height, @@ -130,7 +97,6 @@ class BottomPicker extends StatefulWidget { this.buttonContent, this.buttonStyle, this.itemExtent = 35.0, - @Deprecated('should use headerBuilder instead') this.closeWidget, this.closeOnSubmit = true, this.headerBuilder, this.calendarDays = CupertinoDatePickerWidget.fullWeek, @@ -181,16 +147,10 @@ class BottomPicker extends StatefulWidget { BottomPicker.monthYear({ 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.titleAlignment, this.dismissable = false, this.onChange, this.onSubmit, this.onDismiss, - @Deprecated('should use headerBuilder instead') this.onCloseButtonPressed, this.bottomPickerTheme = BottomPickerTheme.blue, this.gradientColors, this.initialDateTime, @@ -201,16 +161,6 @@ class BottomPicker extends StatefulWidget { this.buttonSingleColor, this.backgroundColor = Colors.white, this.pickerThemeData, - @Deprecated('should use pickerThemeData instead') - this.pickerTextStyle = const TextStyle( - fontSize: 14, - color: Colors.black, - ), - @Deprecated('should use headerBuilder instead') - this.displayCloseIcon = true, - @Deprecated('should use headerBuilder instead') - this.closeIconColor = Colors.black, - @Deprecated('should use headerBuilder instead') this.closeIconSize = 20, this.layoutOrientation = TextDirection.ltr, this.buttonAlignment = MainAxisAlignment.center, this.height, @@ -218,7 +168,6 @@ class BottomPicker extends StatefulWidget { this.buttonContent, this.buttonStyle, this.itemExtent = 35.0, - @Deprecated('should use headerBuilder instead') this.closeWidget, this.closeOnSubmit = true, this.headerBuilder, this.calendarDays = CupertinoDatePickerWidget.fullWeek, @@ -235,16 +184,10 @@ class BottomPicker extends StatefulWidget { BottomPicker.dateTime({ 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.titleAlignment, this.dismissable = false, this.onChange, this.onSubmit, this.onDismiss, - @Deprecated('should use headerBuilder instead') this.onCloseButtonPressed, this.bottomPickerTheme = BottomPickerTheme.blue, this.gradientColors, this.initialDateTime, @@ -258,16 +201,6 @@ class BottomPicker extends StatefulWidget { this.backgroundColor = Colors.white, this.dateOrder = DatePickerDateOrder.ymd, this.pickerThemeData, - @Deprecated('should use pickerThemeData instead') - this.pickerTextStyle = const TextStyle( - fontSize: 14, - color: Colors.black, - ), - @Deprecated('should use headerBuilder instead') - this.displayCloseIcon = true, - @Deprecated('should use headerBuilder instead') - this.closeIconColor = Colors.black, - @Deprecated('should use headerBuilder instead') this.closeIconSize = 20, this.layoutOrientation = TextDirection.ltr, this.buttonAlignment = MainAxisAlignment.center, this.height, @@ -276,7 +209,6 @@ class BottomPicker extends StatefulWidget { this.buttonStyle, this.itemExtent = 30, this.showTimeSeparator = false, - @Deprecated('should use headerBuilder instead') this.closeWidget, this.closeOnSubmit = true, this.headerBuilder, this.calendarDays = CupertinoDatePickerWidget.fullWeek, @@ -292,19 +224,13 @@ class BottomPicker extends StatefulWidget { BottomPicker.time({ super.key, - @Deprecated('should use headerBuilder instead') this.pickerTitle, - @Deprecated('should use headerBuilder instead') this.pickerDescription, required this.initialTime, this.maxTime, this.minTime, - @Deprecated('should use headerBuilder instead') - this.titlePadding = const EdgeInsets.all(0), - @Deprecated('should use headerBuilder instead') this.titleAlignment, this.dismissable = false, this.onChange, this.onSubmit, this.onDismiss, - @Deprecated('should use headerBuilder instead') this.onCloseButtonPressed, this.bottomPickerTheme = BottomPickerTheme.blue, this.gradientColors, this.minuteInterval = 1, @@ -314,16 +240,6 @@ class BottomPicker extends StatefulWidget { this.buttonSingleColor, this.backgroundColor = Colors.white, this.pickerThemeData, - @Deprecated('should use pickerThemeData instead') - this.pickerTextStyle = const TextStyle( - fontSize: 14, - color: Colors.black, - ), - @Deprecated('should use headerBuilder instead') - this.displayCloseIcon = true, - @Deprecated('should use headerBuilder instead') - this.closeIconColor = Colors.black, - @Deprecated('should use headerBuilder instead') this.closeIconSize = 20, this.layoutOrientation = TextDirection.ltr, this.buttonAlignment = MainAxisAlignment.center, this.height, @@ -332,7 +248,6 @@ class BottomPicker extends StatefulWidget { this.buttonStyle, this.showTimeSeparator = false, this.itemExtent = 30, - @Deprecated('should use headerBuilder instead') this.closeWidget, this.closeOnSubmit = true, this.headerBuilder, this.calendarDays = CupertinoDatePickerWidget.fullWeek, @@ -349,20 +264,14 @@ class BottomPicker extends StatefulWidget { BottomPicker.timer({ super.key, - @Deprecated('should use headerBuilder instead') this.pickerTitle, this.timerPickerMode = CupertinoTimerPickerMode.hm, 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.titleAlignment, this.dismissable = false, this.onChange, this.onSubmit, this.onDismiss, this.itemExtent = 30, - @Deprecated('should use headerBuilder instead') this.onCloseButtonPressed, this.bottomPickerTheme = BottomPickerTheme.blue, this.gradientColors, this.minuteInterval = 1, @@ -371,23 +280,12 @@ class BottomPicker extends StatefulWidget { this.buttonSingleColor, this.backgroundColor = Colors.white, this.pickerThemeData, - @Deprecated('should use pickerThemeData instead') - this.pickerTextStyle = const TextStyle( - fontSize: 14, - color: Colors.black, - ), - @Deprecated('should use headerBuilder instead') - this.displayCloseIcon = true, - @Deprecated('should use headerBuilder instead') - this.closeIconColor = Colors.black, - @Deprecated('should use headerBuilder instead') this.closeIconSize = 20, this.layoutOrientation = TextDirection.ltr, this.buttonAlignment = MainAxisAlignment.center, this.height, this.displaySubmitButton = true, this.buttonContent, this.buttonStyle, - @Deprecated('should use headerBuilder instead') this.closeWidget, this.closeOnSubmit = true, this.headerBuilder, this.calendarDays = CupertinoDatePickerWidget.fullWeek, @@ -404,15 +302,9 @@ class BottomPicker extends StatefulWidget { BottomPicker.range({ super.key, - @Deprecated('should use headerBuilder instead') this.pickerTitle, - @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.titleAlignment, this.dismissable = false, - @Deprecated('should use headerBuilder instead') this.onCloseButtonPressed, this.bottomPickerTheme = BottomPickerTheme.blue, this.gradientColors, this.buttonPadding, @@ -420,16 +312,6 @@ class BottomPicker extends StatefulWidget { this.buttonSingleColor, this.backgroundColor = Colors.white, this.pickerThemeData, - @Deprecated('should use pickerThemeData instead') - this.pickerTextStyle = const TextStyle( - fontSize: 14, - color: Colors.black, - ), - @Deprecated('should use headerBuilder instead') - this.displayCloseIcon = true, - @Deprecated('should use headerBuilder instead') - this.closeIconColor = Colors.black, - @Deprecated('should use headerBuilder instead') this.closeIconSize = 20, this.layoutOrientation = TextDirection.ltr, this.buttonAlignment = MainAxisAlignment.center, this.height, @@ -443,7 +325,6 @@ class BottomPicker extends StatefulWidget { this.buttonContent, this.buttonStyle, this.itemExtent = 30, - @Deprecated('should use headerBuilder instead') this.closeWidget, this.closeOnSubmit = true, this.headerBuilder, this.calendarDays = CupertinoDatePickerWidget.fullWeek, @@ -474,16 +355,10 @@ class BottomPicker extends StatefulWidget { BottomPicker.rangeTime({ super.key, - @Deprecated('should use headerBuilder instead') this.pickerTitle, - @Deprecated('should use headerBuilder instead') this.pickerDescription, 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.titleAlignment, this.dismissable = false, - @Deprecated('should use headerBuilder instead') this.onCloseButtonPressed, this.bottomPickerTheme = BottomPickerTheme.blue, this.gradientColors, this.buttonPadding, @@ -491,16 +366,6 @@ class BottomPicker extends StatefulWidget { this.buttonSingleColor, this.backgroundColor = Colors.white, this.pickerThemeData, - @Deprecated('should use pickerThemeData instead') - this.pickerTextStyle = const TextStyle( - fontSize: 14, - color: Colors.black, - ), - @Deprecated('should use headerBuilder instead') - this.displayCloseIcon = true, - @Deprecated('should use headerBuilder instead') - this.closeIconColor = Colors.black, - @Deprecated('should use headerBuilder instead') this.closeIconSize = 20, this.layoutOrientation = TextDirection.ltr, this.buttonAlignment = MainAxisAlignment.center, this.height, @@ -515,7 +380,6 @@ class BottomPicker extends StatefulWidget { this.minuteInterval = 1, this.showTimeSeparator = false, this.itemExtent = 30, - @Deprecated('should use headerBuilder instead') this.closeWidget, this.closeOnSubmit = true, this.headerBuilder, this.calendarDays = CupertinoDatePickerWidget.fullWeek, diff --git a/lib/widgets/bottom_picker_button.dart b/lib/widgets/bottom_picker_button.dart index 7d00bac..943b3ce 100644 --- a/lib/widgets/bottom_picker_button.dart +++ b/lib/widgets/bottom_picker_button.dart @@ -1,14 +1,30 @@ import 'package:bottom_picker/resources/arrays.dart'; import 'package:flutter/material.dart'; +/// A button widget that can be used to open the bottom picker. class BottomPickerButton extends StatelessWidget { + /// The callback function that is called when the button is pressed. final Function onClick; + + /// The theme of the button. final BottomPickerTheme theme; + + /// The list of colors to be used for the gradient background of the button. final List? gradients; + + /// The solid color to be used for the background of the button. final Color? solidColor; + + /// The padding to be used for the button. final double? buttonPadding; + + /// The width of the button. final double? buttonWidth; + + /// The child widget to be used for the button. final Widget? buttonChild; + + /// The style to be used for the button. final BoxDecoration? style; const BottomPickerButton({ diff --git a/lib/widgets/close_icon.dart b/lib/widgets/close_icon.dart index 940f1b2..a48f555 100644 --- a/lib/widgets/close_icon.dart +++ b/lib/widgets/close_icon.dart @@ -1,8 +1,14 @@ import 'package:flutter/material.dart'; +/// A close icon widget that can be used to close the picker. class CloseIcon extends StatelessWidget { + /// The callback function that is called when the close icon is pressed. final Function() onPress; + + /// The color of the close icon. final Color? iconColor; + + /// The size of the close icon. final double? closeIconSize; const CloseIcon({ diff --git a/lib/widgets/date_picker.dart b/lib/widgets/date_picker.dart index 41483ae..80937b6 100644 --- a/lib/widgets/date_picker.dart +++ b/lib/widgets/date_picker.dart @@ -1,20 +1,48 @@ import 'package:bottom_picker/cupertino/cupertino_date_picker.dart'; import 'package:flutter/cupertino.dart'; +/// A date picker widget that can be used to select a date or time. class DatePicker extends StatelessWidget { + /// The mode of the date picker [CupertinoDatePickerMode]. final CupertinoDatePickerMode mode; + + /// The callback function that is called when the selected date changes. final Function(DateTime) onDateChanged; + + /// The initial date to be displayed in the picker. final DateTime? initialDateTime; + + /// The maximum date that can be selected in the picker. final DateTime? maxDateTime; + + /// The minimum date that can be selected in the picker. final DateTime? minDateTime; + + /// The interval of the minutes in the time picker. final int minuteInterval; + + /// Whether to use 24-hour format for the time picker. final bool use24hFormat; + + /// The order in which the date components are displayed in the picker. final DatePickerDateOrder? dateOrder; + + /// The text style to be used for the items in the picker. final TextStyle? textStyle; + + /// The height of each item in the picker. final double? itemExtent; + + /// Whether to show the time separator in the time picker. final bool showTimeSeparator; + + /// The list of days to be displayed in the calendar view of the picker. final List calendarDays; + + /// The theme data to be used for the picker. final CupertinoTextThemeData? pickerThemeData; + + /// The predicate function that determines whether a given hour is selectable in the time picker. final SelectableHourPredicate? hourPredicate; const DatePicker({ diff --git a/lib/widgets/range_picker.dart b/lib/widgets/range_picker.dart index c0b1d1f..6084fa2 100644 --- a/lib/widgets/range_picker.dart +++ b/lib/widgets/range_picker.dart @@ -1,22 +1,54 @@ import 'package:bottom_picker/widgets/date_picker.dart'; import 'package:flutter/cupertino.dart'; +/// A range picker widget that can be used to select a range of dates or times. class RangePicker extends StatefulWidget { + /// The callback function that is called when the first date changes. final Function(DateTime) onFirstDateChanged; + + /// The callback function that is called when the second date changes. final Function(DateTime) onSecondDateChanged; + + /// The initial date to be displayed in the first picker. final DateTime? initialFirstDateTime; + + /// The initial date to be displayed in the second picker. final DateTime? initialSecondDateTime; + + /// The maximum date that can be selected in the first picker. final DateTime? maxFirstDate; + + /// The maximum date that can be selected in the second picker. final DateTime? maxSecondDate; + + /// The minimum date that can be selected in the first picker. final DateTime? minFirstDateTime; + + /// The minimum date that can be selected in the second picker. final DateTime? minSecondDateTime; + + /// The order in which the date components are displayed in the picker. final DatePickerDateOrder? dateOrder; + + /// The text style to be used for the items in the picker. final TextStyle? textStyle; + + /// The mode of the date picker [CupertinoDatePickerMode]. final CupertinoDatePickerMode mode; + + /// Whether to use 24-hour format for the time picker. final bool use24hFormat; + + /// The interval of the minutes in the time picker. final int? minuteInterval; + + /// The height of each item in the picker. final double? itemExtent; + + /// Whether to show the time separator in the time picker. final bool showTimeSeperator; + + /// The theme data to be used for the picker. final CupertinoTextThemeData? pickerThemeData; const RangePicker({ diff --git a/lib/widgets/simple_picker.dart b/lib/widgets/simple_picker.dart index f0d5376..5899995 100644 --- a/lib/widgets/simple_picker.dart +++ b/lib/widgets/simple_picker.dart @@ -3,14 +3,30 @@ import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; +/// A simple picker widget that can be used to select an item from a list of items. class SimplePicker extends StatelessWidget { + /// The index of the selected item in the list of items. final int selectedItemIndex; + + /// The callback function that is called when the selected item changes. final Function(int)? onChange; + + /// The list of items to be displayed in the picker. final List items; + + /// The text style to be used for the items in the picker. final TextStyle? textStyle; + + /// The height of each item in the picker. final double itemExtent; + + /// The widget to be used as the selection overlay in the picker. final Widget? selectionOverlay; + + /// The theme data to be used for the picker. final CupertinoTextThemeData? pickerThemeData; + + /// The diameter ratio of the picker. final double diameterRatio; const SimplePicker({ diff --git a/lib/widgets/time_picker.dart b/lib/widgets/time_picker.dart index 077ef2f..9ac7eb3 100644 --- a/lib/widgets/time_picker.dart +++ b/lib/widgets/time_picker.dart @@ -1,27 +1,70 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +/// A time picker widget that can be used to select a time duration +/// based on the Time picker mode [CupertinoTimerPickerMode]. class TimePicker extends StatelessWidget { + /// The mode of the time picker [CupertinoTimerPickerMode]. + /// + /// Possible values are: + /// - [CupertinoTimerPickerMode.hms]: Displays hours, minutes, and seconds + /// - [CupertinoTimerPickerMode.hm]: Displays hours and minutes + /// - [CupertinoTimerPickerMode.ms]: Displays minutes and seconds + /// + /// mode cannot be null and must be one of the above values. final CupertinoTimerPickerMode mode; + + /// The interval of the minutes in the time picker. + /// By default minuteInterval is set to 1, which means that the user can select any minute value from 0 to 59. + /// + /// if minuteInterval is outside the range of 1 to 59 an assertion error will be thrown. final int minuteInterval; + + /// The text style to be used for the items in the picker. + /// When the textstyle is null the default text style of the [CupertinoTimerPicker] will be used. final TextStyle? textStyle; + + /// The height of each item in the picker. + /// The extent value should be greater than 0, otherwise an assertion error will be thrown. + /// by default the itemExtent value is taking the [_kItemExtent] value of the [CupertinoTimerPicker] which is 32.0. final double itemExtent; + + /// The callback function that is called when the selected time changes. + /// a required parameter that cannot be null, and it will be called with the selected time duration. final Function(Duration) onChange; + + /// The initial duration to be displayed in the picker. + /// When initialDuration is null, the picker will display a duration of zero. final Duration? initialDuration; + + /// The interval of the seconds in the time picker. + /// By default secondInterval is set to 1, which means that the user can select any second value from 0 to 59. + /// if secondInterval is outside the range of 1 to 59 an assertion error will be thrown. final int secondInterval; + + /// The theme data to be used for the picker. + /// When pickerThemeData is null, the default theme data of the [CupertinoTimerPicker] will be used. final CupertinoTextThemeData? pickerThemeData; const TimePicker({ super.key, this.minuteInterval = 1, required this.mode, - required this.textStyle, - required this.itemExtent, + this.textStyle, + this.itemExtent = 32.0, required this.onChange, - required this.initialDuration, + this.initialDuration, this.secondInterval = 1, this.pickerThemeData, - }); + }) : assert( + minuteInterval > 0 && minuteInterval < 60, + 'minuteInterval must be a positive integer from 1 to 59.', + ), + assert(itemExtent > 0, 'itemExtent must be a positive number.'), + assert( + secondInterval > 0 && secondInterval < 60, + 'secondInterval must be a positive integer from 1 to 59.', + ); @override Widget build(BuildContext context) { diff --git a/lib/widgets/year_picker.dart b/lib/widgets/year_picker.dart index c547ba5..721cb15 100644 --- a/lib/widgets/year_picker.dart +++ b/lib/widgets/year_picker.dart @@ -1,12 +1,24 @@ import 'package:bottom_picker/widgets/simple_picker.dart'; import 'package:flutter/cupertino.dart'; +/// A year picker widget that can be used to select a year. class BottomYearDatePicker extends StatefulWidget { + /// The callback function that is called when the selected year changes. final Function(DateTime) onDateChanged; + + /// The initial date to be displayed in the picker. final DateTime? initialDateTime; + + /// The maximum date that can be selected in the picker. final DateTime? maxDateTime; + + /// The minimum date that can be selected in the picker. final DateTime? minDateTime; + + /// The height of each item in the picker. final double? itemExtent; + + /// The theme data to be used for the picker. final CupertinoTextThemeData? pickerThemeData; const BottomYearDatePicker({ diff --git a/pubspec.lock b/pubspec.lock index 2e476a0..161ed16 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -21,10 +21,10 @@ packages: dependency: transitive description: name: characters - sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.4.1" clock: dependency: transitive description: @@ -103,18 +103,18 @@ packages: dependency: transitive description: name: matcher - sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861 url: "https://pub.dev" source: hosted - version: "0.12.17" + version: "0.12.19" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" url: "https://pub.dev" source: hosted - version: "0.11.1" + version: "0.13.0" meta: dependency: transitive description: @@ -180,10 +180,10 @@ packages: dependency: transitive description: name: test_api - sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 + sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a" url: "https://pub.dev" source: hosted - version: "0.7.7" + version: "0.7.10" vector_math: dependency: transitive description: @@ -201,5 +201,5 @@ packages: source: hosted version: "15.0.0" sdks: - dart: ">=3.8.0 <4.0.0" + dart: ">=3.9.0-0 <4.0.0" flutter: ">=3.18.0-18.0.pre.54"