浏览代码

Merge pull request #67 from Unity-Technologies/shiyun/cupertino/skia

fix cupertino -N
/siyaoH-1.17-PlatformMessage
GitHub 4 年前
当前提交
04413a84
共有 6 个文件被更改,包括 303 次插入202 次删除
  1. 275
      com.unity.uiwidgets/Runtime/cupertino/dialog.cs
  2. 5
      com.unity.uiwidgets/Runtime/cupertino/icon_theme_data.cs
  3. 5
      com.unity.uiwidgets/Runtime/cupertino/icons.cs
  4. 17
      com.unity.uiwidgets/Runtime/cupertino/interface_level.cs
  5. 201
      com.unity.uiwidgets/Runtime/cupertino/nav_bar.cs
  6. 2
      com.unity.uiwidgets/Runtime/widgets/preferred_size.cs

275
com.unity.uiwidgets/Runtime/cupertino/dialog.cs


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;

inherit:false,
fontSize: 13.4f,
fontWeight: FontWeight.w400,
//color: CupertinoColors.black,
height: 1.036f,
letterSpacing: -0.25f,
textBaseline: TextBaseline.alphabetic

public const float _kMinButtonFontSize = 10.0f;
public const float _kDialogCornerRadius = 12.0f;
public const float _kDividerThickness = 1.0f;
public const float _kMaxRegularTextScaleFactor = 1.4f;
//public static readonly Color _kDialogColor = new Color(0xC0FFFFFF);
//public static readonly Color _kDialogPressedColor = new Color(0x90FFFFFF);
public static readonly Color _kButtonDividerColor = new Color(0x40FFFFFF);
public static readonly Color _kDialogColor = CupertinoDynamicColor.withBrightness(

color: new Color(0xFFE1E1E1),
darkColor: new Color(0xFF2E2E2E)
);
public const float _kMaxRegularTextScaleFactor = 1.4f;
public static bool _isInAccessibilityMode(BuildContext context) {
MediaQueryData data = MediaQuery.of(context, nullOk: true);

Widget content = null,
List<Widget> actions = null,
ScrollController scrollController = null,
ScrollController actionScrollController = null
ScrollController actionScrollController = null,
TimeSpan? insetAnimationDuration = null,
Curve insetAnimationCurve = null
this.insetAnimationDuration = insetAnimationDuration ?? TimeSpan.FromMilliseconds(100);
this.insetAnimationCurve = insetAnimationCurve ?? Curves.decelerate;
}
public readonly Widget title;

