浏览代码

Temp store.

/main
Yuncong Zhang 6 年前
当前提交
61d8c39d
共有 5 个文件被更改,包括 56 次插入60 次删除
  1. 83
      Runtime/material/dropdown.cs
  2. 3
      Runtime/material/input_border.cs
  3. 22
      Runtime/material/input_decorator.cs
  4. 6
      Runtime/widgets/form.cs
  5. 2
      Runtime/widgets/will_pop_scope.cs

83
Runtime/material/dropdown.cs


borderRadius: BorderRadius.circular(2.0f),
boxShadow: ShadowConstants.kElevationToShadow[elevation ?? 0]
).createBoxPainter();
this.color = color;
this.elevation = elevation;
this.selectedIndex = selectedIndex;
this.resize = resize;
public readonly int elevation;
public readonly int selectedIndex;
public readonly int? elevation;
public readonly int? selectedIndex;
float selectedItemOffset = this.selectedIndex * DropdownConstants._kMenuItemHeight +
float selectedItemOffset = this.selectedIndex ?? 0 * DropdownConstants._kMenuItemHeight +
Constants.kMaterialListPadding.top;
FloatTween top = new FloatTween(
begin: selectedItemOffset.clamp(0.0f, size.height - DropdownConstants._kMenuItemHeight),

}
}
class _DropdownMenu<T> : StatefulWidget where T : Diagnosticable {
class _DropdownMenu<T> : StatefulWidget where T : class {
public _DropdownMenu(
Key key = null,
EdgeInsets padding = null,

}
}
class _DropdownMenuState<T> : State<_DropdownMenu<T>> where T : Diagnosticable {
class _DropdownMenuState<T> : State<_DropdownMenu<T>> where T : class {
CurvedAnimation _fadeOpacity;
CurvedAnimation _resize;

}
public override Widget build(BuildContext context) {
// The menu is shown in three stages (unit timing in brackets):
// [0s - 0.25s] - Fade in a rect-sized menu container with the selected item.
// [0.25s - 0.5s] - Grow the otherwise empty menu container from the center
// until it's big enough for as many items as we're going to show.
// [0.5s - 1.0fs] Fade in the remaining visible items from top to bottom.
//
// When the menu is dismissed we just fade the entire thing out
// in the first 0.25s.
D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
MaterialLocalizations localizations = MaterialLocalizations.of(context);
_DropdownRoute<T> route = this.widget.route;

opacity = new CurvedAnimation(parent: route.animation, curve: new Interval(start, end));
}
var index = itemIndex;
children.Add(new FadeTransition(
opacity: opacity,
child: new InkWell(

),
onTap: () => Navigator.pop(
context,
new _DropdownRouteResult<T>(route.items[itemIndex].value)
new _DropdownRouteResult<T>(route.items[index].value)
)
)
));

float menuHeight,
TextDirection textDirection
) {
this.buttonRect = buttonRect;
this.menuTop = menuTop;
this.menuHeight = menuHeight;
this.textDirection = textDirection;
}
public readonly Rect buttonRect;

