8000 Adding initialTime parameter to MacosTimePicker by Abbas1Hussein · Pull Request #490 · macosui/macos_ui · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Adding initialTime parameter to MacosTimePicker #490

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

Merged
merged 3 commits into from
Jan 21, 2024
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
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 date);
typedef class="x x-first x-last">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 time);
/// {end-template}
typedef class="x x-first x-last">void Function(TimeOfDay time);

/// {template macosTimePicker}
/// A [MacosTimePicker] lets the user choose a time.
Expand All @@ -36,15 +36,21 @@ typedef 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,
});
< 7082 span class='blob-code-inner blob-code-marker ' data-code-marker=" ">
/// 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