public readonly ScrollController actionScrollController;
readonly TimeSpan? m_InsetAnimationDuration;
public readonly TimeSpan insetAnimationDuration;
public readonly Curve insetAnimationCurve;
Widget _buildContent() {
Widget _buildContent(BuildContext context) {
List<Widget> children = new List<Widget>();
if (title != null || content != null) {
Widget titleSection = new _CupertinoDialogAlertContentSection(

}
return new Container(
color: CupertinoDialogUtils._kDialogColor,
color: CupertinoDynamicColor.resolve(CupertinoDialogUtils._kDialogColor, context),
child: new Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,

bool isInAccessibilityMode = CupertinoDialogUtils._isInAccessibilityMode(context);
float textScaleFactor = MediaQuery.of(context).textScaleFactor;
return new MediaQuery(
data: MediaQuery.of(context).copyWith(
textScaleFactor: Mathf.Max(textScaleFactor, 1.0f)
),
return new CupertinoUserInterfaceLevel(
data: CupertinoUserInterfaceLevelData.elevatedlayer,
child: new MediaQuery(
data: MediaQuery.of(context).copyWith(
textScaleFactor: Mathf.Max(textScaleFactor, 1.0f)
),
return new Center(
child: new Container(
margin: EdgeInsets.symmetric(vertical: CupertinoDialogUtils._kEdgePadding),
width: isInAccessibilityMode
? CupertinoDialogUtils._kAccessibilityCupertinoDialogWidth
: CupertinoDialogUtils._kCupertinoDialogWidth,
child: new CupertinoPopupSurface(
isSurfacePainted: false,
child: new _CupertinoDialogRenderWidget(
contentSection: _buildContent(),
actionsSection: _buildActions()
return new AnimatedPadding(
padding: MediaQuery.of(_context).viewInsets + EdgeInsets.symmetric(horizontal: 40.0f, vertical: 24.0f),
duration: insetAnimationDuration,
curve: insetAnimationCurve,
child: MediaQuery.removeViewInsets(
removeLeft: true,
removeTop: true,
removeRight: true,
removeBottom: true,
context: _context,
child: new Center(
child: new Container(
margin: EdgeInsets.symmetric(vertical: CupertinoDialogUtils._kEdgePadding),
width: isInAccessibilityMode
? CupertinoDialogUtils._kAccessibilityCupertinoDialogWidth
: CupertinoDialogUtils._kCupertinoDialogWidth,
child: new CupertinoPopupSurface(
isSurfacePainted: false,
child: new _CupertinoDialogRenderWidget(
contentSection: _buildContent(_context),
actionsSection: _buildActions()
)
)
);
)
);
}
}

child: new Container(
decoration: CupertinoDialogUtils._kCupertinoDialogBlurOverlayDecoration,
child: new Container(
color: isSurfacePainted ? CupertinoDialogUtils._kDialogColor : null,
color: isSurfacePainted ? CupertinoDynamicColor.resolve(CupertinoDialogUtils._kDialogColor, context) : null,
child: child
)
)

class _CupertinoDialogRenderWidget : RenderObjectWidget {
public _CupertinoDialogRenderWidget(
Widget contentSection,
Widget actionsSection,
Key key = null
Key key = null,
Widget contentSection = null,
Widget actionsSection = null
) : base(key: key) {
this.contentSection = contentSection;
this.actionsSection = actionsSection;

public override RenderObject createRenderObject(BuildContext context) {
return new _RenderCupertinoDialog(
dividerThickness: CupertinoDialogUtils._kDividerThickness / MediaQuery.of(context).devicePixelRatio,
isInAccessibilityMode: CupertinoDialogUtils._isInAccessibilityMode(context)
isInAccessibilityMode: CupertinoDialogUtils._isInAccessibilityMode(context),
dividerColor: CupertinoDynamicColor.resolve(CupertinoColors.separator, context)
);
}

((_RenderCupertinoDialog) renderObject).dividerColor =
CupertinoDynamicColor.resolve(CupertinoColors.separator, context);
}
public override Element createElement() {

Element _contentElement;
Element _actionsElement;
public new _CupertinoDialogRenderWidget widget {
get { return base.widget as _CupertinoDialogRenderWidget; }

D.assert(_actionsElement == child);
_actionsElement = null;
}
base.forgetChild(child);
}
protected override void removeChildRenderObject(RenderObject child) {

RenderBox contentSection = null,
RenderBox actionsSection = null,
float dividerThickness = 0.0f,
bool isInAccessibilityMode = false
bool isInAccessibilityMode = false,
Color dividerColor = null
_dividerPaint = new Paint() {
color = dividerColor,
style = PaintingStyle.fill
};
}
public RenderBox contentSection {

readonly float _dividerThickness;
readonly Paint _dividerPaint = new Paint() {
color = CupertinoDialogUtils._kButtonDividerColor,
style = PaintingStyle.fill
};
public readonly Paint _dividerPaint;
public Color dividerColor {
get {
return _dividerPaint.color;
}
set {
if (dividerColor == value) {
return;
}
_dividerPaint.color = value;
markNeedsPaint();
}
}
public override void attach(object owner) {
base.attach(owner);
if (null != contentSection) {

);
}
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null
) {
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
BoxParentData contentSectionParentData = contentSection.parentData as BoxParentData;
BoxParentData actionsSectionParentData = actionsSection.parentData as BoxParentData;
return result.addWithPaintOffset(

public readonly ScrollController scrollController;
public override Widget build(BuildContext context) {
if (title == null && content == null) {
return new SingleChildScrollView(
controller: scrollController,
child: new Container(width: 0.0f, height: 0.0f)
);
}
float textScaleFactor = MediaQuery.of(context).textScaleFactor;
List<Widget> titleContentGroup = new List<Widget>();
if (title != null) {

top: CupertinoDialogUtils._kEdgePadding * textScaleFactor
),
child: new DefaultTextStyle(
style: CupertinoDialogUtils._kCupertinoDialogTitleStyle,
style: CupertinoDialogUtils._kCupertinoDialogTitleStyle.copyWith(
color: CupertinoDynamicColor.resolve(CupertinoColors.label, context)
),
textAlign: TextAlign.center,
child: title
)

top: title == null ? CupertinoDialogUtils._kEdgePadding : 1.0f
),
child: new DefaultTextStyle(
style: CupertinoDialogUtils._kCupertinoDialogContentStyle,
style: CupertinoDialogUtils._kCupertinoDialogContentStyle.copyWith(
color: CupertinoDynamicColor.resolve(CupertinoColors.label, context)
),
textAlign: TextAlign.center,
child: content
)

//ParentDataWidget<_DialogActionButtonParentData>
class _DialogActionButtonParentDataWidget : ParentDataWidget<_ActionButtonParentData> {
public _DialogActionButtonParentDataWidget(
Widget child,
Key key = null,
Key key = null
Widget child = null
) : base(key: key, child: child) {
this.isPressed = isPressed;
}

}
}
}
public override Type debugTypicalAncestorWidgetClass {
get {
return typeof(_CupertinoDialogActionsRenderWidget);
}
}
}
class _DialogActionButtonParentData : MultiChildLayoutParentData {

public class CupertinoDialogAction : StatelessWidget {
public CupertinoDialogAction(
Widget child,
Key key = null,
TextStyle textStyle = null
) {
TextStyle textStyle = null,
Widget child = null
):base(key:key) {
D.assert(child != null);
this.onPressed = onPressed;
this.isDefaultAction = isDefaultAction;

}
public override Widget build(BuildContext context) {
TextStyle style = CupertinoDialogUtils._kCupertinoDialogActionStyle;
TextStyle style = CupertinoDialogUtils._kCupertinoDialogActionStyle.copyWith(
color: CupertinoDynamicColor.resolve(
isDestructiveAction ? CupertinoColors.systemRed : CupertinoColors.systemBlue,
context
)
);
if (isDestructiveAction) {
style = style.copyWith(color: CupertinoColors.destructiveRed);
if (isDefaultAction) {
style = style.copyWith(fontWeight: FontWeight.w600);
if (!enabled) {
style = style.copyWith(color: style.color.withOpacity(0.5f));

dialogWidth: CupertinoDialogUtils._isInAccessibilityMode(context)
? CupertinoDialogUtils._kAccessibilityCupertinoDialogWidth
: CupertinoDialogUtils._kCupertinoDialogWidth,
dividerThickness: _dividerThickness
dividerThickness: _dividerThickness,
dialogColor: CupertinoDynamicColor.resolve(CupertinoDialogUtils._kDialogColor, context),
dialogPressedColor: CupertinoDynamicColor.resolve(CupertinoDialogUtils._kDialogPressedColor, context),
dividerColor: CupertinoDynamicColor.resolve(CupertinoColors.separator, context)
);
}

? CupertinoDialogUtils._kAccessibilityCupertinoDialogWidth
: CupertinoDialogUtils._kCupertinoDialogWidth;
(renderObject as _RenderCupertinoDialogActions).dividerThickness = _dividerThickness;
(renderObject as _RenderCupertinoDialogActions).dialogColor =
CupertinoDynamicColor.resolve( CupertinoDialogUtils._kDialogColor, context);
(renderObject as _RenderCupertinoDialogActions).dialogPressedColor =
CupertinoDynamicColor.resolve( CupertinoDialogUtils._kDialogPressedColor, context);
(renderObject as _RenderCupertinoDialogActions).dividerColor =
CupertinoDynamicColor.resolve(CupertinoColors.separator, context);
}
}

float dialogWidth,
float dividerThickness = 0.0f
float? dialogWidth = null,
float dividerThickness = 0.0f,
Color dialogColor = null,
Color dialogPressedColor = null,
Color dividerColor = null
_buttonBackgroundPaint = new Paint() {
color = dialogColor,
style = PaintingStyle.fill
};
_pressedButtonBackgroundPaint = new Paint(){
color = dialogPressedColor,
style = PaintingStyle.fill
};
_dividerPaint = new Paint(){
color = dividerColor,
style = PaintingStyle.fill
};
public float dialogWidth {
public float? dialogWidth {
get { return _dialogWidth; }
set {
if (value != _dialogWidth) {

}
}
float _dialogWidth;
float? _dialogWidth;
public float dividerThickness {

}
}
}
float _dividerThickness;
public readonly Paint _buttonBackgroundPaint;
public Color dialogColor {
set{
if (value == _buttonBackgroundPaint.color)
return;
_buttonBackgroundPaint.color = value;
markNeedsPaint();
}
}
float _dividerThickness;
public readonly Paint _pressedButtonBackgroundPaint;
readonly Paint _buttonBackgroundPaint = new Paint() {
color = CupertinoDialogUtils._kDialogColor,
style = PaintingStyle.fill
};
public Color dialogPressedColor {
set{
if (value == _pressedButtonBackgroundPaint.color)
return;
readonly Paint _pressedButtonBackgroundPaint = new Paint() {
color = CupertinoDialogUtils._kDialogPressedColor,
style = PaintingStyle.fill
};
_pressedButtonBackgroundPaint.color = value;
markNeedsPaint();
}
}
public readonly Paint _dividerPaint;
readonly Paint _dividerPaint = new Paint() {
color = CupertinoDialogUtils._kButtonDividerColor,
style = PaintingStyle.fill
};
public Color dividerColor{
set {
if (value == _dividerPaint.color)
return;
_dividerPaint.color = value;
markNeedsPaint();
}
}
List<RenderBox> _pressedButtons {
get {

}
protected internal override float computeMinIntrinsicWidth(float height) {
return dialogWidth;
return dialogWidth ?? 0.0f;
return dialogWidth;
return dialogWidth ?? 0.0f;
}
protected internal override float computeMinIntrinsicHeight(float width) {

}
else {
float perButtonWidth = (width - dividerThickness) / 2.0f;
minHeight = Mathf.Max(firstChild.getMinIntrinsicHeight(perButtonWidth),
minHeight = Mathf.Max(
firstChild.getMinIntrinsicHeight(perButtonWidth),
lastChild.getMinIntrinsicHeight(perButtonWidth)
);
}

else if (childCount == 2) {
if (_isSingleButtonRow(width)) {
float perButtonWidth = (width - dividerThickness) / 2.0f;
maxHeight = Mathf.Max(firstChild.getMaxIntrinsicHeight(perButtonWidth),
maxHeight = Mathf.Max(
firstChild.getMaxIntrinsicHeight(perButtonWidth),
lastChild.getMaxIntrinsicHeight(perButtonWidth)
);
}

heightAccumulation += button.getMaxIntrinsicHeight(width);
button = childAfter(button);
}
return heightAccumulation;
}

}
protected override void performLayout() {
if (_isSingleButtonRow(dialogWidth)) {
BoxConstraints constraints = this.constraints;
if (_isSingleButtonRow(dialogWidth ?? 0.0f)) {
if (childCount == 1) {
firstChild.layout(
constraints,

new Size(dialogWidth, firstChild.size.height)
new Size(dialogWidth ?? 0.0f, firstChild.size.height)
);
}
else {

secondButtonParentData.offset =
new Offset(firstChild.size.width + dividerThickness, 0.0f);
size = constraints.constrain(
new Size(dialogWidth,
Mathf.Max(firstChild.size.height, lastChild.size.height
new Size(
dialogWidth ?? 0.0f,
Mathf.Max(
firstChild.size.height,
lastChild.size.height
)
)
);

}
size = constraints.constrain(
new Size(dialogWidth, verticalOffset)
new Size(dialogWidth ?? 0.0f, verticalOffset)
);
}
}

}
Path backgroundFillPath = new Path();
// backgroundFillPath.fillType = PathFillType.evenOdd;
backgroundFillPath.fillType = PathFillType.evenOdd;
backgroundFillPath.addRect(Rect.fromLTWH(0.0f, 0.0f, size.width, size.height));
backgroundFillPath.addRect(verticalDivider);

}
canvas.drawPath(
pressedBackgroundFillPath, _pressedButtonBackgroundPaint
pressedBackgroundFillPath,
_pressedButtonBackgroundPaint
);
Path dividersPath = new Path();
dividersPath.addRect(verticalDivider);

void _drawButtonBackgroundsAndDividersStacked(Canvas canvas, Offset offset) {
Offset dividerOffset = new Offset(0.0f, dividerThickness);
Path backgroundFillPath = new Path();
// ..fillType = PathFillType.evenOdd
backgroundFillPath.fillType = PathFillType.evenOdd;
backgroundFillPath.addRect(Rect.fromLTWH(0.0f, 0.0f, size.width, size.height));
Path pressedBackgroundFillPath = new Path();
Path dividersPath = new Path();

}
}
protected override bool hitTestChildren(BoxHitTestResult result,
protected override bool hitTestChildren(
BoxHitTestResult result,
Offset position = null
) {
return defaultHitTestChildren(result, position: position);

5
com.unity.uiwidgets/Runtime/cupertino/icon_theme_data.cs


Color resolvedColor = CupertinoDynamicColor.resolve(color, context);
return resolvedColor == color ? this : copyWith(color: resolvedColor);
}
public new CupertinoIconThemeData copyWith(Color color = null , float? opacity = null, float? size = null)
public new CupertinoIconThemeData copyWith(
Color color = null ,
float? opacity = null,
float? size = null)
{
return new CupertinoIconThemeData(
color: color ?? this.color,

5
com.unity.uiwidgets/Runtime/cupertino/icons.cs


public static readonly IconData reply_all = new IconData(0xf21d, fontFamily: iconFont);
public static readonly IconData reply_thick_solid = new IconData(0xf21e, fontFamily: iconFont);
public static readonly IconData share_up = new IconData(0xf220, fontFamily: iconFont);
public static readonly IconData shuffle = new IconData(0xf4a9, fontFamily: iconFont);
public static readonly IconData shuffle_medium = new IconData(0xf4a8, fontFamily: iconFont);
public static readonly IconData shuffle_thick = new IconData(0xf221, fontFamily: iconFont);
public static readonly IconData photo_camera = new IconData(0xf3f5, fontFamily: iconFont);
public static readonly IconData photo_camera_solid = new IconData(0xf3f6, fontFamily: iconFont);

public static readonly IconData bell_solid = new IconData(0xf3e2, fontFamily: iconFont);
public static readonly IconData news = new IconData(0xf471, fontFamily: iconFont);
public static readonly IconData news_solid = new IconData(0xf472, fontFamily: iconFont);
public static readonly IconData brightness = new IconData(0xf4B6, fontFamily: iconFont);
public static readonly IconData brightness_solid = new IconData(0xf4B7, fontFamily: iconFont);
}
}

17
com.unity.uiwidgets/Runtime/cupertino/interface_level.cs


public static CupertinoUserInterfaceLevelData? of(BuildContext context, bool nullOk = false ) {
D.assert(context != null);
D.assert(nullOk != null);
//if (nullOk)
// return ;
if (nullOk)
return null;
throw new UIWidgetsError(
"CupertinoUserInterfaceLevel.of() called with a context that does not contain a CupertinoUserInterfaceLevel.\n" +
"No CupertinoUserInterfaceLevel ancestor could be found starting from the context that was passed "+

}
public override bool updateShouldNotify(InheritedWidget oldWidget) {
//throw new System.NotImplementedException();
//oldWidget._data != _data;
/// ?????
if (oldWidget.GetType() == typeof(CupertinoUserInterfaceLevel)) {
return updateShouldNotify(oldWidget);
}
return false;
oldWidget = (CupertinoUserInterfaceLevel) oldWidget;
return ((CupertinoUserInterfaceLevel) oldWidget)._data != _data;
public bool updateShouldNotify(CupertinoUserInterfaceLevel oldWidget) => oldWidget._data != _data;
}
}

201
com.unity.uiwidgets/Runtime/cupertino/nav_bar.cs


using Rect = Unity.UIWidgets.ui.Rect;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using Brightness = Unity.UIWidgets.ui.Brightness;
using Transform = Unity.UIWidgets.widgets.Transform;
namespace Unity.UIWidgets.cupertino {

public const float _kNavBarBackButtonTapWidth = 50.0f;
public static readonly TimeSpan _kNavBarTitleFadeDuration = new TimeSpan(0, 0, 0, 0, 150);
public static readonly TimeSpan _kNavBarTitleFadeDuration = TimeSpan.FromMilliseconds(150);
public static readonly Color _kDefaultNavBarBorderColor = new Color(0x4C000000);

) {
Widget result = child;
if (updateSystemUiOverlay) {
/*bool darkBackground = backgroundColor.computeLuminance() < 0.179f;
SystemUiOverlayStyle overlayStyle = darkBackground
? SystemUiOverlayStyle.light
: SystemUiOverlayStyle.dark;*/
bool isDark = backgroundColor.computeLuminance() < 0.179;
Brightness newBrightness = brightness ?? (isDark ? Brightness.dark : Brightness.light);
SystemUiOverlayStyle overlayStyle;

BuildContext toHeroContext
) => {
D.assert(animation != null);
D.assert(
fromNavBar.componentsKeys.navBarBoxKey.currentContext.owner != null,
() => "The from nav bar to Hero must have been mounted in the previous frame"

topNavBar: fromNavBar
);
}
throw new UIWidgetsError($"Unknown flight direction: {flightDirection}");
};
public static CreateRectTween _linearTranslateWithLargestRectSizeTween = (Rect begin, Rect end) => {

end: end.topLeft & largestSize
);
};
//TransitionBuilder
public static HeroPlaceholderBuilder _navBarHeroLaunchPadBuilder = (
BuildContext context,
Size heroSize,

this.trailing = trailing;
this.border = border ?? NavBarUtils._kDefaultNavBarBorder;
this.backgroundColor = backgroundColor;
this.brightness = brightness ?? Brightness.dark; //todo ????
this.brightness = brightness;
this.padding = padding;
this.actionsForegroundColor = actionsForegroundColor;
this.transitionBetweenRoutes = transitionBetweenRoutes;

public readonly Widget middle;
public readonly Widget trailing;
public readonly Brightness brightness;
public readonly Brightness? brightness;
public readonly Color backgroundColor;
public readonly EdgeInsets padding;

?? CupertinoTheme.of(context).barBackgroundColor;
return backgroundColor.alpha == 0xFF;
}
/*public override bool? fullObstruction {
get { return backgroundColor == null ? null : (bool?) (backgroundColor.alpha == 0xFF); }
}*/
public override Size preferredSize {
get { return Size.fromHeight(NavBarUtils._kNavBarPersistentHeight); }
}

}
public override Widget build(BuildContext context) {
//Color backgroundColor = widget.backgroundColor ?? CupertinoTheme.of(context).barBackgroundColor;
Color backgroundColor =
CupertinoDynamicColor.resolve(widget.backgroundColor, context) ?? CupertinoTheme.of(context).barBackgroundColor;

);
if (!widget.transitionBetweenRoutes || !NavBarUtils._isTransitionable(context)) {
//return NavBarUtils._wrapActiveColor(widget.actionsForegroundColor, context, navBar); // ignore: deprecated_member_use_from_same_package
//widget.actionsForegroundColor, // ignore: deprecated_member_use_from_same_package
actionsForegroundColor,
context,
new Builder(

this.trailing = trailing;
this.border = border ?? NavBarUtils._kDefaultNavBarBorder;
this.backgroundColor = backgroundColor;
this.brightness = brightness ?? Brightness.dark;
this.brightness = brightness;
this.padding = padding;
this.actionsForegroundColor = actionsForegroundColor;
this.transitionBetweenRoutes = transitionBetweenRoutes;

public readonly Color backgroundColor;
public readonly Brightness brightness;
public readonly Brightness? brightness;
public readonly EdgeInsets padding;

}
public override Widget build(BuildContext context) {
//Color actionsForegroundColor = widget.actionsForegroundColor ?? CupertinoTheme.of(context).primaryColor; // ignore: deprecated_member_use_from_same_package
Color actionsForegroundColor = CupertinoDynamicColor.resolve(widget.actionsForegroundColor, context) // ignore: deprecated_member_use_from_same_package
?? CupertinoTheme.of(context).primaryColor;
_NavigationBarStaticComponents components = new _NavigationBarStaticComponents(

);
return NavBarUtils._wrapActiveColor(
widget.actionsForegroundColor, // ignore: deprecated_member_use_from_same_package
actionsForegroundColor,
//new SliverPersistentHeader(
new MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: 1),
child: new SliverPersistentHeader(

components: components,
userMiddle: widget.middle,
//backgroundColor: widget.backgroundColor ?? CupertinoTheme.of(context).barBackgroundColor,
backgroundColor:CupertinoDynamicColor.resolve(widget.backgroundColor, context) ?? CupertinoTheme.of(context).barBackgroundColor,
backgroundColor: CupertinoDynamicColor.resolve(widget.backgroundColor, context) ?? CupertinoTheme.of(context).barBackgroundColor,
brightness: widget.brightness,
border: widget.border,
padding: widget.padding,

}
}
class _LargeTitleNavigationBarSliverDelegate
: SliverPersistentHeaderDelegate {
class _LargeTitleNavigationBarSliverDelegate : SliverPersistentHeaderDelegate {
public _LargeTitleNavigationBarSliverDelegate(
_NavigationBarStaticComponentsKeys keys = null,
_NavigationBarStaticComponents components = null,

float persistentHeight = 0.0f,
bool alwaysShowMiddle =false
) {
D.assert(persistentHeight != null);
D.assert(alwaysShowMiddle != null);
D.assert(transitionBetweenRoutes != null);
this.brightness = brightness ?? Brightness.dark;
this.brightness = brightness;
this.padding = padding;
this.actionsForegroundColor = actionsForegroundColor;
this.transitionBetweenRoutes = transitionBetweenRoutes;

public readonly Widget userMiddle;
public readonly Color backgroundColor;
public readonly Border border;
public Brightness brightness;
public readonly Brightness? brightness;
public readonly EdgeInsets padding;
public readonly Color actionsForegroundColor;
public readonly bool transitionBetweenRoutes;

Widget navBar = NavBarUtils._wrapWithBackground(
border: border,
//backgroundColor: backgroundColor,
backgroundColor: CupertinoDynamicColor.resolve(backgroundColor, context),
brightness: brightness,
child: new DefaultTextStyle(

child: new OverflowBox(
minHeight: 0.0f,
maxHeight: float.PositiveInfinity,
alignment: Alignment.bottomLeft,
alignment: AlignmentDirectional.bottomStart,
child: new Padding(
padding: EdgeInsets.only(
left: NavBarUtils._kNavBarEdgePadding,

transitionOnUserGestures: true,
child: new _TransitionableNavigationBar(
componentsKeys: keys,
//backgroundColor: backgroundColor,
backgroundColor: CupertinoDynamicColor.resolve(backgroundColor, context),
backButtonTextStyle: CupertinoTheme.of(context).textTheme.navActionTextStyle,
titleTextStyle: CupertinoTheme.of(context).textTheme.navTitleTextStyle,

}
public readonly _NavigationBarStaticComponents components;
public readonly EdgeInsets padding;
public readonly bool middleVisible;

style: CupertinoTheme.of(context).textTheme.navTitleTextStyle,
child: middle
);
middle = new AnimatedOpacity(
opacity: middleVisible ? 1.0f : 0.0f,
duration: NavBarUtils._kNavBarTitleFadeDuration,
child: middle
);
middle = middleVisible == null
? middle
: new AnimatedOpacity(
opacity: middleVisible ? 1.0f : 0.0f,
duration: NavBarUtils._kNavBarTitleFadeDuration,
child: middle
);
}
Widget leading = components.leading;

class _NavigationBarStaticComponents {
public _NavigationBarStaticComponents(
_NavigationBarStaticComponentsKeys keys,
ModalRoute route,
Widget userLeading,
string previousPageTitle,
Widget userMiddle,
Widget userTrailing,
Widget userLargeTitle,
EdgeInsets padding,
bool large
bool large,
_NavigationBarStaticComponentsKeys keys = null,
ModalRoute route = null,
Widget userLeading = null,
string previousPageTitle = null,
Widget userMiddle = null,
Widget userTrailing = null,
Widget userLargeTitle = null,
EdgeInsets padding = null
) {
leading = createLeading(
leadingKey: keys.leadingKey,

}
static Widget _derivedTitle(
bool automaticallyImplyTitle,
ModalRoute currentRoute
bool automaticallyImplyTitle ,
ModalRoute currentRoute = null
route.title != null) {
((CupertinoPageRoute)route).title != null) {
return new Text(route.title);
}

public readonly KeyedSubtree leading;
static KeyedSubtree createLeading(
GlobalKey leadingKey,
Widget userLeading,
ModalRoute route,
EdgeInsets padding
GlobalKey leadingKey = null,
Widget userLeading = null,
ModalRoute route = null,
EdgeInsets padding = null
) {
Widget leadingContent = null;

public readonly KeyedSubtree backChevron;
static KeyedSubtree createBackChevron(
GlobalKey backChevronKey,
Widget userLeading,
ModalRoute route,
bool automaticallyImplyLeading
bool automaticallyImplyLeading,
GlobalKey backChevronKey = null,
Widget userLeading = null,
ModalRoute route = null
) {
if (
userLeading != null ||

public readonly KeyedSubtree backLabel;
static KeyedSubtree createBackLabel(
GlobalKey backLabelKey,
Widget userLeading,
ModalRoute route,
string previousPageTitle
GlobalKey backLabelKey = null,
Widget userLeading = null,
ModalRoute route = null,
string previousPageTitle = null
) {
if (
userLeading != null ||

public readonly KeyedSubtree middle;
static KeyedSubtree createMiddle(
GlobalKey middleKey,
Widget userMiddle,
Widget userLargeTitle,
ModalRoute route
GlobalKey middleKey = null,
Widget userMiddle = null,
Widget userLargeTitle = null,
ModalRoute route = null
) {
Widget middleContent = userMiddle;

middleContent = middleContent ?? _derivedTitle(
automaticallyImplyTitle: automaticallyImplyTitle,
currentRoute: route
);
middleContent = middleContent ?? _derivedTitle(automaticallyImplyTitle: automaticallyImplyTitle, currentRoute: route);
if (middleContent == null) {
return null;

public readonly KeyedSubtree trailing;
static KeyedSubtree createTrailing(
GlobalKey trailingKey,
Widget userTrailing,
EdgeInsets padding
GlobalKey trailingKey = null,
Widget userTrailing = null,
EdgeInsets padding = null
) {
if (userTrailing == null) {
return null;

public readonly KeyedSubtree largeTitle;
static KeyedSubtree createLargeTitle(
GlobalKey largeTitleKey,
Widget userLargeTitle,
ModalRoute route
GlobalKey largeTitleKey = null,
Widget userLargeTitle = null,
ModalRoute route = null
) {
if (!large) {
return null;

automaticallyImplyTitle: automaticImplyTitle,
currentRoute: route
);
currentRoute: route);
return new KeyedSubtree(
key: largeTitleKey,
child: largeTitleContent

Color color = null,
string previousPageTitle = null,
VoidCallback onPressed = null
):base(key:key) {
_backChevron = null;
_backLabel = null;

Widget _backChevron,
Widget _backLabel
) {
);
);
}
public readonly Color color;

() => "CupertinoNavigationBarBackButton should only be used in routes that can be popped"
);
}
// actionTextStyle = actionTextStyle.copyWith(color: color);
actionTextStyle = actionTextStyle.copyWith(color: CupertinoDynamicColor.resolve(color, context));
}

),
padding: EdgeInsets.zero,
onPressed: () => {
//Navigator.maybePop(context);
if (onPressed != null) {
onPressed();
} else {

public _BackChevron(Key key = null) : base(key: key) { }
public override Widget build(BuildContext context) {
TextDirection textDirection = Directionality.of(context);
text: char.ConvertFromUtf32(CupertinoIcons.back.codePoint),
text:new string(new[] {(char) CupertinoIcons.back.codePoint}),
//package: CupertinoIcons.back.fontPackage
var matrix = Matrix4.identity();
matrix.scale(-1.0f, 1.0f, 1.0f);
switch (textDirection) {
case TextDirection.rtl:
iconWidget = new Transform(
transform: matrix,
alignment: Alignment.center,
transformHitTests: false,
child: iconWidget
) as Widget;
break;
case TextDirection.ltr:
break;
}
return iconWidget;
}

string specifiedPreviousTitle = null,
ModalRoute route = null
) : base(key: key) {
//D.assert(route != null);
this.specifiedPreviousTitle = specifiedPreviousTitle;
this.route = route;
}

}
return new Align(
alignment: Alignment.centerLeft,
alignment: AlignmentDirectional.centerStart,
widthFactor: 1.0f,
child: textWidget
);

if (specifiedPreviousTitle != null) {
return _buildPreviousTitleWidget(context, specifiedPreviousTitle, null);
}
//else if (route is CupertinoPageRoute cupertinoRoute) {
else if (route is CupertinoPageRoute && !route.isFirst) {
CupertinoPageRoute cupertinoRoute = route as CupertinoPageRoute;
return new ValueListenableBuilder<string>(

bool? largeExpanded = null,
Widget child = null
) : base(key: componentsKeys.navBarBoxKey) {
this.componentsKeys = componentsKeys;
this.backgroundColor = backgroundColor;
this.backButtonTextStyle = backButtonTextStyle;

public RenderBox renderBox {
get {
// RenderBox box = (RenderBox) componentsKeys.navBarBoxKey.currentContext.findRenderObject();
RenderBox box = componentsKeys.navBarBoxKey.currentContext.findRenderObject() as RenderBox;
RenderBox box = componentsKeys.navBarBoxKey.currentContext.findRenderObject() as RenderBox;
D.assert(
box.attached,
() => "_TransitionableNavigationBar.renderBox should be called when building " +

class _NavigationBarTransition : StatelessWidget {
public _NavigationBarTransition(
Animation<float> animation,
_TransitionableNavigationBar topNavBar,
_TransitionableNavigationBar bottomNavBar
Animation<float> animation = null,
_TransitionableNavigationBar topNavBar = null,
_TransitionableNavigationBar bottomNavBar = null
begin: this.bottomNavBar.renderBox.size.height,
end: this.topNavBar.renderBox.size.height
begin: bottomNavBar.renderBox.size.height,
end: topNavBar.renderBox.size.height
begin: this.bottomNavBar.backgroundColor,
end: this.topNavBar.backgroundColor
begin: bottomNavBar.backgroundColor,
end: topNavBar.backgroundColor
begin: this.bottomNavBar.border,
end: this.topNavBar.border
begin: bottomNavBar.border,
end: topNavBar.border
);
}

2
com.unity.uiwidgets/Runtime/widgets/preferred_size.cs


Size preferredSize { get; }
}
public abstract class PreferredSizeWidget : Widget{
public abstract class PreferredSizeWidget : StatefulWidget{
protected PreferredSizeWidget(Key key = null) : base(key: key) {
}

正在加载...
取消
保存