浏览代码

format

/main
fzhangtj 6 年前
当前提交
f687ee0c
共有 6 个文件被更改,包括 139 次插入257 次删除
  1. 3
      Runtime/widgets/modal_barrier.cs
  2. 3
      Runtime/widgets/navigator.cs
  3. 264
      Runtime/widgets/overlay.cs
  4. 7
      Runtime/widgets/pages.cs
  5. 99
      Runtime/widgets/routes.cs
  6. 20
      Runtime/widgets/transitions.cs

3
Runtime/widgets/modal_barrier.cs


}
public override Widget build(BuildContext context) {
return new GestureDetector(
onTapDown: details => {
if (this.dismissible)

this.dismissible = dismissible;
}
public Animation<Color> color => (Animation<Color>)this.listenable;
public Animation<Color> color => (Animation<Color>) this.listenable;
protected internal override Widget build(BuildContext context) {
return new ModalBarrier(color: this.color?.value, dismissible: this.dismissible);

3
Runtime/widgets/navigator.cs


return true;
});
route = this.widget.onUnknownRoute(settings);
D.assert(() => {
if (route == null)

return true;
});
}
return route;
}

264
Runtime/widgets/overlay.cs


using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler;
namespace Unity.UIWidgets.widgets
{
public class OverlayEntry
{
public OverlayEntry(WidgetBuilder builder = null, bool opaque = false, bool maintainState = false)
{
namespace Unity.UIWidgets.widgets {
public class OverlayEntry {
public OverlayEntry(WidgetBuilder builder = null, bool opaque = false, bool maintainState = false) {
D.assert(builder != null);
this._opaque = opaque;
this._maintainState = maintainState;

bool _opaque;
public bool opaque
{
get { return this._opaque; }
set
{
if (this._opaque == value)
{
return;
}
public bool opaque {
get => this._opaque;
set {
if (this._opaque == value) return;
this._opaque = value;
D.assert(this._overlay != null);

bool _maintainState;
public bool maintainState
{
get { return this._maintainState; }
set
{
if (this._maintainState == value)
{
return;
}
public bool maintainState {
get => this._maintainState;
set {
if (this._maintainState == value) return;
this._maintainState = value;
D.assert(this._overlay != null);

internal readonly GlobalKey<_OverlayEntryState> _key = new LabeledGlobalKey<_OverlayEntryState>();
public void remove()
{
public void remove() {
{
}
{
}
public void markNeedsBuild()
{
public void markNeedsBuild() {
public override string ToString()
{
public override string ToString() {
class _OverlayEntry : StatefulWidget
{
internal _OverlayEntry(OverlayEntry entry) : base(key: entry._key)
{
internal class _OverlayEntry : StatefulWidget {
internal _OverlayEntry(OverlayEntry entry) : base(key: entry._key) {
D.assert(entry != null);
this.entry = entry;
}

public override State createState()
{
public override State createState() {
class _OverlayEntryState : State<_OverlayEntry>
{
public override Widget build(BuildContext context)
{
internal class _OverlayEntryState : State<_OverlayEntry> {
public override Widget build(BuildContext context) {
internal void _markNeedsBuild()
{
this.setState(() =>
{
internal void _markNeedsBuild() {
this.setState(() => {
public class Overlay : StatefulWidget
{
public Overlay(Key key = null, List<OverlayEntry> initialEntries = null) : base(key)
{
public class Overlay : StatefulWidget {
public Overlay(Key key = null, List<OverlayEntry> initialEntries = null) : base(key) {
D.assert(initialEntries != null);
this.initialEntries = initialEntries;
}

public static OverlayState of(BuildContext context, Widget debugRequiredFor = null)
{
public static OverlayState of(BuildContext context, Widget debugRequiredFor = null) {
D.assert(() =>
{
if (debugRequiredFor != null && result == null)
{
D.assert(() => {
if (debugRequiredFor != null && result == null) {
var additional = context.widget != debugRequiredFor
? $"\nThe context from which that widget was searching for an overlay was:\n {context}"
: "";

return result;
}
public override State createState()
{
public override State createState() {
public class OverlayState : TickerProviderStateMixin<Overlay>
{
public class OverlayState : TickerProviderStateMixin<Overlay> {
public override void initState()
{
public override void initState() {
public void insert(OverlayEntry entry, OverlayEntry above = null)
{
public void insert(OverlayEntry entry, OverlayEntry above = null) {
this.setState(() =>
{
this.setState(() => {
public void insertAll(ICollection<OverlayEntry> entries, OverlayEntry above = null)
{
public void insertAll(ICollection<OverlayEntry> entries, OverlayEntry above = null) {
foreach (OverlayEntry entry in entries)
{
foreach (OverlayEntry entry in entries) {
this.setState(() =>
{
this.setState(() => {
internal void _remove(OverlayEntry entry)
{
if (this.mounted)
{
internal void _remove(OverlayEntry entry) {
if (this.mounted) {
this.setState(() =>
{
this.setState(() => {
public bool debugIsVisible(OverlayEntry entry)
{
public bool debugIsVisible(OverlayEntry entry) {
D.assert(() =>
{
for (int i = this._entries.Count - 1; i > 0; i -= 1)
{
D.assert(() => {
for (int i = this._entries.Count - 1; i > 0; i -= 1) {
if (candidate == entry)
{
if (candidate == entry) {
result = true;
break;
}

return result;
}
internal void _didChangeEntryOpacity()
{
internal void _didChangeEntryOpacity() {
public override Widget build(BuildContext context)
{
public override Widget build(BuildContext context) {
for (var i = this._entries.Count - 1; i >= 0; i -= 1)
{
for (var i = this._entries.Count - 1; i >= 0; i -= 1) {
if (onstage)
{
if (onstage) {
if (entry.opaque)
{
onstage = false;
}
if (entry.opaque) onstage = false;
else if (entry.maintainState)
{
else if (entry.maintainState) {
offstageChildren.Add(new TickerMode(enabled: false, child: new _OverlayEntry(entry)));
}
}

}
}
class _Theatre : RenderObjectWidget
{
internal _Theatre(Stack onstage = null, List<Widget> offstage = null)
{
internal class _Theatre : RenderObjectWidget {
internal _Theatre(Stack onstage = null, List<Widget> offstage = null) {
D.assert(offstage != null);
D.assert(!offstage.Any((child) => child == null));
this.onstage = onstage;

public readonly List<Widget> offstage;
public override Element createElement()
{
public override Element createElement() {
public override RenderObject createRenderObject(BuildContext context)
{
public override RenderObject createRenderObject(BuildContext context) {
class _TheatreElement : RenderObjectElement
{
public _TheatreElement(RenderObjectWidget widget) : base(widget)
{
internal class _TheatreElement : RenderObjectElement {
public _TheatreElement(RenderObjectWidget widget) : base(widget) {
public new _Theatre widget
{
get { return (_Theatre) base.widget; }
}
public new _Theatre widget => (_Theatre) base.widget;
public new _RenderTheatre renderObject
{
get { return (_RenderTheatre) base.renderObject; }
}
public new _RenderTheatre renderObject => (_RenderTheatre) base.renderObject;
Element _onstage;
static readonly object _onstageSlot = new object();

protected override void insertChildRenderObject(RenderObject child, object slot)
{
protected override void insertChildRenderObject(RenderObject child, object slot) {
if (slot == _onstageSlot)
{
if (slot == _onstageSlot) {
else
{
else {
protected override void moveChildRenderObject(RenderObject child, object slot)
{
if (slot == _onstageSlot)
{
protected override void moveChildRenderObject(RenderObject child, object slot) {
if (slot == _onstageSlot) {
else
{
else {
if (this.renderObject.child == child)
{
if (this.renderObject.child == child) {
else
{
else {
protected override void removeChildRenderObject(RenderObject child)
{
protected override void removeChildRenderObject(RenderObject child) {
{
}
{
}
public override void visitChildren(ElementVisitor visitor)
{
public override void visitChildren(ElementVisitor visitor) {
{
}
public override void debugVisitOnstageChildren(ElementVisitor visitor)
{
public override void debugVisitOnstageChildren(ElementVisitor visitor) {
protected override void forgetChild(Element child)
{
if (child == this._onstage)
{
protected override void forgetChild(Element child) {
if (child == this._onstage) {
else
{
else {
D.assert(this._offstage.Contains(child));
D.assert(!this._forgottenOffstageChildren.Contains(child));
this._forgottenOffstageChildren.Add(child);

public override void mount(Element parent, object newSlot)
{
public override void mount(Element parent, object newSlot) {
for (int i = 0; i < this._offstage.Count; i += 1)
{
for (int i = 0; i < this._offstage.Count; i += 1) {
var newChild = this.inflateWidget(this.widget.offstage[i], previousChild);
this._offstage[i] = newChild;
previousChild = newChild;

public override void update(Widget newWidget)
{
public override void update(Widget newWidget) {
this._offstage = this.updateChildren(this._offstage, this.widget.offstage, forgottenChildren: this._forgottenOffstageChildren);
this._offstage = this.updateChildren(this._offstage, this.widget.offstage,
forgottenChildren: this._forgottenOffstageChildren);
class _RenderTheatre : ContainerRenderObjectMixinRenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack<
RenderBox, StackParentData>
{
public override void setupParentData(RenderObject child)
{
internal class _RenderTheatre :
ContainerRenderObjectMixinRenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack<
RenderBox, StackParentData> {
public override void setupParentData(RenderObject child) {
public override void redepthChildren()
{
public override void redepthChildren() {
public override void visitChildren(RenderObjectVisitor visitor)
{
public override void visitChildren(RenderObjectVisitor visitor) {
public override List<DiagnosticsNode> debugDescribeChildren()
{
public override List<DiagnosticsNode> debugDescribeChildren() {
if (this.firstChild != null)
{
if (this.firstChild != null) {
while (true)
{
while (true) {
children.Add(
child.toDiagnosticsNode(
name: $"offstage {count}",

count += 1;
}
}
else
{
else {
children.Add(
DiagnosticsNode.message(
"no offstage children",

7
Runtime/widgets/pages.cs


using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.widgets {
public abstract class PageRoute : ModalRoute {
public readonly bool fullscreenDialog;

D.assert(pageBuilder != null);
this.opaque = opaque;
this.pageBuilder = pageBuilder;
this.transitionsBuilder = transitionsBuilder??this._defaultTransitionsBuilder;
this.transitionsBuilder = transitionsBuilder ?? this._defaultTransitionsBuilder;
this.transitionDuration = transitionDuration ?? TimeSpan.FromMilliseconds(300);
this.barrierColor = barrierColor;
this.maintainState = maintainState;

public override bool maintainState { get; }
Widget _defaultTransitionsBuilder(BuildContext context, Animation<double>
Widget _defaultTransitionsBuilder(BuildContext context, Animation<double>
public override Widget buildPage(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) {
return this.pageBuilder(context, animation, secondaryAnimation);

99
Runtime/widgets/routes.cs


using System;
using System.Collections.Generic;
using System.Linq;
using RSG;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;

) : base(settings) {
}
public IPromise<object> completed {
get { return this._transitionCompleter; }
}
public IPromise<object> completed => this._transitionCompleter;
internal readonly Promise<object> _transitionCompleter = new Promise<object>();

protected override bool finishedWhenPopped => this.controller.status == AnimationStatus.dismissed;
public virtual Animation<double> animation {
get { return this._animation; }
}
public virtual Animation<double> animation => this._animation;
public AnimationController controller {
get { return this._controller; }
}
public AnimationController controller => this._controller;
internal AnimationController _controller;

this.changedInternalState();
}
public virtual Animation<double> secondaryAnimation {
get { return this._secondaryAnimation; }
}
public virtual Animation<double> secondaryAnimation => this._secondaryAnimation;
readonly ProxyAnimation _secondaryAnimation = new ProxyAnimation(Animations.kAlwaysDismissedAnimation);

}
public virtual bool canTransitionTo(TransitionRoute nextRoute) => true;
public virtual bool canTransitionTo(TransitionRoute nextRoute) {
return true;
}
public virtual bool canTransitionFrom(TransitionRoute previousRoute) => true;
public virtual bool canTransitionFrom(TransitionRoute previousRoute) {
return true;
}
protected internal override void dispose() {
D.assert(!this._transitionCompleter.isCompleted, $"Cannot dispose a {this.GetType()} twice.");

public override void debugFillProperties(DiagnosticPropertiesBuilder description) {
base.debugFillProperties(description);
description.add(new FlagProperty("isCurrent", value: this.isCurrent, ifTrue: "active", ifFalse: "inactive"));
description.add(new FlagProperty("isCurrent", value: this.isCurrent, ifTrue: "active",
ifFalse: "inactive"));
description.add(new FlagProperty("canPop", value: this.canPop, ifTrue: "can pop"));
}
}

}
protected virtual void setState(VoidCallback fn) {
if (this._scopeKey.currentState != null) {
if (this._scopeKey.currentState != null)
}
else {
// The route isn't currently visible, so we don't have to call its setState
// method, but we do still need to call the fn callback, otherwise the state
// in the route won't be updated!
else
}
public RoutePredicate withName(String name) {
public RoutePredicate withName(string name) {
return (Route route) => !route.willHandlePopInternally
&& route is ModalRoute
&& route.settings.name == name;

return;
this.setState(() => { this._offstage = value; });
this._animationProxy.parent = this._offstage ? Animations.kAlwaysCompleteAnimation : base.animation;
this._secondaryAnimationProxy.parent = this._offstage ? Animations.kAlwaysDismissedAnimation : base.secondaryAnimation;
this._secondaryAnimationProxy.parent =
this._offstage ? Animations.kAlwaysDismissedAnimation : base.secondaryAnimation;
}
}

Promise<RoutePopDisposition> result = new Promise<RoutePopDisposition>();
Action<int> fn = null;
fn = (int index) => {
if (index < callbacks.Count) {
if (index < callbacks.Count)
if (!pop) {
if (!pop)
}
else {
else
}
}
else {
else
}
};
fn(0);
return result;

}
return new IgnorePointer(
ignoring: this.animation.status == AnimationStatus.reverse || this.animation.status == AnimationStatus.dismissed,
ignoring: this.animation.status == AnimationStatus.reverse ||
this.animation.status == AnimationStatus.dismissed,
child: barrier
);
}

Widget _buildModalScope(BuildContext context) {
return this._modalScopeCache = this._modalScopeCache ?? new _ModalScope(
key: this._scopeKey,
route: this
// _ModalScope calls buildTransitions() and buildChild(), defined above
);
key: this._scopeKey,
route: this
// _ModalScope calls buildTransitions() and buildChild(), defined above
);
}
public override ICollection<OverlayEntry> createOverlayEntries() {

}
}
abstract class PopupRoute : ModalRoute {
internal abstract class PopupRoute : ModalRoute {
protected PopupRoute(
RouteSettings settings = null
) : base(settings: settings) {

D.assert(routeAware != null);
D.assert(route != null);
HashSet<RouteAware> subscribers = this._listeners.putIfAbsent(route, () => new HashSet<RouteAware>());
if (subscribers.Add(routeAware)) {
routeAware.didPush();
}
if (subscribers.Add(routeAware)) routeAware.didPush();
}
public void unsubscribe(RouteAware routeAware) {

if (route is R && previousRoute is R) {
var previousSubscribers = this._listeners.getOrDefault((R) previousRoute);
if (previousSubscribers != null) {
foreach (RouteAware routeAware in previousSubscribers) {
if (previousSubscribers != null)
foreach (RouteAware routeAware in previousSubscribers)
}
}
if (subscribers != null) {
foreach (RouteAware routeAware in subscribers) {
if (subscribers != null)
foreach (RouteAware routeAware in subscribers)
}
}
}
}

if (previousSubscribers != null) {
foreach (RouteAware routeAware in previousSubscribers) {
if (previousSubscribers != null)
foreach (RouteAware routeAware in previousSubscribers)
}
}
}
}
}

Animation<double> secondaryAnimation) {
return this._pageBuilder(context, animation, secondaryAnimation);
}
public override Widget buildTransitions(BuildContext context, Animation<double> animation,
public override Widget buildTransitions(BuildContext context, Animation<double> animation,
if (this._transitionBuilder == null) {
if (this._transitionBuilder == null)
return new FadeTransition(
opacity: new CurvedAnimation(
parent: animation,

}
return this._transitionBuilder(context, animation, secondaryAnimation, child);
}
}

Color barrierColor = null,
TimeSpan? transitionDuration = null,
RouteTransitionsBuilder transitionBuilder = null
) {
) {
D.assert(pageBuilder != null);
D.assert(!barrierDismissible || barrierLabel != null);
return Navigator.of(context, rootNavigator: true).push(new _DialogRoute(

20
Runtime/widgets/transitions.cs


return this.widget.build(context);
}
}
Widget child = null): base(key: key, listenable: position) {
Widget child = null) : base(key: key, listenable: position) {
D.assert(position != null);
this.transformHitTests = transformHitTests;
this.textDirection = textDirection;

public Animation<Offset> position => (Animation<Offset>)this.listenable;
public Animation<Offset> position => (Animation<Offset>) this.listenable;
protected internal override Widget build(BuildContext context) {
var offset = this.position.value;
if (this.textDirection == TextDirection.rtl)

public class FadeTransition : SingleChildRenderObjectWidget {
public FadeTransition(Key key = null, Animation<double> opacity = null,
Widget child = null): base(key: key, child: child) {
Widget child = null) : base(key: key, child: child) {
public override RenderObject createRenderObject(BuildContext context) {
return new RenderAnimatedOpacity(
opacity: this.opacity

正在加载...
取消
保存