Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
GanZhiXiong committed Apr 7, 2021
1 parent 4b21249 commit 55ed903
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
26 changes: 18 additions & 8 deletions lib/src/gzx_dropdown_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class GZXDropDownHeader extends StatefulWidget {
_GZXDropDownHeaderState createState() => _GZXDropDownHeaderState();
}

class _GZXDropDownHeaderState extends State<GZXDropDownHeader> with SingleTickerProviderStateMixin {
class _GZXDropDownHeaderState extends State<GZXDropDownHeader>
with SingleTickerProviderStateMixin {
bool _isShowDropDownItemWidget = false;
late double _screenWidth;
late int _menuCount;
Expand All @@ -75,8 +76,10 @@ class _GZXDropDownHeaderState extends State<GZXDropDownHeader> with SingleTicker
Widget build(BuildContext context) {
// print('_GZXDropDownHeaderState.build');

_dropDownStyle = widget.dropDownStyle ?? TextStyle(color: Theme.of(context).primaryColor, fontSize: 13);
_iconDropDownColor = widget.iconDropDownColor ?? Theme.of(context).primaryColor;
_dropDownStyle = widget.dropDownStyle ??
TextStyle(color: Theme.of(context).primaryColor, fontSize: 13);
_iconDropDownColor =
widget.iconDropDownColor ?? Theme.of(context).primaryColor;

MediaQueryData mediaQuery = MediaQuery.of(context);
_screenWidth = mediaQuery.size.width;
Expand Down Expand Up @@ -116,11 +119,14 @@ class _GZXDropDownHeaderState extends State<GZXDropDownHeader> with SingleTicker

return GestureDetector(
onTap: () {
final RenderBox? overlay = widget.stackKey.currentContext!.findRenderObject() as RenderBox?;
final RenderBox? overlay =
widget.stackKey.currentContext!.findRenderObject() as RenderBox?;

final RenderBox dropDownItemRenderBox = _keyDropDownHeader.currentContext!.findRenderObject() as RenderBox;
final RenderBox dropDownItemRenderBox =
_keyDropDownHeader.currentContext!.findRenderObject() as RenderBox;

var position = dropDownItemRenderBox.localToGlobal(Offset.zero, ancestor: overlay);
var position =
dropDownItemRenderBox.localToGlobal(Offset.zero, ancestor: overlay);
// print("POSITION : $position ");
var size = dropDownItemRenderBox.size;
// print("SIZE : $size");
Expand Down Expand Up @@ -160,14 +166,18 @@ class _GZXDropDownHeaderState extends State<GZXDropDownHeader> with SingleTicker
item.title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: _isShowDropDownItemWidget ? _dropDownStyle : widget.style.merge(item.style),
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,
color: _isShowDropDownItemWidget
? _iconDropDownColor
: item.style?.color ?? widget.iconColor,
size: item.iconSize ?? widget.iconSize,
),
],
Expand Down
20 changes: 13 additions & 7 deletions lib/src/gzx_dropdown_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class GZXDropDownMenu extends StatefulWidget {
_GZXDropDownMenuState createState() => _GZXDropDownMenuState();
}

class _GZXDropDownMenuState extends State<GZXDropDownMenu> with SingleTickerProviderStateMixin {
class _GZXDropDownMenuState extends State<GZXDropDownMenu>
with SingleTickerProviderStateMixin {
bool _isShowDropDownItemWidget = false;
bool _isShowMask = false;
bool _isControllerDisposed = false;
Expand All @@ -66,7 +67,9 @@ class _GZXDropDownMenuState extends State<GZXDropDownMenu> with SingleTickerProv
super.initState();

widget.controller.addListener(_onController);
_controller = new AnimationController(duration: Duration(milliseconds: widget.animationMilliseconds), vsync: this);
_controller = new AnimationController(
duration: Duration(milliseconds: widget.animationMilliseconds),
vsync: this);
}

_onController() {
Expand All @@ -78,7 +81,8 @@ class _GZXDropDownMenuState extends State<GZXDropDownMenu> with SingleTickerProv
@override
Widget build(BuildContext context) {
// print('_GZXDropDownMenuState.build');
_controller!.duration = Duration(milliseconds: widget.animationMilliseconds);
_controller!.duration =
Duration(milliseconds: widget.animationMilliseconds);
return _buildDropDownWidget();
}

Expand All @@ -99,7 +103,8 @@ class _GZXDropDownMenuState extends State<GZXDropDownMenu> with SingleTickerProv

_isShowDropDownItemWidget = !_isShowDropDownItemWidget;
if (widget.dropdownMenuChanging != null) {
widget.dropdownMenuChanging!(_isShowDropDownItemWidget, _currentMenuIndex);
widget.dropdownMenuChanging!(
_isShowDropDownItemWidget, _currentMenuIndex);
}
if (!_isShowMask) {
_isShowMask = true;
Expand All @@ -109,9 +114,10 @@ class _GZXDropDownMenuState extends State<GZXDropDownMenu> with SingleTickerProv

_animation?.removeListener(_animationListener);
_animation?.removeStatusListener(_animationStatusListener);
_animation = new Tween(begin: 0.0, end: _dropDownHeight).animate(_controller!)
..addListener(_animationListener)
..addStatusListener(_animationStatusListener);
_animation =
new Tween(begin: 0.0, end: _dropDownHeight).animate(_controller!)
..addListener(_animationListener)
..addStatusListener(_animationStatusListener);

if (_isControllerDisposed) return;

Expand Down

0 comments on commit 55ed903

Please sign in to comment.