43 lines
1.2 KiB
Dart
43 lines
1.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_drawing_board/flutter_drawing_board.dart';
|
|
|
|
import 'pdf_page_display.dart';
|
|
|
|
/// Drawing overlay for annotating PDF pages.
|
|
///
|
|
/// Uses flutter_drawing_board to provide a paint canvas over the PDF.
|
|
/// Only available in single-page mode.
|
|
class PaintModeLayer extends StatelessWidget {
|
|
final PdfPageDisplay pageDisplay;
|
|
|
|
const PaintModeLayer({
|
|
super.key,
|
|
required this.pageDisplay,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox.expand(
|
|
child: LayoutBuilder(
|
|
builder: (context, constraints) {
|
|
final maxSize = Size(constraints.maxWidth, constraints.maxHeight);
|
|
final (pageSize, _) = pageDisplay.calculateScaledPageSizes(maxSize);
|
|
|
|
return DrawingBoard(
|
|
background: SizedBox(
|
|
width: pageSize.width,
|
|
height: pageSize.height,
|
|
child: pageDisplay,
|
|
),
|
|
boardConstrained: true,
|
|
minScale: 1,
|
|
maxScale: 3,
|
|
alignment: Alignment.topRight,
|
|
boardBoundaryMargin: EdgeInsets.zero,
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|