Files
MWClash/lib/common/color.dart

37 lines
791 B
Dart
Raw Normal View History

2024-04-30 23:38:49 +08:00
import 'package:flutter/material.dart';
extension ColorExtension on Color {
toLight() {
return withOpacity(0.6);
}
toLighter() {
return withOpacity(0.4);
}
toSoft() {
return withOpacity(0.12);
}
toLittle() {
return withOpacity(0.03);
}
Color darken([double amount = .1]) {
assert(amount >= 0 && amount <= 1);
final hsl = HSLColor.fromColor(this);
final hslDark = hsl.withLightness((hsl.lightness - amount).clamp(0.0, 1.0));
return hslDark.toColor();
}
2024-08-01 23:51:00 +08:00
}
extension ColorSchemeExtension on ColorScheme {
ColorScheme toPrueBlack(bool isPrueBlack) => isPrueBlack
? copyWith(
surface: Colors.black,
background: Colors.black,
surfaceContainer: surfaceContainer.darken(0.05),
2024-08-01 23:51:00 +08:00
)
: this;
}