Skip to content

Commit

Permalink
0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
lijy91 committed Jan 17, 2022
1 parent 6be06d4 commit d78b0a3
Show file tree
Hide file tree
Showing 10 changed files with 675 additions and 125 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.1.4

- [macos & windows] Implemented getOpacity & setOpacity methods #37 #45
- [macos] Implement setProgressBar method #40
- [windows] Fix `focus`, `blur` event not responding
- [windows] Implement `focus` & `blur` methods
- [macos & windows] Implement getTitleBarHeight methods #34

## 0.1.3

- [windows] #31 Optimize setTitleBarStyle method.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 LiJianying <[email protected]>
Copyright (c) 2022 LiJianying <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
346 changes: 293 additions & 53 deletions README-ZH.md

Large diffs are not rendered by default.

346 changes: 293 additions & 53 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions example/macos/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- FlutterMacOS (1.0.0)
- window_manager (0.1.2):
- window_manager (0.1.4):
- FlutterMacOS

DEPENDENCIES:
Expand All @@ -15,7 +15,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
window_manager: 8c227608c115dbd132510c023d3644274aaec8a8
window_manager: 02776e5a599084cd4576e27a42dd5ec6f49132cf

PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c

Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.3"
version: "0.1.4"
sdks:
dart: ">=2.14.0 <3.0.0"
flutter: ">=1.20.0"
21 changes: 21 additions & 0 deletions lib/src/window_listener.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
abstract class WindowListener {
/// Emitted when the window gains focus.
void onWindowFocus() {}

/// Emitted when the window loses focus.
void onWindowBlur() {}

/// Emitted when window is maximized.
void onWindowMaximize() {}

/// Emitted when the window exits from a maximized state.
void onWindowUnmaximize() {}

/// Emitted when the window is minimized.
void onWindowMinimize() {}

/// Emitted when the window is restored from a minimized state.
void onWindowRestore() {}

/// Emitted after the window has been resized.
void onWindowResize() {}

/// Emitted when the window is being moved to a new position.
void onWindowMove() {}

/// Emitted when the window enters a full-screen state.
void onWindowEnterFullScreen() {}

/// Emitted when the window leaves a full-screen state.
void onWindowLeaveFullScreen() {}

/// Emitted all events.
void onWindowEvent(String eventName) {}
}
67 changes: 54 additions & 13 deletions lib/src/window_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const kWindowEventMove = 'move';
const kWindowEventEnterFullScreen = 'enter-full-screen';
const kWindowEventLeaveFullScreen = 'leave-full-screen';

