Improve error messages for impossible actions during paint mode

This commit is contained in:
2026-02-04 11:50:27 +01:00
parent 704bd0b928
commit d626271ad2

View File

@@ -92,6 +92,10 @@ class _SheetViewerPageState extends State<SheetViewerPage>
}
void _toggleFullscreen() {
if (_isPaintMode) {
_showSnackBar('Cannot enter fullscreen while in paint mode');
return;
}
FullScreen.setFullScreen(!widget.config.fullscreen);
}
@@ -111,13 +115,7 @@ class _SheetViewerPageState extends State<SheetViewerPage>
void _togglePaintMode() {
if (widget.config.twoPageMode) {
// Paint mode only works in single page mode
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Paint mode is only available in single page mode'),
duration: Duration(seconds: 2),
),
);
_showSnackBar('Paint mode is only available in single page mode');
return;
}
@@ -125,19 +123,14 @@ class _SheetViewerPageState extends State<SheetViewerPage>
}
void _toggleTwoPageMode() {
if (_isPaintMode) {
_showSnackBar('Cannot enter two-page mode while painting');
return;
}
setState(() {
widget.config.twoPageMode = !widget.config.twoPageMode;
_storageService.writeConfig(widget.config);
if (widget.config.twoPageMode && _isPaintMode) {
_isPaintMode = false;
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Paint mode disabled in two-page mode'),
duration: Duration(seconds: 2),
),
);
}
});
}
@@ -252,4 +245,10 @@ class _SheetViewerPageState extends State<SheetViewerPage>
),
);
}
void _showSnackBar(String message) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(message), duration: Duration(seconds: 2)),
);
}
}