Merge main
# Conflicts: # app/lib/ui/motion/motion.dart
This commit is contained in:
@@ -13,8 +13,18 @@ typedef ArtifactHtmlBuilder =
|
|||||||
/// empty `sandbox` blocks scripts, forms, popups and navigation; on Android and
|
/// empty `sandbox` blocks scripts, forms, popups and navigation; on Android and
|
||||||
/// iOS in a web view with JavaScript disabled and navigation refused. The
|
/// iOS in a web view with JavaScript disabled and navigation refused. The
|
||||||
/// document never runs code with the app's origin or credentials.
|
/// document never runs code with the app's origin or credentials.
|
||||||
Widget defaultArtifactHtml(BuildContext context, String html) =>
|
///
|
||||||
SizedBox.expand(
|
/// The preview stops at the floating bars instead of passing behind them: on
|
||||||
|
/// the web the iframe is a platform view that takes every click over its
|
||||||
|
/// area, even where a bar is drawn on top, which left the viewer's actions
|
||||||
|
/// and pager unclickable.
|
||||||
|
Widget defaultArtifactHtml(BuildContext context, String html) {
|
||||||
|
final padding = MediaQuery.paddingOf(context);
|
||||||
|
return Padding(
|
||||||
|
padding: EdgeInsets.only(top: padding.top, bottom: padding.bottom),
|
||||||
|
child: SizedBox.expand(
|
||||||
key: const Key('artifact-html-preview'),
|
key: const Key('artifact-html-preview'),
|
||||||
child: impl.InertHtmlView(html: html),
|
child: impl.InertHtmlView(html: html),
|
||||||
);
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -101,48 +101,48 @@ class ArtifactViewerBody extends StatelessWidget {
|
|||||||
// no empty glass bar, and no bottom clearance reserved for one.
|
// no empty glass bar, and no bottom clearance reserved for one.
|
||||||
if (resolved == null && count <= 1) return swipe;
|
if (resolved == null && count <= 1) return swipe;
|
||||||
return FloatingBarOverlay(
|
return FloatingBarOverlay(
|
||||||
bar: Padding(
|
// The SafeArea already lifts the bar by the inherited bottom inset (a
|
||||||
padding: withFloatingBarClearance(context, EdgeInsets.zero),
|
// shell bar below the pane); adding that clearance again floated the
|
||||||
child: SafeArea(
|
// bar far above it.
|
||||||
top: false,
|
bar: SafeArea(
|
||||||
minimum: const EdgeInsets.all(8),
|
top: false,
|
||||||
child: SizedBox(
|
minimum: const EdgeInsets.all(8),
|
||||||
height: 56,
|
child: SizedBox(
|
||||||
child: GlassPill(
|
height: 56,
|
||||||
cupertino: usesCupertinoHost(context),
|
child: GlassPill(
|
||||||
child: Padding(
|
cupertino: usesCupertinoHost(context),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2),
|
child: Padding(
|
||||||
child: Row(
|
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2),
|
||||||
key: const Key('artifact-viewer-actions'),
|
child: Row(
|
||||||
children: [
|
key: const Key('artifact-viewer-actions'),
|
||||||
if (resolved != null && !resolved.external)
|
children: [
|
||||||
ArtifactFileActions(
|
if (resolved != null && !resolved.external)
|
||||||
key: ValueKey<String>(
|
ArtifactFileActions(
|
||||||
'viewer-files-${page.group.stageKey}\u0000'
|
key: ValueKey<String>(
|
||||||
'${page.group.visit}\u0000${page.artifact.url}',
|
'viewer-files-${page.group.stageKey}\u0000'
|
||||||
),
|
'${page.group.visit}\u0000${page.artifact.url}',
|
||||||
artifact: page.artifact,
|
|
||||||
resolved: resolved,
|
|
||||||
fetch: fetch,
|
|
||||||
bridge: fileBridge,
|
|
||||||
compact: true,
|
|
||||||
),
|
|
||||||
if (resolved != null)
|
|
||||||
_Actions(
|
|
||||||
resolved: resolved,
|
|
||||||
onOpen: onOpen,
|
|
||||||
onCopy: onCopy,
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: _Pager(
|
|
||||||
index: index,
|
|
||||||
count: count,
|
|
||||||
onPrevious: onPrevious,
|
|
||||||
onNext: onNext,
|
|
||||||
),
|
),
|
||||||
|
artifact: page.artifact,
|
||||||
|
resolved: resolved,
|
||||||
|
fetch: fetch,
|
||||||
|
bridge: fileBridge,
|
||||||
|
compact: true,
|
||||||
),
|
),
|
||||||
],
|
if (resolved != null)
|
||||||
),
|
_Actions(
|
||||||
|
resolved: resolved,
|
||||||
|
onOpen: onOpen,
|
||||||
|
onCopy: onCopy,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: _Pager(
|
||||||
|
index: index,
|
||||||
|
count: count,
|
||||||
|
onPrevious: onPrevious,
|
||||||
|
onNext: onNext,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -336,7 +336,8 @@ class _TabEntranceState extends State<_TabEntrance>
|
|||||||
_controller = AnimationController(
|
_controller = AnimationController(
|
||||||
vsync: this,
|
vsync: this,
|
||||||
duration:
|
duration:
|
||||||
Motion.standard + Motion.tabEntranceStagger * (widget.count - 1),
|
Motion.tabEntranceDuration +
|
||||||
|
Motion.tabEntranceStagger * (widget.count - 1),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,7 +346,7 @@ class _TabEntranceState extends State<_TabEntrance>
|
|||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
if (_started) return;
|
if (_started) return;
|
||||||
_started = true;
|
_started = true;
|
||||||
final duration = Motion.of(context, Motion.standard);
|
final duration = Motion.of(context, Motion.tabEntranceDuration);
|
||||||
_controller.duration =
|
_controller.duration =
|
||||||
duration + Motion.tabEntranceStagger * (widget.count - 1);
|
duration + Motion.tabEntranceStagger * (widget.count - 1);
|
||||||
if (duration == Duration.zero) {
|
if (duration == Duration.zero) {
|
||||||
@@ -365,16 +366,47 @@ class _TabEntranceState extends State<_TabEntrance>
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final total = _controller.duration!.inMicroseconds;
|
final total = _controller.duration!.inMicroseconds;
|
||||||
final start = Motion.tabEntranceStagger.inMicroseconds * widget.index;
|
final start = Motion.tabEntranceStagger.inMicroseconds * widget.index;
|
||||||
|
final window = Motion.tabEntranceDuration.inMicroseconds;
|
||||||
final begin = total == 0 ? 0.0 : start / total;
|
final begin = total == 0 ? 0.0 : start / total;
|
||||||
final animation = CurvedAnimation(
|
final end = total == 0 ? 1.0 : (start + window) / total;
|
||||||
|
final pop = CurvedAnimation(
|
||||||
parent: _controller,
|
parent: _controller,
|
||||||
curve: Interval(begin, 1, curve: Motion.curve),
|
curve: Interval(
|
||||||
|
begin,
|
||||||
|
end.clamp(begin, 1.0).toDouble(),
|
||||||
|
curve: Curves.easeOutBack,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final opacity = CurvedAnimation(
|
||||||
|
parent: _controller,
|
||||||
|
curve: Interval(
|
||||||
|
begin,
|
||||||
|
total == 0
|
||||||
|
? 1.0
|
||||||
|
: (start + window * Motion.tabEntranceOpacityPortion)
|
||||||
|
.clamp(start, total)
|
||||||
|
.toDouble() /
|
||||||
|
total,
|
||||||
|
curve: Curves.easeOut,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
return FadeTransition(
|
return FadeTransition(
|
||||||
opacity: animation,
|
opacity: opacity,
|
||||||
child: ScaleTransition(
|
// Tabs (and their badge counts) stay announced while they fade in.
|
||||||
scale: Tween<double>(begin: 0.88, end: 1).animate(animation),
|
alwaysIncludeSemantics: true,
|
||||||
|
child: AnimatedBuilder(
|
||||||
|
animation: pop,
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
|
builder: (context, child) => Transform.translate(
|
||||||
|
offset: Offset(0, (1 - pop.value) * Motion.tabEntranceSlideDistance),
|
||||||
|
child: Transform.scale(
|
||||||
|
scale: Tween<double>(
|
||||||
|
begin: Motion.tabEntranceScaleBegin,
|
||||||
|
end: 1,
|
||||||
|
).evaluate(pop),
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,20 @@ abstract final class Motion {
|
|||||||
/// The point at which the incoming tab begins to appear.
|
/// The point at which the incoming tab begins to appear.
|
||||||
static const double tabFadeThroughIncomingAt = 0.35;
|
static const double tabFadeThroughIncomingAt = 0.35;
|
||||||
|
|
||||||
/// Delay between neighbouring controls entering as one group.
|
/// Duration of each tab's entrance pop.
|
||||||
static const Duration tabEntranceStagger = Duration(milliseconds: 40);
|
static const Duration tabEntranceDuration = Duration(milliseconds: 260);
|
||||||
|
|
||||||
|
/// Delay between neighbouring tabs entering as one group.
|
||||||
|
static const Duration tabEntranceStagger = Duration(milliseconds: 70);
|
||||||
|
|
||||||
|
/// The scale at which a tab starts its entrance pop.
|
||||||
|
static const double tabEntranceScaleBegin = 0.6;
|
||||||
|
|
||||||
|
/// The upward travel distance of a tab's entrance pop, in logical pixels.
|
||||||
|
static const double tabEntranceSlideDistance = 6;
|
||||||
|
|
||||||
|
/// The fraction of a tab's entrance spent fading in.
|
||||||
|
static const double tabEntranceOpacityPortion = 0.6;
|
||||||
|
|
||||||
static const Curve curve = Curves.easeOutCubic;
|
static const Curve curve = Curves.easeOutCubic;
|
||||||
|
|
||||||
|
|||||||
@@ -726,6 +726,9 @@ void main() {
|
|||||||
);
|
);
|
||||||
final pager = tester.getRect(find.byKey(artifactNextKey));
|
final pager = tester.getRect(find.byKey(artifactNextKey));
|
||||||
expect(pager.bottom, lessThanOrEqualTo(size.height - 120));
|
expect(pager.bottom, lessThanOrEqualTo(size.height - 120));
|
||||||
|
// Right above the stacked bar, not lifted by its clearance twice
|
||||||
|
// (the bar is one 56 px pill above the inset plus its margin).
|
||||||
|
expect(pager.bottom, greaterThanOrEqualTo(size.height - 120 - 56));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,14 +171,23 @@ void main() {
|
|||||||
);
|
);
|
||||||
final entrance = find.descendant(
|
final entrance = find.descendant(
|
||||||
of: find.byType(FloatingDestinationBar),
|
of: find.byType(FloatingDestinationBar),
|
||||||
matching: find.byType(FadeTransition),
|
matching: find.byWidgetPredicate(
|
||||||
|
(widget) =>
|
||||||
|
widget is FadeTransition && widget.child is AnimatedBuilder,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
expect(
|
double firstOpacity() =>
|
||||||
tester.widget<FadeTransition>(entrance.first).opacity.value,
|
tester.widget<FadeTransition>(entrance.at(0)).opacity.value;
|
||||||
inInclusiveRange(0, 1),
|
double lastOpacity() =>
|
||||||
);
|
tester.widget<FadeTransition>(entrance.at(2)).opacity.value;
|
||||||
await tester.pump(const Duration(milliseconds: 320));
|
expect(firstOpacity(), 0);
|
||||||
expect(tester.widget<FadeTransition>(entrance.first).opacity.value, 1);
|
expect(lastOpacity(), 0);
|
||||||
|
await tester.pump(const Duration(milliseconds: 130));
|
||||||
|
expect(firstOpacity(), greaterThan(0.9));
|
||||||
|
expect(lastOpacity(), lessThan(0.2));
|
||||||
|
await tester.pump(const Duration(milliseconds: 270));
|
||||||
|
expect(firstOpacity(), 1);
|
||||||
|
expect(lastOpacity(), 1);
|
||||||
await tester.tap(find.byKey(tabKey(1)));
|
await tester.tap(find.byKey(tabKey(1)));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user