From f975b794d08a784aa16d9844c237d2617f096e1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=9B=BD=E7=A5=A5?= Date: Fri, 14 Nov 2025 17:26:32 +0800 Subject: [PATCH 1/4] =?UTF-8?q?docs(dark-mode):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=B7=B1=E8=89=B2=E6=A8=A1=E5=BC=8F=E6=96=87=E6=A1=A3=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E5=92=8C=E4=BB=A3=E7=A0=81=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新深色模式切换代码示例链接至实际文件路径 - 调整JSON配置代码块格式,统一缩进为两个空格 - 优化MaterialApp主题配置代码注释排版 - 修复themeMode属性重复声明的语法错误 --- tdesign-site/site/docs/dark-mode.md | 156 ++++++++++++++-------------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/tdesign-site/site/docs/dark-mode.md b/tdesign-site/site/docs/dark-mode.md index 95dca3fcf..53a1f3cb1 100644 --- a/tdesign-site/site/docs/dark-mode.md +++ b/tdesign-site/site/docs/dark-mode.md @@ -13,11 +13,11 @@ spline: explain ## 使用之前 -使用之前,请先阅读 flutter 官方文档:[使用 Themes 统一颜色和字体风格](https://docs.flutter.cn/cookbook/design/themes)。 +使用之前,请先阅读 flutter 官方文档:[使用 Themes 统一颜色和字体风格](https://docs.flutter.cn/cookbook/design/themes/)。 TDFlutter 的深色模式是基于上述 flutter 官方文档对 [ThemeData](https://api.flutter-io.cn/flutter/material/ThemeData-class.html) 进行自定义配置和重载主题实现的。 -具体代码请参考 [深色模式切换](https://github.com/Tencent/tdesign-flutter/pull/768/commits/c5bf979a4b54c119e196ced2f6006deb69339fde)。 +具体代码请参考 [深色模式切换](https://github.com/Tencent/tdesign-flutter/blob/develop/tdesign-component/example/lib/component_test/dark_test.dart)。 ## 主题配置 @@ -30,60 +30,60 @@ TDFlutter 的深色模式是基于上述 flutter 官方文档对 [ThemeData](htt ```json { "defaultDark": { - "ref": { - "brandNormalColor": "brandColor8", - "warningNormalColor": "warningColor5", - "errorNormalColor": "errorColor6", - "successNormalColor": "successColor5", - "brandFocusColor": "brandColor1", - "brandActiveColor": "brandColor9", - "brandDisabledColor": "brandColor3", - "brandLightColor": "brandColor1", - "brandColorLightActive": "brandColor2", - "warningFocusColor": "warningColor2", - "warningActiveColor": "warningColor4", - "warningDisabledColor": "warningColor3", - "warningLightColor": "warningColor1", - "warningColorLightActive": "warningColor2", - "errorFocusColor": "errorColor2", - "errorActiveColor": "errorColor5", - "errorDisabledColor": "errorColor3", - "errorLightColor": "errorColor1", - "errorColorLightActive": "errorColor2", - "successFocusColor": "successColor2", - "successActiveColor": "successColor4", - "successDisabledColor": "successColor3", - "successLightColor": "successColor1", - "successColorLightActive": "successColor2", - "bgColorPage": "grayColor14", - "bgColorContainer": "grayColor13", - "bgColorSecondaryContainer": "grayColor12", - "bgColorComponent": "grayColor11", - "bgColorContainerActive": "grayColor12", - "bgColorSecondaryContainerActive": "grayColor11", - "bgColorComponentActive": "grayColor10", - "bgColorComponentDisabled": "grayColor12", - "textColorPrimary": "fontWhColor1", - "textColorSecondary": "fontWhColor2", - "textColorPlaceholder": "fontWhColor3", - "textDisabledColor": "fontWhColor4", - "textColorAnti": "fontWhColor1", - "textColorBrand": "brandColor8", - "textColorLink": "brandColor8", - "componentStrokeColor": "grayColor11", - "componentBorderColor": "grayColor9" - }, - "color": { - "brandColor1": "#1b2f51", - "brandColor2": "#173463", - "brandColor3": "#143975", - "brandColor4": "#103d88", - "brandColor5": "#0d429a", - "brandColor6": "#054bbe", - "brandColor7": "#2667d4", - "brandColor8": "#4582e6", - "brandColor9": "#699ef5", - "brandColor10": "#96bbf8" + "ref": { + "brandNormalColor": "brandColor8", + "warningNormalColor": "warningColor5", + "errorNormalColor": "errorColor6", + "successNormalColor": "successColor5", + "brandFocusColor": "brandColor1", + "brandActiveColor": "brandColor9", + "brandDisabledColor": "brandColor3", + "brandLightColor": "brandColor1", + "brandColorLightActive": "brandColor2", + "warningFocusColor": "warningColor2", + "warningActiveColor": "warningColor4", + "warningDisabledColor": "warningColor3", + "warningLightColor": "warningColor1", + "warningColorLightActive": "warningColor2", + "errorFocusColor": "errorColor2", + "errorActiveColor": "errorColor5", + "errorDisabledColor": "errorColor3", + "errorLightColor": "errorColor1", + "errorColorLightActive": "errorColor2", + "successFocusColor": "successColor2", + "successActiveColor": "successColor4", + "successDisabledColor": "successColor3", + "successLightColor": "successColor1", + "successColorLightActive": "successColor2", + "bgColorPage": "grayColor14", + "bgColorContainer": "grayColor13", + "bgColorSecondaryContainer": "grayColor12", + "bgColorComponent": "grayColor11", + "bgColorContainerActive": "grayColor12", + "bgColorSecondaryContainerActive": "grayColor11", + "bgColorComponentActive": "grayColor10", + "bgColorComponentDisabled": "grayColor12", + "textColorPrimary": "fontWhColor1", + "textColorSecondary": "fontWhColor2", + "textColorPlaceholder": "fontWhColor3", + "textDisabledColor": "fontWhColor4", + "textColorAnti": "fontWhColor1", + "textColorBrand": "brandColor8", + "textColorLink": "brandColor8", + "componentStrokeColor": "grayColor11", + "componentBorderColor": "grayColor9" + }, + "color": { + "brandColor1": "#1b2f51", + "brandColor2": "#173463", + "brandColor3": "#143975", + "brandColor4": "#103d88", + "brandColor5": "#0d429a", + "brandColor6": "#054bbe", + "brandColor7": "#2667d4", + "brandColor8": "#4582e6", + "brandColor9": "#699ef5", + "brandColor10": "#96bbf8" } } } @@ -119,29 +119,29 @@ class App extends StatelessWidget { @override Widget build(BuildContext context) { - // MaterialApp中设置theme,darkTheme,themeMode三个属性如下,如果有自定义主题属性,可以通过copyWith()方法修改。 - // 注:主题切换需要业务自己实现,比如使用Provider,具体可参考tdesign-flutter/tdesign-component/example/lib/component_test/dark_test.dart - return MaterialApp( - title: '深色模式切换测试', - - /// 默认浅色模式 - theme: themeData.systemThemeDataLight!.copyWith( - /// 根据自己的需求用 TD 颜色覆盖 Material/Cupertino 的颜色 - cupertinoOverrideTheme: const CupertinoThemeData().copyWith( - barBackgroundColor: themeData.bgColorContainer.withOpacity(0.5), - ), - /// ... 更多重载主题 - ), + // MaterialApp中设置theme,darkTheme,themeMode三个属性如下,如果有自定义主题属性,可以通过copyWith()方法修改。 + // 注:主题切换需要业务自己实现,比如使用Provider,具体可参考tdesign-flutter/tdesign-component/example/lib/component_test/dark_test.dart + return MaterialApp( + title: '深色模式切换测试', + + /// 默认浅色模式 + theme: themeData.systemThemeDataLight!.copyWith( + /// 根据自己的需求用 TD 颜色覆盖 Material/Cupertino 的颜色 + cupertinoOverrideTheme: const CupertinoThemeData().copyWith( + barBackgroundColor: themeData.bgColorContainer.withOpacity(0.5), + ), + /// ... 更多重载主题 + ), - /// 深色模式 - darkTheme: themeData.systemThemeDataDark?.copyWith( - cupertinoOverrideTheme: const CupertinoThemeData().copyWith( - barBackgroundColor: themeData.dark?.grayColor13.withOpacity(0.5), - ), + /// 深色模式 + darkTheme: themeData.systemThemeDataDark?.copyWith( + cupertinoOverrideTheme: const CupertinoThemeData().copyWith( + barBackgroundColor: themeData.dark?.grayColor13.withOpacity(0.5), + ), - /// ... 更多重载主题 - ), - themeMode: themeModeProvider.themeMode, + /// ... 更多重载主题 + ), + themeMode: themeModeProvider.themeMode, ); } } @@ -161,7 +161,7 @@ return MaterialApp( // 深色模式(已忽略细节) darkTheme: _themeData.systemThemeDataDark, // MaterialApp 主题模式默认跟随系统 - themeMode: themeMode: ThemeMode.system, + themeMode: ThemeMode.system, ); ``` From e1ab4a2573885088b61059e118b5cbd1be3c9404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=9B=BD=E7=A5=A5?= Date: Fri, 14 Nov 2025 17:35:13 +0800 Subject: [PATCH 2/4] =?UTF-8?q?docs(dark-mode):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=B7=B1=E8=89=B2=E6=A8=A1=E5=BC=8F=E6=96=87=E6=A1=A3=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改了 MaterialApp 中 theme、darkTheme、themeMode 属性的注释说明 - 补充了主题切换需业务方自行实现的说明 - 提供了具体的代码示例文件路径引用 - 添加了关于 SharedPreferences 使用方式的注意事项 - 优化了文档中的代码块排版和注释格式 --- tdesign-site/site/docs/dark-mode.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tdesign-site/site/docs/dark-mode.md b/tdesign-site/site/docs/dark-mode.md index 53a1f3cb1..02bfd3406 100644 --- a/tdesign-site/site/docs/dark-mode.md +++ b/tdesign-site/site/docs/dark-mode.md @@ -119,8 +119,10 @@ class App extends StatelessWidget { @override Widget build(BuildContext context) { - // MaterialApp中设置theme,darkTheme,themeMode三个属性如下,如果有自定义主题属性,可以通过copyWith()方法修改。 - // 注:主题切换需要业务自己实现,比如使用Provider,具体可参考tdesign-flutter/tdesign-component/example/lib/component_test/dark_test.dart + /// MaterialApp 中设置 theme、darkTheme、themeMode 三个属性 + /// 如下所示,如果有自定义主题属性,可以通过 copyWith() 方法修改。 + /// 注:主题切换需要业务自己实现,比如使用 Provider + /// 具体可参考 tdesign-flutter/tdesign-component/example/lib/component_test/dark_test.dart return MaterialApp( title: '深色模式切换测试', @@ -138,7 +140,6 @@ class App extends StatelessWidget { cupertinoOverrideTheme: const CupertinoThemeData().copyWith( barBackgroundColor: themeData.dark?.grayColor13.withOpacity(0.5), ), - /// ... 更多重载主题 ), themeMode: themeModeProvider.themeMode, @@ -180,6 +181,8 @@ return MaterialApp( 1. 新建 `ThemeModeProvider` 类,并继承 `ChangeNotifier`,添加主题模式属性和切换主题模式的方法。并使用 `SharedPreferencesAsync` 持久化主题模式。 +注:旧版本的 `shared_preferences` 包请使用 `SharedPreferences.getInstance();`,具体请参考 [shared_preferences](https://pub.dev/packages/shared_preferences) 文档。 + ```dart import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; From 3003da040304b0e61f428a428022a4d30709d344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=9B=BD=E7=A5=A5?= Date: Fri, 14 Nov 2025 19:26:01 +0800 Subject: [PATCH 3/4] =?UTF-8?q?docs(getting-started):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E7=94=9F=E6=88=90=E5=99=A8=E6=B7=B1=E8=89=B2?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E7=89=88=E6=9C=AC=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将深色模式支持的版本号链接化,方便用户直接查看更新日志 - 优化文档表述,使信息更加清晰易读 --- tdesign-site/site/docs/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tdesign-site/site/docs/getting-started.md b/tdesign-site/site/docs/getting-started.md index 2365e32b5..66319f225 100644 --- a/tdesign-site/site/docs/getting-started.md +++ b/tdesign-site/site/docs/getting-started.md @@ -77,7 +77,7 @@ TDTheme.defaultData().fontBodyLarge ### 主题生成器 如果你不想自定义太多颜色,但是想要拥有好看的自定义主题,“主题生成器”是个不错的选择。 -* 注: 0.2.6版本开始,主题生成器已支持“深色模式”,具体可参考[深色模式](https://tdesign.tencent.com/flutter/dark-mode) * +* 注:[0.2.6](https://tdesign.tencent.com/flutter/changelog#%F0%9F%8C%88-0-2-6-2025-11-14) 版本开始,主题生成器已支持“深色模式”,具体可参考[深色模式](https://tdesign.tencent.com/flutter/dark-mode)。 1. 进入[TDesign官网](https://tdesign.tencent.com/vue/custom-theme),点击下方的主题生成器,然后再右边生成器里选择想要的颜色,点击下载。 From ba31b50546df8ab3605c2ae31edf4b9ec967ba56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=9B=BD=E7=A5=A5?= Date: Sat, 15 Nov 2025 14:23:23 +0800 Subject: [PATCH 4/4] =?UTF-8?q?feat(ios):=20=E8=BF=81=E7=A7=BBios=EF=BC=8C?= =?UTF-8?q?=E9=87=87=E7=94=A8=20UISceneDelegate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/ios/Runner/AppDelegate.h | 2 +- .../example/ios/Runner/AppDelegate.m | 5 ++- .../example/ios/Runner/Info.plist | 39 ++++++++++++++----- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/tdesign-component/example/ios/Runner/AppDelegate.h b/tdesign-component/example/ios/Runner/AppDelegate.h index 36e21bbf9..01e6e1d47 100644 --- a/tdesign-component/example/ios/Runner/AppDelegate.h +++ b/tdesign-component/example/ios/Runner/AppDelegate.h @@ -1,6 +1,6 @@ #import #import -@interface AppDelegate : FlutterAppDelegate +@interface AppDelegate : FlutterAppDelegate @end diff --git a/tdesign-component/example/ios/Runner/AppDelegate.m b/tdesign-component/example/ios/Runner/AppDelegate.m index 70e83933d..cebafc9ec 100644 --- a/tdesign-component/example/ios/Runner/AppDelegate.m +++ b/tdesign-component/example/ios/Runner/AppDelegate.m @@ -5,9 +5,12 @@ @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - [GeneratedPluginRegistrant registerWithRegistry:self]; // Override point for customization after application launch. return [super application:application didFinishLaunchingWithOptions:launchOptions]; } +- (void)didInitializeImplicitFlutterEngine:(NSObject*)engineBridge { + [GeneratedPluginRegistrant registerWithRegistry:engineBridge.pluginRegistry]; +} + @end diff --git a/tdesign-component/example/ios/Runner/Info.plist b/tdesign-component/example/ios/Runner/Info.plist index 55b3bfc10..b622876f1 100644 --- a/tdesign-component/example/ios/Runner/Info.plist +++ b/tdesign-component/example/ios/Runner/Info.plist @@ -2,6 +2,8 @@ + CADisableMinimumFrameDurationOnPhone + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName @@ -18,17 +20,40 @@ APPL CFBundleShortVersionString $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + NSCameraUsageDescription UploadComponentNeeded NSMicrophoneUsageDescription UploadComponentNeeded NSPhotoLibraryUsageDescription UploadComponentNeeded - CFBundleSignature - ???? - CFBundleVersion - $(FLUTTER_BUILD_NUMBER) - LSRequiresIPhoneOS + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneClassName + UIWindowScene + UISceneConfigurationName + flutter + UISceneDelegateClassName + FlutterSceneDelegate + UISceneStoryboardFile + Main + + + + + UIApplicationSupportsIndirectInputEvents UILaunchStoryboardName LaunchScreen @@ -49,9 +74,5 @@ UIViewControllerBasedStatusBarAppearance - CADisableMinimumFrameDurationOnPhone - - UIApplicationSupportsIndirectInputEvents -