浏览代码

update

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
645b8f2d
共有 7 个文件被更改,包括 948 次插入0 次删除
  1. 22
      com.unity.uiwidgets/Runtime/material/theme_data.cs
  2. 580
      com.unity.uiwidgets/Runtime/material/navigation_rail.cs
  3. 3
      com.unity.uiwidgets/Runtime/material/navigation_rail.cs.meta
  4. 189
      com.unity.uiwidgets/Runtime/material/navigation_rail_theme.cs
  5. 3
      com.unity.uiwidgets/Runtime/material/navigation_rail_theme.cs.meta
  6. 148
      com.unity.uiwidgets/Runtime/material/snack_bar_theme.cs
  7. 3
      com.unity.uiwidgets/Runtime/material/snack_bar_theme.cs.meta

22
com.unity.uiwidgets/Runtime/material/theme_data.cs


using System.Collections.Generic;
using System.Linq;
using uiwidgets;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.service;

public readonly IconThemeData accentIconTheme;
public readonly TabBarTheme tabBarTheme;
public readonly TooltipThemeData tooltipTheme;
public readonly CardTheme cardTheme;

public readonly ColorScheme colorScheme;
public readonly SnackBarThemeData snackBarTheme;
public readonly NavigationRailThemeData navigationRailTheme;
public readonly BottomSheetThemeData bottomSheetTheme;
public readonly CupertinoThemeData cupertinoOverrideTheme;
/// A theme for customizing the color, shape, elevation, and text style of
/// popup menus.
public readonly PopupMenuThemeData popupMenuTheme;
/// A theme for customizing the color and text style of a [MaterialBanner].
public readonly MaterialBannerThemeData bannerTheme;
/// A theme for customizing the color, thickness, and indents of [Divider]s,
/// [VerticalDivider]s, etc.
public readonly DividerThemeData dividerTheme;
public readonly ButtonBarThemeData buttonBarTheme;
public ThemeData copyWith(

580
com.unity.uiwidgets/Runtime/material/navigation_rail.cs


using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
class NavigationRail : StatefulWidget {
public NavigationRail(
Color backgroundColor = null,
bool? extended = null,
Widget leading = null,
Widget trailing = null,
List<NavigationRailDestination> destinations = null,
int? selectedIndex = null,
ValueChanged<int> onDestinationSelected = null,
float? elevation = null,
float? groupAlignment = null,
NavigationRailLabelType? labelType = null,
TextStyle unselectedLabelTextStyle = null,
TextStyle selectedLabelTextStyle = null,
IconThemeData unselectedIconTheme = null,
IconThemeData selectedIconTheme = null,
float? minWidth = null,
float? minExtendedWidth = null
) {
D.assert(destinations != null && destinations.Count >= 2);
D.assert(selectedIndex != null);
D.assert(0 <= selectedIndex && selectedIndex < destinations.Count);
D.assert(elevation == null || elevation > 0);
D.assert(minWidth == null || minWidth > 0);
D.assert(minExtendedWidth == null || minExtendedWidth > 0);
D.assert((minWidth == null || minExtendedWidth == null) || minExtendedWidth >= minWidth);
D.assert(extended != null);
D.assert(!extended.Value || (labelType == null || labelType == NavigationRailLabelType.none));
this.backgroundColor = backgroundColor;
this.extended = extended;
this.leading = leading;
this.trailing = trailing;
this.destinations = destinations;
this.selectedIndex = selectedIndex;
this.onDestinationSelected = onDestinationSelected;
this.elevation = elevation;
this.groupAlignment = groupAlignment;
this.labelType = labelType;
this.unselectedLabelTextStyle = unselectedLabelTextStyle;
this.selectedLabelTextStyle = selectedLabelTextStyle;
this.unselectedIconTheme = unselectedIconTheme;
this.selectedIconTheme = selectedIconTheme;
this.minWidth = minWidth;
this.minExtendedWidth = minExtendedWidth;
}
public readonly Color backgroundColor;
public readonly bool? extended;
public readonly Widget leading;
public readonly Widget trailing;
public readonly List<NavigationRailDestination> destinations;
public readonly int? selectedIndex;
public readonly ValueChanged<int> onDestinationSelected;
public readonly float? elevation;
public readonly float? groupAlignment;
public readonly NavigationRailLabelType? labelType;
public readonly TextStyle unselectedLabelTextStyle;
public readonly TextStyle selectedLabelTextStyle;
public readonly IconThemeData unselectedIconTheme;
public readonly IconThemeData selectedIconTheme;
public readonly float? minWidth;
public readonly float? minExtendedWidth;
public static Animation<float> extendedAnimation(BuildContext context) {
return context.dependOnInheritedWidgetOfExactType<_ExtendedNavigationRailAnimation>().animation;
}
public override State createState() => new _NavigationRailState();
}
class _NavigationRailState : TickerProviderStateMixin<NavigationRail> {
List<AnimationController> _destinationControllers = new List<AnimationController>();
List<Animation<float>> _destinationAnimations;
AnimationController _extendedController;
Animation<float> _extendedAnimation;
public override void initState() {
base.initState();
_initControllers();
}
public override void dispose() {
_disposeControllers();
base.dispose();
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
base.didUpdateWidget(oldWidget);
var checkOldWidget = (NavigationRail) oldWidget;
if (oldWidget is NavigationRail navigationRail) {
if (widget.extended != navigationRail.extended) {
if (widget.extended ?? false) {
_extendedController.forward();
}
else {
_extendedController.reverse();
}
}
if (widget.destinations.Count != navigationRail.destinations.Count) {
_resetState();
return;
}
if (widget.selectedIndex != navigationRail.selectedIndex) {
_destinationControllers[navigationRail.selectedIndex.Value].reverse();
_destinationControllers[widget.selectedIndex.Value].forward();
return;
}
}
}
public override Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
NavigationRailThemeData navigationRailTheme = NavigationRailTheme.of(context);
MaterialLocalizations localizations = MaterialLocalizations.of(context);
Color backgroundColor =
widget.backgroundColor ?? navigationRailTheme.backgroundColor ?? theme.colorScheme.surface;
float elevation = widget.elevation ?? navigationRailTheme.elevation ?? 0;
float minWidth = widget.minWidth ?? material_._minRailWidth;
float minExtendedWidth = widget.minExtendedWidth ?? material_._minExtendedRailWidth;
Color baseSelectedColor = theme.colorScheme.primary;
Color baseColor = theme.colorScheme.onSurface.withOpacity(0.64f);
IconThemeData defaultUnselectedIconTheme =
widget.unselectedIconTheme ?? navigationRailTheme.unselectedIconTheme;
IconThemeData unselectedIconTheme = new IconThemeData(
size: defaultUnselectedIconTheme?.size ?? 24.0f,
color: defaultUnselectedIconTheme?.color ?? theme.colorScheme.onSurface,
opacity: defaultUnselectedIconTheme?.opacity ?? 1.0f
);
IconThemeData defaultSelectedIconTheme = widget.selectedIconTheme ?? navigationRailTheme.selectedIconTheme;
IconThemeData selectedIconTheme = new IconThemeData(
size: defaultSelectedIconTheme?.size ?? 24.0f,
color: defaultSelectedIconTheme?.color ?? theme.colorScheme.primary,
opacity: defaultSelectedIconTheme?.opacity ?? 0.64f
);
TextStyle unselectedLabelTextStyle = theme.textTheme.bodyText1.copyWith(color: baseColor)
.merge(widget.unselectedLabelTextStyle ?? navigationRailTheme.unselectedLabelTextStyle);
TextStyle selectedLabelTextStyle = theme.textTheme.bodyText1.copyWith(color: baseSelectedColor)
.merge(widget.selectedLabelTextStyle ?? navigationRailTheme.selectedLabelTextStyle);
float groupAlignment = widget.groupAlignment ?? navigationRailTheme.groupAlignment ?? -1.0f;
NavigationRailLabelType labelType =
widget.labelType ?? navigationRailTheme.labelType ?? NavigationRailLabelType.none;
var materialChildren = new List<Widget>();
materialChildren.Add(material_._verticalSpacer);
if (widget.leading != null) {
materialChildren.AddRange(new List<Widget>() {
new ConstrainedBox(
constraints: new BoxConstraints(
minWidth: Mathf.Lerp(minWidth, minExtendedWidth, _extendedAnimation.value)
),
child: widget.leading
),
material_._verticalSpacer,
});
}
var alignChildren = new List<Widget>();
for (int i = 0; i < widget.destinations.Count; i += 1) {
alignChildren.Add(new _RailDestination(
minWidth: minWidth,
minExtendedWidth: minExtendedWidth,
extendedTransitionAnimation: _extendedAnimation,
selected: widget.selectedIndex == i,
icon: widget.selectedIndex == i ? widget.destinations[i].selectedIcon : widget.destinations[i].icon,
label: widget.destinations[i].label,
destinationAnimation: _destinationAnimations[i],
labelType: labelType,
iconTheme: widget.selectedIndex == i ? selectedIconTheme : unselectedIconTheme,
labelTextStyle: widget.selectedIndex == i ? selectedLabelTextStyle : unselectedLabelTextStyle,
onTap: () => { widget.onDestinationSelected(i); },
indexLabel: localizations.tabLabel(
tabIndex: i + 1,
tabCount: widget.destinations.Count
)
));
}
if (widget.trailing != null) {
alignChildren.Add(new ConstrainedBox(
constraints: new BoxConstraints(
minWidth: Mathf.Lerp(minWidth, minExtendedWidth, _extendedAnimation.value)
),
child: widget.trailing
));
}
materialChildren.Add(new Expanded(
child: new Align(
alignment: new Alignment(0, groupAlignment),
child: new Column(
mainAxisSize: MainAxisSize.min,
children: alignChildren
)
)
));
return new _ExtendedNavigationRailAnimation(
animation: _extendedAnimation,
child: new Material(
elevation: elevation,
color: backgroundColor,
child: new Column(
children: materialChildren
)
)
);
}
void _disposeControllers() {
foreach (AnimationController controller in _destinationControllers) {
controller.dispose();
}
_extendedController.dispose();
}
void _initControllers() {
_destinationControllers = widget.destinations.Select((destination, i) => {
var result = new AnimationController(
duration: ThemeUtils.kThemeAnimationDuration,
vsync: this
);
result.addListener(_rebuild);
return result;
}).ToList();
_destinationAnimations = _destinationControllers.Select((AnimationController controller) => controller.view)
.ToList();
_destinationControllers[widget.selectedIndex ?? 0].setValue(1.0f);
_extendedController = new AnimationController(
duration: ThemeUtils.kThemeAnimationDuration,
vsync: this,
value: widget.extended ?? false ? 1.0f : 0.0f
);
_extendedAnimation = new CurvedAnimation(
parent: _extendedController,
curve: Curves.easeInOut
);
_extendedController.addListener(() => { _rebuild(); });
}
void _resetState() {
_disposeControllers();
_initControllers();
}
void _rebuild() {
setState(() => {
// Rebuilding when any of the controllers tick, i.e. when the items are
// animating.
});
}
}
internal class _RailDestination : StatelessWidget {
internal _RailDestination(
float? minWidth = null,
float? minExtendedWidth = null,
Widget icon = null,
Widget label = null,
Animation<float> destinationAnimation = null,
Animation<float> extendedTransitionAnimation = null,
NavigationRailLabelType? labelType = null,
bool? selected = null,
IconThemeData iconTheme = null,
TextStyle labelTextStyle = null,
VoidCallback onTap = null,
string indexLabel = null
) {
D.assert(minWidth != null);
D.assert(minExtendedWidth != null);
D.assert(icon != null);
D.assert(label != null);
D.assert(destinationAnimation != null);
D.assert(extendedTransitionAnimation != null);
D.assert(labelType != null);
D.assert(selected != null);
D.assert(iconTheme != null);
D.assert(labelTextStyle != null);
D.assert(onTap != null);
D.assert(indexLabel != null);
this.minWidth = minWidth;
this.minExtendedWidth = minExtendedWidth;
this.icon = icon;
this.label = label;
this.destinationAnimation = destinationAnimation;
this.extendedTransitionAnimation = extendedTransitionAnimation;
this.labelType = labelType;
this.selected = selected;
this.iconTheme = iconTheme;
this.labelTextStyle = labelTextStyle;
this.onTap = onTap;
this.indexLabel = indexLabel;
_positionAnimation = new CurvedAnimation(
parent: new ReverseAnimation(destinationAnimation),
curve: Curves.easeInOut,
reverseCurve: Curves.easeInOut.flipped
);
}
public readonly float? minWidth;
public readonly float? minExtendedWidth;
public readonly Widget icon;
public readonly Widget label;
public readonly Animation<float> destinationAnimation;
public readonly NavigationRailLabelType? labelType;
public readonly bool? selected;
public readonly Animation<float> extendedTransitionAnimation;
public readonly IconThemeData iconTheme;
public readonly TextStyle labelTextStyle;
public readonly VoidCallback onTap;
public readonly string indexLabel;
public readonly Animation<float> _positionAnimation;
public override Widget build(BuildContext context) {
Widget themedIcon = new IconTheme(
data: iconTheme,
child: icon
);
Widget styledLabel = new DefaultTextStyle(
style: labelTextStyle,
child: label
);
Widget content = null;
switch (labelType) {
case NavigationRailLabelType.none:
Widget iconPart = new SizedBox(
width: minWidth,
height: minWidth,
child: new Align(
alignment: Alignment.center,
child: themedIcon
)
);
if (extendedTransitionAnimation.value == 0) {
content = new Stack(
children: new List<Widget>() {
iconPart,
new SizedBox(
width: 0,
height: 0,
child: new Opacity(
opacity: 0.0f,
child: label
)
)
}
)
;
}
else {
content = new ConstrainedBox(
constraints: new BoxConstraints(
minWidth: Mathf.Lerp(minWidth ?? 0, minExtendedWidth ?? 0,
extendedTransitionAnimation.value)
),
child: new ClipRect(
child: new Row(
children: new List<Widget> {
iconPart,
new Align(
heightFactor: 1.0f,
widthFactor: extendedTransitionAnimation.value,
alignment: AlignmentDirectional.centerStart,
child: new Opacity(
opacity: _extendedLabelFadeValue(),
child: styledLabel
)
),
new SizedBox(width: material_._horizontalDestinationPadding),
}
)
)
);
}
break;
case NavigationRailLabelType.selected:
float appearingAnimationValue = 1 - _positionAnimation.value;
float verticalPadding = Mathf.Lerp(material_._verticalDestinationPaddingNoLabel,
material_._verticalDestinationPaddingWithLabel, appearingAnimationValue);
content = new Container(
constraints: new BoxConstraints(
minWidth: minWidth ?? 0,
minHeight: minWidth ?? 0
),
padding: EdgeInsets.symmetric(horizontal: material_._horizontalDestinationPadding),
child:
new ClipRect(
child: new Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: new List<Widget>() {
new SizedBox(height: verticalPadding),
themedIcon,
new Align(
alignment: Alignment.topCenter,
heightFactor: appearingAnimationValue,
widthFactor: 1.0f,
child: new Opacity(
opacity: selected ?? false
? _normalLabelFadeInValue()
: _normalLabelFadeOutValue(),
child: styledLabel
)
),
new SizedBox(height: verticalPadding)
}
)
)
);
break;
case NavigationRailLabelType.all:
content = new Container(
constraints: new BoxConstraints(
minWidth: minWidth ?? 0,
minHeight: minWidth ?? 0
),
padding: EdgeInsets.symmetric(horizontal: material_._horizontalDestinationPadding),
child:
new Column(
children: new List<Widget>() {
new SizedBox(height: material_._verticalDestinationPaddingWithLabel),
themedIcon,
styledLabel,
new SizedBox(height: material_._verticalDestinationPaddingWithLabel),
}
));
break;
}
ColorScheme colors = Theme.of(context).colorScheme;
return new Material(
type: MaterialType.transparency,
clipBehavior: Clip.none,
child: new InkResponse(
onTap: onTap,
onHover: (_) => { },
highlightShape:
BoxShape.rectangle,
borderRadius:
BorderRadius.all(Radius.circular((minWidth ?? 0) / 2.0f)),
containedInkWell:
true,
splashColor: colors.primary.withOpacity(0.12f),
hoverColor: colors.primary.withOpacity(0.04f),
child: content
)
);
}
float _normalLabelFadeInValue() {
if (destinationAnimation.value < 0.25f) {
return 0;
}
else if (destinationAnimation.value < 0.75f) {
return (destinationAnimation.value - 0.25f) * 2;
}
else {
return 1;
}
}
float _normalLabelFadeOutValue() {
if (destinationAnimation.value > 0.75f) {
return (destinationAnimation.value - 0.75f) * 4.0f;
}
else {
return 0;
}
}
float _extendedLabelFadeValue() {
return extendedTransitionAnimation.value < 0.25f ? extendedTransitionAnimation.value * 4.0f : 1.0f;
}
}
public enum NavigationRailLabelType {
none,
selected,
all,
}
class NavigationRailDestination {
public NavigationRailDestination(
Widget icon,
Widget selectedIcon = null,
Widget label = null
) {
D.assert(icon != null);
selectedIcon = selectedIcon ?? icon;
this.icon = icon;
this.selectedIcon = selectedIcon;
this.label = label;
}
public readonly Widget icon;
public readonly Widget selectedIcon;
public readonly Widget label;
}
class _ExtendedNavigationRailAnimation : InheritedWidget {
public _ExtendedNavigationRailAnimation(
Key key = null,
Animation<float> animation = null,
Widget child = null
) : base(key: key, child: child) {
D.assert(child != null);
this.animation = animation;
}
public readonly Animation<float> animation;
public override bool updateShouldNotify(InheritedWidget oldWidget) =>
oldWidget is _ExtendedNavigationRailAnimation extendedNavigationRailAnimation
&& animation != extendedNavigationRailAnimation.animation;
}
public partial class material_ {
public static readonly float _minRailWidth = 72.0f;
public static readonly float _minExtendedRailWidth = 256.0f;
public static readonly float _horizontalDestinationPadding = 8.0f;
public static readonly float _verticalDestinationPaddingNoLabel = 24.0f;
public static readonly float _verticalDestinationPaddingWithLabel = 16.0f;
public static readonly Widget _verticalSpacer = new SizedBox(height: 8.0f);
}
}

