add fullscreen mode
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:hive/hive.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:pdfrx/pdfrx.dart';
|
||||
import 'package:flutter_fullscreen/flutter_fullscreen.dart';
|
||||
|
||||
import 'login_page.dart';
|
||||
|
||||
@@ -25,6 +26,10 @@ Future<void> main() async {
|
||||
Hive.init(dir.path); // Needed only if not web
|
||||
}
|
||||
|
||||
// setup for flutter_fullscreen
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await FullScreen.ensureInitialized();
|
||||
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:sheetless/api.dart';
|
||||
import 'package:sheetless/bt_pedal_shortcuts.dart';
|
||||
import 'package:sheetless/sheet.dart';
|
||||
import 'package:sheetless/storage_helper.dart';
|
||||
import 'package:flutter_fullscreen/flutter_fullscreen.dart';
|
||||
|
||||
class SheetViewerPage extends StatefulWidget {
|
||||
final Sheet sheet;
|
||||
@@ -25,7 +26,8 @@ class SheetViewerPage extends StatefulWidget {
|
||||
State<SheetViewerPage> createState() => _SheetViewerPageState();
|
||||
}
|
||||
|
||||
class _SheetViewerPageState extends State<SheetViewerPage> {
|
||||
class _SheetViewerPageState extends State<SheetViewerPage>
|
||||
with FullScreenListener {
|
||||
final log = Logger("SheetViewerPage");
|
||||
final StorageHelper storageHelper = StorageHelper();
|
||||
|
||||
@@ -37,12 +39,14 @@ class _SheetViewerPageState extends State<SheetViewerPage> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
FullScreen.addListener(this);
|
||||
super.initState();
|
||||
documentLoaded = loadPdf();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
FullScreen.removeListener(this);
|
||||
document?.dispose(); // Make sure document gets garbage collected
|
||||
super.dispose();
|
||||
}
|
||||
@@ -66,25 +70,16 @@ class _SheetViewerPageState extends State<SheetViewerPage> {
|
||||
return true;
|
||||
}
|
||||
|
||||
void toggleFullscreen() {
|
||||
widget.config.fullscreen = !widget.config.fullscreen;
|
||||
storageHelper.writeConfig(widget.config);
|
||||
@override
|
||||
void onFullScreenChanged(bool enabled, SystemUiMode? systemUiMode) {
|
||||
setState(() {
|
||||
widget.config.fullscreen = enabled;
|
||||
storageHelper.writeConfig(widget.config);
|
||||
});
|
||||
}
|
||||
|
||||
if (widget.config.fullscreen) {
|
||||
log.info("enter fullscreen");
|
||||
// enter fullscreen
|
||||
SystemChrome.setEnabledSystemUIMode(
|
||||
SystemUiMode.immersiveSticky,
|
||||
overlays: [],
|
||||
);
|
||||
} else {
|
||||
// exit fullscreen
|
||||
log.info("exit fullscreen");
|
||||
SystemChrome.setEnabledSystemUIMode(
|
||||
SystemUiMode.edgeToEdge,
|
||||
overlays: SystemUiOverlay.values,
|
||||
);
|
||||
}
|
||||
void toggleFullscreen() {
|
||||
FullScreen.setFullScreen(!widget.config.fullscreen);
|
||||
}
|
||||
|
||||
void turnPage(int numTurns) {
|
||||
@@ -100,38 +95,42 @@ class _SheetViewerPageState extends State<SheetViewerPage> {
|
||||
onTurnPageForward: () => turnPage(1),
|
||||
onTurnPageBackward: () => turnPage(-1),
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(widget.sheet.name),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
if (widget.config.twoPageMode) {
|
||||
// TODO: notification that paint mode only in single page mode
|
||||
} else {
|
||||
paintMode = !paintMode;
|
||||
}
|
||||
});
|
||||
},
|
||||
icon: Icon(Icons.brush),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
widget.config.twoPageMode = !widget.config.twoPageMode;
|
||||
storageHelper.writeConfig(widget.config);
|
||||
if (widget.config.twoPageMode) {
|
||||
paintMode = false;
|
||||
// TODO: notification that paint mode was deactivated since only possible in single page mode
|
||||
}
|
||||
});
|
||||
},
|
||||
icon: Icon(
|
||||
widget.config.twoPageMode ? Icons.filter_1 : Icons.filter_2,
|
||||
appBar: widget.config.fullscreen
|
||||
? null
|
||||
: AppBar(
|
||||
title: Text(widget.sheet.name),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
if (widget.config.twoPageMode) {
|
||||
// TODO: notification that paint mode only in single page mode
|
||||
} else {
|
||||
paintMode = !paintMode;
|
||||
}
|
||||
});
|
||||
},
|
||||
icon: Icon(Icons.brush),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
widget.config.twoPageMode = !widget.config.twoPageMode;
|
||||
storageHelper.writeConfig(widget.config);
|
||||
if (widget.config.twoPageMode) {
|
||||
paintMode = false;
|
||||
// TODO: notification that paint mode was deactivated since only possible in single page mode
|
||||
}
|
||||
});
|
||||
},
|
||||
icon: Icon(
|
||||
widget.config.twoPageMode
|
||||
? Icons.filter_1
|
||||
: Icons.filter_2,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: FutureBuilder(
|
||||
future: documentLoaded,
|
||||
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
|
||||
@@ -155,12 +154,13 @@ class _SheetViewerPageState extends State<SheetViewerPage> {
|
||||
// print("Touch at x = ${details.localPosition.dx}");
|
||||
// print("Screenwidth = ${screenWidth}");
|
||||
// Check where the user tapped
|
||||
// if (details.localPosition.dy < 100) {
|
||||
// TODO
|
||||
// setState(() {
|
||||
// toggleFullscreen();
|
||||
// });
|
||||
if (details.localPosition.dx < screenWidth / 2) {
|
||||
if (details.localPosition.dy < 100) {
|
||||
// TODO
|
||||
setState(() {
|
||||
toggleFullscreen();
|
||||
});
|
||||
} else if (details.localPosition.dx <
|
||||
screenWidth / 2) {
|
||||
// Left half of the screen
|
||||
turnPage(-1);
|
||||
} else {
|
||||
|
||||
@@ -7,13 +7,21 @@
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
|
||||
#include <screen_retriever_linux/screen_retriever_linux_plugin.h>
|
||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||
#include <window_manager/window_manager_plugin.h>
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin");
|
||||
flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar);
|
||||
g_autoptr(FlPluginRegistrar) screen_retriever_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverLinuxPlugin");
|
||||
screen_retriever_linux_plugin_register_with_registrar(screen_retriever_linux_registrar);
|
||||
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
||||
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
||||
g_autoptr(FlPluginRegistrar) window_manager_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin");
|
||||
window_manager_plugin_register_with_registrar(window_manager_registrar);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
flutter_secure_storage_linux
|
||||
screen_retriever_linux
|
||||
url_launcher_linux
|
||||
window_manager
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
|
||||
@@ -7,12 +7,16 @@ import Foundation
|
||||
|
||||
import flutter_secure_storage_macos
|
||||
import path_provider_foundation
|
||||
import screen_retriever_macos
|
||||
import sqflite_darwin
|
||||
import url_launcher_macos
|
||||
import window_manager
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin"))
|
||||
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
||||
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
|
||||
}
|
||||
|
||||
56
pubspec.lock
56
pubspec.lock
@@ -150,6 +150,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.9.8"
|
||||
flutter_fullscreen:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_fullscreen
|
||||
sha256: "37fc83866ded6477efdd5653bed3a6edaaa831dada48a3ca58b2395ce1cc282f"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
flutter_launcher_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -504,6 +512,46 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.28.0"
|
||||
screen_retriever:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: screen_retriever
|
||||
sha256: "570dbc8e4f70bac451e0efc9c9bb19fa2d6799a11e6ef04f946d7886d2e23d0c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
screen_retriever_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: screen_retriever_linux
|
||||
sha256: f7f8120c92ef0784e58491ab664d01efda79a922b025ff286e29aa123ea3dd18
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
screen_retriever_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: screen_retriever_macos
|
||||
sha256: "71f956e65c97315dd661d71f828708bd97b6d358e776f1a30d5aa7d22d78a149"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
screen_retriever_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: screen_retriever_platform_interface
|
||||
sha256: ee197f4581ff0d5608587819af40490748e1e39e648d7680ecf95c05197240c0
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
screen_retriever_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: screen_retriever_windows
|
||||
sha256: "449ee257f03ca98a57288ee526a301a430a344a161f9202b4fcc38576716fe13"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
@@ -725,6 +773,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.14.0"
|
||||
window_manager:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: window_manager
|
||||
sha256: "7eb6d6c4164ec08e1bf978d6e733f3cebe792e2a23fb07cbca25c2872bfdbdcd"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.1"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -48,6 +48,7 @@ dependencies:
|
||||
flutter_drawing_board: ^0.9.8
|
||||
flutter_launcher_icons: ^0.14.4
|
||||
hive: ^2.2.3
|
||||
flutter_fullscreen: ^1.2.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
@@ -8,13 +8,19 @@
|
||||
|
||||
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
|
||||
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
||||
#include <screen_retriever_windows/screen_retriever_windows_plugin_c_api.h>
|
||||
#include <url_launcher_windows/url_launcher_windows.h>
|
||||
#include <window_manager/window_manager_plugin.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
|
||||
PermissionHandlerWindowsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
||||
ScreenRetrieverWindowsPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("ScreenRetrieverWindowsPluginCApi"));
|
||||
UrlLauncherWindowsRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
|
||||
WindowManagerPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("WindowManagerPlugin"));
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
flutter_secure_storage_windows
|
||||
permission_handler_windows
|
||||
screen_retriever_windows
|
||||
url_launcher_windows
|
||||
window_manager
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
|
||||
Reference in New Issue
Block a user