Skip to content

Commit a630418

Browse files
committed
Support for macos!
1 parent 110e31e commit a630418

File tree

21 files changed

+296
-21
lines changed

21 files changed

+296
-21
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
*.swp
66
.DS_Store
77
.atom/
8+
.build/
89
.buildlog/
910
.history
1011
.svn/
12+
.swiftpm/
1113
migrate_working_dir/
1214

1315
# IntelliJ related

ios/Flutter/Debug.xcconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
12
#include "Generated.xcconfig"

ios/Flutter/Release.xcconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
12
#include "Generated.xcconfig"

ios/Podfile

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

lib/bloc.dart

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ class AppBloc with AppSystemTray {
7777

7878
void onAddLeakItemClick() async {
7979
if (_leakInput == null || _leakInput?.trim().isEmpty == true) {
80-
WinToast.instance().showToast(type: ToastType.text01, title: 'No input entered!');
80+
_showToast('No input entered!');
8181
return;
8282
}
8383
if ((await AppSharedPreferences.leakChecklist).contains(_leakInput)) {
84-
WinToast.instance().showToast(type: ToastType.text01, title: 'Repetitive input not allowed!');
84+
_showToast('Repetitive input not allowed!');
8585
return;
8686
}
8787
await AppSharedPreferences.addToLeakChecklist(_leakInput!);
@@ -224,6 +224,10 @@ class AppBloc with AppSystemTray {
224224
}
225225

226226
Future<void> _checkProxySettings() async {
227+
if (Platform.isMacOS) {
228+
// todo: implement macOS
229+
return;
230+
}
227231
final localNetwork = await AppCmd.getLocalNetworkInfo();
228232
_localNetwork.value = localNetwork;
229233
final proxyResult = await AppCmd.getProxySettings();
@@ -259,12 +263,20 @@ class AppBloc with AppSystemTray {
259263
}
260264

261265
if (remaining < 1073741824 && lowBalanceToastCount < 2) {
262-
WinToast.instance().showToast(type: ToastType.text01, title: 'Less than 1 GB is left in your kerio account!');
266+
_showToast('Less than 1 GB is left in your kerio account!');
263267
await AppSharedPreferences.setKerioLowBalanceToastCount(lowBalanceToastCount + 1);
264268
await AppSharedPreferences.setKerioLowBalanceToastDate(today.toIso8601String());
265269
}
266270
}
267271

272+
void _showToast(String title) {
273+
if (Platform.isMacOS) {
274+
// todo: implement macOS
275+
return;
276+
}
277+
WinToast.instance().showToast(type: ToastType.text01, title: title);
278+
}
279+
268280
void _checkNetworkConnectivity() async {
269281
final result = await (Connectivity().checkConnectivity());
270282
if (result == ConnectivityResult.none) {

lib/main.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ Future<void> initSingleInstance() async {
4040
}
4141

4242
Future<void> initWinToast() async {
43+
if (Platform.isMacOS) {
44+
// todo: implement macos
45+
return Future.value();
46+
}
4347
await WinToast.instance().initialize(
4448
appName: 'IRNet',
4549
productName: 'IRNet',

lib/utils/system_tray.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ mixin AppSystemTray {
3030

3131
Future<void> initSystemTray() async {
3232
await _systemTray.initSystemTray(
33-
title: "system tray",
33+
title: null,
3434
iconPath: 'assets/loading.ico',
3535
);
3636
final Menu menu = Menu();

lib/views/kerio_login.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ class _KerioLoginViewState extends State<KerioLoginView> {
246246
final value = snapshot.data ?? false;
247247
return CheckboxListTile(
248248
title: const Text('Auto?'),
249+
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
249250
value: value,
250251
onChanged: (enabled) async {
251252
await AppSharedPreferences.setKerioAutoLogin(enabled ?? false);

lib/views/options.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:io';
2+
13
import 'package:flutter/material.dart';
24
import 'package:launch_at_startup/launch_at_startup.dart';
35

@@ -32,7 +34,9 @@ class _AppOptionsState extends State<AppOptions> {
3234
final value = snapshot.data ?? false;
3335
return CheckboxListTile(
3436
title: const Text('Launch on windows startup?'),
37+
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
3538
value: value,
39+
enabled: !Platform.isMacOS, // todo: implement macos
3640
onChanged: (enabled) {
3741
if (enabled == true) {
3842
LaunchAtStartup.instance.enable();
@@ -53,6 +57,7 @@ class _AppOptionsState extends State<AppOptions> {
5357
final value = snapshot.data ?? false;
5458
return CheckboxListTile(
5559
title: const Text('Show leak detection on system tray icon?'),
60+
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
5661
value: value,
5762
onChanged: (enabled) async {
5863
await AppSharedPreferences.setShowLeakInSysTray(enabled ?? false);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
12
#include "ephemeral/Flutter-Generated.xcconfig"

0 commit comments

Comments
 (0)