Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change theme data, use extensions on colors instead #341

Open
ikbendewilliam opened this issue Apr 2, 2024 · 0 comments
Open

Change theme data, use extensions on colors instead #341

ikbendewilliam opened this issue Apr 2, 2024 · 0 comments
Assignees
Labels
improve code Improve the code

Comments

@ikbendewilliam
Copy link
Collaborator

Use extensions on colors instead and add colors directly on theme.

class ADTheme {
  final bool isDarkTheme;
  final Color text;
  final Color inverseText;
  final Color errorText;
  final Color buttonTextDisabled;
  final Color primary;
...

extension ColorTextTheme on Color {
  TextStyle get titleHuge => TextStyle(fontSize: 40, color: this, fontFamily: ThemeFonts.title, height: 1.2, fontWeight: FontWeight.w900);
  TextStyle get titleBig => TextStyle(fontSize: 30, color: this, fontFamily: ThemeFonts.title, height: 1.2, fontWeight: FontWeight.w900);
  TextStyle get titleNormal => TextStyle(fontSize: 24, color: this, fontFamily: ThemeFonts.title, fontWeight: FontWeight.w900);
  TextStyle get titleSmall => TextStyle(fontSize: 18, color: this, fontFamily: ThemeFonts.title, fontWeight: FontWeight.w900);
  TextStyle get titleListItem => TextStyle(fontSize: 18, color: this, fontFamily: ThemeFonts.title, fontWeight: FontWeight.bold);
  TextStyle get labelButtonBig => TextStyle(fontSize: 16, color: this, fontFamily: ThemeFonts.button, fontWeight: FontWeight.bold);
  TextStyle get labelButtonSmall => TextStyle(fontSize: 14, color: this, fontFamily: ThemeFonts.button, fontWeight: FontWeight.bold);
  TextStyle get bodyBig => TextStyle(fontSize: 18, color: this, fontFamily: ThemeFonts.body);
  TextStyle get bodyNormal => TextStyle(fontSize: 16, color: this, fontFamily: ThemeFonts.body);
  TextStyle get bodySmall => TextStyle(fontSize: 14, color: this, fontFamily: ThemeFonts.body);
  TextStyle get bodyUltraSmall => TextStyle(fontSize: 12, color: this, fontFamily: ThemeFonts.body);
  TextStyle get infoBodySubHeader => TextStyle(fontSize: 14, color: this, fontFamily: ThemeFonts.body, fontWeight: FontWeight.w600);

  Border get border => Border.all(color: this);
}

extension TextStyleExtension on TextStyle {
  TextStyle get bold => copyWith(fontWeight: FontWeight.bold);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improve code Improve the code
Projects
Status: In Review
Development

No branches or pull requests

2 participants