import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../my_load_image.dart';
import 'package:cs_resources/constants/color_constants.dart';

//设置颜色兼容黑色模式
class DarkThemeUtil {

  /// 默认黑暗模式下的颜色为[ColorConstants.darkScaffoldBackgroundColor].

  /// 如果想自定义黑暗模式下的颜色
  static Color? multiColors(Color? lightColor, {Color? darkColor}) {
    Color? color;
    if (Get.isDarkMode) {
      color = darkColor ?? ColorConstants.darkScaffoldBackgroundColor;
    } else {
      color = lightColor;
    }
    return color;
  }

  /// 默认黑暗模式下的颜色不变.
  /// 如果想自定义黑暗模式下的图标颜色填充颜色就行
  static MyAssetImage 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 MyAssetImage multiImagePath(String imgPath, {double? width, double? height, String? darkImagePath}) {
    return MyAssetImage(
      Get.isDarkMode && darkImagePath != null ? darkImagePath : imgPath,
      width: width,
      height: height,
    );
  }
}
