Skip to content

Commit

Permalink
Merge pull request #28 from shetz163/master
Browse files Browse the repository at this point in the history
GZXDropDownHeaderItem add style
  • Loading branch information
GanZhiXiong authored Jun 3, 2020
2 parents bace915 + 98ce84a commit 5dba16f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 38 deletions.
8 changes: 5 additions & 3 deletions example/lib/gzx_dropdown_menu_test_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ class _GZXDropDownMenuTestPageState extends State<GZXDropDownMenuTestPage> {
items: [
GZXDropDownHeaderItem(_dropDownHeaderItemStrings[0]),
GZXDropDownHeaderItem(_dropDownHeaderItemStrings[1]),
GZXDropDownHeaderItem(_dropDownHeaderItemStrings[2]),
GZXDropDownHeaderItem(
_dropDownHeaderItemStrings[2],
style: TextStyle(color: Colors.yellow),
),
GZXDropDownHeaderItem(_dropDownHeaderItemStrings[3], iconData: Icons.filter_frames, iconSize: 18),
],
// GZXDropDownHeader对应第一父级Stack的key
Expand Down Expand Up @@ -194,8 +197,7 @@ class _GZXDropDownMenuTestPageState extends State<GZXDropDownMenuTestPage> {
dropDownHeight: 40 * 8.0,
dropDownWidget: _buildConditionListWidget(_brandSortConditions, (value) {
_selectBrandSortCondition = value;
_dropDownHeaderItemStrings[1] =
_selectBrandSortCondition.name == '全部' ? '品牌' : _selectBrandSortCondition.name;
_dropDownHeaderItemStrings[1] = _selectBrandSortCondition.name == '全部' ? '品牌' : _selectBrandSortCondition.name;
_dropdownMenuController.hide();
setState(() {});
})),
Expand Down
69 changes: 34 additions & 35 deletions lib/src/gzx_dropdown_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,40 +140,43 @@ class _GZXDropDownHeaderState extends State<GZXDropDownHeader> with SingleTicker
setState(() {});
},
child: Container(
color: widget.color,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Flexible(
child: Text(
color: widget.color,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Flexible(
child: Text(
item.title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: _isShowDropDownItemWidget ? _dropDownStyle : widget.style,
)),
Icon(
!_isShowDropDownItemWidget
? item.iconData ?? Icons.arrow_drop_down
: item.iconData ?? Icons.arrow_drop_up,
color: _isShowDropDownItemWidget ? _iconDropDownColor : widget.iconColor,
size: item.iconSize ?? widget.iconSize,
style: _isShowDropDownItemWidget ? _dropDownStyle : widget.style.merge(item.style),
),
],
),
),
Icon(
!_isShowDropDownItemWidget ? item.iconData ?? Icons.arrow_drop_down : item.iconData ?? Icons.arrow_drop_up,
color: _isShowDropDownItemWidget ? _iconDropDownColor : item?.style?.color ?? widget.iconColor,
size: item.iconSize ?? widget.iconSize,
),
],
),
index == widget.items.length - 1
? Container()
: Container(
height: widget.dividerHeight,
decoration:
BoxDecoration(border: Border(right: BorderSide(color: widget.dividerColor, width: 1))),
)
],
)),
),
index == widget.items.length - 1
? Container()
: Container(
height: widget.dividerHeight,
decoration: BoxDecoration(
border: Border(
right: BorderSide(color: widget.dividerColor, width: 1),
),
),
)
],
),
),
);
}
}
Expand All @@ -182,10 +185,6 @@ class GZXDropDownHeaderItem {
final String title;
final IconData iconData;
final double iconSize;

GZXDropDownHeaderItem(
this.title, {
this.iconData,
this.iconSize,
});
final TextStyle style;
GZXDropDownHeaderItem(this.title, {this.iconData, this.iconSize, this.style});
}

0 comments on commit 5dba16f

Please sign in to comment.