Skip to content

Commit d78b0a3

Browse files
committed
0.1.4
1 parent 6be06d4 commit d78b0a3

File tree

10 files changed

+675
-125
lines changed

10 files changed

+675
-125
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 0.1.4
2+
3+
- [macos & windows] Implemented getOpacity & setOpacity methods #37 #45
4+
- [macos] Implement setProgressBar method #40
5+
- [windows] Fix `focus`, `blur` event not responding
6+
- [windows] Implement `focus` & `blur` methods
7+
- [macos & windows] Implement getTitleBarHeight methods #34
8+
19
## 0.1.3
210

311
- [windows] #31 Optimize setTitleBarStyle method.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 LiJianying <[email protected]>
3+
Copyright (c) 2022 LiJianying <[email protected]>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README-ZH.md

Lines changed: 293 additions & 53 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 293 additions & 53 deletions
Large diffs are not rendered by default.

example/macos/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PODS:
22
- FlutterMacOS (1.0.0)
3-
- window_manager (0.1.2):
3+
- window_manager (0.1.4):
44
- FlutterMacOS
55

66
DEPENDENCIES:
@@ -15,7 +15,7 @@ EXTERNAL SOURCES:
1515

1616
SPEC CHECKSUMS:
1717
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
18-
window_manager: 8c227608c115dbd132510c023d3644274aaec8a8
18+
window_manager: 02776e5a599084cd4576e27a42dd5ec6f49132cf
1919

2020
PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c
2121

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ packages:
169169
path: ".."
170170
relative: true
171171
source: path
172-
version: "0.1.3"
172+
version: "0.1.4"
173173
sdks:
174174
dart: ">=2.14.0 <3.0.0"
175175
flutter: ">=1.20.0"

lib/src/window_listener.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,34 @@
11
abstract class WindowListener {
2+
/// Emitted when the window gains focus.
23
void onWindowFocus() {}
4+
5+
/// Emitted when the window loses focus.
36
void onWindowBlur() {}
7+
8+
/// Emitted when window is maximized.
49
void onWindowMaximize() {}
10+
11+
/// Emitted when the window exits from a maximized state.
512
void onWindowUnmaximize() {}
13+
14+
/// Emitted when the window is minimized.
615
void onWindowMinimize() {}
16+
17+
/// Emitted when the window is restored from a minimized state.
718
void onWindowRestore() {}
19+
20+
/// Emitted after the window has been resized.
821
void onWindowResize() {}
22+
23+
/// Emitted when the window is being moved to a new position.
924
void onWindowMove() {}
25+
26+
/// Emitted when the window enters a full-screen state.
1027
void onWindowEnterFullScreen() {}
28+
29+
/// Emitted when the window leaves a full-screen state.
1130
void onWindowLeaveFullScreen() {}
31+
32+
/// Emitted all events.
1233
void onWindowEvent(String eventName) {}
1334
}

lib/src/window_manager.dart

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const kWindowEventMove = 'move';
1717
const kWindowEventEnterFullScreen = 'enter-full-screen';
1818
const kWindowEventLeaveFullScreen = 'leave-full-screen';
1919