return true;
});
D.assert(this.textDirection != null);
float left;
switch (this.textDirection) {
case TextDirection.rtl:

}
}
class _DropdownRouteResult<T> {
class _DropdownRouteResult<T> where T: class {
public _DropdownRouteResult(T result) {
this.result = result;
}

public static bool operator ==(_DropdownRouteResult<T> left, dynamic right) {
if (!(right is _DropdownRouteResult<T>)) {
return false;
}
_DropdownRouteResult<T> typedOther = right as _DropdownRouteResult<T>;
return left.result.Equals(typedOther.result);
public static bool operator ==(_DropdownRouteResult<T> left, _DropdownRouteResult<T> right) {
return left.result == right.result;
public static bool operator !=(_DropdownRouteResult<T> left, dynamic right) {
return !(left == right);
public static bool operator !=(_DropdownRouteResult<T> left, _DropdownRouteResult<T> right) {
return left.result != right.result;
}
public override int GetHashCode() {

class _DropdownRoute<T> : PopupRoute where T : Diagnosticable {
class _DropdownRoute<T> : PopupRoute where T : class {
public _DropdownRoute(
List<DropdownMenuItem<T>> items = null,
EdgeInsets padding = null,

if (this.scrollController == null) {
float scrollOffset = preferredMenuHeight > maxMenuHeight
? Mathf.Max(0.0f, selectedItemOffset - (buttonTop - menuTop) ?? 0.0f)
? Mathf.Max(0.0f, selectedItemOffset ?? 0.0f - (buttonTop - (menuTop ?? 0.0f)))
: 0.0f;
this.scrollController = new ScrollController(initialScrollOffset: scrollOffset);
}

}
}
public class DropdownMenuItem<T> : StatelessWidget where T : Diagnosticable {
/// Creates an item for a dropdown menu.
///
/// The [child] argument is required.
public class DropdownMenuItem<T> : StatelessWidget where T : class {
public DropdownMenuItem(
Key key = null,
T value = null,

}
public class DropdownButtonHideUnderline : InheritedWidget {
/// Creates a [DropdownButtonHideUnderline]. A non-null [child] must
/// be given.
public DropdownButtonHideUnderline(
Key key = null,
Widget child = null

}
}
public class DropdownButton<T> : StatefulWidget where T : Diagnosticable {
public class DropdownButton<T> : StatefulWidget where T : class {
public DropdownButton(
Key key = null,
List<DropdownMenuItem<T>> items = null,

D.assert(items == null || value == null ||
items.Where<DropdownMenuItem<T>>((DropdownMenuItem<T> item) => item.value.Equals(value)).ToList()
.Count == 1);
this.items = items;
this.value = value;
this.hint = hint;
this.disabledHint = disabledHint;
this.onChanged = onChanged;
this.elevation = elevation;
this.style = style;
this.iconSize = iconSize;
this.isDense = isDense;
this.isExpanded = isExpanded;
}
public readonly List<DropdownMenuItem<T>> items;

}
}
class _DropdownButtonState<T> : State<DropdownButton<T>>, WidgetsBindingObserver where T : Diagnosticable {
class _DropdownButtonState<T> : State<DropdownButton<T>>, WidgetsBindingObserver where T : class {
int? _selectedIndex;
_DropdownRoute<T> _dropdownRoute;

_DropdownRouteResult<T> value = newValue as _DropdownRouteResult<T>;
this._dropdownRoute = null;
if (!this.mounted || newValue == null) {
return null;
return;
return null;
});
}

D.assert(MaterialD.debugCheckHasMaterial(context));
D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
// The width of the button and the menu are defined by the widest
// item and the width of the hint.
List<Widget> items = this._enabled ? new List<Widget>(this.widget.items) : new List<Widget>();
int hintIndex = 0;
if (this.widget.hint != null || (!this._enabled && this.widget.disabledHint != null)) {

}
}
public class DropdownButtonFormField<T> : FormField<T> where T : Diagnosticable {
public class DropdownButtonFormField<T> : FormField<T> where T : class {
public DropdownButtonFormField(
Key key = null,
T value = null,

this.onChanged = onChanged;
}
/// Called when the user selects an item.
public State createState() {
public override State createState() {
class _DropdownButtonFormFieldState<T> : FormFieldState<T> where T : Diagnosticable {
class _DropdownButtonFormFieldState<T> : FormFieldState<T> where T : class {
public DropdownButtonFormField<T> widget {
get { return base.widget as DropdownButtonFormField<T>; }
}

3
Runtime/material/input_border.cs


float gapPercentage = 0.0f,
TextDirection? textDirection = null
) {
D.assert(gapExtent != null);
D.assert(gapPercentage >= 0.0f && gapPercentage <= 1.0f);
D.assert(_cornersAreCircular(this.borderRadius));

if (gapStart == null || gapExtent <= 0.0f || gapPercentage == 0.0f) {
if (gapExtent <= 0.0f || gapPercentage == 0.0f) {
canvas.drawRRect(center, paint);
}
else {

22
Runtime/material/input_decorator.cs


TextDirection? textDirection = null,
Color fillColor = null
) : base(repaint: repaint) {
this.borderAnimation = borderAnimation;
this.border = border;
this.gapAnimation = gapAnimation;
this.gap = gap;
this.textDirection = textDirection;
this.fillColor = fillColor;
}
Animation<float> borderAnimation;

TextDirection textDirection;
TextDirection? textDirection;
Color fillColor;
public override void paint(Canvas canvas, Size size) {

Widget container = null
) {
D.assert(contentPadding != null);
D.assert(isCollapsed != null);
D.assert(floatingLabelHeight != null);
D.assert(floatingLabelProgress != null);
this.contentPadding = contentPadding;
this.isCollapsed = isCollapsed;
this.floatingLabelHeight = floatingLabelHeight;

public bool isFocused {
get { return this._isFocused; }
set {
D.assert(value != null);
if (this._isFocused == value) {
return;
}

box.layout(boxConstraints, parentUsesSize: true);
float baseline = box.getDistanceToBaseline(this.textBaseline ?? 0.0f) ?? 0.0f;
D.assert(baseline != null && baseline >= 0.0f);
D.assert(baseline >= 0.0f);
boxToBaseline[box] = baseline;
aboveBaseline = Math.Max(baseline, aboveBaseline);
belowBaseline = Math.Max(box.size.height - baseline, belowBaseline);

}
}
protected override void insertChildRenderObject(RenderObject child, dynamic slotValue) {
protected override void insertChildRenderObject(RenderObject child, object slotValue) {
_DecorationSlot slot = slotValue;
_DecorationSlot slot = (_DecorationSlot) slotValue;
this._updateRenderObject(child, slot);
D.assert(this.renderObject.childToSlot.ContainsKey((RenderBox) child));
D.assert(this.renderObject.slotToChild.ContainsKey(slot));

D.assert(!this.renderObject.slotToChild.ContainsKey((_DecorationSlot) this.slot));
}
protected override void moveChildRenderObject(RenderObject child, dynamic slotValue) {
protected override void moveChildRenderObject(RenderObject child, object slotValue) {
D.assert(false, "not reachable");
}
}

bool isEmpty = false,
Widget child = null
) : base(key: key) {
D.assert(isFocused != null);
D.assert(isEmpty != null);
}
public readonly InputDecoration decoration;

6
Runtime/widgets/form.cs


public delegate void FormFieldSetter<T>(T newValue);
public delegate Widget FormFieldBuilder<T>(FormFieldState<T> field) where T : Diagnosticable;
public delegate Widget FormFieldBuilder<T>(FormFieldState<T> field) where T : class;
public class FormField<T> : StatefulWidget where T : Diagnosticable {
public class FormField<T> : StatefulWidget where T : class {
public FormField(
Key key = null,
FormFieldBuilder<T> builder = null,

}
}
public class FormFieldState<T> : State<FormField<T>> where T : Diagnosticable {
public class FormFieldState<T> : State<FormField<T>> where T : class {
T _value;
string _errorText;

2
Runtime/widgets/will_pop_scope.cs


WillPopCallback onWillPop = null
) : base(key: key) {
D.assert(child != null);
this.onWillPop = onWillPop;
this.child = child;
}
public readonly Widget child;

正在加载...
取消
保存