Skip to content
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

Added: expanded and collapsed color property for expansion icon #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class MyHomePageState extends State<MyHomePage> {
),
body: ExpandableTheme(
data: const ExpandableThemeData(
iconColor: Colors.blue,
useInkWell: true,
),
child: ListView(
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ packages:
path: ".."
relative: true
source: path
version: "5.0.0"
version: "5.0.1"
fake_async:
dependency: transitive
description:
Expand Down
22 changes: 15 additions & 7 deletions lib/expandable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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;
Expand Down Expand Up @@ -113,7 +115,8 @@ class ExpandableThemeData {
final BorderRadius? inkWellBorderRadius;

const ExpandableThemeData({
this.iconColor,
this.expandedIconColor,
this.collapsedIconColor,
this.useInkWell,
this.animationDuration,
this.scrollAnimationDuration,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 &&
Expand All @@ -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 &&
Expand Down Expand Up @@ -737,7 +745,7 @@ class _ExpandableIconState extends State<ExpandableIcon>
: animationController!.value),
child: Icon(
showSecondIcon ? theme.collapseIcon! : theme.expandIcon!,
color: theme.iconColor!,
color: showSecondIcon? theme.collapsedIconColor! : theme.expandedIconColor!,
size: theme.iconSize!,
),
);
Expand Down