-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: deprecate YaruThemeDataExtension in favor of YaruColorSchemeExt…
…ension (#349)
- Loading branch information
Showing
3 changed files
with
45 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,46 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:yaru/src/colors.dart'; | ||
|
||
/// Yaru-specific theming extensions. | ||
@Deprecated('Use YaruColorSchemeExtension instead.') | ||
extension YaruThemeDataExtension on ThemeData { | ||
@Deprecated('Use ColorScheme.success instead.') | ||
Color get successColor => colorScheme.success; | ||
|
||
@Deprecated('Use ColorScheme.warning instead.') | ||
Color get warningColor => colorScheme.warning; | ||
} | ||
|
||
/// Yaru-specific color scheme extensions. | ||
extension YaruColorSchemeExtension on ColorScheme { | ||
/// Whether the brightness is dark. | ||
bool get isDark => brightness == Brightness.dark; | ||
|
||
/// Whether the brightness is light. | ||
bool get isLight => brightness == Brightness.light; | ||
|
||
/// Whether the primary color is either black or white. | ||
bool get isHighContrast => | ||
const [Colors.black, Colors.white].contains(primary); | ||
|
||
/// A color to indicate success e.g. for text input validation. | ||
/// | ||
/// ```dart | ||
/// Theme.of(context).successColor | ||
/// Theme.of(context).colorScheme.success | ||
/// ``` | ||
/// | ||
/// See also: | ||
/// * [ThemeData.colorScheme.error] | ||
Color get successColor => YaruColors.success; | ||
/// * [ColorScheme.error] | ||
Color get success => YaruColors.success; | ||
|
||
/// A color to indicate warnings. | ||
/// | ||
/// This is the counterpart of [ThemeData.colorScheme.error]. | ||
/// This is the counterpart of [ColorScheme.error]. | ||
/// | ||
/// ```dart | ||
/// Theme.of(context).warningColor | ||
/// Theme.of(context).colorScheme.warning | ||
/// ``` | ||
/// | ||
/// See also: | ||
/// * [ThemeData.colorScheme.error] | ||
Color get warningColor => YaruColors.warning; | ||
/// * [ColorScheme.error] | ||
Color get warning => YaruColors.warning; | ||
} |