3
com.unity.uiwidgets/Runtime/material/navigation_rail.cs.meta


fileFormatVersion: 2
guid: 44154d21b3bb4de8a16fdb712a524a0f
timeCreated: 1611214615

189
com.unity.uiwidgets/Runtime/material/navigation_rail_theme.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
public class NavigationRailThemeData : Diagnosticable, IEquatable<NavigationRailThemeData> {
public NavigationRailThemeData(
Color backgroundColor = null,
float? elevation = null,
TextStyle unselectedLabelTextStyle = null,
TextStyle selectedLabelTextStyle = null,
IconThemeData unselectedIconTheme = null,
IconThemeData selectedIconTheme = null,
float? groupAlignment = null,
NavigationRailLabelType? labelType = null
) {
this.backgroundColor = backgroundColor;
this.elevation = elevation;
this.unselectedLabelTextStyle = unselectedLabelTextStyle;
this.selectedLabelTextStyle = selectedLabelTextStyle;
this.unselectedIconTheme = unselectedIconTheme;
this.selectedIconTheme = selectedIconTheme;
this.groupAlignment = groupAlignment;
this.labelType = labelType;
}
public readonly Color backgroundColor;
public readonly float? elevation;
public readonly TextStyle unselectedLabelTextStyle;
public readonly TextStyle selectedLabelTextStyle;
public readonly IconThemeData unselectedIconTheme;
public readonly IconThemeData selectedIconTheme;
public readonly float? groupAlignment;
public readonly NavigationRailLabelType? labelType;
NavigationRailThemeData copyWith(
Color backgroundColor,
float? elevation,
TextStyle unselectedLabelTextStyle,
TextStyle selectedLabelTextStyle,
IconThemeData unselectedIconTheme,
IconThemeData selectedIconTheme,
float? groupAlignment,
NavigationRailLabelType? labelType
) {
return new NavigationRailThemeData(
backgroundColor: backgroundColor ?? this.backgroundColor,
elevation: elevation ?? this.elevation,
unselectedLabelTextStyle: unselectedLabelTextStyle ?? this.unselectedLabelTextStyle,
selectedLabelTextStyle: selectedLabelTextStyle ?? this.selectedLabelTextStyle,
unselectedIconTheme: unselectedIconTheme ?? this.unselectedIconTheme,
selectedIconTheme: selectedIconTheme ?? this.selectedIconTheme,
groupAlignment: groupAlignment ?? this.groupAlignment,
labelType: labelType ?? this.labelType
);
}
static NavigationRailThemeData lerp(NavigationRailThemeData a, NavigationRailThemeData b, float t) {
if (a == null && b == null)
return null;
return new NavigationRailThemeData(
backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t),
elevation: Mathf.Lerp(a?.elevation ?? 0, b?.elevation ?? 0, t),
unselectedLabelTextStyle: TextStyle.lerp(a?.unselectedLabelTextStyle, b?.unselectedLabelTextStyle, t),
selectedLabelTextStyle: TextStyle.lerp(a?.selectedLabelTextStyle, b?.selectedLabelTextStyle, t),
unselectedIconTheme: IconThemeData.lerp(a?.unselectedIconTheme, b?.unselectedIconTheme, t),
selectedIconTheme: IconThemeData.lerp(a?.selectedIconTheme, b?.selectedIconTheme, t),
groupAlignment: Mathf.Lerp(a?.groupAlignment ?? 0, b?.groupAlignment ?? 0, t),
labelType: t < 0.5 ? a?.labelType : b?.labelType
);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
NavigationRailThemeData defaultData = new NavigationRailThemeData();
properties.add(new ColorProperty("backgroundColor", backgroundColor,
defaultValue: defaultData.backgroundColor));
properties.add(new FloatProperty("elevation", elevation, defaultValue: defaultData.elevation));
properties.add(new DiagnosticsProperty<TextStyle>("unselectedLabelTextStyle", unselectedLabelTextStyle,
defaultValue: defaultData.unselectedLabelTextStyle));
properties.add(new DiagnosticsProperty<TextStyle>("selectedLabelTextStyle", selectedLabelTextStyle,
defaultValue: defaultData.selectedLabelTextStyle));
properties.add(new DiagnosticsProperty<IconThemeData>("unselectedIconTheme", unselectedIconTheme,
defaultValue: defaultData.unselectedIconTheme));
properties.add(new DiagnosticsProperty<IconThemeData>("selectedIconTheme", selectedIconTheme,
defaultValue: defaultData.selectedIconTheme));
properties.add(
new FloatProperty("groupAlignment", groupAlignment, defaultValue: defaultData.groupAlignment));
properties.add(new DiagnosticsProperty<NavigationRailLabelType?>("labelType", labelType,
defaultValue: defaultData.labelType));
}
public static bool operator ==(NavigationRailThemeData self, NavigationRailThemeData other) {
return Equals(self, other);
}
public static bool operator !=(NavigationRailThemeData self, NavigationRailThemeData other) {
return Equals(self, other);
}
public bool Equals(NavigationRailThemeData other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return Equals(backgroundColor, other.backgroundColor) && Nullable.Equals(elevation, other.elevation) &&
Equals(unselectedLabelTextStyle, other.unselectedLabelTextStyle) &&
Equals(selectedLabelTextStyle, other.selectedLabelTextStyle) &&
Equals(unselectedIconTheme, other.unselectedIconTheme) &&
Equals(selectedIconTheme, other.selectedIconTheme) &&
Nullable.Equals(groupAlignment, other.groupAlignment) && labelType == other.labelType;
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != GetType()) {
return false;
}
return Equals((NavigationRailThemeData) obj);
}
public override int GetHashCode() {
unchecked {
var hashCode = (backgroundColor != null ? backgroundColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ elevation.GetHashCode();
hashCode = (hashCode * 397) ^
(unselectedLabelTextStyle != null ? unselectedLabelTextStyle.GetHashCode() : 0);
hashCode = (hashCode * 397) ^
(selectedLabelTextStyle != null ? selectedLabelTextStyle.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (unselectedIconTheme != null ? unselectedIconTheme.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (selectedIconTheme != null ? selectedIconTheme.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ groupAlignment.GetHashCode();
hashCode = (hashCode * 397) ^ labelType.GetHashCode();
return hashCode;
}
}
}
public class NavigationRailTheme : InheritedTheme {
public NavigationRailTheme(
Key key = null,
NavigationRailThemeData data = null,
Widget child = null
) : base(key: key, child: child) {
D.assert(data != null);
this.data = data;
}
public readonly NavigationRailThemeData data;
public static NavigationRailThemeData of(BuildContext context) {
NavigationRailTheme navigationRailTheme =
context.dependOnInheritedWidgetOfExactType<NavigationRailTheme>();
return navigationRailTheme?.data ?? Theme.of(context).navigationRailTheme;
}
public override Widget wrap(BuildContext context, Widget child) {
NavigationRailTheme ancestorTheme = context.findAncestorWidgetOfExactType<NavigationRailTheme>();
return ReferenceEquals(this, ancestorTheme) ? child : new NavigationRailTheme(data: data, child: child);
}
public override bool updateShouldNotify(InheritedWidget oldWidget) =>
oldWidget is NavigationRailTheme navigationRail && data != navigationRail.data;
}
}

3
com.unity.uiwidgets/Runtime/material/navigation_rail_theme.cs.meta


fileFormatVersion: 2
guid: ea446a1e5a704c9faf0c50c5d1f9d5a8
timeCreated: 1611214357

148
com.unity.uiwidgets/Runtime/material/snack_bar_theme.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Object = UnityEngine.Object;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
public enum SnackBarBehavior {
fix,
floating,
}
public class SnackBarThemeData : Diagnosticable, IEquatable<SnackBarThemeData> {
public SnackBarThemeData(
Color backgroundColor,
Color actionTextColor,
Color disabledActionTextColor,
TextStyle contentTextStyle,
float? elevation,
ShapeBorder shape,
SnackBarBehavior behavior
) {
D.assert(elevation == null || elevation >= 0.0f);
this.backgroundColor = backgroundColor;
this.actionTextColor = actionTextColor;
this.disabledActionTextColor = disabledActionTextColor;
this.contentTextStyle = contentTextStyle;
this.elevation = elevation;
this.shape = shape;
this.behavior = behavior;
}
public readonly Color backgroundColor;
public readonly Color actionTextColor;
public readonly Color disabledActionTextColor;
public readonly TextStyle contentTextStyle;
public readonly float? elevation;
public readonly ShapeBorder shape;
public readonly SnackBarBehavior behavior;
public SnackBarThemeData copyWith(
Color backgroundColor,
Color actionTextColor,
Color disabledActionTextColor,
TextStyle contentTextStyle,
float? elevation,
ShapeBorder shape,
SnackBarBehavior? behavior
) {
return new SnackBarThemeData(
backgroundColor: backgroundColor ?? this.backgroundColor,
actionTextColor: actionTextColor ?? this.actionTextColor,
disabledActionTextColor: disabledActionTextColor ?? this.disabledActionTextColor,
contentTextStyle: contentTextStyle ?? this.contentTextStyle,
elevation: elevation ?? this.elevation,
shape: shape ?? this.shape,
behavior: behavior ?? this.behavior
);
}
static SnackBarThemeData lerp(SnackBarThemeData a, SnackBarThemeData b, float t) {
return new SnackBarThemeData(
backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t),
actionTextColor: Color.lerp(a?.actionTextColor, b?.actionTextColor, t),
disabledActionTextColor: Color.lerp(a?.disabledActionTextColor, b?.disabledActionTextColor, t),
contentTextStyle: TextStyle.lerp(a?.contentTextStyle, b?.contentTextStyle, t),
elevation: Mathf.Lerp(a?.elevation ?? 0, b?.elevation ?? 0, t),
shape: ShapeBorder.lerp(a?.shape, b?.shape, t),
behavior: t < 0.5 ? a.behavior : b.behavior
);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new ColorProperty("backgroundColor", backgroundColor, defaultValue: null));
properties.add(new ColorProperty("actionTextColor", actionTextColor, defaultValue: null));
properties.add(new ColorProperty("disabledActionTextColor", disabledActionTextColor, defaultValue: null));
properties.add(
new DiagnosticsProperty<TextStyle>("contentTextStyle", contentTextStyle, defaultValue: null));
properties.add(new FloatProperty("elevation", elevation, defaultValue: null));
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", shape, defaultValue: null));
properties.add(new DiagnosticsProperty<SnackBarBehavior>("behavior", behavior, defaultValue: null));
}
public static bool operator ==(SnackBarThemeData self, SnackBarThemeData other) {
return Equals(self, other);
}
public static bool operator !=(SnackBarThemeData self, SnackBarThemeData other) {
return Equals(self, other);
}
public bool Equals(SnackBarThemeData other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return Equals(backgroundColor, other.backgroundColor) && Equals(actionTextColor, other.actionTextColor) &&
Equals(disabledActionTextColor, other.disabledActionTextColor) &&
Equals(contentTextStyle, other.contentTextStyle) && Nullable.Equals(elevation, other.elevation) &&
Equals(shape, other.shape) && behavior == other.behavior;
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != GetType()) {
return false;
}
return Equals((SnackBarThemeData) obj);
}
public override int GetHashCode() {
unchecked {
var hashCode = (backgroundColor != null ? backgroundColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (actionTextColor != null ? actionTextColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^
(disabledActionTextColor != null ? disabledActionTextColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (contentTextStyle != null ? contentTextStyle.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ elevation.GetHashCode();
hashCode = (hashCode * 397) ^ (shape != null ? shape.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (int) behavior;
return hashCode;
}
}
}
}

3
com.unity.uiwidgets/Runtime/material/snack_bar_theme.cs.meta


fileFormatVersion: 2
guid: e778095633af486ebf85e2dc802baf55
timeCreated: 1611212714
正在加载...
取消
保存