-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from tomaszpolanski/enable-full-screen-on-desktop
feat: enable full screen on desktop
- Loading branch information
Showing
20 changed files
with
351 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 33 additions & 14 deletions
47
packages/flutter_deck/lib/src/controls/fullscreen/fullscreen.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,44 @@ | ||
export 'stub.dart' | ||
if (dart.library.io) 'io.dart' | ||
if (dart.library.html) 'web.dart'; | ||
import 'package:flutter_deck/src/controls/fullscreen/window_proxy/window_proxy.dart'; | ||
|
||
/// Describes a collection of functions that can mutate and retrieve | ||
/// the application's fullscreen state. | ||
abstract class FlutterDeckFullscreenManagerBase { | ||
class FlutterDeckFullscreenManager { | ||
/// Default constructor for [FlutterDeckFullscreenManager]. | ||
/// | ||
/// The [windowProxy] is required for getting and setting window properties | ||
/// from underlying platform. | ||
FlutterDeckFullscreenManager(WindowProxyBase windowProxy) | ||
: _windowProxy = windowProxy; | ||
|
||
final WindowProxyBase _windowProxy; | ||
bool _initialized = false; | ||
|
||
Future<WindowProxyBase> get _instance async { | ||
if (!_initialized) { | ||
await _windowProxy.initialize(); | ||
_initialized = true; | ||
} | ||
return _windowProxy; | ||
} | ||
|
||
/// Returns whether or not this platform has support to enter/leave fullscreen | ||
bool canFullscreen() => false; | ||
bool canFullscreen() => _windowProxy.canFullscreen(); | ||
|
||
/// Returns whether or not the application is currently fullscreen | ||
bool isInFullscreen() => throw UnsupportedError( | ||
'isInFullscreen cannot be called on this platform', | ||
); | ||
Future<bool> isInFullscreen() async { | ||
final windowProxy = await _instance; | ||
return windowProxy.isInFullscreen(); | ||
} | ||
|
||
/// Application enters fullscreen | ||
void enterFullscreen() => throw UnsupportedError( | ||
'enterFullscreen cannot be called on this platform', | ||
); | ||
Future<void> enterFullscreen() async { | ||
final windowProxy = await _instance; | ||
await windowProxy.enterFullscreen(); | ||
} | ||
|
||
/// Application leaves fullscreen | ||
void leaveFullscreen() => throw UnsupportedError( | ||
'leaveFullscreen cannot be called on this platform', | ||
); | ||
Future<void> leaveFullscreen() async { | ||
final windowProxy = await _instance; | ||
await windowProxy.leaveFullscreen(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
packages/flutter_deck/lib/src/controls/fullscreen/web.dart
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
packages/flutter_deck/lib/src/controls/fullscreen/window_proxy/_io.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:flutter_deck/src/controls/fullscreen/window_proxy/window_proxy.dart'; | ||
import 'package:window_manager/window_manager.dart'; | ||
|
||
/// The dart:io implementation of [WindowProxyBase]. | ||
class WindowProxy implements WindowProxyBase { | ||
@override | ||
Future<void> initialize() => windowManager.ensureInitialized(); | ||
|
||
@override | ||
bool canFullscreen() => | ||
Platform.isLinux || Platform.isWindows || Platform.isMacOS; | ||
|
||
@override | ||
Future<bool> isInFullscreen() => windowManager.isFullScreen(); | ||
|
||
@override | ||
Future<void> enterFullscreen() => windowManager.setFullScreen(true); | ||
|
||
@override | ||
Future<void> leaveFullscreen() => windowManager.setFullScreen(false); | ||
} |
31 changes: 31 additions & 0 deletions
31
packages/flutter_deck/lib/src/controls/fullscreen/window_proxy/_stub.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'package:flutter_deck/src/controls/fullscreen/window_proxy/window_proxy.dart'; | ||
|
||
/// The stub implementation of [WindowProxyBase]. | ||
class WindowProxy implements WindowProxyBase { | ||
@override | ||
Future<void> initialize() => throw UnsupportedError( | ||
'initialize cannot be called on this platform', | ||
); | ||
|
||
/// Returns whether or not this platform has support to enter/leave fullscreen | ||
@override | ||
bool canFullscreen() => false; | ||
|
||
/// Returns whether or not the application is currently fullscreen | ||
@override | ||
Future<bool> isInFullscreen() => throw UnsupportedError( | ||
'isInFullscreen cannot be called on this platform', | ||
); | ||
|
||
/// Application enters fullscreen | ||
@override | ||
Future<void> enterFullscreen() => throw UnsupportedError( | ||
'enterFullscreen cannot be called on this platform', | ||
); | ||
|
||
/// Application leaves fullscreen | ||
@override | ||
Future<void> leaveFullscreen() => throw UnsupportedError( | ||
'leaveFullscreen cannot be called on this platform', | ||
); | ||
} |
27 changes: 27 additions & 0 deletions
27
packages/flutter_deck/lib/src/controls/fullscreen/window_proxy/_web.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// This file is conditionally included when compiling to web. | ||
// ignore: avoid_web_libraries_in_flutter | ||
import 'dart:html' as html; | ||
|
||
import 'package:flutter_deck/src/controls/fullscreen/window_proxy/window_proxy.dart'; | ||
|
||
/// The web implementation of [WindowProxyBase]. | ||
class WindowProxy implements WindowProxyBase { | ||
@override | ||
Future<void> initialize() async { | ||
// No need for initialization | ||
} | ||
|
||
@override | ||
bool canFullscreen() => true; | ||
|
||
@override | ||
Future<bool> isInFullscreen() async => | ||
html.window.document.fullscreenElement != null; | ||
|
||
@override | ||
Future<void> enterFullscreen() async => | ||
html.window.document.documentElement?.requestFullscreen(); | ||
|
||
@override | ||
Future<void> leaveFullscreen() async => html.window.document.exitFullscreen(); | ||
} |
21 changes: 21 additions & 0 deletions
21
packages/flutter_deck/lib/src/controls/fullscreen/window_proxy/window_proxy.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export '_stub.dart' | ||
if (dart.library.io) '_io.dart' | ||
if (dart.library.html) '_web.dart'; | ||
|
||
/// Thin proxy/wrapper around platform specific window API implementation | ||
abstract class WindowProxyBase { | ||
/// Initializes window API | ||
Future<void> initialize(); | ||
|
||
/// Returns whether or not this platform has support to enter/leave fullscreen | ||
bool canFullscreen(); | ||
|
||
/// Application enters fullscreen | ||
Future<void> enterFullscreen(); | ||
|
||
/// Returns whether or not the application is currently fullscreen | ||
Future<bool> isInFullscreen(); | ||
|
||
/// Application leaves fullscreen | ||
Future<void> leaveFullscreen(); | ||
} |
Oops, something went wrong.