diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 9625e105..7c569640 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 11.0 + 12.0 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 6b8f839a..c9f8f38f 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -275,7 +275,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -349,7 +349,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -398,7 +398,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/lib/src/platform_provider.dart b/lib/src/platform_provider.dart index fcec4075..e49a1909 100644 --- a/lib/src/platform_provider.dart +++ b/lib/src/platform_provider.dart @@ -152,12 +152,19 @@ class PlatformSettingsData { /// Set to true (wrapped) by default which could be a breaking change. If it is then set this value to false final bool wrapCupertinoAppBarMiddleWithMediaQuery; + /// With Material3 spec defining buttons text as being non ALL CAPS (see https://m3.material.io/components/buttons/overview#388f6096-c34d-4a22-8b1f-11ad69963f7c) + /// If this is set to true then using [PlatformText] with material3 style will default to sentence case and not ALL CAPS. Material 2 will continue to be ALL CAPS + /// If this is set to false then it will default to previous behavour of ALL CAPS. + /// Going forward [PlatformText] will likely be removed when the material3 property on ThemeData is removed and all material widgets will assume material3 style. + final bool matchMaterialCaseForPlatformText; + PlatformSettingsData({ this.iosUsesMaterialWidgets = false, this.iosUseZeroPaddingForAppbarPlatformIcon = false, this.legacyIosUsesMaterialWidgets = false, this.platformStyle = const PlatformStyleData(), this.wrapCupertinoAppBarMiddleWithMediaQuery = true, + this.matchMaterialCaseForPlatformText = true, }); } diff --git a/lib/src/platform_text.dart b/lib/src/platform_text.dart index e9e6e7d1..4c751d64 100644 --- a/lib/src/platform_text.dart +++ b/lib/src/platform_text.dart @@ -6,12 +6,27 @@ import 'dart:ui' as ui show TextHeightBehavior; +import 'package:flutter/material.dart' show Theme; import 'package:flutter/widgets.dart'; import 'platform.dart' show isMaterial; +import 'platform_provider.dart' show PlatformProvider; +import 'platform_theme.dart' show PlatformTheme; String formatData(BuildContext context, String data) { if (isMaterial(context)) { + final providerState = PlatformProvider.of(context); + final matchMaterialCaseForPlatformText = + providerState?.settings.matchMaterialCaseForPlatformText ?? true; + + final m3 = PlatformTheme.of(context)?.isMaterial3 ?? + Theme.of(context).useMaterial3; + + // If it material3 and we want to match the casing as defined for material3 then do not return ALL CAPS + if (m3 && matchMaterialCaseForPlatformText) { + return data; + } + return data.toUpperCase(); } return data; diff --git a/lib/src/platform_theme.dart b/lib/src/platform_theme.dart index 540ae6f6..adbdf6f7 100644 --- a/lib/src/platform_theme.dart +++ b/lib/src/platform_theme.dart @@ -118,6 +118,10 @@ class _PlatformThemeState extends State applyToBothDarkAndLightTheme: applyToBothDarkAndLightTheme); } + bool get isMaterial3 => + (isDark ? _materialDarkTheme : _materialLightTheme)?.useMaterial3 ?? + false; + void _setMaterialThemeType({ required bool? useMaterial3, bool applyToBothDarkAndLightTheme = false, @@ -167,6 +171,7 @@ class PlatformThemeState { set themeMode(ThemeMode? themeMode) => _parent.themeMode = themeMode; bool get isDark => _parent.isDark; + bool get isMaterial3 => _parent.isMaterial3; CupertinoThemeData? get cupertinoLightTheme => _parent._cupertinoLightTheme; CupertinoThemeData? get cupertinoDarkTheme => _parent._cupertinoDarkTheme;