11import 'package:appflowy/generated/flowy_svgs.g.dart' ;
22import 'package:appflowy/generated/locale_keys.g.dart' ;
3- import 'package:appflowy/util/theme_extension.dart' ;
43import 'package:appflowy/workspace/presentation/home/menu/sidebar/space/shared_widget.dart' ;
4+ import 'package:appflowy_ui/appflowy_ui.dart' ;
55import 'package:easy_localization/easy_localization.dart' ;
66import 'package:flowy_infra/size.dart' ;
77import 'package:flowy_infra_ui/style_widget/text.dart' ;
@@ -260,18 +260,21 @@ class OkCancelButton extends StatelessWidget {
260260}
261261
262262ToastificationItem showToastNotification ({
263+ BuildContext ? context,
263264 String ? message,
264265 TextSpan ? richMessage,
265266 String ? description,
266267 ToastificationType type = ToastificationType .success,
267268 ToastificationCallbacks ? callbacks,
269+ bool showCloseButton = false ,
268270 double bottomPadding = 100 ,
269271}) {
270272 assert (
271273 (message == null ) != (richMessage == null ),
272274 "Exactly one of message or richMessage must be non-null." ,
273275 );
274276 return toastification.showCustom (
277+ context: context,
275278 alignment: Alignment .bottomCenter,
276279 autoCloseDuration: const Duration (milliseconds: 3000 ),
277280 callbacks: callbacks ?? const ToastificationCallbacks (),
@@ -288,6 +291,7 @@ ToastificationItem showToastNotification({
288291 richMessage: richMessage,
289292 type: type,
290293 onDismiss: () => toastification.dismiss (item),
294+ showCloseButton: showCloseButton,
291295 );
292296 },
293297 );
@@ -390,25 +394,31 @@ class DesktopToast extends StatelessWidget {
390394 this .richMessage,
391395 required this .type,
392396 this .onDismiss,
397+ this .showCloseButton = false ,
393398 });
394399
395400 final String ? message;
396401 final TextSpan ? richMessage;
397402 final ToastificationType type;
398403 final void Function ()? onDismiss;
404+ final bool showCloseButton;
399405
400406 @override
401407 Widget build (BuildContext context) {
408+ final theme = AppFlowyTheme .of (context);
409+
402410 return Center (
403411 child: Container (
404412 constraints: const BoxConstraints (maxWidth: 360.0 ),
405- padding: const EdgeInsets .symmetric (horizontal: 12.0 , vertical: 8.0 ),
413+ padding: EdgeInsets .symmetric (
414+ horizontal: theme.spacing.xl,
415+ vertical: theme.spacing.l,
416+ ),
406417 margin: const EdgeInsets .only (bottom: 32.0 ),
407418 decoration: BoxDecoration (
408- color: Theme .of (context).isLightMode
409- ? const Color (0xFF333333 )
410- : const Color (0xFF363D49 ),
411- borderRadius: const BorderRadius .all (Radius .circular (8.0 )),
419+ color: theme.surfaceColorScheme.inverse,
420+ borderRadius: BorderRadius .circular (theme.borderRadius.l),
421+ boxShadow: theme.shadow.small,
412422 ),
413423 child: Row (
414424 mainAxisSize: MainAxisSize .min,
@@ -425,42 +435,49 @@ class DesktopToast extends StatelessWidget {
425435 size: const Size .square (20.0 ),
426436 blendMode: null ,
427437 ),
428- const HSpace (8.0 ),
438+ HSpace (
439+ theme.spacing.m,
440+ ),
429441 // text
430442 Flexible (
431443 child: message != null
432- ? FlowyText (
444+ ? Text (
433445 message! ,
434446 maxLines: 2 ,
435- figmaLineHeight: 20.0 ,
436447 overflow: TextOverflow .ellipsis,
437- color: const Color (0xFFFFFFFF ),
448+ style: theme.textStyle.body.standard (
449+ color: theme.textColorScheme.onFill,
450+ ),
438451 )
439452 : RichText (
440453 text: richMessage! ,
441454 maxLines: 2 ,
442455 overflow: TextOverflow .ellipsis,
443456 ),
444457 ),
445- const HSpace (16.0 ),
446- // close
447- MouseRegion (
448- cursor: SystemMouseCursors .click,
449- child: GestureDetector (
450- behavior: HitTestBehavior .opaque,
451- onTap: onDismiss,
452- child: const SizedBox .square (
453- dimension: 24.0 ,
454- child: Center (
455- child: FlowySvg (
456- FlowySvgs .toast_close_s,
457- size: Size .square (16.0 ),
458- color: Color (0xFFBDBDBD ),
458+ if (showCloseButton) ...[
459+ HSpace (
460+ theme.spacing.xl,
461+ ),
462+ // close
463+ MouseRegion (
464+ cursor: SystemMouseCursors .click,
465+ child: GestureDetector (
466+ behavior: HitTestBehavior .opaque,
467+ onTap: onDismiss,
468+ child: const SizedBox .square (
469+ dimension: 24.0 ,
470+ child: Center (
471+ child: FlowySvg (
472+ FlowySvgs .toast_close_s,
473+ size: Size .square (20.0 ),
474+ color: Color (0xFFBDBDBD ),
475+ ),
459476 ),
460477 ),
461478 ),
462479 ),
463- ) ,
480+ ] ,
464481 ],
465482 ),
466483 ),
0 commit comments