-
Notifications
You must be signed in to change notification settings - Fork 508
feat: ✨ Tooltip actions' horizontal placement #570
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
Open
aditya-css
wants to merge
1
commit into
master
Choose a base branch
from
feature/tooltip_action_inside_horizontal
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import '../models/tooltip_action_config.dart'; | ||
import '../widget/action_widget.dart'; | ||
import '../widget/default_tooltip_text_widget.dart'; | ||
|
||
class ToolTipContent extends StatelessWidget { | ||
/// Builds the tooltip content layout based on action position configuration. | ||
/// | ||
/// Supports following layouts: | ||
/// - Vertical layout (actions at bottom) for [TooltipActionPosition.inside] | ||
/// - Horizontal layout (actions on left/right) for | ||
/// [TooltipActionPosition.insideLeft] and [TooltipActionPosition.insideRight] | ||
const ToolTipContent({ | ||
required this.description, | ||
required this.titleTextAlign, | ||
required this.descriptionTextAlign, | ||
required this.titleAlignment, | ||
required this.descriptionAlignment, | ||
required this.tooltipActionConfig, | ||
required this.tooltipActions, | ||
required this.textColor, | ||
this.title, | ||
this.titleTextStyle, | ||
this.descTextStyle, | ||
this.titlePadding, | ||
this.descriptionPadding, | ||
this.titleTextDirection, | ||
this.descriptionTextDirection, | ||
super.key, | ||
}) : assert( | ||
title != null || description != null, | ||
'Either title or description must be provided', | ||
); | ||
|
||
final String? title; | ||
final TextAlign titleTextAlign; | ||
final String? description; | ||
final TextAlign descriptionTextAlign; | ||
final AlignmentGeometry titleAlignment; | ||
final AlignmentGeometry descriptionAlignment; | ||
final TextStyle? titleTextStyle; | ||
final TextStyle? descTextStyle; | ||
final Color textColor; | ||
final EdgeInsets? titlePadding; | ||
final EdgeInsets? descriptionPadding; | ||
final TextDirection? titleTextDirection; | ||
final TextDirection? descriptionTextDirection; | ||
final TooltipActionConfig tooltipActionConfig; | ||
final List<Widget> tooltipActions; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final shouldShowActionsInside = | ||
tooltipActions.isNotEmpty && tooltipActionConfig.position.isInside; | ||
final textTheme = Theme.of(context).textTheme; | ||
|
||
// Build title widget | ||
Widget? titleWidget; | ||
if (title case final title?) { | ||
titleWidget = DefaultTooltipTextWidget( | ||
padding: titlePadding ?? EdgeInsets.zero, | ||
text: title, | ||
textAlign: titleTextAlign, | ||
alignment: titleAlignment, | ||
textColor: textColor, | ||
textDirection: titleTextDirection, | ||
textStyle: titleTextStyle ?? | ||
textTheme.titleLarge?.merge(TextStyle(color: textColor)), | ||
); | ||
} | ||
|
||
// Build description widget | ||
Widget? descriptionWidget; | ||
if (description case final desc?) { | ||
descriptionWidget = DefaultTooltipTextWidget( | ||
padding: descriptionPadding ?? EdgeInsets.zero, | ||
text: desc, | ||
textAlign: descriptionTextAlign, | ||
alignment: descriptionAlignment, | ||
textColor: textColor, | ||
textDirection: descriptionTextDirection, | ||
textStyle: descTextStyle ?? | ||
textTheme.titleSmall?.merge(TextStyle(color: textColor)), | ||
); | ||
} | ||
|
||
// Build action widget | ||
Widget? actionWidget; | ||
if (shouldShowActionsInside) { | ||
actionWidget = ActionWidget( | ||
tooltipActionConfig: tooltipActionConfig, | ||
children: tooltipActions, | ||
); | ||
} | ||
|
||
// For vertical action positioning (default), use Column layout | ||
final contentColumn = Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: <Widget>[ | ||
if (titleWidget != null) titleWidget, | ||
if (descriptionWidget != null) descriptionWidget, | ||
if (actionWidget != null && | ||
tooltipActionConfig.position.isInsideVertical) | ||
actionWidget, | ||
], | ||
); | ||
|
||
// If no horizontal action positioning, return vertical layout | ||
if (actionWidget == null || | ||
!tooltipActionConfig.position.isInsideHorizontal) { | ||
return contentColumn; | ||
} | ||
|
||
// For horizontal action positioning, use Row layout | ||
final gap = SizedBox( | ||
width: tooltipActionConfig.gapBetweenContentAndAction, | ||
); | ||
return Row( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
if (tooltipActionConfig.position.isInsideLeft) ...[ | ||
actionWidget, | ||
gap, | ||
], | ||
Flexible(child: contentColumn), | ||
if (tooltipActionConfig.position.isInsideRight) ...[ | ||
gap, | ||
actionWidget, | ||
], | ||
], | ||
); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The
description
parameter should remain required to maintain backward compatibility. Making it optional without a major version bump could break existing implementations that rely on the required nature of this parameter.Copilot uses AI. Check for mistakes.