Skip to content

Commit 0ffd6d3

Browse files
committed
wip: Add window_manager_macos package
1 parent 29f494a commit 0ffd6d3

14 files changed

+303
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
26+
/pubspec.lock
27+
**/doc/api/
28+
.dart_tool/
29+
build/
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: "2663184aa79047d0a33a14a3b607954f8fdd8730"
8+
channel: "stable"
9+
10+
project_type: plugin
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
17+
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
18+
- platform: macos
19+
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
20+
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
21+
22+
# User provided section
23+
24+
# List of Local paths (relative to this file) that should be
25+
# ignored by the migrate tool.
26+
#
27+
# Files that are not part of the templates will be ignored by default.
28+
unmanaged_files:
29+
- 'lib/main.dart'
30+
- 'ios/Runner.xcodeproj/project.pbxproj'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.0.1
2+
3+
* TODO: Describe initial release.

packages/window_manager_macos/LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TODO: Add your license here.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# window_manager_macos
2+
3+
A new Flutter plugin project.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter
8+
[plug-in package](https://flutter.dev/to/develop-plugins),
9+
a specialized package that includes platform-specific implementation code for
10+
Android and/or iOS.
11+
12+
For help getting started with Flutter development, view the
13+
[online documentation](https://docs.flutter.dev), which offers tutorials,
14+
samples, guidance on mobile development, and a full API reference.
15+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include: package:flutter_lints/flutter.yaml
2+
3+
# Additional information about this file can be found at
4+
# https://dart.dev/guides/language/analysis-options
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
import 'window_manager_macos_platform_interface.dart';
3+
4+
class WindowManagerMacos {
5+
Future<String?> getPlatformVersion() {
6+
return WindowManagerMacosPlatform.instance.getPlatformVersion();
7+
}
8+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import 'package:flutter/foundation.dart';
2+
import 'package:flutter/services.dart';
3+
4+
import 'window_manager_macos_platform_interface.dart';
5+
6+
/// An implementation of [WindowManagerMacosPlatform] that uses method channels.
7+
class MethodChannelWindowManagerMacos extends WindowManagerMacosPlatform {
8+
/// The method channel used to interact with the native platform.
9+
@visibleForTesting
10+
final methodChannel = const MethodChannel('window_manager_macos');
11+
12+
@override
13+
Future<String?> getPlatformVersion() async {
14+
final version = await methodChannel.invokeMethod<String>('getPlatformVersion');
15+
return version;
16+
}
17+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
2+
3+
import 'window_manager_macos_method_channel.dart';
4+
5+
abstract class WindowManagerMacosPlatform extends PlatformInterface {
6+
/// Constructs a WindowManagerMacosPlatform.
7+
WindowManagerMacosPlatform() : super(token: _token);
8+
9+
static final Object _token = Object();
10+
11+
static WindowManagerMacosPlatform _instance = MethodChannelWindowManagerMacos();
12+
13+
/// The default instance of [WindowManagerMacosPlatform] to use.
14+
///
15+
/// Defaults to [MethodChannelWindowManagerMacos].
16+
static WindowManagerMacosPlatform get instance => _instance;
17+
18+
/// Platform-specific implementations should set this with their own
19+
/// platform-specific class that extends [WindowManagerMacosPlatform] when
20+
/// they register themselves.
21+
static set instance(WindowManagerMacosPlatform instance) {
22+
PlatformInterface.verifyToken(instance, _token);
23+
_instance = instance;
24+
}
25+
26+
Future<String?> getPlatformVersion() {
27+
throw UnimplementedError('platformVersion() has not been implemented.');
28+
}
29+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Cocoa
2+
import FlutterMacOS
3+
4+
public class WindowManagerMacosPlugin: NSObject, FlutterPlugin {
5+
public static func register(with registrar: FlutterPluginRegistrar) {
6+
let channel = FlutterMethodChannel(name: "window_manager_macos", binaryMessenger: registrar.messenger)
7+
let instance = WindowManagerMacosPlugin()
8+
registrar.addMethodCallDelegate(instance, channel: channel)
9+
}
10+
11+
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
12+
switch call.method {
13+
case "getPlatformVersion":
14+
result("macOS " + ProcessInfo.processInfo.operatingSystemVersionString)
15+
default:
16+
result(FlutterMethodNotImplemented)
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)