diff --git a/packages/flutter/lib/src/cupertino/dialog.dart b/packages/flutter/lib/src/cupertino/dialog.dart index 0a7286bb70..6551bc95b3 100644 --- a/packages/flutter/lib/src/cupertino/dialog.dart +++ b/packages/flutter/lib/src/cupertino/dialog.dart @@ -23,7 +23,7 @@ import 'theme.dart'; // Apple Design Resources(https://developer.apple.com/design/resources/). // However the values are not exactly the same as native, so eyeballing is needed. const TextStyle _kCupertinoDialogTitleStyle = TextStyle( - fontFamily: '.SF UI Display', + fontFamily: 'PingFang SC', inherit: false, fontSize: 17.0, fontWeight: FontWeight.w600, @@ -33,7 +33,7 @@ const TextStyle _kCupertinoDialogTitleStyle = TextStyle( ); const TextStyle _kCupertinoDialogContentStyle = TextStyle( - fontFamily: '.SF UI Text', + fontFamily: 'PingFang SC', inherit: false, fontSize: 13.0, fontWeight: FontWeight.w400, @@ -43,7 +43,7 @@ const TextStyle _kCupertinoDialogContentStyle = TextStyle( ); const TextStyle _kCupertinoDialogActionStyle = TextStyle( - fontFamily: '.SF UI Text', + fontFamily: 'PingFang SC', inherit: false, fontSize: 16.8, fontWeight: FontWeight.w400, @@ -52,7 +52,7 @@ const TextStyle _kCupertinoDialogActionStyle = TextStyle( // CupertinoActionSheet-specific text styles. const TextStyle _kActionSheetActionStyle = TextStyle( - fontFamily: '.SF UI Text', + fontFamily: 'PingFang SC', inherit: false, fontSize: 20.0, fontWeight: FontWeight.w400, @@ -60,7 +60,7 @@ const TextStyle _kActionSheetActionStyle = TextStyle( ); const TextStyle _kActionSheetContentStyle = TextStyle( - fontFamily: '.SF UI Text', + fontFamily: 'PingFang SC', inherit: false, fontSize: 13.0, fontWeight: FontWeight.w400, diff --git a/packages/flutter/lib/src/cupertino/text_theme.dart b/packages/flutter/lib/src/cupertino/text_theme.dart index 2ea7fecb0d..8b09b31d35 100644 --- a/packages/flutter/lib/src/cupertino/text_theme.dart +++ b/packages/flutter/lib/src/cupertino/text_theme.dart @@ -14,7 +14,7 @@ import 'colors.dart'; // Values derived from https://developer.apple.com/design/resources/. const TextStyle _kDefaultTextStyle = TextStyle( inherit: false, - fontFamily: '.SF Pro Text', + fontFamily: 'PingFang SC', fontSize: 17.0, letterSpacing: -0.41, color: CupertinoColors.label, @@ -28,7 +28,7 @@ const TextStyle _kDefaultTextStyle = TextStyle( // Values derived from https://developer.apple.com/design/resources/. const TextStyle _kDefaultActionTextStyle = TextStyle( inherit: false, - fontFamily: '.SF Pro Text', + fontFamily: 'PingFang SC', fontSize: 17.0, letterSpacing: -0.41, color: CupertinoColors.activeBlue, @@ -51,7 +51,7 @@ const TextStyle _kDefaultTabLabelTextStyle = TextStyle( const TextStyle _kDefaultMiddleTitleTextStyle = TextStyle( inherit: false, - fontFamily: '.SF Pro Text', + fontFamily: 'PingFang SC', fontSize: 17.0, fontWeight: FontWeight.w600, letterSpacing: -0.41, @@ -60,7 +60,7 @@ const TextStyle _kDefaultMiddleTitleTextStyle = TextStyle( const TextStyle _kDefaultLargeTitleTextStyle = TextStyle( inherit: false, - fontFamily: '.SF Pro Display', + fontFamily: 'PingFang SC', fontSize: 34.0, fontWeight: FontWeight.w700, letterSpacing: 0.41, @@ -80,7 +80,7 @@ const TextStyle _kDefaultLargeTitleTextStyle = TextStyle( // * https://github.com/flutter/flutter/pull/65501#discussion_r486557093 const TextStyle _kDefaultPickerTextStyle = TextStyle( inherit: false, - fontFamily: '.SF Pro Display', + fontFamily: 'PingFang SC', fontSize: 21.0, fontWeight: FontWeight.w400, letterSpacing: -0.6, @@ -95,7 +95,7 @@ const TextStyle _kDefaultPickerTextStyle = TextStyle( // Value extracted from off-center labels. Centered labels have a font size of 25pt. const TextStyle _kDefaultDateTimePickerTextStyle = TextStyle( inherit: false, - fontFamily: '.SF Pro Display', + fontFamily: 'PingFang SC', fontSize: 21, fontWeight: FontWeight.normal, color: CupertinoColors.label, diff --git a/packages/flutter/lib/src/material/chip.dart b/packages/flutter/lib/src/material/chip.dart index 6179e281ba..ad6b748430 100644 --- a/packages/flutter/lib/src/material/chip.dart +++ b/packages/flutter/lib/src/material/chip.dart @@ -2132,7 +2132,7 @@ class _UnconstrainedInkSplashFactory extends InteractiveInkFeatureFactory { required TextDirection textDirection, bool containedInkWell = false, RectCallback? rectCallback, - BorderRadius? borderRadius, + BorderRadiusGeometry? borderRadius, ShapeBorder? customBorder, double? radius, VoidCallback? onRemoved, @@ -2143,7 +2143,7 @@ class _UnconstrainedInkSplashFactory extends InteractiveInkFeatureFactory { position: position, color: color, rectCallback: rectCallback, - borderRadius: borderRadius, + borderRadius: borderRadius?.resolve(textDirection), customBorder: customBorder, radius: radius, onRemoved: onRemoved, diff --git a/packages/flutter/lib/src/material/ink_highlight.dart b/packages/flutter/lib/src/material/ink_highlight.dart index 76d0c382c8..d6cd688931 100644 --- a/packages/flutter/lib/src/material/ink_highlight.dart +++ b/packages/flutter/lib/src/material/ink_highlight.dart @@ -43,7 +43,7 @@ class InkHighlight extends InteractiveInkFeature { required TextDirection textDirection, BoxShape shape = BoxShape.rectangle, double? radius, - BorderRadius? borderRadius, + BorderRadiusGeometry? borderRadius, ShapeBorder? customBorder, RectCallback? rectCallback, super.onRemoved, @@ -72,7 +72,7 @@ class InkHighlight extends InteractiveInkFeature { final BoxShape _shape; final double? _radius; - final BorderRadius _borderRadius; + final BorderRadiusGeometry? _borderRadius; final ShapeBorder? _customBorder; final RectCallback? _rectCallback; final TextDirection _textDirection; @@ -120,10 +120,22 @@ class InkHighlight extends InteractiveInkFeature { break; case BoxShape.rectangle: if (_borderRadius != BorderRadius.zero) { + Radius tl=Radius.zero, tr=Radius.zero, bl=Radius.zero, br=Radius.zero; + if (_borderRadius is BorderRadiusDirectional) { + tl = (_borderRadius as BorderRadiusDirectional).topStart; + tr = (_borderRadius as BorderRadiusDirectional).topEnd; + bl = (_borderRadius as BorderRadiusDirectional).bottomStart; + br = (_borderRadius as BorderRadiusDirectional).bottomEnd; + } else if (_borderRadius is BorderRadius) { + tl = (_borderRadius as BorderRadius).topLeft; + tr = (_borderRadius as BorderRadius).topRight; + bl = (_borderRadius as BorderRadius).bottomLeft; + br = (_borderRadius as BorderRadius).bottomRight; + } final RRect clipRRect = RRect.fromRectAndCorners( rect, - topLeft: _borderRadius.topLeft, topRight: _borderRadius.topRight, - bottomLeft: _borderRadius.bottomLeft, bottomRight: _borderRadius.bottomRight, + topLeft: tl, topRight: tr, + bottomLeft: bl, bottomRight: br, ); canvas.drawRRect(clipRRect, paint); } else { diff --git a/packages/flutter/lib/src/painting/gradient.dart b/packages/flutter/lib/src/painting/gradient.dart index 103b2b0fbc..f6fdbabe51 100644 --- a/packages/flutter/lib/src/painting/gradient.dart +++ b/packages/flutter/lib/src/painting/gradient.dart @@ -226,7 +226,7 @@ abstract class Gradient { /// The shader's transform will be resolved from the [transform] of this /// gradient. @factory - Shader createShader(Rect rect, { TextDirection? textDirection }); + Shader createShader(Rect rect, { TextDirection? textDirection = TextDirection.ltr }); /// Returns a new gradient with its properties scaled by the given factor. /// @@ -432,7 +432,7 @@ class LinearGradient extends Gradient { final TileMode tileMode; @override - Shader createShader(Rect rect, { TextDirection? textDirection }) { + Shader createShader(Rect rect, { TextDirection? textDirection = TextDirection.ltr }) { return ui.Gradient.linear( begin.resolve(textDirection).withinRect(rect), end.resolve(textDirection).withinRect(rect), @@ -710,7 +710,7 @@ class RadialGradient extends Gradient { final double focalRadius; @override - Shader createShader(Rect rect, { TextDirection? textDirection }) { + Shader createShader(Rect rect, { TextDirection? textDirection = TextDirection.ltr }) { return ui.Gradient.radial( center.resolve(textDirection).withinRect(rect), radius * rect.shortestSide, @@ -984,7 +984,7 @@ class SweepGradient extends Gradient { final TileMode tileMode; @override - Shader createShader(Rect rect, { TextDirection? textDirection }) { + Shader createShader(Rect rect, { TextDirection? textDirection = TextDirection.ltr }) { return ui.Gradient.sweep( center.resolve(textDirection).withinRect(rect), colors, _impliedStops(), tileMode, diff --git a/packages/flutter/lib/src/painting/text_style.dart b/packages/flutter/lib/src/painting/text_style.dart index ad909501c5..72b296754e 100644 --- a/packages/flutter/lib/src/painting/text_style.dart +++ b/packages/flutter/lib/src/painting/text_style.dart @@ -33,6 +33,11 @@ const String _kColorBackgroundWarning = 'Cannot provide both a backgroundColor a // defaults set in the engine (eg, LibTxt's text_style.h, paragraph_style.h). const double _kDefaultFontSize = 14.0; +List? _sFontFamilyFallback = []; +void TextStyleSetFontFamilyFallback(List? fontFamilyFallback) { + _sFontFamilyFallback = fontFamilyFallback; +} + // Examples can assume: // late BuildContext context; @@ -587,7 +592,10 @@ class TextStyle with Diagnosticable { /// prefixed with 'packages/package_name/' (e.g. 'packages/cool_fonts/Roboto'). /// The package name should be provided by the `package` argument in the /// constructor. - List? get fontFamilyFallback => _package == null ? _fontFamilyFallback : _fontFamilyFallback?.map((String str) => 'packages/$_package/$str').toList(); + List? get fontFamilyFallback { + List? fallbackFontFamily = _package == null ? _fontFamilyFallback : _fontFamilyFallback?.map((String str) => 'packages/$_package/$str').toList(); + return fallbackFontFamily ?? _sFontFamilyFallback; + } final List? _fontFamilyFallback; // This is stored in order to prefix the fontFamilies in _fontFamilyFallback diff --git a/packages/flutter_tools/lib/src/build_info.dart b/packages/flutter_tools/lib/src/build_info.dart index ce9b4993ed..77a3d38ca4 100644 --- a/packages/flutter_tools/lib/src/build_info.dart +++ b/packages/flutter_tools/lib/src/build_info.dart @@ -11,8 +11,10 @@ import 'base/file_system.dart'; import 'base/logger.dart'; import 'base/os.dart'; import 'base/utils.dart'; +import 'base/process.dart'; import 'convert.dart'; import 'globals.dart' as globals; +import 'package:path/path.dart' as p; /// Whether icon font subsetting is enabled by default. const bool kIconTreeShakerEnabledDefault = true; @@ -1114,3 +1116,30 @@ String? _uncapitalize(String? s) { } return s.substring(0, 1).toLowerCase() + s.substring(1); } + + +Future executePrebuildScript({bool fullRestart = true}) async { + + final String intlToolPath = p.join(globals.fs.currentDirectory.path, 'tools', 'intl_cli', 'intl_cli'); + if (globals.fs.file(intlToolPath).existsSync()){ + final List script = globals.platform.isWindows ? ['python'] : []; + final List extraArgs = fullRestart ? ['-c'] : []; + final RunResult ret = await globals.processUtils.run( + [...script, intlToolPath, '-p', globals.fs.currentDirectory.path, ...extraArgs], + workingDirectory: globals.fs.currentDirectory.path, + ); + return ret; + } + + final String prebuildScriptPath = p.join(globals.fs.currentDirectory.path, 'banban_base','prebuild.py'); + final File scriptFile = globals.fs.file(prebuildScriptPath); + if (scriptFile.existsSync()) { + final RunResult ret = await globals.processUtils.run( + ['python', prebuildScriptPath], + workingDirectory: globals.fs.currentDirectory.path, + ); + return ret; + } + + return null; +} diff --git a/packages/flutter_tools/lib/src/commands/build.dart b/packages/flutter_tools/lib/src/commands/build.dart index 8ecd83bb21..402860706d 100644 --- a/packages/flutter_tools/lib/src/commands/build.dart +++ b/packages/flutter_tools/lib/src/commands/build.dart @@ -8,6 +8,7 @@ import '../android/android_sdk.dart'; import '../base/file_system.dart'; import '../base/logger.dart'; import '../base/os.dart'; +import '../base/process.dart'; import '../build_info.dart'; import '../build_system/build_system.dart'; import '../commands/build_linux.dart'; @@ -103,6 +104,14 @@ abstract class BuildSubCommand extends FlutterCommand { bool get reportNullSafety => true; bool get supported => true; + @override + Future runCommand() async { + final RunResult? ret = await executePrebuildScript(fullRestart: false); + if ((ret?.exitCode ?? 0) != 0) { + return FlutterCommandResult.fail(); + } + return FlutterCommandResult.success(); + } /// Display a message describing the current null safety runtime mode /// that was selected. diff --git a/packages/flutter_tools/lib/src/commands/build_apk.dart b/packages/flutter_tools/lib/src/commands/build_apk.dart index 946d790485..71b450ecce 100644 --- a/packages/flutter_tools/lib/src/commands/build_apk.dart +++ b/packages/flutter_tools/lib/src/commands/build_apk.dart @@ -95,6 +95,7 @@ class BuildApkCommand extends BuildSubCommand { @override Future runCommand() async { + await super.runCommand(); if (globals.androidSdk == null) { exitWithNoSdkMessage(); } diff --git a/packages/flutter_tools/lib/src/commands/build_appbundle.dart b/packages/flutter_tools/lib/src/commands/build_appbundle.dart index d40d3da9ba..d0eaabfed1 100644 --- a/packages/flutter_tools/lib/src/commands/build_appbundle.dart +++ b/packages/flutter_tools/lib/src/commands/build_appbundle.dart @@ -107,6 +107,8 @@ class BuildAppBundleCommand extends BuildSubCommand { @override Future runCommand() async { + await super.runCommand(); + if (globals.androidSdk == null) { exitWithNoSdkMessage(); } diff --git a/packages/flutter_tools/lib/src/commands/build_ios.dart b/packages/flutter_tools/lib/src/commands/build_ios.dart index f8ff34b8a9..ad16efb5cd 100644 --- a/packages/flutter_tools/lib/src/commands/build_ios.dart +++ b/packages/flutter_tools/lib/src/commands/build_ios.dart @@ -482,6 +482,8 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand { @override Future runCommand() async { + await super.runCommand(); + defaultBuildMode = environmentType == EnvironmentType.simulator ? BuildMode.debug : BuildMode.release; final BuildInfo buildInfo = await cachedBuildInfo; diff --git a/packages/flutter_tools/lib/src/commands/build_windows.dart b/packages/flutter_tools/lib/src/commands/build_windows.dart index 0c94f53afd..2b247a6bf9 100644 --- a/packages/flutter_tools/lib/src/commands/build_windows.dart +++ b/packages/flutter_tools/lib/src/commands/build_windows.dart @@ -44,6 +44,7 @@ class BuildWindowsCommand extends BuildSubCommand { @override Future runCommand() async { + await super.runCommand(); final FlutterProject flutterProject = FlutterProject.current(); final BuildInfo buildInfo = await getBuildInfo(); if (!featureFlags.isWindowsEnabled) { diff --git a/packages/flutter_tools/lib/src/flutter_manifest.dart b/packages/flutter_tools/lib/src/flutter_manifest.dart index 37753b65b0..b7d4745dea 100644 --- a/packages/flutter_tools/lib/src/flutter_manifest.dart +++ b/packages/flutter_tools/lib/src/flutter_manifest.dart @@ -597,6 +597,8 @@ void _validateFlutter(YamlMap? yaml, List errors) { break; case 'generate': break; + case 'assets-filter': + break; case 'deferred-components': _validateDeferredComponents(kvp, errors); break; diff --git a/packages/flutter_tools/lib/src/run_hot.dart b/packages/flutter_tools/lib/src/run_hot.dart index 2c26dfe66f..87cb94bf25 100644 --- a/packages/flutter_tools/lib/src/run_hot.dart +++ b/packages/flutter_tools/lib/src/run_hot.dart @@ -15,6 +15,7 @@ import 'base/context.dart'; import 'base/file_system.dart'; import 'base/logger.dart'; import 'base/platform.dart'; +import 'base/process.dart'; import 'base/utils.dart'; import 'build_info.dart'; import 'compile.dart'; @@ -350,6 +351,12 @@ class HotRunner extends ResidentRunner { }) async { await _calculateTargetPlatform(); + final RunResult? ret = await executePrebuildScript(fullRestart: false); + if ((ret?.exitCode ?? 0) != 0) { + globals.printError('Prebuild script execution failed in run() !!! $ret'); + return 1; + } + final Stopwatch appStartedTimer = Stopwatch()..start(); final File mainFile = globals.fs.file(mainPath); firstBuildTime = DateTime.now(); @@ -703,6 +710,14 @@ class HotRunner extends ResidentRunner { return OperationResult(1, 'Device initialization has not completed.'); } await _calculateTargetPlatform(); + + final RunResult? ret = await executePrebuildScript(fullRestart: false); + if ((ret?.exitCode ?? 0) != 0) { + const String errorMsg = 'Prebuild script execution failed in restart() !!!'; + globals.printError(errorMsg); + return OperationResult(1, errorMsg); + } + final Stopwatch timer = Stopwatch()..start(); // Run source generation if needed.