Files
pipelines/app/lib/features/chat/workspace/chat_tape_exit.dart
T

38 lines
952 B
Dart

import 'dart:ui' as ui;
import 'package:flutter/widgets.dart';
/// Only the top exit is a picture. The looping chat below remains one retained
/// live tree; the picture is released when the tape completes.
class ChatTapeExit extends CustomPainter {
const ChatTapeExit({
required this.image,
required this.source,
required this.workspace,
});
final ui.Image image;
final Rect source;
final Size workspace;
@override
void paint(Canvas canvas, Size size) {
final scale = image.width / workspace.width;
canvas.drawImageRect(
image,
Rect.fromLTRB(
source.left * scale,
source.top * scale,
source.right * scale,
source.bottom * scale,
),
Offset.zero & size,
Paint(),
);
}
@override
bool shouldRepaint(ChatTapeExit oldDelegate) =>
image != oldDelegate.image ||
source != oldDelegate.source ||
workspace != oldDelegate.workspace;
}