Skip to content

Commit

Permalink
Merge pull request #25 from BlueBubblesApp/zach/3.0.3/merge
Browse files Browse the repository at this point in the history
Zach/3.0.3/merge
  • Loading branch information
zlshames authored Jun 26, 2022
2 parents 1acea86 + 3804f10 commit d183abc
Show file tree
Hide file tree
Showing 16 changed files with 589 additions and 170 deletions.
2 changes: 1 addition & 1 deletion .ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ platform_properties:
]
os: Mac-12
cpu: x86
device_os: iOS-15.1
device_os: iOS-15
xcode: 13a233
windows:
properties:
Expand Down
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ environment:
# dependency on precisely how Cirrus is detected by our tools.
BOT: "true"

gcp_credentials: ENCRYPTED[!2c88dee9c9d9805b214c9f7ad8f3bc8fae936cdb0f881d562101151c408c7e024a41222677d5831df90c60d2dd6cd80a!]
gcp_credentials: ENCRYPTED[!ebad0a1f4f7a446b77944c33651460a7ab010b4617273cb016cf354eb8fc22aa92e37a3c58bfa4a0c40a799351e027a6!]

# LINUX SHARDS
task:
Expand Down
2 changes: 1 addition & 1 deletion bin/internal/engine.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d1b9a6938ad77326ac3a94d92bbc77933ed829ed
ffe7b86a1e5b5cb63c8385ae1adc759e372ee8f4
11 changes: 10 additions & 1 deletion packages/flutter/lib/src/material/ink_sparkle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ class InkSparkle extends InteractiveInkFeature {
_animationController = AnimationController(
duration: _animationDuration,
vsync: controller.vsync,
)..addListener(controller.markNeedsPaint)..forward();
)..addListener(controller.markNeedsPaint)
..addStatusListener(_handleStatusChanged)
..forward();

_radiusScale = TweenSequence<double>(
<TweenSequenceItem<double>>[
Expand Down Expand Up @@ -208,6 +210,11 @@ class InkSparkle extends InteractiveInkFeature {
_turbulenceSeed = turbulenceSeed ?? math.Random().nextDouble() * 1000.0;
}

void _handleStatusChanged(AnimationStatus status) {
if (status == AnimationStatus.completed)
dispose();
}

static const Duration _animationDuration = Duration(milliseconds: 617);
static const double _targetRadiusMultiplier = 2.3;
static const double _rotateRight = math.pi * 0.0078125;
Expand Down Expand Up @@ -258,6 +265,8 @@ class InkSparkle extends InteractiveInkFeature {

@override
void paintFeature(Canvas canvas, Matrix4 transform) {
assert(_animationController.isAnimating);

// InkSparkle can only paint if its shader has been compiled.
if (_InkSparkleFactory._shaderManager == null) {
// Skipping paintFeature because the shader it relies on is not ready to
Expand Down
6 changes: 6 additions & 0 deletions packages/flutter/lib/src/material/material.dart
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,12 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController

bool absorbHitTest;

@visibleForTesting
List<InkFeature>? get debugInkFeatures {
if (kDebugMode)
return _inkFeatures;
return null;
}
List<InkFeature>? _inkFeatures;

@override
Expand Down
17 changes: 14 additions & 3 deletions packages/flutter/lib/src/material/slider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,7 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
platform: Theme.of(context).platform,
hasFocus: hasFocus,
hovering: hovering,
gestureSettings: MediaQuery.of(context).gestureSettings,
);
}

Expand All @@ -884,7 +885,8 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
..semanticFormatterCallback = semanticFormatterCallback
..platform = Theme.of(context).platform
..hasFocus = hasFocus
..hovering = hovering;
..hovering = hovering
..gestureSettings = MediaQuery.of(context).gestureSettings;
// Ticker provider cannot change since there's a 1:1 relationship between
// the _SliderRenderObjectWidget object and the _SliderState object.
}
Expand All @@ -907,6 +909,7 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
required TextDirection textDirection,
required bool hasFocus,
required bool hovering,
required DeviceGestureSettings gestureSettings,
}) : assert(value != null && value >= 0.0 && value <= 1.0),
assert(state != null),
assert(textDirection != null),
Expand All @@ -930,11 +933,13 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
..onStart = _handleDragStart
..onUpdate = _handleDragUpdate
..onEnd = _handleDragEnd
..onCancel = _endInteraction;
..onCancel = _endInteraction
..gestureSettings = gestureSettings;
_tap = TapGestureRecognizer()
..team = team
..onTapDown = _handleTapDown
..onTapUp = _handleTapUp;
..onTapUp = _handleTapUp
..gestureSettings = gestureSettings;
_overlayAnimation = CurvedAnimation(
parent: _state.overlayController,
curve: Curves.fastOutSlowIn,
Expand Down Expand Up @@ -1019,6 +1024,12 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
markNeedsSemanticsUpdate();
}

