Skip to content

Commit aa1a3b2

Browse files
committed
style: reformat tour components and tests with dartfmt
1 parent 0d950df commit aa1a3b2

13 files changed

Lines changed: 508 additions & 449 deletions

lib/src/components/dialogs.dart

Lines changed: 61 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -52,66 +52,71 @@ Future<PreDialogButtonType> showPreDialog(
5252
await onPreDialogIsDisplayed(true);
5353
} else {
5454
overlayEntry = OverlayEntry(
55-
builder: (context) => Material(
56-
color: Colors.black54,
57-
child: AlertDialog(
58-
title: Text(config.title, style: TextStyle(color: config.textColor)),
59-
content: Column(
60-
mainAxisSize: MainAxisSize.min,
61-
crossAxisAlignment: CrossAxisAlignment.start,
62-
children: [
63-
Text(
64-
config.content,
65-
style: TextStyle(color: config.textColor, fontSize: 13.5),
55+
builder:
56+
(context) => Material(
57+
color: Colors.black54,
58+
child: AlertDialog(
59+
title: Text(
60+
config.title,
61+
style: TextStyle(color: config.textColor),
6662
),
67-
const SizedBox(height: 20),
68-
_CheckboxRow(
69-
text: config.applyToAllPagesLabel,
70-
baseTextColor: config.textColor,
71-
checkboxTextStyle: config.applyToAllCheckboxLabelStyle,
72-
onChanged: (value) {
73-
isChecked = value;
74-
onApplyToAllPagesCheckboxChanged?.call(value);
75-
},
63+
content: Column(
64+
mainAxisSize: MainAxisSize.min,
65+
crossAxisAlignment: CrossAxisAlignment.start,
66+
children: [
67+
Text(
68+
config.content,
69+
style: TextStyle(color: config.textColor, fontSize: 13.5),
70+
),
71+
const SizedBox(height: 20),
72+
_CheckboxRow(
73+
text: config.applyToAllPagesLabel,
74+
baseTextColor: config.textColor,
75+
checkboxTextStyle: config.applyToAllCheckboxLabelStyle,
76+
onChanged: (value) {
77+
isChecked = value;
78+
onApplyToAllPagesCheckboxChanged?.call(value);
79+
},
80+
),
81+
],
7682
),
77-
],
78-
),
79-
backgroundColor: config.backgroundColor,
80-
shape: RoundedRectangleBorder(
81-
borderRadius: BorderRadius.circular(config.borderRadius),
82-
),
83-
actions: [
84-
TextButton(
85-
onPressed: () async {
86-
config.onDismissButtonPressed?.call();
87-
complete(PreDialogButtonType.dismiss);
88-
},
89-
style: config.dismissButtonStyle,
90-
child: DefaultTextStyle.merge(
91-
style:
92-
TextStyle(color: ColorScheme.of(context).onSurfaceVariant),
93-
child: Text(config.dismissButtonLabel),
83+
backgroundColor: config.backgroundColor,
84+
shape: RoundedRectangleBorder(
85+
borderRadius: BorderRadius.circular(config.borderRadius),
9486
),
87+
actions: [
88+
TextButton(
89+
onPressed: () async {
90+
config.onDismissButtonPressed?.call();
91+
complete(PreDialogButtonType.dismiss);
92+
},
93+
style: config.dismissButtonStyle,
94+
child: DefaultTextStyle.merge(
95+
style: TextStyle(
96+
color: ColorScheme.of(context).onSurfaceVariant,
97+
),
98+
child: Text(config.dismissButtonLabel),
99+
),
100+
),
101+
TextButton(
102+
onPressed: () async {
103+
config.onLaterButtonPressed?.call();
104+
complete(PreDialogButtonType.later);
105+
},
106+
style: config.laterButtonStyle,
107+
child: Text(config.laterButtonLabel),
108+
),
109+
FilledButton(
110+
onPressed: () async {
111+
config.onAcceptButtonPressed?.call();
112+
complete(PreDialogButtonType.accept);
113+
},
114+
style: config.acceptButtonStyle,
115+
child: Text(config.acceptButtonLabel),
116+
),
117+
],
95118
),
96-
TextButton(
97-
onPressed: () async {
98-
config.onLaterButtonPressed?.call();
99-
complete(PreDialogButtonType.later);
100-
},
101-
style: config.laterButtonStyle,
102-
child: Text(config.laterButtonLabel),
103-
),
104-
FilledButton(
105-
onPressed: () async {
106-
config.onAcceptButtonPressed?.call();
107-
complete(PreDialogButtonType.accept);
108-
},
109-
style: config.acceptButtonStyle,
110-
child: Text(config.acceptButtonLabel),
111-
),
112-
],
113-
),
114-
),
119+
),
115120
);
116121

117122
Overlay.of(context, rootOverlay: true).insert(overlayEntry);

lib/src/components/features_child.dart

Lines changed: 88 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ class _FeaturesChildState extends State<FeaturesChild>
126126

127127
_autoSetQuadrantAlignment(rect!);
128128

129-
final size = MediaQuery.maybeOf(context)?.size ??
129+
final size =
130+
MediaQuery.maybeOf(context)?.size ??
130131
MediaQueryData.fromView(View.of(context)).size;
131132

132133
switch (_quadrantAlignment!) {
@@ -146,8 +147,12 @@ class _FeaturesChildState extends State<FeaturesChild>
146147
} else {
147148
alignment = Alignment.bottomCenter;
148149
}
149-
introduceRect =
150-
Rect.fromLTWH(left, 0, dialogWidth, introduceRect.height);
150+
introduceRect = Rect.fromLTWH(
151+
left,
152+
0,
153+
dialogWidth,
154+
introduceRect.height,
155+
);
151156
}
152157
case QuadrantAlignment.left:
153158
introduceRect = Rect.fromLTRB(0, 0, rect!.left, size.height);
@@ -187,8 +192,12 @@ class _FeaturesChildState extends State<FeaturesChild>
187192
} else {
188193
alignment = Alignment.topCenter;
189194
}
190-
introduceRect =
191-
Rect.fromLTWH(left, introduceRect.top, dialogWidth, size.height);
195+
introduceRect = Rect.fromLTWH(
196+
left,
197+
introduceRect.top,
198+
dialogWidth,
199+
size.height,
200+
);
192201
}
193202
case QuadrantAlignment.inside:
194203
introduceRect = rect!;
@@ -287,100 +296,100 @@ class _FeaturesChildState extends State<FeaturesChild>
287296
return rect == null
288297
? const Center(child: CircularProgressIndicator())
289298
: Stack(
290-
children: [
291-
// Border widget
299+
children: [
300+
// Border widget
301+
Positioned.fromRect(
302+
rect: rect!.inflate(widget.childConfig.borderSizeInflate),
303+
child: AnimatedBuilder(
304+
animation: _scaleAnimation,
305+
builder: (context, child) {
306+
return Transform.scale(
307+
scale: _scaleAnimation.value,
308+
child: Material(
309+
color: widget.childConfig.backgroundColor,
310+
shape: widget.childConfig.shapeBorder,
311+
),
312+
);
313+
},
314+
),
315+
),
316+
317+
// Child widget.
318+
if (widget.childConfig.enableAnimation &&
319+
widget.childConfig.isAnimateChild)
292320
Positioned.fromRect(
293-
rect: rect!.inflate(widget.childConfig.borderSizeInflate),
321+
rect: rect!,
294322
child: AnimatedBuilder(
295323
animation: _scaleAnimation,
296324
builder: (context, child) {
297325
return Transform.scale(
298326
scale: _scaleAnimation.value,
299-
child: Material(
300-
color: widget.childConfig.backgroundColor,
301-
shape: widget.childConfig.shapeBorder,
302-
),
327+
child: widget.child,
303328
);
304329
},
305330
),
331+
)
332+
else
333+
Positioned.fromRect(
334+
rect: rect!,
335+
child: widget.child,
306336
),
307337

308-
// Child widget.
309-
if (widget.childConfig.enableAnimation &&
310-
widget.childConfig.isAnimateChild)
311-
Positioned.fromRect(
312-
rect: rect!,
313-
child: AnimatedBuilder(
314-
animation: _scaleAnimation,
315-
builder: (context, child) {
316-
return Transform.scale(
317-
scale: _scaleAnimation.value,
318-
child: widget.child,
319-
);
320-
},
321-
),
322-
)
323-
else
324-
Positioned.fromRect(
325-
rect: rect!,
326-
child: widget.child,
327-
),
328-
329-
// Introduction widget.
330-
Positioned.fromRect(
331-
rect: introduceRect,
332-
child: IgnorePointer(
333-
child: Padding(
334-
padding: widget.padding,
335-
child: Align(
336-
alignment: alignment,
337-
child: widget.introduceConfig.builder(
338-
context,
339-
rect!,
340-
widget.introduce,
341-
),
338+
// Introduction widget.
339+
Positioned.fromRect(
340+
rect: introduceRect,
341+
child: IgnorePointer(
342+
child: Padding(
343+
padding: widget.padding,
344+
child: Align(
345+
alignment: alignment,
346+
child: widget.introduceConfig.builder(
347+
context,
348+
rect!,
349+
widget.introduce,
342350
),
343351
),
344352
),
345353
),
346-
347-
Scaffold(
348-
resizeToAvoidBottomInset: true,
349-
backgroundColor: Colors.transparent,
350-
body: Stack(
351-
children: [
352-
// Skip text widget.
353-
if (!(widget.isLastState && widget.doneConfig.enabled) &&
354-
widget.skipConfig.enabled)
355-
Positioned.fill(
356-
child: Align(
357-
alignment: widget.skipConfig.alignment,
358-
child: widget.skip,
359-
),
354+
),
355+
356+
Scaffold(
357+
resizeToAvoidBottomInset: true,
358+
backgroundColor: Colors.transparent,
359+
body: Stack(
360+
children: [
361+
// Skip text widget.
362+
if (!(widget.isLastState && widget.doneConfig.enabled) &&
363+
widget.skipConfig.enabled)
364+
Positioned.fill(
365+
child: Align(
366+
alignment: widget.skipConfig.alignment,
367+
child: widget.skip,
360368
),
369+
),
361370

362-
// Next text widget.
363-
if (!(widget.isLastState && widget.doneConfig.enabled) &&
364-
widget.nextConfig.enabled)
365-
Positioned.fill(
366-
child: Align(
367-
alignment: widget.nextConfig.alignment,
368-
child: widget.next,
369-
),
371+
// Next text widget.
372+
if (!(widget.isLastState && widget.doneConfig.enabled) &&
373+
widget.nextConfig.enabled)
374+
Positioned.fill(
375+
child: Align(
376+
alignment: widget.nextConfig.alignment,
377+
child: widget.next,
370378
),
379+
),
371380

372-
// Done text widget.
373-
if (widget.isLastState && widget.doneConfig.enabled)
374-
Positioned.fill(
375-
child: Align(
376-
alignment: widget.doneConfig.alignment,
377-
child: widget.done,
378-
),
381+
// Done text widget.
382+
if (widget.isLastState && widget.doneConfig.enabled)
383+
Positioned.fill(
384+
child: Align(
385+
alignment: widget.doneConfig.alignment,
386+
child: widget.done,
379387
),
380-
],
381-
),
388+
),
389+
],
382390
),
383-
],
384-
);
391+
),
392+
],
393+
);
385394
}
386395
}

lib/src/components/features_tour_padding.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ class FeaturesTourPadding extends StatelessWidget {
4747
return AnimatedPadding(
4848
duration: animationDuration,
4949
curve: animationCurve,
50-
padding: value != null && indexes.contains(value)
51-
? padding
52-
: EdgeInsets.zero,
50+
padding:
51+
value != null && indexes.contains(value)
52+
? padding
53+
: EdgeInsets.zero,
5354
child: child,
5455
);
5556
},

lib/src/features_tour.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class FeaturesTour extends StatefulWidget {
241241
/// If the callback returns a [Future], the tour will wait for it to complete before
242242
/// proceeding to the next step.
243243
final FutureOr<void> Function(IntroduceResult introduceResult)?
244-
onAfterIntroduce;
244+
onAfterIntroduce;
245245

246246
@override
247247
State<FeaturesTour> createState() => _FeaturesTourState();

0 commit comments

Comments
 (0)