12345678910111213141516171819202122232425262728293031323334 |
- import 'package:flutter/material.dart';
- import 'package:ftrecruiter/comm/constants/color_constants.dart';
- import 'package:ftrecruiter/comm/widget/my_load_image.dart';
- import 'package:ftrecruiter/local/theme/theme_config.dart';
- import 'package:get/get.dart';
- //设置颜色兼容黑色模式
- class DarkThemeUtil {
- /// 默认黑暗模式下的颜色为[ColorConstants.darkScaffoldBackgroundColor].
- /// 如果想自定义黑暗模式下的颜色
- static Color multiColors(Color lightColor, {Color? darkColor}) {
- Color color;
- if (Get.isDarkMode) {
- color = darkColor ?? ThemeConfig.darkTheme.cardTheme.color ?? ColorConstants.darkScaffoldBackgroundColor;
- } else {
- color = lightColor;
- }
- return color;
- }
- /// 默认黑暗模式下的颜色不变.
- /// 如果想自定义黑暗模式下的图标颜色填充颜色就行
- static Widget multiImageColorFit(String imgPath, double width, double height, {Color? darkColor, BoxFit? fit}) {
- return MyAssetImage(imgPath, width: width, height: height, color: Get.isDarkMode ? darkColor : null, fit: fit);
- }
- /// 默认黑暗模式下的图片资源不变
- /// 如果想自定义黑暗模式下的图片资源,可以直接替换图片
- static Widget multiImagePath(String imgPath, double width, double height, {String? darkImagePath}) {
- return MyAssetImage(Get.isDarkMode && darkImagePath != null ? darkImagePath : imgPath,
- width: width, height: height);
- }
- }
|