|
|
|
|
|
|
} |
|
|
|
|
|
|
|
class _CupertinoDialogRenderElement : RenderObjectElement { |
|
|
|
public _CupertinoDialogRenderElement(_CupertinoDialogRenderWidget widget) : base(widget) { } |
|
|
|
public _CupertinoDialogRenderElement(_CupertinoDialogRenderWidget widget) : base(widget) { |
|
|
|
} |
|
|
|
|
|
|
|
Element _contentElement; |
|
|
|
Element _actionsElement; |
|
|
|
|
|
|
List<Widget> interactiveButtons = new List<Widget>(); |
|
|
|
for (int i = 0; i < this.widget.children.Count; i += 1) { |
|
|
|
interactiveButtons.Add( |
|
|
|
new _PressableActionButton( |
|
|
|
new _PressableDialogActionButton( |
|
|
|
child: this.widget.children[i] |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class _PressableActionButton : StatefulWidget { |
|
|
|
public _PressableActionButton( |
|
|
|
class _PressableDialogActionButton : StatefulWidget { |
|
|
|
public _PressableDialogActionButton( |
|
|
|
Widget child |
|
|
|
) { |
|
|
|
this.child = child; |
|
|
|
|
|
|
|
|
|
|
public override State createState() { |
|
|
|
return new _PressableActionButtonState(); |
|
|
|
return new _PressableDialogActionButtonState(); |
|
|
|
class _PressableActionButtonState : State<_PressableActionButton> { |
|
|
|
class _PressableDialogActionButtonState : State<_PressableDialogActionButton> { |
|
|
|
return new _ActionButtonParentDataWidget( |
|
|
|
return new _DialogActionButtonParentDataWidget( |
|
|
|
isPressed: this._isPressed, |
|
|
|
child: new GestureDetector( |
|
|
|
behavior: HitTestBehavior.opaque, |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class _ActionButtonParentDataWidget : ParentDataWidget<_CupertinoDialogActionsRenderWidget> { |
|
|
|
public _ActionButtonParentDataWidget( |
|
|
|
class _DialogActionButtonParentDataWidget : ParentDataWidget<_CupertinoDialogActionsRenderWidget> { |
|
|
|
public _DialogActionButtonParentDataWidget( |
|
|
|
Widget child, |
|
|
|
bool isPressed = false, |
|
|
|
Key key = null |
|
|
|
|
|
|
public readonly bool isPressed; |
|
|
|
|
|
|
|
public override void applyParentData(RenderObject renderObject) { |
|
|
|
D.assert(renderObject.parentData is _ActionButtonParentData); |
|
|
|
_ActionButtonParentData parentData = renderObject.parentData as _ActionButtonParentData; |
|
|
|
D.assert(renderObject.parentData is _DialogActionButtonParentData); |
|
|
|
_DialogActionButtonParentData parentData = renderObject.parentData as _DialogActionButtonParentData; |
|
|
|
if (parentData.isPressed != this.isPressed) { |
|
|
|
parentData.isPressed = this.isPressed; |
|
|
|
AbstractNodeMixinDiagnosticableTree targetParent = renderObject.parent; |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class _ActionButtonParentData : MultiChildLayoutParentData { |
|
|
|
public _ActionButtonParentData( |
|
|
|
class _DialogActionButtonParentData : MultiChildLayoutParentData { |
|
|
|
public _DialogActionButtonParentData( |
|
|
|
bool isPressed = false |
|
|
|
) { |
|
|
|
this.isPressed = isPressed; |
|
|
|
|
|
|
|
|
|
|
RenderBox currentChild = this.firstChild; |
|
|
|
while (currentChild != null) { |
|
|
|
D.assert(currentChild.parentData is _ActionButtonParentData); |
|
|
|
_ActionButtonParentData parentData = currentChild.parentData as _ActionButtonParentData; |
|
|
|
D.assert(currentChild.parentData is _DialogActionButtonParentData); |
|
|
|
_DialogActionButtonParentData parentData = currentChild.parentData as _DialogActionButtonParentData; |
|
|
|
if (parentData.isPressed) { |
|
|
|
childList.Add(currentChild); |
|
|
|
} |
|
|
|
|
|
|
get { |
|
|
|
RenderBox currentChild = this.firstChild; |
|
|
|
while (currentChild != null) { |
|
|
|
D.assert(currentChild.parentData is _ActionButtonParentData); |
|
|
|
_ActionButtonParentData parentData = currentChild.parentData as _ActionButtonParentData; |
|
|
|
D.assert(currentChild.parentData is _DialogActionButtonParentData); |
|
|
|
_DialogActionButtonParentData parentData = currentChild.parentData as _DialogActionButtonParentData; |
|
|
|
if (parentData.isPressed) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public override void setupParentData(RenderObject child) { |
|
|
|
if (!(child.parentData is _ActionButtonParentData)) { |
|
|
|
child.parentData = new _ActionButtonParentData(); |
|
|
|
if (!(child.parentData is _DialogActionButtonParentData)) { |
|
|
|
child.parentData = new _DialogActionButtonParentData(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
RenderBox prevChild = null; |
|
|
|
|
|
|
|
while (child != null) { |
|
|
|
D.assert(child.parentData is _ActionButtonParentData); |
|
|
|
_ActionButtonParentData currentButtonParentData = child.parentData as _ActionButtonParentData; |
|
|
|
D.assert(child.parentData is _DialogActionButtonParentData); |
|
|
|
_DialogActionButtonParentData currentButtonParentData = |
|
|
|
child.parentData as _DialogActionButtonParentData; |
|
|
|
D.assert(prevChild.parentData is _ActionButtonParentData); |
|
|
|
_ActionButtonParentData previousButtonParentData = prevChild.parentData as _ActionButtonParentData; |
|
|
|
D.assert(prevChild.parentData is _DialogActionButtonParentData); |
|
|
|
_DialogActionButtonParentData previousButtonParentData = |
|
|
|
prevChild.parentData as _DialogActionButtonParentData; |
|
|
|
isPrevButtonPressed = previousButtonParentData.isPressed; |
|
|
|
} |
|
|
|
|
|
|
|