Skip to content

Commit

Permalink
update support M3
Browse files Browse the repository at this point in the history
  • Loading branch information
CarGuo committed Nov 23, 2023
1 parent 00babf2 commit 69dfe7e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
42 changes: 34 additions & 8 deletions lib/common/utils/common_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,21 +199,47 @@ class CommonUtils {

static getThemeData(Color color) {
return ThemeData(
useMaterial3: false,
primaryColor: color,
///用来适配 Theme.of(context).primaryColorLight 和 primaryColorDark 的颜色变化,不设置可能会是默认蓝色
primarySwatch: color as MaterialColor,

/// Card 在 M3 下,会有 apply Overlay
colorScheme: ColorScheme.fromSeed(
seedColor: color,
primary: color,

brightness: Brightness.light,

///影响 card 的表色,因为 M3 下是 applySurfaceTint ,在 Material 里
surfaceTint: Colors.transparent,
),

/// 受到 iconThemeData.isConcrete 的印象,需要全参数才不会进入 fallback
iconTheme: IconThemeData(
size: 24.0,
fill: 0.0,
weight: 400.0,
grade: 0.0,
opticalSize: 48.0,
color: Colors.white,
opacity: 0.8,
),

///修改 FloatingActionButton的默认主题行为
floatingActionButtonTheme: FloatingActionButtonThemeData(
foregroundColor: Colors.white,
backgroundColor: color,
shape: CircleBorder()),
appBarTheme: AppBarTheme(
systemOverlayStyle: SystemUiOverlayStyle.light.copyWith(
systemNavigationBarContrastEnforced: true,
systemStatusBarContrastEnforced: true,
systemNavigationBarColor: color,
statusBarColor: color,
systemNavigationBarDividerColor: color.withAlpha(199),
iconTheme: IconThemeData(
color: Colors.white,
size: 24.0,
),
backgroundColor: color,
titleTextStyle: Typography.dense2021.titleLarge,
systemOverlayStyle: SystemUiOverlayStyle.light,
),

// 如果需要去除对应的水波纹效果
// splashFactory: NoSplash.splashFactory,
// textButtonTheme: TextButtonThemeData(
Expand Down
2 changes: 1 addition & 1 deletion lib/page/trend/trend_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class TrendPageState extends State<TrendPage>
Radius.circular(size / 2),
),
),
closedColor: Theme.of(context).colorScheme.secondary,
closedColor: Theme.of(context).primaryColor,
closedBuilder: (BuildContext context, VoidCallback openContainer) {
return SizedBox(
width: size,
Expand Down

0 comments on commit 69dfe7e

Please sign in to comment.