Skip to content

Commit f624f7c

Browse files
initial macos implementation
1 parent 2a94a74 commit f624f7c

File tree

163 files changed

+12588
-56
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+12588
-56
lines changed

Diff for: .metadata

+31-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,39 @@
11
# This file tracks properties of this Flutter project.
22
# Used by Flutter tool to assess capabilities and perform upgrades etc.
33
#
4-
# This file should be version controlled and should not be manually edited.
4+
# This file should be version controlled.
55

66
version:
7-
revision: c860cba910319332564e1e9d470a17074c1f2dfd
7+
revision: 18a827f3933c19f51862dde3fa472197683249d6
88
channel: stable
99

1010
project_type: plugin
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: 18a827f3933c19f51862dde3fa472197683249d6
17+
base_revision: 18a827f3933c19f51862dde3fa472197683249d6
18+
- platform: android
19+
create_revision: 18a827f3933c19f51862dde3fa472197683249d6
20+
base_revision: 18a827f3933c19f51862dde3fa472197683249d6
21+
- platform: ios
22+
create_revision: 18a827f3933c19f51862dde3fa472197683249d6
23+
base_revision: 18a827f3933c19f51862dde3fa472197683249d6
24+
- platform: macos
25+
create_revision: 18a827f3933c19f51862dde3fa472197683249d6
26+
base_revision: 18a827f3933c19f51862dde3fa472197683249d6
27+
- platform: web
28+
create_revision: 18a827f3933c19f51862dde3fa472197683249d6
29+
base_revision: 18a827f3933c19f51862dde3fa472197683249d6
30+
31+
# User provided section
32+
33+
# List of Local paths (relative to this file) that should be
34+
# ignored by the migrate tool.
35+
#
36+
# Files that are not part of the templates will be ignored by default.
37+
unmanaged_files:
38+
- 'lib/main.dart'
39+
- 'ios/Runner.xcodeproj/project.pbxproj'

Diff for: example/lib/in_app_browser_example.screen.dart

+22-18
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'dart:async';
22
import 'dart:collection';
33
import 'dart:io';
44

5+
import 'package:flutter/foundation.dart';
56
import 'package:flutter/material.dart';
67
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
78

@@ -18,9 +19,7 @@ class MyInAppBrowser extends InAppBrowser {
1819
}
1920

2021
@override
21-
Future onLoadStart(url) async {
22-
23-
}
22+
Future onLoadStart(url) async {}
2423

