Skip to content

Commit

Permalink
feat: support x86 macos
Browse files Browse the repository at this point in the history
  • Loading branch information
suyulin committed Jan 6, 2024
1 parent 39d6fb1 commit e8e2a0b
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 99 deletions.
Binary file modified bin/afptool-rs
Binary file not shown.
16 changes: 14 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:macos_ui/macos_ui.dart';
import 'package:provider/provider.dart';
import 'package:rkflashtool_ui/pages/buttons_page.dart';

import 'theme.dart';

Future<void> _configureMacosWindowUtils() async {
const config = MacosWindowUtilsConfig();
await config.apply();
}
Future<void> main() async {
if (!kIsWeb) {
if (Platform.isMacOS) {
await _configureMacosWindowUtils();
}
}
runApp(const MacosUIGalleryApp());
}

Expand All @@ -22,7 +33,7 @@ class MacosUIGalleryApp extends StatelessWidget {
return MacosApp(
title: 'RK Flash Tool ',
theme: MacosThemeData.light(),
darkTheme: MacosThemeData.dark(),
// darkTheme: MacosThemeData.dark(),
themeMode: appTheme.mode,
debugShowCheckedModeBanner: false,
home: const WidgetGallery(),
Expand Down Expand Up @@ -60,6 +71,7 @@ class _WidgetGalleryState extends State<WidgetGallery> {
return PlatformMenuBar(
menus: [],
child: MacosWindow(
backgroundColor: const Color.fromARGB(1, 255, 255, 255),
endSidebar: Sidebar(
startWidth: 200,
minWidth: 200,
Expand Down
9 changes: 6 additions & 3 deletions lib/pages/buttons_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,11 @@ class _ButtonsPageState extends State<ButtonsPage> {
@override
Widget build(BuildContext context) {
return MacosScaffold(
backgroundColor: const Color.fromARGB(1, 255, 255, 255),

children: [
ContentArea(

builder: (context, scrollController) {
return Column(
children: [
Expand All @@ -306,16 +309,16 @@ class _ButtonsPageState extends State<ButtonsPage> {
Padding(
padding: const EdgeInsets.all(8.0),
child: PushButton(
buttonSize: ButtonSize.large,
onPressed:
isLoading ? null : unPackFirmwareHandle,
controlSize: ControlSize.large,
child: const Text('固件'),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: PushButton(
buttonSize: ButtonSize.large,
controlSize: ControlSize.large,
onPressed:
isLoading ? null : updateFirmwareHandle,
child: const Text('升级'),
Expand All @@ -324,7 +327,7 @@ class _ButtonsPageState extends State<ButtonsPage> {
Padding(
padding: const EdgeInsets.all(8.0),
child: PushButton(
buttonSize: ButtonSize.large,
controlSize: ControlSize.large,
onPressed:
isLoading ? null : changeDeviceStatusHandle,
child: const Text('切换'),
Expand Down
4 changes: 4 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
import FlutterMacOS
import Foundation

import appkit_ui_element_colors
import macos_ui
import macos_window_utils
import path_provider_foundation

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AppkitUiElementColorsPlugin.register(with: registry.registrar(forPlugin: "AppkitUiElementColorsPlugin"))
MacOSUiPlugin.register(with: registry.registrar(forPlugin: "MacOSUiPlugin"))
MacOSWindowUtilsPlugin.register(with: registry.registrar(forPlugin: "MacOSWindowUtilsPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
}
8 changes: 7 additions & 1 deletion macos/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
platform :osx, '10.14'
platform :osx, '11.2'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down Expand Up @@ -38,6 +38,12 @@ end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
xcconfig_path = config.base_configuration_reference.real_path
xcconfig = File.read(xcconfig_path)
xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
end
flutter_additional_macos_build_settings(target)
end
end
22 changes: 17 additions & 5 deletions macos/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,29 +1,41 @@
PODS:
- appkit_ui_element_colors (1.0.0):
- FlutterMacOS
- FlutterMacOS (1.0.0)
- macos_ui (0.1.0):
- FlutterMacOS
- macos_window_utils (1.0.0):
- FlutterMacOS
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS

DEPENDENCIES:
- appkit_ui_element_colors (from `Flutter/ephemeral/.symlinks/plugins/appkit_ui_element_colors/macos`)
- FlutterMacOS (from `Flutter/ephemeral`)
- macos_ui (from `Flutter/ephemeral/.symlinks/plugins/macos_ui/macos`)
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/macos`)
- macos_window_utils (from `Flutter/ephemeral/.symlinks/plugins/macos_window_utils/macos`)
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)

EXTERNAL SOURCES:
appkit_ui_element_colors:
:path: Flutter/ephemeral/.symlinks/plugins/appkit_ui_element_colors/macos
FlutterMacOS:
:path: Flutter/ephemeral
macos_ui:
:path: Flutter/ephemeral/.symlinks/plugins/macos_ui/macos
macos_window_utils:
:path: Flutter/ephemeral/.symlinks/plugins/macos_window_utils/macos
path_provider_foundation:
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/macos
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin

SPEC CHECKSUMS:
appkit_ui_element_colors: 39bb2d80be3f19b152ccf4c70d5bbe6cba43d74a
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
macos_ui: 6229a8922cd97bafb7d9636c8eb8dfb0744183ca
path_provider_foundation: eaf5b3e458fc0e5fbb9940fb09980e853fe058b8
macos_window_utils: 933f91f64805e2eb91a5bd057cf97cd097276663
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943

PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367
PODFILE CHECKSUM: 473617a8680597afae85a9a9dd66005925bad542

COCOAPODS: 1.11.3
COCOAPODS: 1.14.3
17 changes: 10 additions & 7 deletions macos/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C80D4294CF70F00263BE5 = {
Expand Down Expand Up @@ -565,7 +565,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = Z22N3LP85N;
DEVELOPMENT_TEAM = 3288K5LX9E;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "rk-flashtool";
Expand All @@ -574,7 +574,8 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.orvibo.fe.rkflashtool-ui";
MACOSX_DEPLOYMENT_TARGET = 11.2;
PRODUCT_BUNDLE_IDENTIFIER = "com.orvibo.fe.rkflashtool-uii";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
};
Expand Down Expand Up @@ -699,7 +700,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = Z22N3LP85N;
DEVELOPMENT_TEAM = 3288K5LX9E;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "rk-flashtool";
Expand All @@ -708,7 +709,8 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.orvibo.fe.rkflashtool-ui";
MACOSX_DEPLOYMENT_TARGET = 11.2;
PRODUCT_BUNDLE_IDENTIFIER = "com.orvibo.fe.rkflashtool-uii";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
Expand All @@ -727,7 +729,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = Z22N3LP85N;
DEVELOPMENT_TEAM = 3288K5LX9E;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "rk-flashtool";
Expand All @@ -736,7 +738,8 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.orvibo.fe.rkflashtool-ui";
MACOSX_DEPLOYMENT_TARGET = 11.2;
PRODUCT_BUNDLE_IDENTIFIER = "com.orvibo.fe.rkflashtool-uii";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 2 additions & 2 deletions macos/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.business</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
Expand All @@ -28,7 +30,5 @@
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.business</string>
</dict>
</plist>
Loading

0 comments on commit e8e2a0b

Please sign in to comment.