| 
									
										
										
										
											2023-10-02 12:44:40 +05:30
										 |  |  | import 'package:appflowy/generated/locale_keys.g.dart'; | 
					
						
							| 
									
										
										
										
											2023-02-26 16:27:17 +08:00
										 |  |  | import 'package:appflowy/startup/startup.dart'; | 
					
						
							| 
									
										
										
										
											2023-10-02 12:44:40 +05:30
										 |  |  | import 'package:easy_localization/easy_localization.dart'; | 
					
						
							| 
									
										
										
										
											2022-11-19 17:53:30 +08:00
										 |  |  | import 'package:flowy_infra/size.dart'; | 
					
						
							| 
									
										
										
										
											2022-06-01 15:28:54 +08:00
										 |  |  | import 'package:flowy_infra_ui/style_widget/text.dart'; | 
					
						
							|  |  |  | import 'package:flutter/material.dart'; | 
					
						
							|  |  |  | import 'package:fluttertoast/fluttertoast.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class FlowyMessageToast extends StatelessWidget { | 
					
						
							|  |  |  |   final String message; | 
					
						
							|  |  |  |   const FlowyMessageToast({required this.message, Key? key}) : super(key: key); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   Widget build(BuildContext context) { | 
					
						
							| 
									
										
										
										
											2023-10-02 09:12:24 +02:00
										 |  |  |     return DecoratedBox( | 
					
						
							| 
									
										
										
										
											2023-04-10 21:18:36 -05:00
										 |  |  |       decoration: BoxDecoration( | 
					
						
							|  |  |  |         borderRadius: const BorderRadius.all(Radius.circular(4)), | 
					
						
							|  |  |  |         color: Theme.of(context).colorScheme.surface, | 
					
						
							| 
									
										
										
										
											2022-06-01 15:28:54 +08:00
										 |  |  |       ), | 
					
						
							| 
									
										
										
										
											2022-08-31 09:19:31 +08:00
										 |  |  |       child: Padding( | 
					
						
							|  |  |  |         padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), | 
					
						
							| 
									
										
										
										
											2022-11-19 17:53:30 +08:00
										 |  |  |         child: FlowyText.medium( | 
					
						
							|  |  |  |           message, | 
					
						
							|  |  |  |           fontSize: FontSizes.s16, | 
					
						
							|  |  |  |         ), | 
					
						
							| 
									
										
										
										
											2022-08-31 09:19:31 +08:00
										 |  |  |       ), | 
					
						
							| 
									
										
										
										
											2022-06-01 15:28:54 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void initToastWithContext(BuildContext context) { | 
					
						
							|  |  |  |   getIt<FToast>().init(context); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void showMessageToast(String message) { | 
					
						
							|  |  |  |   final child = FlowyMessageToast(message: message); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getIt<FToast>().showToast( | 
					
						
							|  |  |  |     child: child, | 
					
						
							|  |  |  |     gravity: ToastGravity.BOTTOM, | 
					
						
							|  |  |  |     toastDuration: const Duration(seconds: 3), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-06-10 22:38:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-02 12:44:40 +05:30
										 |  |  | void showSnackBarMessage( | 
					
						
							|  |  |  |   BuildContext context, | 
					
						
							|  |  |  |   String message, { | 
					
						
							|  |  |  |   bool showCancel = false, | 
					
						
							|  |  |  | }) { | 
					
						
							| 
									
										
										
										
											2023-06-10 22:38:25 +08:00
										 |  |  |   ScaffoldMessenger.of(context).showSnackBar( | 
					
						
							|  |  |  |     SnackBar( | 
					
						
							| 
									
										
										
										
											2023-10-02 12:44:40 +05:30
										 |  |  |       action: !showCancel | 
					
						
							|  |  |  |           ? null | 
					
						
							|  |  |  |           : SnackBarAction( | 
					
						
							|  |  |  |               label: LocaleKeys.button_Cancel.tr(), | 
					
						
							|  |  |  |               textColor: Theme.of(context).colorScheme.onSurface, | 
					
						
							|  |  |  |               onPressed: () { | 
					
						
							|  |  |  |                 ScaffoldMessenger.of(context).hideCurrentSnackBar(); | 
					
						
							|  |  |  |               }, | 
					
						
							|  |  |  |             ), | 
					
						
							| 
									
										
										
										
											2023-06-10 22:38:25 +08:00
										 |  |  |       content: FlowyText( | 
					
						
							|  |  |  |         message, | 
					
						
							|  |  |  |         color: Theme.of(context).colorScheme.onSurface, | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } |