Skip to content

Commit

Permalink
Added initialTime parameter to MacosTimePicker
Browse files Browse the repository at this point in the history
  • Loading branch information
Abbas1Hussein committed Oct 19, 2023
1 parent b3a8e53 commit 5ec00bc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@ metrics

coverage_report
coverage
example/macos/Flutter/GeneratedPluginRegistrant.swift
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [2.0.3]
### 🔄 Updated 🔄
* Added `initialTime` parameter to `MacosTimePicker`, allowing to set an initial time for the picker.This provides more customization options for selecting time.

## [2.0.2]
### 🛠️ Fixed 🛠️
* Fixed images in generated documentation.
Expand Down
14 changes: 10 additions & 4 deletions lib/src/selectors/time_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ enum TimePickerStyle {

/// {template onTimeChanged}
/// The action to perform when a new time is selected.
/// {endtemplate}
typedef OnTimeChanged = Function(TimeOfDay time);
/// {end-template}
typedef OnTimeChanged = void Function(TimeOfDay time);

/// {template macosTimePicker}
/// A [MacosTimePicker] lets the user choose a time.
Expand All @@ -36,15 +36,21 @@ typedef OnTimeChanged = Function(TimeOfDay time);
///
/// The [onTimeChanged] callback passes through the user's selected time, and
/// must be provided.
/// {endtemplate}
/// {end-template}
class MacosTimePicker extends StatefulWidget {
/// {@macro macosTimePicker}
const MacosTimePicker({
super.key,
required this.onTimeChanged,
this.initialTime,
this.style = TimePickerStyle.combined,
});

/// Set an initial date for the picker.
///
/// Defaults to `TimeOfDay.now()`.
final TimeOfDay? initialTime;

/// The [TimePickerStyle] to use.
///
/// Defaults to [TimePickerStyle.combined].
Expand All @@ -58,7 +64,7 @@ class MacosTimePicker extends StatefulWidget {
}

class _MacosTimePickerState extends State<MacosTimePicker> {
final _initialTime = TimeOfDay.now();
late final _initialTime = widget.initialTime ?? TimeOfDay.now();
late int _selectedHour;
late int _selectedMinute;
late DayPeriod _selectedPeriod;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: macos_ui
description: Flutter widgets and themes implementing the current macOS design language.
version: 2.0.2
version: 2.0.3
homepage: "https://macosui.dev"
repository: "https://github.com/GroovinChip/macos_ui"

Expand Down

0 comments on commit 5ec00bc

Please sign in to comment.