mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 11:08:03 +08:00
63
lib/common/widgets/flutter/time_picker.dart
Normal file
63
lib/common/widgets/flutter/time_picker.dart
Normal file
@@ -0,0 +1,63 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Future<TimeOfDay?> showTimePicker({
|
||||
required BuildContext context,
|
||||
required TimeOfDay initialTime,
|
||||
TransitionBuilder? builder,
|
||||
bool barrierDismissible = true,
|
||||
Color? barrierColor,
|
||||
String? barrierLabel,
|
||||
bool useRootNavigator = true,
|
||||
TimePickerEntryMode initialEntryMode = TimePickerEntryMode.dial,
|
||||
String? cancelText,
|
||||
String? confirmText,
|
||||
String? helpText,
|
||||
String? errorInvalidText,
|
||||
String? hourLabelText,
|
||||
String? minuteLabelText,
|
||||
RouteSettings? routeSettings,
|
||||
EntryModeChangeCallback? onEntryModeChanged,
|
||||
Offset? anchorPoint,
|
||||
Orientation? orientation,
|
||||
Icon? switchToInputEntryModeIcon,
|
||||
Icon? switchToTimerEntryModeIcon,
|
||||
bool emptyInitialInput = false,
|
||||
BoxConstraints? constraints,
|
||||
}) {
|
||||
assert(debugCheckHasMaterialLocalizations(context));
|
||||
|
||||
final Widget dialog = DialogTheme(
|
||||
data: const DialogThemeData(constraints: BoxConstraints(minWidth: 280.0)),
|
||||
child: TimePickerDialog(
|
||||
initialTime: initialTime,
|
||||
initialEntryMode: initialEntryMode,
|
||||
cancelText: cancelText,
|
||||
confirmText: confirmText,
|
||||
helpText: helpText,
|
||||
errorInvalidText: errorInvalidText,
|
||||
hourLabelText: hourLabelText,
|
||||
minuteLabelText: minuteLabelText,
|
||||
orientation: orientation,
|
||||
onEntryModeChanged: onEntryModeChanged,
|
||||
switchToInputEntryModeIcon: switchToInputEntryModeIcon,
|
||||
switchToTimerEntryModeIcon: switchToTimerEntryModeIcon,
|
||||
emptyInitialInput: emptyInitialInput,
|
||||
),
|
||||
);
|
||||
return showDialog<TimeOfDay>(
|
||||
context: context,
|
||||
barrierDismissible: barrierDismissible,
|
||||
barrierColor: barrierColor,
|
||||
barrierLabel: barrierLabel,
|
||||
useRootNavigator: useRootNavigator,
|
||||
builder: (BuildContext context) {
|
||||
return builder == null ? dialog : builder(context, dialog);
|
||||
},
|
||||
routeSettings: routeSettings,
|
||||
anchorPoint: anchorPoint,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user