mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
* Manually fix every use of Point.x and Point.y
Some of these were moved to dx/dy, but not all.
* Manually convert uses of the old gradient API
* Remove old reference to Point.
* Mechanical changes
I applied the following at the root of the Flutter repository:
git ls-files -z | xargs -0 sed -i 's/\bPoint[.]origin\b/Offset.zero/g'
git ls-files -z | xargs -0 sed -i 's/\bPoint[.]lerp\b/Offset.lerp/g'
git ls-files -z | xargs -0 sed -i 's/\bnew Point\b/new Offset/g'
git ls-files -z | xargs -0 sed -i 's/\bconst Point\b/const Offset/g'
git ls-files -z | xargs -0 sed -i 's/\bstatic Point /static Offset /g'
git ls-files -z | xargs -0 sed -i 's/\bfinal Point /final Offset /g'
git ls-files -z | xargs -0 sed -i 's/^\( *\)Point /\1Offset /g'
git ls-files -z | xargs -0 sed -i 's/ui[.]Point\b/ui.Offset/g'
git ls-files -z | xargs -0 sed -i 's/(Point\b/(Offset/g'
git ls-files -z | xargs -0 sed -i 's/\([[{,]\) Point\b/\1 Offset/g'
git ls-files -z | xargs -0 sed -i 's/@required Point\b/@required Offset/g'
git ls-files -z | xargs -0 sed -i 's/<Point>/<Offset>/g'
git ls-files -z | xargs -0 sed -i 's/[.]toOffset()//g'
git ls-files -z | xargs -0 sed -i 's/[.]toPoint()//g'
git ls-files -z | xargs -0 sed -i 's/\bshow Point, /show /g'
git ls-files -z | xargs -0 sed -i 's/\bshow Point;/show Offset;/g'
* Mechanical changes - dartdocs
I applied the following at the root of the Flutter repository:
git ls-files -z | xargs -0 sed -i 's/\ba \[Point\]/an [Offset]/g'
git ls-files -z | xargs -0 sed -i 's/\[Point\]/[Offset]/g'
* Further improvements and a test
* Fix minor errors from rebasing...
* Roll engine
189 lines
5.6 KiB
Dart
189 lines
5.6 KiB
Dart
// Copyright 2015 The Chromium 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_test/flutter_test.dart';
|
|
import 'package:flutter/rendering.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
import 'package:vector_math/vector_math_64.dart';
|
|
|
|
void main() {
|
|
testWidgets('Transform origin', (WidgetTester tester) async {
|
|
bool didReceiveTap = false;
|
|
await tester.pumpWidget(
|
|
new Stack(
|
|
children: <Widget>[
|
|
new Positioned(
|
|
top: 100.0,
|
|
left: 100.0,
|
|
child: new Container(
|
|
width: 100.0,
|
|
height: 100.0,
|
|
decoration: const BoxDecoration(
|
|
backgroundColor: const Color(0xFF0000FF),
|
|
),
|
|
),
|
|
),
|
|
new Positioned(
|
|
top: 100.0,
|
|
left: 100.0,
|
|
child: new Container(
|
|
width: 100.0,
|
|
height: 100.0,
|
|
child: new Transform(
|
|
transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0),
|
|
origin: const Offset(100.0, 50.0),
|
|
child: new GestureDetector(
|
|
onTap: () {
|
|
didReceiveTap = true;
|
|
},
|
|
child: new Container(
|
|
decoration: const BoxDecoration(
|
|
backgroundColor: const Color(0xFF00FFFF),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
|
|
expect(didReceiveTap, isFalse);
|
|
await tester.tapAt(const Offset(110.0, 110.0));
|
|
expect(didReceiveTap, isFalse);
|
|
await tester.tapAt(const Offset(190.0, 150.0));
|
|
expect(didReceiveTap, isTrue);
|
|
});
|
|
|
|
testWidgets('Transform alignment', (WidgetTester tester) async {
|
|
bool didReceiveTap = false;
|
|
await tester.pumpWidget(
|
|
new Stack(
|
|
children: <Widget>[
|
|
new Positioned(
|
|
top: 100.0,
|
|
left: 100.0,
|
|
child: new Container(
|
|
width: 100.0,
|
|
height: 100.0,
|
|
decoration: const BoxDecoration(
|
|
backgroundColor: const Color(0xFF0000FF),
|
|
),
|
|
),
|
|
),
|
|
new Positioned(
|
|
top: 100.0,
|
|
left: 100.0,
|
|
child: new Container(
|
|
width: 100.0,
|
|
height: 100.0,
|
|
child: new Transform(
|
|
transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0),
|
|
alignment: const FractionalOffset(1.0, 0.5),
|
|
child: new GestureDetector(
|
|
onTap: () {
|
|
didReceiveTap = true;
|
|
},
|
|
child: new Container(
|
|
decoration: const BoxDecoration(
|
|
backgroundColor: const Color(0xFF00FFFF),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
|
|
expect(didReceiveTap, isFalse);
|
|
await tester.tapAt(const Offset(110.0, 110.0));
|
|
expect(didReceiveTap, isFalse);
|
|
await tester.tapAt(const Offset(190.0, 150.0));
|
|
expect(didReceiveTap, isTrue);
|
|
});
|
|
|
|
testWidgets('Transform offset + alignment', (WidgetTester tester) async {
|
|
bool didReceiveTap = false;
|
|
await tester.pumpWidget(new Stack(
|
|
children: <Widget>[
|
|
new Positioned(
|
|
top: 100.0,
|
|
left: 100.0,
|
|
child: new Container(
|
|
width: 100.0,
|
|
height: 100.0,
|
|
decoration: const BoxDecoration(
|
|
backgroundColor: const Color(0xFF0000FF),
|
|
),
|
|
),
|
|
),
|
|
new Positioned(
|
|
top: 100.0,
|
|
left: 100.0,
|
|
child: new Container(
|
|
width: 100.0,
|
|
height: 100.0,
|
|
child: new Transform(
|
|
transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0),
|
|
origin: const Offset(100.0, 0.0),
|
|
alignment: const FractionalOffset(0.0, 0.5),
|
|
child: new GestureDetector(
|
|
onTap: () {
|
|
didReceiveTap = true;
|
|
},
|
|
child: new Container(
|
|
decoration: const BoxDecoration(
|
|
backgroundColor: const Color(0xFF00FFFF),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
));
|
|
|
|
expect(didReceiveTap, isFalse);
|
|
await tester.tapAt(const Offset(110.0, 110.0));
|
|
expect(didReceiveTap, isFalse);
|
|
await tester.tapAt(const Offset(190.0, 150.0));
|
|
expect(didReceiveTap, isTrue);
|
|
});
|
|
|
|
testWidgets('Composited transform offset', (WidgetTester tester) async {
|
|
await tester.pumpWidget(
|
|
new Center(
|
|
child: new SizedBox(
|
|
width: 400.0,
|
|
height: 300.0,
|
|
child: new ClipRect(
|
|
child: new Transform(
|
|
transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0),
|
|
child: new Opacity(
|
|
opacity: 0.9,
|
|
child: new Container(
|
|
decoration: const BoxDecoration(
|
|
backgroundColor: const Color(0xFF00FF00),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
final List<Layer> layers = tester.layers
|
|
..retainWhere((Layer layer) => layer is TransformLayer);
|
|
expect(layers.length, 2);
|
|
// The first transform is from the render view.
|
|
final TransformLayer layer = layers[1];
|
|
final Matrix4 transform = layer.transform;
|
|
expect(transform.getTranslation(), equals(new Vector3(100.0, 75.0, 0.0)));
|
|
});
|
|
}
|