opt & fix

- update make script (taget mac)
- only set system overlay once
This commit is contained in:
Junyuan Feng
2022-05-19 16:06:12 +08:00
parent 36d7dc7bb2
commit 0533766c1c
13 changed files with 72 additions and 57 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -49,4 +49,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
COCOAPODS: 1.11.2 COCOAPODS: 1.11.3

View File

@@ -354,7 +354,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 135; CURRENT_PROJECT_VERSION = 136;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
@@ -362,7 +362,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.135; MARKETING_VERSION = 1.0.136;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -484,7 +484,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 135; CURRENT_PROJECT_VERSION = 136;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
@@ -492,7 +492,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.135; MARKETING_VERSION = 1.0.136;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -508,7 +508,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 135; CURRENT_PROJECT_VERSION = 136;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
@@ -516,7 +516,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.135; MARKETING_VERSION = 1.0.136;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:toolbox/core/utils.dart';
import 'package:toolbox/data/res/build_data.dart'; import 'package:toolbox/data/res/build_data.dart';
import 'package:toolbox/data/store/setting.dart'; import 'package:toolbox/data/store/setting.dart';
import 'package:toolbox/generated/l10n.dart'; import 'package:toolbox/generated/l10n.dart';
@@ -26,6 +27,7 @@ class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
setTransparentNavigationBar(context);
return ValueListenableBuilder<int>( return ValueListenableBuilder<int>(
valueListenable: locator<SettingStore>().primaryColor.listenable(), valueListenable: locator<SettingStore>().primaryColor.listenable(),
builder: (_, value, __) { builder: (_, value, __) {

View File

@@ -75,13 +75,9 @@ Widget buildSwitch(BuildContext context, StoreProperty<bool> prop,
void setTransparentNavigationBar(BuildContext context) { void setTransparentNavigationBar(BuildContext context) {
if (Platform.isAndroid) { if (Platform.isAndroid) {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
statusBarColor: Colors.transparent, systemNavigationBarColor: Colors.transparent,
systemNavigationBarColor: Colors.transparent, systemNavigationBarContrastEnforced: true));
systemNavigationBarContrastEnforced: true,
systemNavigationBarIconBrightness:
isDarkMode(context) ? Brightness.light : Brightness.dark,
));
} }
} }

View File

@@ -2,9 +2,9 @@
class BuildData { class BuildData {
static const String name = "ServerBox"; static const String name = "ServerBox";
static const int build = 135; static const int build = 136;
static const String engine = static const String engine =
"Flutter 3.0.0 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision ee4e09cce0 (3 days ago) • 2022-05-09 16:45:18 -0700\nEngine • revision d1b9a6938a\nTools • Dart 2.17.0 • DevTools 2.12.2\n"; "Flutter 3.0.0 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision ee4e09cce0 (9 days ago) • 2022-05-09 16:45:18 -0700\nEngine • revision d1b9a6938a\nTools • Dart 2.17.0 • DevTools 2.12.2\n";
static const String buildAt = "2022-05-13 09:32:15.654170"; static const String buildAt = "2022-05-19 15:59:10.728748";
static const int modifications = 15; static const int modifications = 15;
} }

View File

@@ -86,7 +86,6 @@ class _MyHomePageState extends State<MyHomePage>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
setTransparentNavigationBar(context);
super.build(context); super.build(context);
return WillPopScope( return WillPopScope(
child: _buildMain(context), child: _buildMain(context),

View File

@@ -31,4 +31,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c
COCOAPODS: 1.11.2 COCOAPODS: 1.11.3

View File

@@ -420,14 +420,14 @@
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 79; CURRENT_PROJECT_VERSION = 136;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MARKETING_VERSION = 1.0.79; MARKETING_VERSION = 1.0.136;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
@@ -550,14 +550,14 @@
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 79; CURRENT_PROJECT_VERSION = 136;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MARKETING_VERSION = 1.0.79; MARKETING_VERSION = 1.0.136;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -574,14 +574,14 @@
CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 79; CURRENT_PROJECT_VERSION = 136;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MARKETING_VERSION = 1.0.79; MARKETING_VERSION = 1.0.136;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;

View File

@@ -6,11 +6,21 @@ import 'dart:io';
const appName = 'ServerBox'; const appName = 'ServerBox';
const buildDataFilePath = 'lib/data/res/build_data.dart'; const buildDataFilePath = 'lib/data/res/build_data.dart';
const apkPath = 'build/app/outputs/flutter-apk/app-release.apk';
const xcarchivePath = 'build/ios/archive/Runner.xcarchive'; const xcarchivePath = 'build/ios/archive/Runner.xcarchive';
const macosAppPath = 'build/macos/Build/Products/Release/$appName.app';
var regiOSProjectVer = RegExp(r'CURRENT_PROJECT_VERSION = .+;'); var regiOSProjectVer = RegExp(r'CURRENT_PROJECT_VERSION = .+;');
var regiOSMarketVer = RegExp(r'MARKETING_VERSION = .+'); var regiOSMarketVer = RegExp(r'MARKETING_VERSION = .+');
const iOSInfoPlistPath = 'ios/Runner.xcodeproj/project.pbxproj';
const macOSInfoPlistPath = 'macos/Runner.xcodeproj/project.pbxproj';
const skslFileSuffix = '.sksl.json'; const skslFileSuffix = '.sksl.json';
const buildFuncs = {
'ios': flutterBuildIOS,
'macos': flutterBuildMacOS,
'android': flutterBuildAndroid,
};
int? build; int? build;
Future<int> getGitCommitCount() async { Future<int> getGitCommitCount() async {
@@ -87,16 +97,25 @@ void flutterRun(String? mode) {
mode: ProcessStartMode.inheritStdio, runInShell: true); mode: ProcessStartMode.inheritStdio, runInShell: true);
} }
Future<void> flutterBuild(String source, String target, bool isAndroid) async { Future<void> flutterBuild(
String source, String target, String buildType) async {
final args = [ final args = [
'build', 'build',
isAndroid ? 'apk' : 'ipa', buildType,
'--target-platform=android-arm64',
'--build-number=$build',
'--build-name=1.0.$build',
'--bundle-sksl-path=${isAndroid ? 'android' : 'ios'}$skslFileSuffix',
]; ];
if (!isAndroid) args.removeAt(2); // No sksl cache for macos
if ('macos' != buildType) {
args.add('--bundle-sksl-path=$buildType$skslFileSuffix');
}
final isAndroid = 'apk' == buildType;
// [--target-platform] only for Android
if (isAndroid) {
args.addAll([
'--target-platform=android-arm64',
'--build-number=$build',
'--build-name=1.0.$build',
]);
}
print('Building with args: ${args.join(' ')}'); print('Building with args: ${args.join(' ')}');
final buildResult = await Process.run('flutter', args, runInShell: true); final buildResult = await Process.run('flutter', args, runInShell: true);
final exitCode = buildResult.exitCode; final exitCode = buildResult.exitCode;
@@ -123,23 +142,30 @@ Future<void> flutterBuild(String source, String target, bool isAndroid) async {
} }
Future<void> flutterBuildIOS() async { Future<void> flutterBuildIOS() async {
await changeiOSVersion(); await changeInfoPlistVersion();
await flutterBuild( await flutterBuild(
xcarchivePath, './release/${appName}_build.xcarchive', false); xcarchivePath, './release/${appName}_ios_build.xcarchive', 'ipa');
}
Future<void> flutterBuildMacOS() async {
await changeInfoPlistVersion();
await flutterBuild(
macosAppPath, './release/${appName}_macos_build.app', 'macos');
} }
Future<void> flutterBuildAndroid() async { Future<void> flutterBuildAndroid() async {
await flutterBuild('./build/app/outputs/flutter-apk/app-release.apk', await flutterBuild(apkPath, './release/${appName}_build_Arm64.apk', 'apk');
'./release/${appName}_build_Arm64.apk', true);
} }
Future<void> changeiOSVersion() async { Future<void> changeInfoPlistVersion() async {
final file = File('ios/Runner.xcodeproj/project.pbxproj'); for (final path in [iOSInfoPlistPath, macOSInfoPlistPath]) {
final contents = await file.readAsString(); final file = File(path);
final newContents = contents final contents = await file.readAsString();
.replaceAll(regiOSMarketVer, 'MARKETING_VERSION = 1.0.$build;') final newContents = contents
.replaceAll(regiOSProjectVer, 'CURRENT_PROJECT_VERSION = $build;'); .replaceAll(regiOSMarketVer, 'MARKETING_VERSION = 1.0.$build;')
await file.writeAsString(newContents); .replaceAll(regiOSProjectVer, 'CURRENT_PROJECT_VERSION = $build;');
await file.writeAsString(newContents);
}
} }
void main(List<String> args) async { void main(List<String> args) async {
@@ -155,25 +181,19 @@ void main(List<String> args) async {
return flutterRun(args.length == 2 ? args[1] : null); return flutterRun(args.length == 2 ? args[1] : null);
case 'build': case 'build':
final stopwatch = Stopwatch()..start(); final stopwatch = Stopwatch()..start();
final buildFunc = [flutterBuildIOS, flutterBuildAndroid];
build = await getGitCommitCount(); build = await getGitCommitCount();
await updateBuildData(); await updateBuildData();
await dartFormat(); await dartFormat();
if (args.length > 1) { if (args.length > 1) {
final platform = args[1]; final platform = args[1];
switch (platform) { if (buildFuncs.keys.contains(platform)) {
case 'ios': await buildFuncs[platform]!();
buildFunc.remove(flutterBuildAndroid); } else {
break; print('Unknown platform: $platform');
case 'android':
buildFunc.remove(flutterBuildIOS);
break;
default:
print('Unknown platform: $platform');
exit(1);
} }
return;
} }
for (final func in buildFunc) { for (final func in buildFuncs.values) {
await func(); await func();
} }
print('Build finished in ${stopwatch.elapsed}'); print('Build finished in ${stopwatch.elapsed}');