| 
									
										
										
										
											2022-11-10 14:22:18 +08:00
										 |  |  | import 'package:flutter/material.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @immutable | 
					
						
							| 
									
										
										
										
											2022-11-17 15:28:57 +08:00
										 |  |  | class AFThemeExtension extends ThemeExtension<AFThemeExtension> { | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   static AFThemeExtension of(BuildContext context) => | 
					
						
							|  |  |  |       Theme.of(context).extension<AFThemeExtension>()!; | 
					
						
							| 
									
										
										
										
											2022-11-17 15:28:57 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   const AFThemeExtension({ | 
					
						
							| 
									
										
										
										
											2022-11-10 14:22:18 +08:00
										 |  |  |     required this.warning, | 
					
						
							|  |  |  |     required this.success, | 
					
						
							| 
									
										
										
										
											2022-11-22 20:06:32 +08:00
										 |  |  |     required this.tint1, | 
					
						
							|  |  |  |     required this.tint2, | 
					
						
							|  |  |  |     required this.tint3, | 
					
						
							|  |  |  |     required this.tint4, | 
					
						
							|  |  |  |     required this.tint5, | 
					
						
							|  |  |  |     required this.tint6, | 
					
						
							|  |  |  |     required this.tint7, | 
					
						
							|  |  |  |     required this.tint8, | 
					
						
							|  |  |  |     required this.tint9, | 
					
						
							| 
									
										
										
										
											2022-11-10 14:22:18 +08:00
										 |  |  |     required this.greyHover, | 
					
						
							|  |  |  |     required this.greySelect, | 
					
						
							|  |  |  |     required this.lightGreyHover, | 
					
						
							|  |  |  |     required this.toggleOffFill, | 
					
						
							| 
									
										
										
										
											2023-04-03 23:51:26 -05:00
										 |  |  |     required this.textColor, | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |     required this.secondaryTextColor, | 
					
						
							| 
									
										
										
										
											2023-08-10 07:59:24 -05:00
										 |  |  |     required this.calloutBGColor, | 
					
						
							| 
									
										
										
										
											2023-09-01 10:15:21 +03:30
										 |  |  |     required this.tableCellBGColor, | 
					
						
							| 
									
										
										
										
											2023-09-23 09:47:48 +08:00
										 |  |  |     required this.calendarWeekendBGColor, | 
					
						
							| 
									
										
										
										
											2022-11-17 15:28:57 +08:00
										 |  |  |     required this.code, | 
					
						
							|  |  |  |     required this.callout, | 
					
						
							|  |  |  |     required this.caption, | 
					
						
							| 
									
										
										
										
											2023-05-01 21:18:51 -05:00
										 |  |  |     required this.progressBarBGColor, | 
					
						
							|  |  |  |     required this.toggleButtonBGColor, | 
					
						
							| 
									
										
										
										
											2023-09-24 17:55:47 +05:30
										 |  |  |     required this.gridRowCountColor, | 
					
						
							| 
									
										
										
										
											2022-11-10 14:22:18 +08:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   final Color? warning; | 
					
						
							|  |  |  |   final Color? success; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   final Color tint1; | 
					
						
							|  |  |  |   final Color tint2; | 
					
						
							|  |  |  |   final Color tint3; | 
					
						
							|  |  |  |   final Color tint4; | 
					
						
							|  |  |  |   final Color tint5; | 
					
						
							|  |  |  |   final Color tint6; | 
					
						
							|  |  |  |   final Color tint7; | 
					
						
							|  |  |  |   final Color tint8; | 
					
						
							|  |  |  |   final Color tint9; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   final Color textColor; | 
					
						
							|  |  |  |   final Color secondaryTextColor; | 
					
						
							|  |  |  |   final Color greyHover; | 
					
						
							|  |  |  |   final Color greySelect; | 
					
						
							|  |  |  |   final Color lightGreyHover; | 
					
						
							|  |  |  |   final Color toggleOffFill; | 
					
						
							|  |  |  |   final Color progressBarBGColor; | 
					
						
							|  |  |  |   final Color toggleButtonBGColor; | 
					
						
							|  |  |  |   final Color calloutBGColor; | 
					
						
							|  |  |  |   final Color tableCellBGColor; | 
					
						
							|  |  |  |   final Color calendarWeekendBGColor; | 
					
						
							|  |  |  |   final Color gridRowCountColor; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   final TextStyle code; | 
					
						
							|  |  |  |   final TextStyle callout; | 
					
						
							|  |  |  |   final TextStyle caption; | 
					
						
							| 
									
										
										
										
											2022-11-10 14:22:18 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							| 
									
										
										
										
											2022-11-17 15:28:57 +08:00
										 |  |  |   AFThemeExtension copyWith({ | 
					
						
							| 
									
										
										
										
											2022-11-10 14:22:18 +08:00
										 |  |  |     Color? warning, | 
					
						
							|  |  |  |     Color? success, | 
					
						
							| 
									
										
										
										
											2022-11-22 20:06:32 +08:00
										 |  |  |     Color? tint1, | 
					
						
							|  |  |  |     Color? tint2, | 
					
						
							|  |  |  |     Color? tint3, | 
					
						
							|  |  |  |     Color? tint4, | 
					
						
							|  |  |  |     Color? tint5, | 
					
						
							|  |  |  |     Color? tint6, | 
					
						
							|  |  |  |     Color? tint7, | 
					
						
							|  |  |  |     Color? tint8, | 
					
						
							|  |  |  |     Color? tint9, | 
					
						
							| 
									
										
										
										
											2023-04-03 23:51:26 -05:00
										 |  |  |     Color? textColor, | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |     Color? secondaryTextColor, | 
					
						
							| 
									
										
										
										
											2023-08-10 07:59:24 -05:00
										 |  |  |     Color? calloutBGColor, | 
					
						
							| 
									
										
										
										
											2023-09-01 10:15:21 +03:30
										 |  |  |     Color? tableCellBGColor, | 
					
						
							| 
									
										
										
										
											2022-11-10 14:22:18 +08:00
										 |  |  |     Color? greyHover, | 
					
						
							|  |  |  |     Color? greySelect, | 
					
						
							|  |  |  |     Color? lightGreyHover, | 
					
						
							|  |  |  |     Color? toggleOffFill, | 
					
						
							| 
									
										
										
										
											2023-05-01 21:18:51 -05:00
										 |  |  |     Color? progressBarBGColor, | 
					
						
							|  |  |  |     Color? toggleButtonBGColor, | 
					
						
							| 
									
										
										
										
											2023-09-23 09:47:48 +08:00
										 |  |  |     Color? calendarWeekendBGColor, | 
					
						
							| 
									
										
										
										
											2023-09-24 17:55:47 +05:30
										 |  |  |     Color? gridRowCountColor, | 
					
						
							| 
									
										
										
										
											2022-11-17 15:28:57 +08:00
										 |  |  |     TextStyle? code, | 
					
						
							|  |  |  |     TextStyle? callout, | 
					
						
							|  |  |  |     TextStyle? caption, | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   }) => | 
					
						
							|  |  |  |       AFThemeExtension( | 
					
						
							|  |  |  |         warning: warning ?? this.warning, | 
					
						
							|  |  |  |         success: success ?? this.success, | 
					
						
							|  |  |  |         tint1: tint1 ?? this.tint1, | 
					
						
							|  |  |  |         tint2: tint2 ?? this.tint2, | 
					
						
							|  |  |  |         tint3: tint3 ?? this.tint3, | 
					
						
							|  |  |  |         tint4: tint4 ?? this.tint4, | 
					
						
							|  |  |  |         tint5: tint5 ?? this.tint5, | 
					
						
							|  |  |  |         tint6: tint6 ?? this.tint6, | 
					
						
							|  |  |  |         tint7: tint7 ?? this.tint7, | 
					
						
							|  |  |  |         tint8: tint8 ?? this.tint8, | 
					
						
							|  |  |  |         tint9: tint9 ?? this.tint9, | 
					
						
							|  |  |  |         textColor: textColor ?? this.textColor, | 
					
						
							|  |  |  |         secondaryTextColor: secondaryTextColor ?? this.secondaryTextColor, | 
					
						
							|  |  |  |         calloutBGColor: calloutBGColor ?? this.calloutBGColor, | 
					
						
							|  |  |  |         tableCellBGColor: tableCellBGColor ?? this.tableCellBGColor, | 
					
						
							|  |  |  |         greyHover: greyHover ?? this.greyHover, | 
					
						
							|  |  |  |         greySelect: greySelect ?? this.greySelect, | 
					
						
							|  |  |  |         lightGreyHover: lightGreyHover ?? this.lightGreyHover, | 
					
						
							|  |  |  |         toggleOffFill: toggleOffFill ?? this.toggleOffFill, | 
					
						
							|  |  |  |         progressBarBGColor: progressBarBGColor ?? this.progressBarBGColor, | 
					
						
							|  |  |  |         toggleButtonBGColor: toggleButtonBGColor ?? this.toggleButtonBGColor, | 
					
						
							|  |  |  |         calendarWeekendBGColor: | 
					
						
							|  |  |  |             calendarWeekendBGColor ?? this.calendarWeekendBGColor, | 
					
						
							|  |  |  |         gridRowCountColor: gridRowCountColor ?? this.gridRowCountColor, | 
					
						
							|  |  |  |         code: code ?? this.code, | 
					
						
							|  |  |  |         callout: callout ?? this.callout, | 
					
						
							|  |  |  |         caption: caption ?? this.caption, | 
					
						
							|  |  |  |       ); | 
					
						
							| 
									
										
										
										
											2022-11-10 14:22:18 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							| 
									
										
										
										
											2022-11-17 15:28:57 +08:00
										 |  |  |   ThemeExtension<AFThemeExtension> lerp( | 
					
						
							|  |  |  |       ThemeExtension<AFThemeExtension>? other, double t) { | 
					
						
							|  |  |  |     if (other is! AFThemeExtension) { | 
					
						
							| 
									
										
										
										
											2022-11-10 14:22:18 +08:00
										 |  |  |       return this; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-11-17 15:28:57 +08:00
										 |  |  |     return AFThemeExtension( | 
					
						
							| 
									
										
										
										
											2022-11-10 14:22:18 +08:00
										 |  |  |       warning: Color.lerp(warning, other.warning, t), | 
					
						
							|  |  |  |       success: Color.lerp(success, other.success, t), | 
					
						
							| 
									
										
										
										
											2022-11-22 20:06:32 +08:00
										 |  |  |       tint1: Color.lerp(tint1, other.tint1, t)!, | 
					
						
							|  |  |  |       tint2: Color.lerp(tint2, other.tint2, t)!, | 
					
						
							|  |  |  |       tint3: Color.lerp(tint3, other.tint3, t)!, | 
					
						
							|  |  |  |       tint4: Color.lerp(tint4, other.tint4, t)!, | 
					
						
							|  |  |  |       tint5: Color.lerp(tint5, other.tint5, t)!, | 
					
						
							|  |  |  |       tint6: Color.lerp(tint6, other.tint6, t)!, | 
					
						
							|  |  |  |       tint7: Color.lerp(tint7, other.tint7, t)!, | 
					
						
							|  |  |  |       tint8: Color.lerp(tint8, other.tint8, t)!, | 
					
						
							|  |  |  |       tint9: Color.lerp(tint9, other.tint9, t)!, | 
					
						
							| 
									
										
										
										
											2023-04-03 23:51:26 -05:00
										 |  |  |       textColor: Color.lerp(textColor, other.textColor, t)!, | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |       secondaryTextColor: Color.lerp( | 
					
						
							|  |  |  |         secondaryTextColor, | 
					
						
							|  |  |  |         other.secondaryTextColor, | 
					
						
							|  |  |  |         t, | 
					
						
							|  |  |  |       )!, | 
					
						
							| 
									
										
										
										
											2023-08-10 07:59:24 -05:00
										 |  |  |       calloutBGColor: Color.lerp(calloutBGColor, other.calloutBGColor, t)!, | 
					
						
							| 
									
										
										
										
											2023-09-01 10:15:21 +03:30
										 |  |  |       tableCellBGColor: | 
					
						
							|  |  |  |           Color.lerp(tableCellBGColor, other.tableCellBGColor, t)!, | 
					
						
							| 
									
										
										
										
											2022-11-10 14:22:18 +08:00
										 |  |  |       greyHover: Color.lerp(greyHover, other.greyHover, t)!, | 
					
						
							|  |  |  |       greySelect: Color.lerp(greySelect, other.greySelect, t)!, | 
					
						
							|  |  |  |       lightGreyHover: Color.lerp(lightGreyHover, other.lightGreyHover, t)!, | 
					
						
							|  |  |  |       toggleOffFill: Color.lerp(toggleOffFill, other.toggleOffFill, t)!, | 
					
						
							| 
									
										
										
										
											2023-05-01 21:18:51 -05:00
										 |  |  |       progressBarBGColor: | 
					
						
							|  |  |  |           Color.lerp(progressBarBGColor, other.progressBarBGColor, t)!, | 
					
						
							|  |  |  |       toggleButtonBGColor: | 
					
						
							|  |  |  |           Color.lerp(toggleButtonBGColor, other.toggleButtonBGColor, t)!, | 
					
						
							| 
									
										
										
										
											2023-09-23 09:47:48 +08:00
										 |  |  |       calendarWeekendBGColor: | 
					
						
							|  |  |  |           Color.lerp(calendarWeekendBGColor, other.calendarWeekendBGColor, t)!, | 
					
						
							| 
									
										
										
										
											2023-10-05 10:40:41 +08:00
										 |  |  |       gridRowCountColor: | 
					
						
							|  |  |  |           Color.lerp(gridRowCountColor, other.gridRowCountColor, t)!, | 
					
						
							| 
									
										
										
										
											2022-11-17 15:28:57 +08:00
										 |  |  |       code: other.code, | 
					
						
							|  |  |  |       callout: other.callout, | 
					
						
							|  |  |  |       caption: other.caption, | 
					
						
							| 
									
										
										
										
											2022-11-10 14:22:18 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-01-30 03:56:19 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | enum FlowyTint { | 
					
						
							|  |  |  |   tint1, | 
					
						
							|  |  |  |   tint2, | 
					
						
							|  |  |  |   tint3, | 
					
						
							|  |  |  |   tint4, | 
					
						
							|  |  |  |   tint5, | 
					
						
							|  |  |  |   tint6, | 
					
						
							|  |  |  |   tint7, | 
					
						
							|  |  |  |   tint8, | 
					
						
							|  |  |  |   tint9; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   String toJson() => name; | 
					
						
							|  |  |  |   static FlowyTint fromJson(String json) { | 
					
						
							|  |  |  |     try { | 
					
						
							|  |  |  |       return FlowyTint.values.byName(json); | 
					
						
							|  |  |  |     } catch (_) { | 
					
						
							|  |  |  |       return FlowyTint.tint1; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 16:55:15 +08:00
										 |  |  |   static FlowyTint fromId(String id) { | 
					
						
							|  |  |  |     return FlowyTint.values.firstWhere( | 
					
						
							|  |  |  |       (element) => element.id == id, | 
					
						
							|  |  |  |       orElse: () => FlowyTint.tint1, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |    | 
					
						
							|  |  |  |   Color color(BuildContext context) => switch (this) { | 
					
						
							|  |  |  |         FlowyTint.tint1 => AFThemeExtension.of(context).tint1, | 
					
						
							|  |  |  |         FlowyTint.tint2 => AFThemeExtension.of(context).tint2, | 
					
						
							|  |  |  |         FlowyTint.tint3 => AFThemeExtension.of(context).tint3, | 
					
						
							|  |  |  |         FlowyTint.tint4 => AFThemeExtension.of(context).tint4, | 
					
						
							|  |  |  |         FlowyTint.tint5 => AFThemeExtension.of(context).tint5, | 
					
						
							|  |  |  |         FlowyTint.tint6 => AFThemeExtension.of(context).tint6, | 
					
						
							|  |  |  |         FlowyTint.tint7 => AFThemeExtension.of(context).tint7, | 
					
						
							|  |  |  |         FlowyTint.tint8 => AFThemeExtension.of(context).tint8, | 
					
						
							|  |  |  |         FlowyTint.tint9 => AFThemeExtension.of(context).tint9, | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2024-04-30 16:55:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   String get id => switch (this) { | 
					
						
							|  |  |  |         // DON'T change this name because it's saved in the database!
 | 
					
						
							|  |  |  |         FlowyTint.tint1 => 'appflowy_them_color_tint1', | 
					
						
							|  |  |  |         FlowyTint.tint2 => 'appflowy_them_color_tint2', | 
					
						
							|  |  |  |         FlowyTint.tint3 => 'appflowy_them_color_tint3', | 
					
						
							|  |  |  |         FlowyTint.tint4 => 'appflowy_them_color_tint4', | 
					
						
							|  |  |  |         FlowyTint.tint5 => 'appflowy_them_color_tint5', | 
					
						
							|  |  |  |         FlowyTint.tint6 => 'appflowy_them_color_tint6', | 
					
						
							|  |  |  |         FlowyTint.tint7 => 'appflowy_them_color_tint7', | 
					
						
							|  |  |  |         FlowyTint.tint8 => 'appflowy_them_color_tint8', | 
					
						
							|  |  |  |         FlowyTint.tint9 => 'appflowy_them_color_tint9', | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2023-01-30 03:56:19 +01:00
										 |  |  | } |