YSColors.dart 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_wallet/tools/YSTools.dart';
  3. import 'package:provider/provider.dart';
  4. final ThemeData lightTheme = ThemeData(
  5. primaryColor: const Color(0xFFF1F1F1),
  6. cardColor: Colors.white,
  7. canvasColor: const Color(0xFFF6F6F6),
  8. dividerColor: const Color(0xFFE6E0E0),
  9. indicatorColor: Colors.black,
  10. disabledColor: Colors.black54,
  11. shadowColor: Colors.black45,
  12. primaryColorDark: const Color(0xFF4C4A5A),
  13. primaryColorLight: const Color(0xFF9F9F9F),
  14. textTheme: TextTheme(
  15. titleMedium: TextStyle(fontSize: zsp(14),color: const Color(0xFF4C4A5A)),
  16. titleLarge: TextStyle(fontSize: zsp(21),color: const Color(0xFF4C4A5A)),
  17. titleSmall: TextStyle(fontSize: zsp(12),color: const Color(0xFF9F9F9F)),
  18. bodyMedium: TextStyle(fontSize: zsp(14),color: Colors.white),
  19. bodyLarge: TextStyle(fontSize: zsp(21),color: Colors.white),
  20. bodySmall: TextStyle(fontSize: zsp(12),color: Colors.white),
  21. headlineMedium: TextStyle(fontSize: zsp(18),color: Colors.white),
  22. labelMedium: TextStyle(fontSize: zsp(14),color: const Color(0xFF969799)),
  23. labelLarge: TextStyle(fontSize: zsp(21),color: const Color(0xFF969799)),
  24. labelSmall: TextStyle(fontSize: zsp(12),color: const Color(0xFF969799)),
  25. displayMedium: TextStyle(fontSize: zsp(14),color: Colors.black),
  26. displayLarge: TextStyle(fontSize: zsp(21),color: Colors.black),
  27. displaySmall: TextStyle(fontSize: zsp(12),color: Colors.black),
  28. ),
  29. tabBarTheme: const TabBarTheme(
  30. unselectedLabelColor: Color(0xFF9F9F9F),
  31. labelColor: Colors.black,
  32. dividerColor: Color(0xFFF6F6F6)
  33. ),
  34. hintColor: Colors.black,
  35. );
  36. final ThemeData darkTheme = ThemeData(
  37. primaryColor: const Color(0xFF212123),
  38. cardColor: const Color(0xFF212123),
  39. canvasColor: const Color(0xFFF6F6F6),
  40. dividerColor: const Color(0xFFE6E0E0),
  41. indicatorColor: Colors.white,
  42. disabledColor: Colors.black54,
  43. shadowColor: Colors.black45,
  44. primaryColorDark: const Color(0xFF4C4A5A),
  45. primaryColorLight: const Color(0xFF9F9F9F),
  46. textTheme: TextTheme(
  47. titleMedium: TextStyle(fontSize: zsp(14),color: Colors.white),
  48. titleLarge: TextStyle(fontSize: zsp(21),color: Colors.white),
  49. titleSmall: TextStyle(fontSize: zsp(12),color: Colors.white),
  50. bodyMedium: TextStyle(fontSize: zsp(14),color: Colors.white),
  51. bodyLarge: TextStyle(fontSize: zsp(21),color: Colors.white),
  52. bodySmall: TextStyle(fontSize: zsp(12),color: Colors.white),
  53. headlineMedium: TextStyle(fontSize: zsp(18),color: Colors.white),
  54. labelMedium: TextStyle(fontSize: zsp(14),color: const Color(0xFF969799)),
  55. labelLarge: TextStyle(fontSize: zsp(21),color: const Color(0xFF969799)),
  56. labelSmall: TextStyle(fontSize: zsp(12),color: const Color(0xFF969799)),
  57. displayMedium: TextStyle(fontSize: zsp(14),color: Colors.black),
  58. displayLarge: TextStyle(fontSize: zsp(21),color: Colors.black),
  59. displaySmall: TextStyle(fontSize: zsp(12),color: Colors.black),
  60. ),
  61. tabBarTheme: const TabBarTheme(
  62. unselectedLabelColor: Color(0xFF9F9F9F),
  63. labelColor: Colors.black,
  64. dividerColor: Color(0xFF212123)
  65. ),
  66. hintColor: Colors.black,
  67. );
  68. class ThemeManager with ChangeNotifier {
  69. ThemeData themeData = darkTheme;
  70. ThemeData get value => themeData;
  71. setTheme(ThemeData theme) {
  72. themeData = theme;
  73. notifyListeners();
  74. }
  75. }
  76. setThemFunc(BuildContext context,ThemeData data) {
  77. final themeManager = Provider.of<ThemeManager>(context, listen: false);
  78. themeManager.setTheme(data);
  79. }
  80. class YSColors{
  81. static TextStyle titleStyle(BuildContext context) => TextStyle(fontSize: zsp(18),color: Theme.of(context).textTheme.titleLarge?.color,
  82. fontWeight: FontWeight.normal,decoration: TextDecoration.none);
  83. static TextStyle title2Style(BuildContext context) => TextStyle(fontSize: zsp(18),color: Theme.of(context).textTheme.bodyLarge?.color,
  84. fontWeight: FontWeight.normal,decoration: TextDecoration.none);
  85. static TextStyle title3Style(BuildContext context) => TextStyle(fontSize: zsp(18),color: Theme.of(context).textTheme.labelLarge?.color,
  86. fontWeight: FontWeight.normal,decoration: TextDecoration.none);
  87. static TextStyle title4Style(BuildContext context) => TextStyle(fontSize: zsp(18),color: Theme.of(context).textTheme.displayLarge?.color,
  88. fontWeight: FontWeight.normal,decoration: TextDecoration.none);
  89. static TextStyle contentStyle(BuildContext context) => TextStyle(fontSize: zsp(14),color: Theme.of(context).textTheme.titleMedium?.color,
  90. fontWeight: FontWeight.normal,decoration: TextDecoration.none);
  91. static TextStyle content2Style(BuildContext context) => TextStyle(fontSize: zsp(14),color: Theme.of(context).textTheme.bodyMedium?.color,
  92. fontWeight: FontWeight.normal,decoration: TextDecoration.none);
  93. static TextStyle content3Style(BuildContext context) => TextStyle(fontSize: zsp(14),color: Theme.of(context).textTheme.labelMedium?.color,
  94. fontWeight: FontWeight.normal,decoration: TextDecoration.none);
  95. static TextStyle content4Style(BuildContext context) => TextStyle(fontSize: zsp(14),color: Theme.of(context).textTheme.displayMedium?.color,
  96. fontWeight: FontWeight.normal,decoration: TextDecoration.none);
  97. static TextStyle subStyle(BuildContext context) => TextStyle(fontSize: zsp(12),color: Theme.of(context).textTheme.titleSmall?.color,
  98. fontWeight: FontWeight.normal,decoration: TextDecoration.none);
  99. static TextStyle sub2Style(BuildContext context) => TextStyle(fontSize: zsp(12),color: Theme.of(context).textTheme.bodySmall?.color,
  100. fontWeight: FontWeight.normal,decoration: TextDecoration.none);
  101. static TextStyle sub3Style(BuildContext context) => TextStyle(fontSize: zsp(12),color: Theme.of(context).textTheme.labelSmall?.color,
  102. fontWeight: FontWeight.normal,decoration: TextDecoration.none);
  103. static TextStyle sub4Style(BuildContext context) => TextStyle(fontSize: zsp(12),color: Theme.of(context).textTheme.displaySmall?.color,
  104. fontWeight: FontWeight.normal,decoration: TextDecoration.none);
  105. static backgroundColor(BuildContext context) => Theme.of(context).primaryColor;
  106. static containColor(BuildContext context) => Theme.of(context).cardColor;
  107. static contain2Color(BuildContext context) => Theme.of(context).canvasColor;
  108. static unSelectedColor(BuildContext context) => Theme.of(context).tabBarTheme.unselectedLabelColor;
  109. static selectedColor(BuildContext context) => Theme.of(context).tabBarTheme.labelColor;
  110. static tabColor(BuildContext context) => Theme.of(context).tabBarTheme.dividerColor;
  111. static lineColor(BuildContext context) => Theme.of(context).dividerColor;
  112. static shadowColor(BuildContext context) => Theme.of(context).shadowColor;
  113. static alertColor(BuildContext context) => Theme.of(context).disabledColor;
  114. static buttonColor(BuildContext context) => Theme.of(context).hintColor;
  115. static TextStyle buttonStyle(BuildContext context) => TextStyle(fontSize: zsp(18),color: Theme.of(context).textTheme.headlineMedium?.color);
  116. static sColor(BuildContext context) => Theme.of(context).primaryColorDark;
  117. static uColor(BuildContext context) => Theme.of(context).primaryColorLight;
  118. static iconColor(BuildContext context) => Theme.of(context).indicatorColor;
  119. static String imageStyle(BuildContext context,String name){
  120. String path = 'images/$name.png';
  121. if(Theme.of(context).primaryColor != const Color(0xFFF1F1F1)){
  122. path = 'images/$name.png';
  123. }
  124. return path;
  125. }
  126. }
  127. // static titleStyle(BuildContext context) => Theme.of(context).textTheme.titleLarge;
  128. // static title2Style(BuildContext context) => Theme.of(context).textTheme.bodyLarge;
  129. // static title3Style(BuildContext context) => Theme.of(context).textTheme.labelLarge;
  130. // static contentStyle(BuildContext context) => Theme.of(context).textTheme.titleMedium;
  131. // static content2Style(BuildContext context) => Theme.of(context).textTheme.bodyMedium;
  132. // static content3Style(BuildContext context) => Theme.of(context).textTheme.labelMedium;
  133. // static subStyle(BuildContext context) => Theme.of(context).textTheme.titleSmall;
  134. // static sub2Style(BuildContext context) => Theme.of(context).textTheme.bodySmall;
  135. // static sub3Style(BuildContext context) => Theme.of(context).textTheme.labelSmall;
  136. // static buttonStyle(BuildContext context) => Theme.of(context).textTheme.headlineMedium;