From 37266f855fc202a16465ae99e2e729f978cf32ae Mon Sep 17 00:00:00 2001 From: Abdurahmon Date: Fri, 11 Jun 2021 17:12:04 +0500 Subject: [PATCH] add expanded and collapsed colors --- example/lib/main.dart | 3 +-- example/pubspec.lock | 2 +- lib/expandable.dart | 22 +++++++++++++++------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index fd22d56..f167662 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -34,7 +34,6 @@ class MyHomePageState extends State { ), body: ExpandableTheme( data: const ExpandableThemeData( - iconColor: Colors.blue, useInkWell: true, ), child: ListView( @@ -321,7 +320,7 @@ class Card3 extends StatelessWidget { theme: const ExpandableThemeData( expandIcon: Icons.arrow_right, collapseIcon: Icons.arrow_drop_down, - iconColor: Colors.white, + expandedIconColor: Colors.white, iconSize: 28.0, iconRotationAngle: math.pi / 2, iconPadding: EdgeInsets.only(right: 5), diff --git a/example/pubspec.lock b/example/pubspec.lock index 74a39b1..2b87eaf 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -49,7 +49,7 @@ packages: path: ".." relative: true source: path - version: "5.0.0" + version: "5.0.1" fake_async: dependency: transitive description: diff --git a/lib/expandable.dart b/lib/expandable.dart index 5b9f32d..ea71fc8 100644 --- a/lib/expandable.dart +++ b/lib/expandable.dart @@ -7,7 +7,8 @@ import 'package:flutter/material.dart'; class ExpandableThemeData { static final ExpandableThemeData defaults = ExpandableThemeData( - iconColor: Colors.black54, + expandedIconColor: Colors.black54, + collapsedIconColor: Colors.black54, useInkWell: true, inkWellBorderRadius: BorderRadius.zero, animationDuration: const Duration(milliseconds: 300), @@ -33,7 +34,8 @@ class ExpandableThemeData { static final ExpandableThemeData empty = ExpandableThemeData(); // Expand icon color. - final Color? iconColor; + final Color? expandedIconColor; + final Color? collapsedIconColor; // If true then [InkWell] will be used in the header for a ripple effect. final bool? useInkWell; @@ -113,7 +115,8 @@ class ExpandableThemeData { final BorderRadius? inkWellBorderRadius; const ExpandableThemeData({ - this.iconColor, + this.expandedIconColor, + this.collapsedIconColor, this.useInkWell, this.animationDuration, this.scrollAnimationDuration, @@ -146,7 +149,10 @@ class ExpandableThemeData { return theme; } else { return ExpandableThemeData( - iconColor: theme.iconColor ?? defaults.iconColor, + expandedIconColor: + theme.expandedIconColor ?? defaults.expandedIconColor, + collapsedIconColor: + theme.collapsedIconColor ?? defaults.collapsedIconColor, useInkWell: theme.useInkWell ?? defaults.useInkWell, inkWellBorderRadius: theme.inkWellBorderRadius ?? defaults.inkWellBorderRadius, @@ -197,7 +203,8 @@ class ExpandableThemeData { } bool isFull() { - return this.iconColor != null && + return this.expandedIconColor != null && + this.collapsedIconColor != null && this.useInkWell != null && this.inkWellBorderRadius != null && this.animationDuration != null && @@ -222,7 +229,8 @@ class ExpandableThemeData { if (identical(this, o)) { return true; } else if (o is ExpandableThemeData) { - return this.iconColor == o.iconColor && + return this.expandedIconColor == o.expandedIconColor && + this.collapsedIconColor == o.collapsedIconColor && this.useInkWell == o.useInkWell && this.inkWellBorderRadius == o.inkWellBorderRadius && this.animationDuration == o.animationDuration && @@ -737,7 +745,7 @@ class _ExpandableIconState extends State : animationController!.value), child: Icon( showSecondIcon ? theme.collapseIcon! : theme.expandIcon!, - color: theme.iconColor!, + color: showSecondIcon? theme.collapsedIconColor! : theme.expandedIconColor!, size: theme.iconSize!, ), );