// WindowManager
class WindowManager {
WindowManager._() {
_channel.setMethodCallHandler(_methodCallHandler);
Expand Down Expand Up @@ -93,6 +94,8 @@ class WindowManager {
}

/// Removes focus from the window.
///
/// @platforms macos,windows
Future<void> blur({bool inactive = false}) async {
await _channel.invokeMethod('blur');
}
Expand All @@ -114,12 +117,12 @@ class WindowManager {
await _channel.invokeMethod('hide');
}

/// Returns bool - Whether the window is visible to the user.
/// Returns `bool` - Whether the window is visible to the user.
Future<bool> isVisible() async {
return await _channel.invokeMethod('isVisible');
}

/// Returns bool - Whether the window is maximized.
/// Returns `bool` - Whether the window is maximized.
Future<bool> isMaximized() async {
return await _channel.invokeMethod('isMaximized');
}
Expand All @@ -134,7 +137,7 @@ class WindowManager {
await _channel.invokeMethod('unmaximize');
}

/// Returns bool - Whether the window is minimized.
/// Returns `bool` - Whether the window is minimized.
Future<bool> isMinimized() async {
return await _channel.invokeMethod('isMinimized');
}
Expand All @@ -149,7 +152,7 @@ class WindowManager {
await _channel.invokeMethod('restore');
}

/// Returns bool - Whether the window is in fullscreen mode.
/// Returns `bool` - Whether the window is in fullscreen mode.
Future<bool> isFullScreen() async {
return await _channel.invokeMethod('isFullScreen');
}
Expand All @@ -173,7 +176,7 @@ class WindowManager {
await _channel.invokeMethod('setBackgroundColor', arguments);
}

/// Returns Rect - The bounds of the window as Object.
/// Returns `Rect` - The bounds of the window as Object.
Future<Rect> getBounds() async {
Offset position = await getPosition();
Size size = await getSize();
Expand All @@ -186,7 +189,7 @@ class WindowManager {
await setSize(bounds.size);
}

/// Returns Offset - Contains the window's current position.
/// Returns `Offset` - Contains the window's current position.
Future<Offset> getPosition() async {
final Map<String, dynamic> arguments = {
'devicePixelRatio': window.devicePixelRatio,
Expand All @@ -207,7 +210,7 @@ class WindowManager {
await _channel.invokeMethod('setPosition', arguments);
}

/// Returns Size - Contains the window's width and height.
/// Returns `Size` - Contains the window's width and height.
Future<Size> getSize() async {
final Map<String, dynamic> arguments = {
'devicePixelRatio': window.devicePixelRatio,
Expand All @@ -217,7 +220,7 @@ class WindowManager {
return Size(resultData['width'], resultData['height']);
}

/// Resizes the window to width and height.
/// Resizes the window to `width` and `height`.
Future<void> setSize(Size size, {animate = false}) async {
final Map<String, dynamic> arguments = {
'devicePixelRatio': window.devicePixelRatio,
Expand All @@ -228,6 +231,7 @@ class WindowManager {
await _channel.invokeMethod('setSize', arguments);
}

/// Sets the minimum size of window to `width` and `height`.
Future<void> setMinimumSize(Size size) async {
final Map<String, dynamic> arguments = {
'devicePixelRatio': window.devicePixelRatio,
Expand All @@ -237,6 +241,7 @@ class WindowManager {
await _channel.invokeMethod('setMinimumSize', arguments);
}

/// Sets the maximum size of window to `width` and `height`.
Future<void> setMaximumSize(Size size) async {
final Map<String, dynamic> arguments = {
'devicePixelRatio': window.devicePixelRatio,
Expand All @@ -246,64 +251,84 @@ class WindowManager {
await _channel.invokeMethod('setMaximumSize', arguments);
}

/// Returns `bool` - Whether the window can be manually resized by the user.
Future<bool> isResizable() async {
return await _channel.invokeMethod('isResizable');
}

/// Sets whether the window can be manually resized by the user.
setResizable(isResizable) {
final Map<String, dynamic> arguments = {
'isResizable': isResizable,
};
_channel.invokeMethod('setResizable', arguments);
}

/// Returns `bool` - Whether the window can be moved by user.
///
/// @platforms macos
Future<bool> isMovable() async {
return await _channel.invokeMethod('isMovable');
}

/// Sets whether the window can be moved by user.
///
/// @platforms macos
setMovable(isMovable) {
final Map<String, dynamic> arguments = {
'isMovable': isMovable,
};
_channel.invokeMethod('setMovable', arguments);
}

/// Returns `bool` - Whether the window can be manually minimized by the user.
///
/// @platforms macos,windows
Future<bool> isMinimizable() async {
return await _channel.invokeMethod('isMinimizable');
}

/// Sets whether the window can be manually minimized by user.
///
/// @platforms macos,windows
setMinimizable(isMinimizable) {
final Map<String, dynamic> arguments = {
'isMinimizable': isMinimizable,
};
_channel.invokeMethod('setMinimizable', arguments);
}

/// Returns `bool` - Whether the window can be manually closed by user.
///
/// @platforms macos,windows
Future<bool> isClosable() async {
return await _channel.invokeMethod('isClosable');
}

/// Sets whether the window can be manually closed by user.
///
/// @platforms macos,windows
Future<void> setClosable(bool isClosable) async {
final Map<String, dynamic> arguments = {
'isClosable': isClosable,
};
await _channel.invokeMethod('setClosable', arguments);
}

/// Returns bool - Whether the window is always on top of other windows.
/// Returns `bool` - Whether the window is always on top of other windows.
Future<bool> isAlwaysOnTop() async {
return await _channel.invokeMethod('isAlwaysOnTop');
}

/// Sets whether the window should show always on top of other windows. After setting this, the window is still a normal window, not a toolbox window which can not be focused on.
/// Sets whether the window should show always on top of other windows.
Future<void> setAlwaysOnTop(bool isAlwaysOnTop) async {
final Map<String, dynamic> arguments = {
'isAlwaysOnTop': isAlwaysOnTop,
};
await _channel.invokeMethod('setAlwaysOnTop', arguments);
}

/// Returns String - The title of the native window.
/// Returns `String` - The title of the native window.
Future<String> getTitle() async {
return await _channel.invokeMethod('getTitle');
}
Expand All @@ -317,6 +342,8 @@ class WindowManager {
}

/// Changes the title bar style of native window.
///
/// @platforms macos,windows
Future<void> setTitleBarStyle(
String titleBarStyle, {
bool windowButtonVisibility = true,
Expand All @@ -328,6 +355,9 @@ class WindowManager {
await _channel.invokeMethod('setTitleBarStyle', arguments);
}

/// Returns `int` - The title bar height of the native window.
///
/// @platforms macos,windows
Future<int> getTitleBarHeight() async {
return await _channel.invokeMethod('getTitleBarHeight');
}
Expand All @@ -341,39 +371,50 @@ class WindowManager {
}

/// Sets progress value in progress bar. Valid range is [0, 1.0].
///
/// @platforms macos
Future<void> setProgressBar(double progress) async {
final Map<String, dynamic> arguments = {
'progress': progress,
};
await _channel.invokeMethod('setProgressBar', arguments);
}

/// Returns bool - Whether the window has a shadow.
/// Returns `bool` - Whether the window has a shadow.
///
/// @platforms macos
Future<bool> hasShadow() async {
return await _channel.invokeMethod('hasShadow');
}

/// Sets whether the window should have a shadow.
///
/// @platforms macos
Future<void> setHasShadow(bool hasShadow) async {
final Map<String, dynamic> arguments = {
'hasShadow': hasShadow,
};
await _channel.invokeMethod('setHasShadow', arguments);
}

/// Returns double - between 0.0 (fully transparent) and 1.0 (fully opaque). On Linux, always returns 1.
/// Returns `double` - between 0.0 (fully transparent) and 1.0 (fully opaque). On Linux, always returns 1.
///
/// @platforms macos,windows
Future<double> getOpacity() async {
return await _channel.invokeMethod('getOpacity');
}

/// Sets the opacity of the window.
///
/// @platforms macos,windows
Future<void> setOpacity(double opacity) async {
final Map<String, dynamic> arguments = {
'opacity': opacity,
};
await _channel.invokeMethod('setOpacity', arguments);
}

/// Starts a window drag based on the specified mouse-down event.
Future<void> startDragging() async {
await _channel.invokeMethod('startDragging');
}
Expand Down
2 changes: 1 addition & 1 deletion macos/window_manager.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
Pod::Spec.new do |s|
s.name = 'window_manager'
s.version = '0.1.2'
s.version = '0.1.4'
s.summary = 'A new flutter plugin project.'
s.description = <<-DESC
A new flutter plugin project.
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: window_manager
description: This plugin allows Flutter desktop apps to resizing and repositioning the window.
version: 0.1.3
version: 0.1.4
homepage: https://github.com/leanflutter/window_manager

environment:
Expand Down

0 comments on commit d78b0a3

Please sign in to comment.