-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
chore: adjust toast component #8060
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
chore: adjust toast component #8060
Conversation
Reviewer's GuideThis PR refactors the toast component to leverage AppFlowyTheme for all styling (spacing, colors, borders, shadows, and text) and introduces an optional close button toggle in DesktopToast. Sequence Diagram for Displaying a Toast with a Close ButtonsequenceDiagram
participant C as Client Code
participant S as showToastNotification()
participant T as Toastification
participant D as DesktopToast
C->>S: call(message, showCloseButton: true)
S->>T: show(builder: (context, item) -> ...)
T-->>S: item
S-->>C: item
T->>D: new DesktopToast(showCloseButton: true)
Updated Class Diagram for Toast ComponentsclassDiagram
direction LR
class showToastNotification {
+showToastNotification(description, type, callbacks, showCloseButton, bottomPadding) ToastificationItem
}
class DesktopToast {
+String? message
+TextSpan? richMessage
+ToastificationType type
+void Function()? onDismiss
+bool showCloseButton
+build(BuildContext context) Widget
}
showToastNotification --|> DesktopToast : creates
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @richardshiue - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `frontend/appflowy_flutter/lib/workspace/presentation/widgets/dialogs.dart:498` </location>
<code_context>
this.richMessage,
required this.type,
this.onDismiss,
+ this.showCloseButton = false,
});
</code_context>
<issue_to_address>
Assert that onDismiss is provided when showCloseButton is true
Add an assertion in the constructor to ensure that if showCloseButton is true, onDismiss is not null: `assert(!showCloseButton || onDismiss != null);`. This will prevent the close button from being non-functional.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
this.richMessage,
required this.type,
this.onDismiss,
this.showCloseButton = false,
});
=======
this.richMessage,
required this.type,
this.onDismiss,
this.showCloseButton = false,
}) : assert(!showCloseButton || onDismiss != null, 'onDismiss must be provided if showCloseButton is true');
>>>>>>> REPLACE
</suggested_fix>
### Comment 2
<location> `frontend/appflowy_flutter/lib/workspace/presentation/widgets/dialogs.dart:561` </location>
<code_context>
- child: FlowySvg(
- FlowySvgs.toast_close_s,
- size: Size.square(16.0),
- color: Color(0xFFBDBDBD),
+ if (showCloseButton) ...[
+ HSpace(
</code_context>
<issue_to_address>
Avoid hard-coded icon color; use theme colors instead
Use a theme-based color (e.g., `theme.iconColorScheme.onSurfaceVariant`) to ensure the icon adapts to different themes and modes.
Suggested implementation:
```
if (showCloseButton) ...[
HSpace(
```
```
// Close button
if (showCloseButton) ...[
HSpace(
theme.spacing.s,
),
FlowySvg(
FlowySvgs.toast_close_s,
size: Size.square(16.0),
color: theme.iconColorScheme.onSurfaceVariant,
),
],
// text
Flexible(
child: message != null
? Text(
message!,
maxLines: 2,
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| this.richMessage, | ||
| required this.type, | ||
| this.onDismiss, | ||
| this.showCloseButton = false, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (bug_risk): Assert that onDismiss is provided when showCloseButton is true
Add an assertion in the constructor to ensure that if showCloseButton is true, onDismiss is not null: assert(!showCloseButton || onDismiss != null);. This will prevent the close button from being non-functional.
| this.richMessage, | |
| required this.type, | |
| this.onDismiss, | |
| this.showCloseButton = false, | |
| }); | |
| this.richMessage, | |
| required this.type, | |
| this.onDismiss, | |
| this.showCloseButton = false, | |
| }) : assert(!showCloseButton || onDismiss != null, 'onDismiss must be provided if showCloseButton is true'); |
| color: Color(0xFFBDBDBD), | ||
| if (showCloseButton) ...[ | ||
| HSpace( | ||
| theme.spacing.xl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Avoid hard-coded icon color; use theme colors instead
Use a theme-based color (e.g., theme.iconColorScheme.onSurfaceVariant) to ensure the icon adapts to different themes and modes.
Suggested implementation:
if (showCloseButton) ...[
HSpace(
// Close button
if (showCloseButton) ...[
HSpace(
theme.spacing.s,
),
FlowySvg(
FlowySvgs.toast_close_s,
size: Size.square(16.0),
color: theme.iconColorScheme.onSurfaceVariant,
),
],
// text
Flexible(
child: message != null
? Text(
message!,
maxLines: 2,
68a1941 to
67a01c5
Compare
67a01c5 to
e761732
Compare
e761732 to
a08f2e9
Compare
Feature Preview
PR Checklist
Summary by Sourcery
Adjust the desktop toast component to use the new AppFlowyTheme for styling and add an optional close button.
Enhancements: