@@ -65,11 +65,25 @@ const ShapeBorder _kDefaultShape = RoundedRectangleBorder(borderRadius: _kDefaul
65
65
/// TimePickerEntryMode.input] mode, [TextField] s are displayed and the user
66
66
/// types in the time they wish to select.
67
67
enum TimePickerEntryMode {
68
- /// Tapping/dragging on a clock dial.
68
+ /// User picks time from a clock dial.
69
+ ///
70
+ /// Can switch to [input] by activating a mode button in the dialog.
69
71
dial,
70
72
71
- /// Text input.
73
+ /// User can input the time by typing it into text fields.
74
+ ///
75
+ /// Can switch to [dial] by activating a mode button in the dialog.
72
76
input,
77
+
78
+ /// User can only pick time from a clock dial.
79
+ ///
80
+ /// There is no user interface to switch to another mode.
81
+ dialOnly,
82
+
83
+ /// User can only input the time by typing it into text fields.
84
+ ///
85
+ /// There is no user interface to switch to another mode.
86
+ inputOnly
73
87
}
74
88
75
89
/// Provides properties for rendering time picker header fragments.
@@ -2055,6 +2069,10 @@ class _TimePickerDialogState extends State<TimePickerDialog> with RestorationMix
2055
2069
_autofocusMinute.value = false ;
2056
2070
_entryMode.value = TimePickerEntryMode .dial;
2057
2071
break ;
2072
+ case TimePickerEntryMode .dialOnly:
2073
+ case TimePickerEntryMode .inputOnly:
2074
+ FlutterError ('Can not change entry mode from $_entryMode ' );
2075
+ break ;
2058
2076
}
2059
2077
});
2060
2078
}
@@ -2118,7 +2136,7 @@ class _TimePickerDialogState extends State<TimePickerDialog> with RestorationMix
2118
2136
}
2119
2137
2120
2138
void _handleOk () {
2121
- if (_entryMode.value == TimePickerEntryMode .input) {
2139
+ if (_entryMode.value == TimePickerEntryMode .input || _entryMode.value == TimePickerEntryMode .inputOnly ) {
2122
2140
final FormState form = _formKey.currentState! ;
2123
2141
if (! form.validate ()) {
2124
2142
setState (() { _autovalidateMode.value = AutovalidateMode .always; });
@@ -2141,6 +2159,7 @@ class _TimePickerDialogState extends State<TimePickerDialog> with RestorationMix
2141
2159
final double timePickerHeight;
2142
2160
switch (_entryMode.value) {
2143
2161
case TimePickerEntryMode .dial:
2162
+ case TimePickerEntryMode .dialOnly:
2144
2163
switch (orientation) {
2145
2164
case Orientation .portrait:
2146
2165
timePickerWidth = _kTimePickerWidthPortrait;
@@ -2157,6 +2176,7 @@ class _TimePickerDialogState extends State<TimePickerDialog> with RestorationMix
2157
2176
}
2158
2177
break ;
2159
2178
case TimePickerEntryMode .input:
2179
+ case TimePickerEntryMode .inputOnly:
2160
2180
timePickerWidth = _kTimePickerWidthPortrait;
2161
2181
timePickerHeight = _kTimePickerHeightInput;
2162
2182
break ;
@@ -2177,16 +2197,17 @@ class _TimePickerDialogState extends State<TimePickerDialog> with RestorationMix
2177
2197
final Widget actions = Row (
2178
2198
children: < Widget > [
2179
2199
const SizedBox (width: 10.0 ),
2180
- IconButton (
2181
- color: TimePickerTheme .of (context).entryModeIconColor ?? theme.colorScheme.onSurface.withOpacity (
2182
- theme.colorScheme.brightness == Brightness .dark ? 1.0 : 0.6 ,
2200
+ if (_entryMode.value == TimePickerEntryMode .dial || _entryMode.value == TimePickerEntryMode .input)
2201
+ IconButton (
2202
+ color: TimePickerTheme .of (context).entryModeIconColor ?? theme.colorScheme.onSurface.withOpacity (
2203
+ theme.colorScheme.brightness == Brightness .dark ? 1.0 : 0.6 ,
2204
+ ),
2205
+ onPressed: _handleEntryModeToggle,
2206
+ icon: Icon (_entryMode.value == TimePickerEntryMode .dial ? Icons .keyboard : Icons .access_time),
2207
+ tooltip: _entryMode.value == TimePickerEntryMode .dial
2208
+ ? MaterialLocalizations .of (context).inputTimeModeButtonLabel
2209
+ : MaterialLocalizations .of (context).dialModeButtonLabel,
2183
2210
),
2184
- onPressed: _handleEntryModeToggle,
2185
- icon: Icon (_entryMode.value == TimePickerEntryMode .dial ? Icons .keyboard : Icons .access_time),
2186
- tooltip: _entryMode.value == TimePickerEntryMode .dial
2187
- ? MaterialLocalizations .of (context).inputTimeModeButtonLabel
2188
- : MaterialLocalizations .of (context).dialModeButtonLabel,
2189
- ),
2190
2211
Expanded (
2191
2212
child: Container (
2192
2213
alignment: AlignmentDirectional .centerEnd,
@@ -2214,6 +2235,7 @@ class _TimePickerDialogState extends State<TimePickerDialog> with RestorationMix
2214
2235
final Widget picker;
2215
2236
switch (_entryMode.value) {
2216
2237
case TimePickerEntryMode .dial:
2238
+ case TimePickerEntryMode .dialOnly:
2217
2239
final Widget dial = Padding (
2218
2240
padding: orientation == Orientation .portrait ? const EdgeInsets .symmetric (horizontal: 36 , vertical: 24 ) : const EdgeInsets .all (24 ),
2219
2241
child: ExcludeSemantics (
@@ -2280,6 +2302,7 @@ class _TimePickerDialogState extends State<TimePickerDialog> with RestorationMix
2280
2302
}
2281
2303
break ;
2282
2304
case TimePickerEntryMode .input:
2305
+ case TimePickerEntryMode .inputOnly:
2283
2306
picker = Form (
2284
2307
key: _formKey,
2285
2308
autovalidateMode: _autovalidateMode.value,
@@ -2313,7 +2336,7 @@ class _TimePickerDialogState extends State<TimePickerDialog> with RestorationMix
2313
2336
backgroundColor: TimePickerTheme .of (context).backgroundColor ?? theme.colorScheme.surface,
2314
2337
insetPadding: EdgeInsets .symmetric (
2315
2338
horizontal: 16.0 ,
2316
- vertical: _entryMode.value == TimePickerEntryMode .input ? 0.0 : 24.0 ,
2339
+ vertical: ( _entryMode.value == TimePickerEntryMode .input || _entryMode.value == TimePickerEntryMode .inputOnly) ? 0.0 : 24.0 ,
2317
2340
),
2318
2341
child: AnimatedContainer (
2319
2342
width: dialogSize.width,
0 commit comments