2524
@override
2625
Future onLoadStop(url) async {
@@ -61,26 +60,30 @@ class InAppBrowserExampleScreen extends StatefulWidget {
6160
}
6261

6362
class _InAppBrowserExampleScreenState extends State<InAppBrowserExampleScreen> {
64-
late PullToRefreshController pullToRefreshController;
63+
PullToRefreshController? pullToRefreshController;
6564

6665
@override
6766
void initState() {
6867
super.initState();
6968

70-
pullToRefreshController = PullToRefreshController(
71-
settings: PullToRefreshSettings(
72-
color: Colors.black,
73-
),
74-
onRefresh: () async {
75-
if (Platform.isAndroid) {
76-
widget.browser.webViewController.reload();
77-
} else if (Platform.isIOS) {
78-
widget.browser.webViewController.loadUrl(
79-
urlRequest: URLRequest(
80-
url: await widget.browser.webViewController.getUrl()));
81-
}
82-
},
83-
);
69+
pullToRefreshController = kIsWeb ||
70+
![TargetPlatform.iOS, TargetPlatform.android]
71+
.contains(defaultTargetPlatform)
72+
? null
73+
: PullToRefreshController(
74+
settings: PullToRefreshSettings(
75+
color: Colors.black,
76+
),
77+
onRefresh: () async {
78+
if (Platform.isAndroid) {
79+
widget.browser.webViewController.reload();
80+
} else if (Platform.isIOS) {
81+
widget.browser.webViewController.loadUrl(
82+
urlRequest: URLRequest(
83+
url: await widget.browser.webViewController.getUrl()));
84+
}
85+
},
86+
);
8487
widget.browser.pullToRefreshController = pullToRefreshController;
8588
}
8689

@@ -103,6 +106,7 @@ class _InAppBrowserExampleScreenState extends State<InAppBrowserExampleScreen> {
103106
URLRequest(url: Uri.parse("https://flutter.dev")),
104107
settings: InAppBrowserClassSettings(
105108
browserSettings: InAppBrowserSettings(
109+
hidden: false,
106110
toolbarTopBackgroundColor: Colors.blue,
107111
presentationStyle: ModalPresentationStyle.POPOVER
108112
),

Diff for: example/lib/in_app_webiew_example.screen.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
6363
contextMenuItemClicked.title);
6464
});
6565

66-
pullToRefreshController = kIsWeb
66+
pullToRefreshController = kIsWeb || ![TargetPlatform.iOS, TargetPlatform.android].contains(defaultTargetPlatform)
6767
? null
6868
: PullToRefreshController(
6969
settings: PullToRefreshSettings(

Diff for: example/lib/main.dart

+58-10
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,65 @@ Future main() async {
3333
}
3434

3535
PointerInterceptor myDrawer({required BuildContext context}) {
36-
final children = [
36+
var children = [
3737
ListTile(
3838
title: Text('InAppWebView'),
3939
onTap: () {
4040
Navigator.pushReplacementNamed(context, '/');
4141
},
42-
)
42+
),
43+
ListTile(
44+
title: Text('InAppBrowser'),
45+
onTap: () {
46+
Navigator.pushReplacementNamed(context, '/InAppBrowser');
47+
},
48+
),
49+
ListTile(
50+
title: Text('ChromeSafariBrowser'),
51+
onTap: () {
52+
Navigator.pushReplacementNamed(context, '/ChromeSafariBrowser');
53+
},
54+
),
55+
ListTile(
56+
title: Text('WebAuthenticationSession'),
57+
onTap: () {
58+
Navigator.pushReplacementNamed(context, '/WebAuthenticationSession');
59+
},
60+
),
61+
ListTile(
62+
title: Text('HeadlessInAppWebView'),
63+
onTap: () {
64+
Navigator.pushReplacementNamed(context, '/HeadlessInAppWebView');
65+
},
66+
),
4367
];
44-
if (!kIsWeb) {
45-
children.addAll([
68+
if (kIsWeb) {
69+
children = [
4670
ListTile(
47-
title: Text('InAppBrowser'),
71+
title: Text('InAppWebView'),
4872
onTap: () {
49-
Navigator.pushReplacementNamed(context, '/InAppBrowser');
73+
Navigator.pushReplacementNamed(context, '/');
5074
},
51-
),
75+
)
76+
];
77+
} else if (defaultTargetPlatform == TargetPlatform.macOS) {
78+
children = [
79+
// ListTile(
80+
// title: Text('InAppWebView'),
81+
// onTap: () {
82+
// Navigator.pushReplacementNamed(context, '/');
83+
// },
84+
// ),
85+
// ListTile(
86+
// title: Text('InAppBrowser'),
87+
// onTap: () {
88+
// Navigator.pushReplacementNamed(context, '/InAppBrowser');
89+
// },
90+
// ),
5291
ListTile(
53-
title: Text('ChromeSafariBrowser'),
92+
title: Text('InAppBrowser'),
5493
onTap: () {
55-
Navigator.pushReplacementNamed(context, '/ChromeSafariBrowser');
94+
Navigator.pushReplacementNamed(context, '/');
5695
},
5796
),
5897
ListTile(
@@ -67,7 +106,7 @@ PointerInterceptor myDrawer({required BuildContext context}) {
67106
Navigator.pushReplacementNamed(context, '/HeadlessInAppWebView');
68107
},
69108
),
70-
]);
109+
];
71110
}
72111
return PointerInterceptor(
73112
child: Drawer(
@@ -110,6 +149,15 @@ class _MyAppState extends State<MyApp> {
110149
'/': (context) => InAppWebViewExampleScreen(),
111150
});
112151
}
152+
if (defaultTargetPlatform == TargetPlatform.macOS) {
153+
return MaterialApp(initialRoute: '/', routes: {
154+
// '/': (context) => InAppWebViewExampleScreen(),
155+
// '/InAppBrowser': (context) => InAppBrowserExampleScreen(),
156+
'/': (context) => InAppBrowserExampleScreen(),
157+
'/HeadlessInAppWebView': (context) => HeadlessInAppWebViewExampleScreen(),
158+
'/WebAuthenticationSession': (context) => WebAuthenticationSessionExampleScreen(),
159+
});
160+
}
113161
return MaterialApp(initialRoute: '/', routes: {
114162
'/': (context) => InAppWebViewExampleScreen(),
115163
'/InAppBrowser': (context) => InAppBrowserExampleScreen(),

Diff for: example/lib/web_authentication_session_example.screen.dart

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class _WebAuthenticationSessionExampleScreenState
4848
onPressed: () async {
4949
if (session == null &&
5050
!kIsWeb &&
51-
defaultTargetPlatform == TargetPlatform.iOS &&
51+
[TargetPlatform.iOS, TargetPlatform.macOS]
52+
.contains(defaultTargetPlatform) &&
5253
await WebAuthenticationSession.isAvailable()) {
5354
session = await WebAuthenticationSession.create(
5455
url: Uri.parse(

Diff for: example/macos/.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Flutter-related
2+
**/Flutter/ephemeral/
3+
**/Pods/
4+
5+
# Xcode-related
6+
**/dgph
7+
**/xcuserdata/

Diff for: example/macos/Flutter/Flutter-Debug.xcconfig

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2+
#include "ephemeral/Flutter-Generated.xcconfig"

Diff for: example/macos/Flutter/Flutter-Release.xcconfig

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2+
#include "ephemeral/Flutter-Generated.xcconfig"
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// Generated file. Do not edit.
3+
//
4+
5+
import FlutterMacOS
6+
import Foundation
7+
8+
import flutter_inappwebview
9+
import path_provider_macos
10+
import url_launcher_macos
11+
12+
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
13+
InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin"))
14+
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
15+
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
16+
}

Diff for: example/macos/Podfile

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
platform :osx, '10.11'
2+
3+
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
4+
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
5+
6+
project 'Runner', {
7+
'Debug' => :debug,
8+
'Profile' => :release,
9+
'Release' => :release,
10+
}
11+
12+
def flutter_root
13+
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
14+
unless File.exist?(generated_xcode_build_settings_path)
15+
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
16+
end
17+
18+
File.foreach(generated_xcode_build_settings_path) do |line|
19+
matches = line.match(/FLUTTER_ROOT\=(.*)/)
20+
return matches[1].strip if matches
21+
end
22+
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
23+
end
24+
25+
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
26+
27+
flutter_macos_podfile_setup
28+
29+
target 'Runner' do
30+
use_frameworks!
31+
use_modular_headers!
32+
33+
flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
34+
end
35+
36+
post_install do |installer|
37+
installer.pods_project.targets.each do |target|
38+
flutter_additional_macos_build_settings(target)
39+
end
40+
end

0 commit comments

Comments
 (0)