DeviceGestureSettings? get gestureSettings => _drag.gestureSettings;
set gestureSettings(DeviceGestureSettings? gestureSettings) {
_drag.gestureSettings = gestureSettings;
_tap.gestureSettings = gestureSettings;
}

TargetPlatform _platform;
TargetPlatform get platform => _platform;
set platform(TargetPlatform value) {
Expand Down
4 changes: 3 additions & 1 deletion packages/flutter/lib/src/widgets/reorderable_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1272,11 +1272,13 @@ class ReorderableDragStartListener extends StatelessWidget {
}

void _startDragging(BuildContext context, PointerDownEvent event) {
final DeviceGestureSettings? gestureSettings = MediaQuery.maybeOf(context)?.gestureSettings;
final SliverReorderableListState? list = SliverReorderableList.maybeOf(context);
list?.startItemDragReorder(
index: index,
event: event,
recognizer: createRecognizer(),
recognizer: createRecognizer()
..gestureSettings = gestureSettings,
);
}
}
Expand Down
16 changes: 11 additions & 5 deletions packages/flutter/test/material/ink_sparkle_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,23 @@ void main() {
final Finder buttonFinder = find.text('Sparkle!');
await tester.tap(buttonFinder);
await tester.pump();
await tester.pumpAndSettle();
await tester.pump(const Duration(milliseconds: 200));

final MaterialInkController material = Material.of(tester.element(buttonFinder))!;
await tester.pump(const Duration(milliseconds: 200));
expect(material, paintsExactlyCountTimes(#drawRect, 1));

// ignore: avoid_dynamic_calls
expect((material as dynamic).debugInkFeatures, hasLength(1));

await tester.pumpAndSettle();
// ink feature is disposed.
// ignore: avoid_dynamic_calls
expect((material as dynamic).debugInkFeatures, isEmpty);
},
skip: kIsWeb, // [intended] SPIR-V shaders are not yet supported for web.
);

testWidgets('InkSparkle default splashFactory paints with drawPaint when unbounded', (WidgetTester tester) async {
testWidgets('InkSparkle default splashFactory paints with drawPaint when unbounded', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
home: Scaffold(
body: Center(
Expand All @@ -72,10 +79,9 @@ void main() {
final Finder buttonFinder = find.text('Sparkle!');
await tester.tap(buttonFinder);
await tester.pump();
await tester.pumpAndSettle();
await tester.pump(const Duration(milliseconds: 200));

final MaterialInkController material = Material.of(tester.element(buttonFinder))!;
await tester.pump(const Duration(milliseconds: 200));
expect(material, paintsExactlyCountTimes(#drawPaint, 1));
},
skip: kIsWeb, // [intended] SPIR-V shaders are not yet supported for web.
Expand Down
108 changes: 108 additions & 0 deletions packages/flutter/test/material/slider_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'dart:ui';

import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart';
Expand Down Expand Up @@ -2841,4 +2842,111 @@ void main() {
paints..rrect()..rrect()..rrect()..rrect()..rrect()..rrect(color: color),
);
});

// Regression test for https://github.com/flutter/flutter/issues/103566
testWidgets('Drag gesture uses provided gesture settings', (WidgetTester tester) async {
double value = 0.5;
bool dragStarted = false;
final Key sliderKey = UniqueKey();

await tester.pumpWidget(
MaterialApp(
home: Directionality(
textDirection: TextDirection.ltr,
child: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return Material(
child: Center(
child: GestureDetector(
behavior: HitTestBehavior.deferToChild,
onHorizontalDragStart: (DragStartDetails details) {
dragStarted = true;
},
child: MediaQuery(
data: MediaQuery.of(context).copyWith(gestureSettings: const DeviceGestureSettings(touchSlop: 20)),
child: Slider(
value: value,
key: sliderKey,
onChanged: (double newValue) {
setState(() {
value = newValue;
});
},
),
),
),
),
);
},
),
),
),
);

TestGesture drag = await tester.startGesture(tester.getCenter(find.byKey(sliderKey)));
await tester.pump(kPressTimeout);

// Less than configured touch slop, more than default touch slop
await drag.moveBy(const Offset(19.0, 0));
await tester.pump();

expect(value, 0.5);
expect(dragStarted, true);

dragStarted = false;

await drag.up();
await tester.pumpAndSettle();

drag = await tester.startGesture(tester.getCenter(find.byKey(sliderKey)));
await tester.pump(kPressTimeout);

bool sliderEnd = false;

await tester.pumpWidget(
MaterialApp(
home: Directionality(
textDirection: TextDirection.ltr,
child: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return Material(
child: Center(
child: GestureDetector(
behavior: HitTestBehavior.deferToChild,
onHorizontalDragStart: (DragStartDetails details) {
dragStarted = true;
},
child: MediaQuery(
data: MediaQuery.of(context).copyWith(gestureSettings: const DeviceGestureSettings(touchSlop: 10)),
child: Slider(
value: value,
key: sliderKey,
onChanged: (double newValue) {
setState(() {
value = newValue;
});
},
onChangeEnd: (double endValue) {
sliderEnd = true;
},
),
),
),
),
);
},
),
),
),
);

// More than touch slop.
await drag.moveBy(const Offset(12.0, 0));

await drag.up();
await tester.pumpAndSettle();

expect(sliderEnd, true);
expect(dragStarted, false);
});
}
57 changes: 57 additions & 0 deletions packages/flutter/test/widgets/reorderable_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,63 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
testWidgets('SliverReorderableList works well when having gestureSettings', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/103404
const int itemCount = 5;
int onReorderCallCount = 0;
final List<int> items = List<int>.generate(itemCount, (int index) => index);

void handleReorder(int fromIndex, int toIndex) {
onReorderCallCount += 1;
if (toIndex > fromIndex) {
toIndex -= 1;
}
items.insert(toIndex, items.removeAt(fromIndex));
}
// The list has five elements of height 100
await tester.pumpWidget(
MaterialApp(
home: MediaQuery(
data: const MediaQueryData(gestureSettings: DeviceGestureSettings(touchSlop: 8.0)),
child: CustomScrollView(
slivers: <Widget>[
SliverReorderableList(
itemCount: itemCount,
itemBuilder: (BuildContext context, int index) {
return SizedBox(
key: ValueKey<int>(items[index]),
height: 100,
child: ReorderableDragStartListener(
index: index,
child: Text('item ${items[index]}'),
),
);
},
onReorder: handleReorder,
)
],
),
),
),
);

// Start gesture on first item
final TestGesture drag = await tester.startGesture(tester.getCenter(find.text('item 0')));
await tester.pump(kPressTimeout);

// Drag a little bit to make `ImmediateMultiDragGestureRecognizer` compete with `VerticalDragGestureRecognizer`
await drag.moveBy(const Offset(0, 10));
await tester.pump();
// Drag enough to move down the first item
await drag.moveBy(const Offset(0, 40));
await tester.pump();
await drag.up();
await tester.pumpAndSettle();

expect(onReorderCallCount, 1);
expect(items, orderedEquals(<int>[1, 0, 2, 3, 4]));
});

// Regression test for https://github.com/flutter/flutter/issues/100451
testWidgets('SliverReorderableList.builder respects findChildIndexCallback', (WidgetTester tester) async {
bool finderCalled = false;
Expand Down
8 changes: 6 additions & 2 deletions packages/flutter_tools/lib/src/convert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ const Encoding utf8ForTesting = cnv.utf8;
/// that aren't UTF-8 and we're not quite sure how this is happening.
/// This tells people to report a bug when they see this.
class Utf8Codec extends Encoding {
const Utf8Codec();
const Utf8Codec({this.reportErrors = true});

final bool reportErrors;

@override
Converter<List<int>, String> get decoder => const Utf8Decoder();
Converter<List<int>, String> get decoder => reportErrors
? const Utf8Decoder()
: const Utf8Decoder(reportErrors: false);

@override
Converter<String, List<int>> get encoder => cnv.utf8.encoder;
Expand Down
Loading

0 comments on commit d183abc

Please sign in to comment.