Skip to content

Commit

Permalink
chore: Update DockSide enum
Browse files Browse the repository at this point in the history
  • Loading branch information
lijy91 committed Jul 1, 2023
1 parent de6d072 commit 854ea08
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions example/lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -255,19 +255,19 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
accessoryView: Row(
children: [
CupertinoButton(
child: const Text('LEFT'),
child: const Text('dock left'),
onPressed: () async {
windowManager.dock(side: DockSide.LEFT, width: 500);
windowManager.dock(side: DockSide.left, width: 500);
},
),
CupertinoButton(
child: const Text('RIGHT'),
child: const Text('dock right'),
onPressed: () async {
windowManager.dock(side: DockSide.RIGHT, width: 500);
windowManager.dock(side: DockSide.right, width: 500);
},
),
CupertinoButton(
child: const Text('UNDOCK'),
child: const Text('undock'),
onPressed: () async {
windowManager.undock();
},
Expand Down
10 changes: 5 additions & 5 deletions lib/src/window_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const kWindowEventLeaveFullScreen = 'leave-full-screen';
const kWindowEventDocked = 'docked';
const kWindowEventUndocked = 'undocked';

enum DockSide { LEFT, RIGHT }
enum DockSide { left, right }

// WindowManager
class WindowManager {
Expand Down Expand Up @@ -277,16 +277,16 @@ class WindowManager {
Future<DockSide?> isDocked() async {
int? docked = await _channel.invokeMethod('isDocked');
if (docked == 0) return null;
if (docked == 1) return DockSide.LEFT;
if (docked == 2) return DockSide.RIGHT;
if (docked == 1) return DockSide.left;
if (docked == 2) return DockSide.right;
return null;
}

/// Docks the window. only works on Windows
Future<void> dock({required DockSide side, required int width}) async {
final Map<String, dynamic> arguments = {
'left': side == DockSide.LEFT,
'right': side == DockSide.RIGHT,
'left': side == DockSide.left,
'right': side == DockSide.right,
'width': width,
};
await _channel.invokeMethod('dock', arguments);
Expand Down

0 comments on commit 854ea08

Please sign in to comment.