Skip to content

Commit f7fb23e

Browse files
committed
reactive_date_range_picker 2.2.0
1 parent 9d98ec5 commit f7fb23e

File tree

9 files changed

+168
-64
lines changed

9 files changed

+168
-64
lines changed

packages/reactive_date_range_picker/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## [2.2.0]
2+
3+
* mouse cursor
4+
* hover effect support
5+
* expose more input decorator props
6+
* improved disabled state handling
7+
* errorBuilder
8+
19
## [2.1.0]
210

311
* props update

packages/reactive_date_range_picker/example/ios/Flutter/AppFrameworkInfo.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
<key>CFBundleVersion</key>
2222
<string>1.0</string>
2323
<key>MinimumOSVersion</key>
24-
<string>9.0</string>
24+
<string>12.0</string>
2525
</dict>
2626
</plist>

packages/reactive_date_range_picker/example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 50;
6+
objectVersion = 54;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -127,7 +127,7 @@
127127
97C146E61CF9000F007C117D /* Project object */ = {
128128
isa = PBXProject;
129129
attributes = {
130-
LastUpgradeCheck = 1300;
130+
LastUpgradeCheck = 1510;
131131
ORGANIZATIONNAME = "";
132132
TargetAttributes = {
133133
97C146ED1CF9000F007C117D = {
@@ -171,10 +171,12 @@
171171
/* Begin PBXShellScriptBuildPhase section */
172172
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
173173
isa = PBXShellScriptBuildPhase;
174+
alwaysOutOfDate = 1;
174175
buildActionMask = 2147483647;
175176
files = (
176177
);
177178
inputPaths = (
179+
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
178180
);
179181
name = "Thin Binary";
180182
outputPaths = (
@@ -185,6 +187,7 @@
185187
};
186188
9740EEB61CF901F6004384FC /* Run Script */ = {
187189
isa = PBXShellScriptBuildPhase;
190+
alwaysOutOfDate = 1;
188191
buildActionMask = 2147483647;
189192
files = (
190193
);
@@ -272,7 +275,7 @@
272275
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
273276
GCC_WARN_UNUSED_FUNCTION = YES;
274277
GCC_WARN_UNUSED_VARIABLE = YES;
275-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
278+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
276279
MTL_ENABLE_DEBUG_INFO = NO;
277280
SDKROOT = iphoneos;
278281
SUPPORTED_PLATFORMS = iphoneos;
@@ -354,7 +357,7 @@
354357
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
355358
GCC_WARN_UNUSED_FUNCTION = YES;
356359
GCC_WARN_UNUSED_VARIABLE = YES;
357-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
360+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
358361
MTL_ENABLE_DEBUG_INFO = YES;
359362
ONLY_ACTIVE_ARCH = YES;
360363
SDKROOT = iphoneos;
@@ -403,7 +406,7 @@
403406
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
404407
GCC_WARN_UNUSED_FUNCTION = YES;
405408
GCC_WARN_UNUSED_VARIABLE = YES;
406-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
409+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
407410
MTL_ENABLE_DEBUG_INFO = NO;
408411
SDKROOT = iphoneos;
409412
SUPPORTED_PLATFORMS = iphoneos;

packages/reactive_date_range_picker/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1300"
3+
LastUpgradeVersion = "1510"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

packages/reactive_date_range_picker/example/ios/Runner/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import UIKit
22
import Flutter
33

4-
@UIApplicationMain
4+
@main
55
@objc class AppDelegate: FlutterAppDelegate {
66
override func application(
77
_ application: UIApplication,

packages/reactive_date_range_picker/example/ios/Runner/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,7 @@
4343
<false/>
4444
<key>CADisableMinimumFrameDurationOnPhone</key>
4545
<true/>
46+
<key>UIApplicationSupportsIndirectInputEvents</key>
47+
<true/>
4648
</dict>
4749
</plist>

packages/reactive_date_range_picker/example/lib/main.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ class MyApp extends StatelessWidget {
1111

1212
FormGroup buildForm() => fb.group({
1313
'dateRange': FormControl<DateTimeRange>(),
14+
'dateRange2': FormControl<DateTimeRange>(
15+
disabled: true,
16+
value: DateTimeRange(
17+
start: DateTime.now(),
18+
end: DateTime.now().add(const Duration(days: 1)),
19+
),
20+
),
1421
});
1522

1623
@override
@@ -43,6 +50,16 @@ class MyApp extends StatelessWidget {
4350
suffixIcon: Icon(Icons.calendar_today),
4451
),
4552
),
53+
const SizedBox(height: 20),
54+
ReactiveDateRangePicker(
55+
formControlName: 'dateRange2',
56+
decoration: const InputDecoration(
57+
labelText: 'Date range',
58+
border: OutlineInputBorder(),
59+
helperText: '',
60+
suffixIcon: Icon(Icons.calendar_today),
61+
),
62+
),
4663
ElevatedButton(
4764
child: const Text('Sign Up'),
4865
onPressed: () {

packages/reactive_date_range_picker/lib/reactive_date_range_picker.dart

Lines changed: 129 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ class ReactiveDateRangePicker extends ReactiveFormField<DateTimeRange, String> {
8282
TextInputType keyboardType = TextInputType.datetime,
8383
Icon? switchToInputEntryModeIcon,
8484
Icon? switchToCalendarEntryModeIcon,
85+
Widget Function(BuildContext context, String error)? errorBuilder,
86+
// input decorator props
87+
TextStyle? baseStyle,
88+
TextAlign? textAlign,
89+
TextAlignVertical? textAlignVertical,
90+
bool expands = false,
91+
MouseCursor cursor = SystemMouseCursors.click,
8592
}) : super(
8693
valueAccessor: valueAccessor ?? DateTimeRangeValueAccessor(),
8794
builder: (field) {
@@ -108,68 +115,135 @@ class ReactiveDateRangePicker extends ReactiveFormField<DateTimeRange, String> {
108115
final effectiveValueAccessor =
109116
valueAccessor ?? DateTimeRangeValueAccessor();
110117

118+
final errorText = field.errorText;
119+
111120
final effectiveLastDate = lastDate ?? DateTime(2100);
112121

113122
return IgnorePointer(
114123
ignoring: !field.control.enabled,
115-
child: GestureDetector(
116-
onTap: () async {
117-
final dateRange = await showDateRangePicker(
118-
context: field.context,
119-
initialDateRange: field.control.value,
120-
firstDate: firstDate ?? DateTime(1900),
121-
lastDate: effectiveLastDate,
122-
currentDate: currentDate,
123-
initialEntryMode: initialEntryMode,
124-
helpText: helpText,
125-
cancelText: cancelText,
126-
confirmText: confirmText,
127-
saveText: saveText,
128-
errorFormatText: errorFormatText,
129-
errorInvalidText: errorInvalidText,
130-
errorInvalidRangeText: errorInvalidRangeText,
131-
fieldStartHintText: fieldStartHintText,
132-
fieldEndHintText: fieldEndHintText,
133-
fieldStartLabelText: fieldStartLabelText,
134-
fieldEndLabelText: fieldEndLabelText,
135-
locale: locale,
136-
useRootNavigator: useRootNavigator,
137-
routeSettings: routeSettings,
138-
textDirection: textDirection,
139-
builder: builder,
140-
barrierDismissible: barrierDismissible,
141-
barrierColor: barrierColor,
142-
anchorPoint: anchorPoint,
143-
keyboardType: keyboardType,
144-
switchToInputEntryModeIcon: switchToInputEntryModeIcon,
145-
switchToCalendarEntryModeIcon:
146-
switchToCalendarEntryModeIcon,
147-
);
148-
149-
if (dateRange == null) {
150-
return;
151-
}
124+
child: HoverBuilder(builder: (context, isHovered) {
125+
return MouseRegion(
126+
cursor: cursor,
127+
child: GestureDetector(
128+
onTap: () async {
129+
final dateRange = await showDateRangePicker(
130+
context: field.context,
131+
initialDateRange: field.control.value,
132+
firstDate: firstDate ?? DateTime(1900),
133+
lastDate: effectiveLastDate,
134+
currentDate: currentDate,
135+
initialEntryMode: initialEntryMode,
136+
helpText: helpText,
137+
cancelText: cancelText,
138+
confirmText: confirmText,
139+
saveText: saveText,
140+
errorFormatText: errorFormatText,
141+
errorInvalidText: errorInvalidText,
142+
errorInvalidRangeText: errorInvalidRangeText,
143+
fieldStartHintText: fieldStartHintText,
144+
fieldEndHintText: fieldEndHintText,
145+
fieldStartLabelText: fieldStartLabelText,
146+
fieldEndLabelText: fieldEndLabelText,
147+
locale: locale,
148+
useRootNavigator: useRootNavigator,
149+
routeSettings: routeSettings,
150+
textDirection: textDirection,
151+
builder: builder,
152+
barrierDismissible: barrierDismissible,
153+
barrierColor: barrierColor,
154+
anchorPoint: anchorPoint,
155+
keyboardType: keyboardType,
156+
switchToInputEntryModeIcon: switchToInputEntryModeIcon,
157+
switchToCalendarEntryModeIcon:
158+
switchToCalendarEntryModeIcon,
159+
);
152160

153-
field.control.markAsTouched();
154-
field.didChange(
155-
effectiveValueAccessor.modelToViewValue(dateRange));
156-
},
157-
child: InputDecorator(
158-
decoration: effectiveDecoration.copyWith(
159-
errorText: field.errorText,
160-
enabled: field.control.enabled,
161-
),
162-
isEmpty: isEmptyValue,
163-
child: Text(
164-
field.value ?? '',
165-
style: Theme.of(field.context)
166-
.textTheme
167-
.titleMedium
168-
?.merge(style),
161+
if (dateRange == null) {
162+
return;
163+
}
164+
165+
field.control.markAsTouched();
166+
field.didChange(
167+
effectiveValueAccessor.modelToViewValue(dateRange));
168+
},
169+
child: InputDecorator(
170+
isFocused: field.control.hasFocus,
171+
isEmpty: isEmptyValue,
172+
baseStyle: baseStyle,
173+
textAlign: textAlign,
174+
textAlignVertical: textAlignVertical,
175+
expands: expands,
176+
decoration: effectiveDecoration.copyWith(
177+
enabled: field.control.enabled,
178+
errorText:
179+
errorBuilder == null ? field.errorText : null,
180+
error: errorBuilder != null && errorText != null
181+
? DefaultTextStyle.merge(
182+
style: Theme.of(field.context)
183+
.textTheme
184+
.bodySmall
185+
?.copyWith(
186+
color: Theme.of(field.context)
187+
.colorScheme
188+
.error,
189+
)
190+
.merge(effectiveDecoration.errorStyle),
191+
child: errorBuilder.call(
192+
field.context,
193+
errorText,
194+
),
195+
)
196+
: null,
197+
),
198+
isHovering: isHovered,
199+
child: Text(
200+
field.value ?? '',
201+
style: Theme.of(field.context)
202+
.textTheme
203+
.titleMedium
204+
?.merge(style)
205+
.copyWith(
206+
color: !field.control.enabled
207+
? Theme.of(field.context).disabledColor
208+
: null,
209+
),
210+
),
211+
),
169212
),
170-
),
171-
),
213+
);
214+
}),
172215
);
173216
},
174217
);
175218
}
219+
220+
class HoverBuilder extends StatefulWidget {
221+
const HoverBuilder({
222+
required this.builder,
223+
super.key,
224+
});
225+
226+
final Widget Function(BuildContext context, bool isHovered) builder;
227+
228+
@override
229+
_HoverBuilderState createState() => _HoverBuilderState();
230+
}
231+
232+
class _HoverBuilderState extends State<HoverBuilder> {
233+
bool _isHovered = false;
234+
235+
@override
236+
Widget build(BuildContext context) {
237+
return MouseRegion(
238+
onEnter: (event) => _onHoverChanged(enabled: true),
239+
onExit: (event) => _onHoverChanged(enabled: false),
240+
child: widget.builder(context, _isHovered),
241+
);
242+
}
243+
244+
void _onHoverChanged({required bool enabled}) {
245+
setState(() {
246+
_isHovered = enabled;
247+
});
248+
}
249+
}

packages/reactive_date_range_picker/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: reactive_date_range_picker
22
description: Wrapper around flutter showDateRangePicker to use with reactive_forms
3-
version: 2.1.0
3+
version: 2.2.0
44
repository: https://github.com/artflutter/reactive_forms_widgets/tree/master/packages/reactive_date_range_picker
55
issue_tracker: https://github.com/artflutter/reactive_forms_widgets/issues
66

0 commit comments

Comments
 (0)