20+
// WindowManager
2021
class WindowManager {
2122
WindowManager._() {
2223
_channel.setMethodCallHandler(_methodCallHandler);
@@ -93,6 +94,8 @@ class WindowManager {
9394
}
9495

9596
/// Removes focus from the window.
97+
///
98+
/// @platforms macos,windows
9699
Future<void> blur({bool inactive = false}) async {
97100
await _channel.invokeMethod('blur');
98101
}
@@ -114,12 +117,12 @@ class WindowManager {
114117
await _channel.invokeMethod('hide');
115118
}
116119

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

122-
/// Returns bool - Whether the window is maximized.
125+
/// Returns `bool` - Whether the window is maximized.
123126
Future<bool> isMaximized() async {
124127
return await _channel.invokeMethod('isMaximized');
125128
}
@@ -134,7 +137,7 @@ class WindowManager {
134137
await _channel.invokeMethod('unmaximize');
135138
}
136139

137-
/// Returns bool - Whether the window is minimized.
140+
/// Returns `bool` - Whether the window is minimized.
138141
Future<bool> isMinimized() async {
139142
return await _channel.invokeMethod('isMinimized');
140143
}
@@ -149,7 +152,7 @@ class WindowManager {
149152
await _channel.invokeMethod('restore');
150153
}
151154

152-
/// Returns bool - Whether the window is in fullscreen mode.
155+
/// Returns `bool` - Whether the window is in fullscreen mode.
153156
Future<bool> isFullScreen() async {
154157
return await _channel.invokeMethod('isFullScreen');
155158
}
@@ -173,7 +176,7 @@ class WindowManager {
173176
await _channel.invokeMethod('setBackgroundColor', arguments);
174177
}
175178

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

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

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

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

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

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

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

259+
/// Sets whether the window can be manually resized by the user.
253260
setResizable(isResizable) {
254261
final Map<String, dynamic> arguments = {
255262
'isResizable': isResizable,
256263
};
257264
_channel.invokeMethod('setResizable', arguments);
258265
}
259266

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

274+
/// Sets whether the window can be moved by user.
275+
///
276+
/// @platforms macos
264277
setMovable(isMovable) {
265278
final Map<String, dynamic> arguments = {
266279
'isMovable': isMovable,
267280
};
268281
_channel.invokeMethod('setMovable', arguments);
269282
}
270283

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

291+
/// Sets whether the window can be manually minimized by user.
292+
///
293+
/// @platforms macos,windows
275294
setMinimizable(isMinimizable) {
276295
final Map<String, dynamic> arguments = {
277296
'isMinimizable': isMinimizable,
278297
};
279298
_channel.invokeMethod('setMinimizable', arguments);
280299
}
281300

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

308+
/// Sets whether the window can be manually closed by user.
309+
///
310+
/// @platforms macos,windows
286311
Future<void> setClosable(bool isClosable) async {
287312
final Map<String, dynamic> arguments = {
288313
'isClosable': isClosable,
289314
};
290315
await _channel.invokeMethod('setClosable', arguments);
291316
}
292317

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

298-
/// 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.
323+
/// Sets whether the window should show always on top of other windows.
299324
Future<void> setAlwaysOnTop(bool isAlwaysOnTop) async {
300325
final Map<String, dynamic> arguments = {
301326
'isAlwaysOnTop': isAlwaysOnTop,
302327
};
303328
await _channel.invokeMethod('setAlwaysOnTop', arguments);
304329
}
305330

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

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

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

343373
/// Sets progress value in progress bar. Valid range is [0, 1.0].
374+
///
375+
/// @platforms macos
344376
Future<void> setProgressBar(double progress) async {
345377
final Map<String, dynamic> arguments = {
346378
'progress': progress,
347379
};
348380
await _channel.invokeMethod('setProgressBar', arguments);
349381
}
350382

351-
/// Returns bool - Whether the window has a shadow.
383+
/// Returns `bool` - Whether the window has a shadow.
384+
///
385+
/// @platforms macos
352386
Future<bool> hasShadow() async {
353387
return await _channel.invokeMethod('hasShadow');
354388
}
355389

356390
/// Sets whether the window should have a shadow.
391+
///
392+
/// @platforms macos
357393
Future<void> setHasShadow(bool hasShadow) async {
358394
final Map<String, dynamic> arguments = {
359395
'hasShadow': hasShadow,
360396
};
361397
await _channel.invokeMethod('setHasShadow', arguments);
362398
}
363399

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

369407
/// Sets the opacity of the window.
408+
///
409+
/// @platforms macos,windows
370410
Future<void> setOpacity(double opacity) async {
371411
final Map<String, dynamic> arguments = {
372412
'opacity': opacity,
373413
};
374414
await _channel.invokeMethod('setOpacity', arguments);
375415
}
376416

417+
/// Starts a window drag based on the specified mouse-down event.
377418
Future<void> startDragging() async {
378419
await _channel.invokeMethod('startDragging');
379420
}

macos/window_manager.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
Pod::Spec.new do |s|
66
s.name = 'window_manager'
7-
s.version = '0.1.2'
7+
s.version = '0.1.4'
88
s.summary = 'A new flutter plugin project.'
99
s.description = <<-DESC
1010
A new flutter plugin project.

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: window_manager
22
description: This plugin allows Flutter desktop apps to resizing and repositioning the window.
3-
version: 0.1.3
3+
version: 0.1.4
44
homepage: https://github.com/leanflutter/window_manager
55

66
environment:

0 commit comments

Comments
 (0)