Reveal full next card behind opaque deck front
This commit is contained in:
@@ -27,6 +27,9 @@ class ChatSwitchCard extends StatelessWidget {
|
|||||||
final shadow = usesCupertinoHost(context)
|
final shadow = usesCupertinoHost(context)
|
||||||
? CupertinoColors.black
|
? CupertinoColors.black
|
||||||
: Theme.of(context).shadowColor;
|
: Theme.of(context).shadowColor;
|
||||||
|
final surface = usesCupertinoHost(context)
|
||||||
|
? CupertinoTheme.of(context).scaffoldBackgroundColor
|
||||||
|
: Theme.of(context).colorScheme.surface;
|
||||||
return LayoutBuilder(
|
return LayoutBuilder(
|
||||||
builder: (context, constraints) => Opacity(
|
builder: (context, constraints) => Opacity(
|
||||||
opacity: pose.opacity,
|
opacity: pose.opacity,
|
||||||
@@ -35,6 +38,7 @@ class ChatSwitchCard extends StatelessWidget {
|
|||||||
transform: pose.transform(constraints.biggest),
|
transform: pose.transform(constraints.biggest),
|
||||||
child: DecoratedBox(
|
child: DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
color: motion.isAnimating && !motion.isTape ? surface : null,
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: shadow.withValues(alpha: .24 * pose.shadow),
|
color: shadow.withValues(alpha: .24 * pose.shadow),
|
||||||
|
|||||||
@@ -65,11 +65,11 @@ Rect quickSwitchRect(
|
|||||||
final deck =
|
final deck =
|
||||||
style == QuickSwitchAnimation.cardStack ||
|
style == QuickSwitchAnimation.cardStack ||
|
||||||
style == QuickSwitchAnimation.deckSlide;
|
style == QuickSwitchAnimation.deckSlide;
|
||||||
final travel = deck
|
// The next card is already full-sized behind the opaque front card.
|
||||||
? outgoing
|
// Sliding the front card aside reveals it instead of exposing empty space
|
||||||
? ((t - .45) / .55).clamp(0.0, 1.0)
|
// above a view still travelling up from the small preview.
|
||||||
: (t / .8).clamp(0.0, 1.0)
|
if (deck && !outgoing) return to;
|
||||||
: t;
|
final travel = deck ? ((t - .45) / .55).clamp(0.0, 1.0) : t;
|
||||||
return Rect.lerp(from, to, travel)!;
|
return Rect.lerp(from, to, travel)!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,6 +101,22 @@ void main() {
|
|||||||
)
|
)
|
||||||
.first,
|
.first,
|
||||||
);
|
);
|
||||||
|
final surfaceColor =
|
||||||
|
tester
|
||||||
|
.widget<DecoratedBox>(
|
||||||
|
find
|
||||||
|
.descendant(
|
||||||
|
of: find.byWidgetPredicate(
|
||||||
|
(w) => w is ChatSwitchCard && w.outgoing,
|
||||||
|
),
|
||||||
|
matching: find.byType(DecoratedBox),
|
||||||
|
)
|
||||||
|
.first,
|
||||||
|
)
|
||||||
|
.decoration
|
||||||
|
as BoxDecoration;
|
||||||
|
expect(surfaceColor.color, isNotNull);
|
||||||
|
expect(surfaceColor.color!.a, 1);
|
||||||
expect(
|
expect(
|
||||||
card.transform.entry(3, 2) != 0,
|
card.transform.entry(3, 2) != 0,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,6 +28,17 @@ void main() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('deck reveals a full-size next card behind the front card', () {
|
||||||
|
for (final style in [
|
||||||
|
QuickSwitchAnimation.cardStack,
|
||||||
|
QuickSwitchAnimation.deckSlide,
|
||||||
|
]) {
|
||||||
|
for (final t in [0.0, .3, .5, 1.0]) {
|
||||||
|
expect(quickSwitchRect(style, t, peek, full, outgoing: false), full);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test('every style settles without residual transforms or missing cards', () {
|
test('every style settles without residual transforms or missing cards', () {
|
||||||
for (final style in QuickSwitchAnimation.values) {
|
for (final style in QuickSwitchAnimation.values) {
|
||||||
for (final outgoing in [true, false]) {
|
for (final outgoing in [true, false]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user