Skip to content

Commit

Permalink
Merge branch 'time_picker' of https://github.com/Abbas1Hussein/macos_ui
Browse files Browse the repository at this point in the history
… into Abbas1Hussein-time_picker
  • Loading branch information
Adrian-Samoticha committed Jan 21, 2024
2 parents e0899a6 + 7be94be commit cb35862
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.4]
### 🔄 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.3]
### 🛠️ Fixed 🛠️
* Fixed a bug that caused the sidebar to appear darker than intended.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/selectors/date_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ enum DatePickerStyle {
/// {template onDateChanged}
/// The action to perform when a new date is selected.
/// {endtemplate}
typedef OnDateChanged = Function(DateTime date);
typedef OnDateChanged = void Function(DateTime date);

/// {template macosDatePicker}
/// A [MacosDatePicker] lets the user choose a date.
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

0 comments on commit cb35862

Please sign in to comment.