-
Notifications
You must be signed in to change notification settings - Fork 33
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
Refactor container expansion logic and update UI to toggle arrow icon #2354
Conversation
📝 WalkthroughWalkthroughThe pull request modifies the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🧹 Nitpick comments (3)
mobile-v3/lib/src/app/dashboard/widgets/analytics_specifics.dart (3)
20-29
: Consider extracting magic numbers as constantsThe toggle logic is clean, but the hardcoded heights (90, 180) should be extracted as named constants for better maintainability.
Consider this refactor:
class _AnalyticsSpecificsState extends State<AnalyticsSpecifics> { + static const double COLLAPSED_HEIGHT = 90.0; + static const double EXPANDED_HEIGHT = 180.0; double containerHeight = 90; bool expanded = false; void toggleContainer() { setState(() { if (expanded) { - containerHeight = 90; + containerHeight = COLLAPSED_HEIGHT; expanded = false; } else { - containerHeight = 180; + containerHeight = EXPANDED_HEIGHT; expanded = true; } }); }
147-147
: Consider extracting animation duration as a constantThe animation configuration uses magic values that should be named constants for consistency and maintainability.
class _AnalyticsSpecificsState extends State<AnalyticsSpecifics> { + static const Duration TOGGLE_ANIMATION_DURATION = Duration(milliseconds: 300); // ... other code ... InkWell( onTap: () => toggleContainer(), child: AnimatedContainer( - duration: Duration(milliseconds: 300), + duration: TOGGLE_ANIMATION_DURATION,Also applies to: 150-152
155-172
: Consider extracting the alert header into a separate widgetThe alert header with the title and arrow icon could be extracted into a reusable widget for better maintainability and potential reuse.
+ class AlertHeader extends StatelessWidget { + final bool expanded; + const AlertHeader({required this.expanded}); + + @override + Widget build(BuildContext context) { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "🚨 Air Quality Alerts", + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600), + ), + Icon(expanded ? Icons.arrow_drop_up : Icons.arrow_drop_down) + ], + ); + } + } // Replace the existing Row with: - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - ... - ) + AlertHeader(expanded: expanded)
if (expanded) ...[ | ||
SizedBox(height: 16), | ||
Text(""), | ||
], |
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.
Remove empty Text widget and implement actual content
The expanded section contains a placeholder empty Text widget that should be replaced with meaningful content.
Would you like help implementing the expanded content section with actual air quality alerts? I can provide a template for displaying alert information.
Summary of Changes (What does this PR do?)
Status of maturity (all need to be checked before merging):
How should this be manually tested?
What are the relevant tickets?
Screenshots (optional)
Summary by CodeRabbit
New Features
Bug Fixes