Skip to content

Commit

Permalink
Refactor container expansion logic and update UI to toggle arrow icon
Browse files Browse the repository at this point in the history
  • Loading branch information
Mozart299 committed Dec 19, 2024
1 parent 8d4ec23 commit 9d9f58c
Showing 1 changed file with 34 additions and 17 deletions.
51 changes: 34 additions & 17 deletions mobile-v3/lib/src/app/dashboard/widgets/analytics_specifics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ class _AnalyticsSpecificsState extends State<AnalyticsSpecifics> {
double containerHeight = 90;
bool expanded = false;

void expandContainer() {
void toggleContainer() {
setState(() {
containerHeight = 180;
expanded = true;
if (expanded) {
containerHeight = 90;
expanded = false;
} else {
containerHeight = 180;
expanded = true;
}
});
}

Expand Down Expand Up @@ -139,26 +144,38 @@ class _AnalyticsSpecificsState extends State<AnalyticsSpecifics> {
),
SizedBox(height: 8 + 4),
InkWell(
onTap: () => this.expandContainer(),
onTap: () => toggleContainer(),
child: AnimatedContainer(
duration: Duration(milliseconds: 300),
padding:
const EdgeInsets.symmetric(vertical: 16, horizontal: 8),
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 8),
height: containerHeight,
color: Theme.of(context).highlightColor,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"🚨 Air Quality Alerts",
style: TextStyle(
fontSize: 16, fontWeight: FontWeight.w600),
),
Icon(Icons.arrow_drop_down)
]),
child: Column(
children: [
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
)
],
),
if (expanded) ...[
SizedBox(height: 16),
Text(""),
],
],
),
decoration: BoxDecoration(
color: Theme.of(context).scaffoldBackgroundColor,
borderRadius: BorderRadius.circular(44)),
Expand Down

0 comments on commit 9d9f58c

Please sign in to comment.