浏览代码

minor fixes (material 2)

/siyaoH-1.17-PlatformMessage
xingweizhu 4 年前
当前提交
243ea12c
共有 5 个文件被更改,包括 76 次插入22 次删除
  1. 9
      com.unity.uiwidgets/Runtime/material/ink_well.cs
  2. 1
      com.unity.uiwidgets/Runtime/material/scaffold.cs
  3. 61
      com.unity.uiwidgets/Runtime/material/theme_data.cs
  4. 2
      com.unity.uiwidgets/Runtime/painting/border_radius.cs
  5. 25
      com.unity.uiwidgets/Runtime/rendering/layer.cs

9
com.unity.uiwidgets/Runtime/material/ink_well.cs


}
public void updateHighlight(_HighlightType type, bool value) {
InkHighlight highlight = _highlights[type];
InkHighlight highlight = _highlights.getOrDefault(type);
D.assert(_highlights[type] != null);
D.assert(_highlights.getOrDefault(type) != null);
_highlights[type] = null;
updateKeepAlive();
}

highlight.deactivate();
}
D.assert(value == (_highlights[type] != null && _highlights[type].active));
D.assert(value == (_highlights.getOrDefault(type) != null && _highlights[type].active));
switch (type) {
case _HighlightType.pressed: {
if (widget.onHighlightChanged != null)

radius: widget.radius,
borderRadius: borderRadius,
customBorder: customBorder,
onRemoved: OnRemoved);
onRemoved: OnRemoved,
textDirection: Directionality.of(context));
return splash;
}

1
com.unity.uiwidgets/Runtime/material/scaffold.cs


this.fabMoveAnimation = fabMoveAnimation;
this.fabMotionAnimator = fabMotionAnimator;
this.geometryNotifier = geometryNotifier;
this.currentController = currentController;
}
public readonly Widget child;

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


public class ThemeData : Diagnosticable, IEquatable<ThemeData> {
public ThemeData(
Brightness? brightness = null,
VisualDensity visualDensity = null,
MaterialColor primarySwatch = null,
Color primaryColor = null,
Brightness? primaryColorBrightness = null,

ChipThemeData chipTheme = null,
RuntimePlatform? platform = null,
MaterialTapTargetSize? materialTapTargetSize = null,
bool? applyElevationOverlayColor = null,
PageTransitionsTheme pageTransitionsTheme = null,
AppBarTheme appBarTheme = null,
BottomAppBarTheme bottomAppBarTheme = null,

) {
brightness = brightness ?? Brightness.light;
bool isDark = brightness == Brightness.dark;
visualDensity = visualDensity ?? new VisualDensity();
primarySwatch = primarySwatch ?? Colors.blue;
primaryColor = primaryColor ?? (isDark ? Colors.grey[900] : primarySwatch);

TextTheme defaultAccentTextTheme = accentIsDark ? typography.white : typography.black;
accentTextTheme = defaultAccentTextTheme.merge(accentTextTheme);
materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded;
applyElevationOverlayColor = applyElevationOverlayColor ?? false;
if (fontFamily != null) {
textTheme = textTheme.apply(fontFamily: fontFamily);
primaryTextTheme = primaryTextTheme.apply(fontFamily: fontFamily);

snackBarTheme = snackBarTheme ?? new SnackBarThemeData();
D.assert(brightness != null);
D.assert(visualDensity != null);
D.assert(primaryColor != null);
D.assert(primaryColorBrightness != null);
D.assert(primaryColorLight != null);

D.assert(primaryIconTheme != null);
D.assert(accentIconTheme != null);
D.assert(materialTapTargetSize != null);
D.assert(applyElevationOverlayColor != null);
D.assert(pageTransitionsTheme != null);
D.assert(appBarTheme != null);
D.assert(bottomAppBarTheme != null);

D.assert(snackBarTheme != null);
this.brightness = brightness ?? Brightness.light;
this.visualDensity = visualDensity;
this.primaryColor = primaryColor;
this.primaryColorBrightness = primaryColorBrightness ?? Brightness.light;
this.primaryColorLight = primaryColorLight;

this.chipTheme = chipTheme;
this.platform = platform.Value;
this.materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded;
this.applyElevationOverlayColor = applyElevationOverlayColor.Value;
this.pageTransitionsTheme = pageTransitionsTheme;
this.appBarTheme = appBarTheme;
this.bottomAppBarTheme = bottomAppBarTheme;

public static ThemeData raw(
Brightness? brightness = null,
VisualDensity visualDensity = null,
Color primaryColor = null,
Brightness? primaryColorBrightness = null,
Color primaryColorLight = null,

ChipThemeData chipTheme = null,
RuntimePlatform? platform = null,
MaterialTapTargetSize? materialTapTargetSize = null,
bool? applyElevationOverlayColor = null,
PageTransitionsTheme pageTransitionsTheme = null,
AppBarTheme appBarTheme = null,
BottomAppBarTheme bottomAppBarTheme = null,

SnackBarThemeData snackBarTheme = null
) {
D.assert(brightness != null);
D.assert(visualDensity != null);
D.assert(primaryColor != null);
D.assert(primaryColorBrightness != null);
D.assert(primaryColorLight != null);

D.assert(accentIconTheme != null);
D.assert(platform != null);
D.assert(materialTapTargetSize != null);
D.assert(applyElevationOverlayColor != null);
D.assert(pageTransitionsTheme != null);
D.assert(appBarTheme != null);
D.assert(bottomAppBarTheme != null);

chipTheme: chipTheme,
platform: platform,
materialTapTargetSize: materialTapTargetSize,
applyElevationOverlayColor: applyElevationOverlayColor,
pageTransitionsTheme: pageTransitionsTheme,
appBarTheme: appBarTheme,
bottomAppBarTheme: bottomAppBarTheme,

snackBarTheme: snackBarTheme);
}
public static ThemeData from(
ColorScheme colorScheme,
TextTheme textTheme = null
) {
D.assert(colorScheme != null);
bool isDark = colorScheme.brightness == Brightness.dark;
Color primarySurfaceColor = isDark ? colorScheme.surface : colorScheme.primary;
Color onPrimarySurfaceColor = isDark ? colorScheme.onSurface : colorScheme.onPrimary;
return new ThemeData(
brightness: colorScheme.brightness,
primaryColor: primarySurfaceColor,
primaryColorBrightness: ThemeData.estimateBrightnessForColor(primarySurfaceColor),
canvasColor: colorScheme.background,
accentColor: colorScheme.secondary,
accentColorBrightness: ThemeData.estimateBrightnessForColor(colorScheme.secondary),
scaffoldBackgroundColor: colorScheme.background,
bottomAppBarColor: colorScheme.surface,
cardColor: colorScheme.surface,
dividerColor: colorScheme.onSurface.withOpacity(0.12f),
backgroundColor: colorScheme.background,
dialogBackgroundColor: colorScheme.background,
errorColor: colorScheme.error,
textTheme: textTheme,
indicatorColor: onPrimarySurfaceColor,
applyElevationOverlayColor: isDark,
colorScheme: colorScheme
);
}
public static ThemeData light() {
return new ThemeData(brightness: Brightness.light);
}

public ThemeData copyWith(
Brightness? brightness = null,
VisualDensity visualDensity = null,
Color primaryColor = null,
Brightness? primaryColorBrightness = null,
Color primaryColorLight = null,

ChipThemeData chipTheme = null,
RuntimePlatform? platform = null,
MaterialTapTargetSize? materialTapTargetSize = null,
bool? applyElevationOverlayColor = null,
PageTransitionsTheme pageTransitionsTheme = null,
AppBarTheme appBarTheme = null,
BottomAppBarTheme bottomAppBarTheme = null,

) {
return raw(
brightness: brightness ?? this.brightness,
visualDensity: visualDensity ?? this.visualDensity,
primaryColor: primaryColor ?? this.primaryColor,
primaryColorBrightness: primaryColorBrightness ?? this.primaryColorBrightness,
primaryColorLight: primaryColorLight ?? this.primaryColorLight,

chipTheme: chipTheme ?? this.chipTheme,
platform: platform ?? this.platform,
materialTapTargetSize: materialTapTargetSize ?? this.materialTapTargetSize,
applyElevationOverlayColor: applyElevationOverlayColor ?? this.applyElevationOverlayColor,
pageTransitionsTheme: pageTransitionsTheme ?? this.pageTransitionsTheme,
appBarTheme: appBarTheme ?? this.appBarTheme,
bottomAppBarTheme: bottomAppBarTheme ?? this.bottomAppBarTheme,

D.assert(b != null);
return raw(
brightness: t < 0.5 ? a.brightness : b.brightness,
visualDensity: VisualDensity.lerp(a.visualDensity, b.visualDensity, t),
primaryColor: Color.lerp(a.primaryColor, b.primaryColor, t),
primaryColorBrightness: t < 0.5 ? a.primaryColorBrightness : b.primaryColorBrightness,
primaryColorLight: Color.lerp(a.primaryColorLight, b.primaryColorLight, t),

chipTheme: ChipThemeData.lerp(a.chipTheme, b.chipTheme, t),
platform: t < 0.5 ? a.platform : b.platform,
materialTapTargetSize: t < 0.5 ? a.materialTapTargetSize : b.materialTapTargetSize,
applyElevationOverlayColor: t < 0.5 ? a.applyElevationOverlayColor : b.applyElevationOverlayColor,
pageTransitionsTheme: t < 0.5 ? a.pageTransitionsTheme : b.pageTransitionsTheme,
appBarTheme: AppBarTheme.lerp(a.appBarTheme, b.appBarTheme, t),
bottomAppBarTheme: BottomAppBarTheme.lerp(a.bottomAppBarTheme, b.bottomAppBarTheme, t),

}
return other.brightness == brightness &&
other.visualDensity == visualDensity &&
other.primaryColor == primaryColor &&
other.primaryColorBrightness == primaryColorBrightness &&
other.primaryColorLight == primaryColorLight &&

other.chipTheme == chipTheme &&
other.platform == platform &&
other.materialTapTargetSize == materialTapTargetSize &&
other.applyElevationOverlayColor == applyElevationOverlayColor &&
other.pageTransitionsTheme == pageTransitionsTheme &&
other.appBarTheme == appBarTheme &&
other.bottomAppBarTheme == bottomAppBarTheme &&

unchecked {
var hashCode = brightness.GetHashCode();
hashCode = (hashCode * 397) ^ visualDensity.GetHashCode();
hashCode = (hashCode * 397) ^ primaryColor.GetHashCode();
hashCode = (hashCode * 397) ^ primaryColorBrightness.GetHashCode();
hashCode = (hashCode * 397) ^ primaryColorLight.GetHashCode();

hashCode = (hashCode * 397) ^ chipTheme.GetHashCode();
hashCode = (hashCode * 397) ^ platform.GetHashCode();
hashCode = (hashCode * 397) ^ materialTapTargetSize.GetHashCode();
hashCode = (hashCode * 397) ^ applyElevationOverlayColor.GetHashCode();
hashCode = (hashCode * 397) ^ pageTransitionsTheme.GetHashCode();
hashCode = (hashCode * 397) ^ appBarTheme.GetHashCode();
hashCode = (hashCode * 397) ^ bottomAppBarTheme.GetHashCode();

properties.add(new DiagnosticsProperty<ChipThemeData>("chipTheme", chipTheme));
properties.add(
new DiagnosticsProperty<MaterialTapTargetSize>("materialTapTargetSize", materialTapTargetSize));
properties.add(new DiagnosticsProperty<bool>("applyElevationOverlayColor", applyElevationOverlayColor, level: DiagnosticLevel.debug));
properties.add(
new DiagnosticsProperty<PageTransitionsTheme>("pageTransitionsTheme", pageTransitionsTheme));
properties.add(new DiagnosticsProperty<AppBarTheme>("appBarTheme", appBarTheme));

}
}
static VisualDensity lerp(VisualDensity a, VisualDensity b, float t) {
internal static VisualDensity lerp(VisualDensity a, VisualDensity b, float t) {
return new VisualDensity(
horizontal: Mathf.Lerp(a.horizontal, b.horizontal, t),
vertical: Mathf.Lerp(a.horizontal, b.horizontal, t)

}
public static bool operator !=(VisualDensity self, object other) {
return Equals(self, other);
return !Equals(self, other);
}
public bool Equals(VisualDensity other) {

2
com.unity.uiwidgets/Runtime/painting/border_radius.cs


}
public static bool operator !=(BorderRadiusGeometry left, BorderRadiusGeometry right) {
return Equals(left, right);
return !Equals(left, right);
}
public bool Equals(BorderRadiusGeometry other) {

25
com.unity.uiwidgets/Runtime/rendering/layer.cs


canvas.drawPath(child.clipPath, new Paint() {
color = new Color(0xFFAA0000),
style = PaintingStyle.stroke,
strokeWidth = child.elevation + 10.0f,
strokeWidth = child.elevation.Value + 10.0f,
});
PictureLayer pictureLayer = new PictureLayer(child.clipPath.getBounds());
pictureLayer.picture = recorder.endRecording();

D.assert(physicalModelLayer.lastChild?.debugCreator != physicalModelLayer,
() => "debugCheckElevations has either already visited this layer or failed to remove the" +
" added picture from it.");
float accumulatedElevation = physicalModelLayer.elevation;
float accumulatedElevation = physicalModelLayer.elevation.Value;
accumulatedElevation += modelLayer.elevation;
accumulatedElevation += modelLayer.elevation.Value;
}
ancestor = ancestor.parent;

PhysicalModelLayer predecessor = physicalModelLayers[j];
float predecessorAccumulatedElevation = predecessor.elevation;
float predecessorAccumulatedElevation = predecessor.elevation.Value;
ancestor = predecessor.parent;
while (ancestor != null) {
if (ancestor == predecessor) {

if (ancestor is PhysicalModelLayer modelLayer) {
predecessorAccumulatedElevation += modelLayer.elevation;
predecessorAccumulatedElevation += modelLayer.elevation.Value;
}
ancestor = ancestor.parent;

float? elevation = null,
Color color = null,
Color shadowColor = null) {
D.assert(clipPath != null);
D.assert(elevation != null);
D.assert(color != null);
D.assert(shadowColor != null);
_elevation = elevation.Value;
_elevation = elevation;
_color = color;
this.shadowColor = shadowColor;
}

}
Clip _clipBehavior;
public float elevation {
public float? elevation {
get { return _elevation; }
set {
if (value != _elevation) {

}
}
float _elevation;
float? _elevation;
public Color color {
get { return _color; }

layerOffset = layerOffset ?? Offset.zero;
D.assert(clipPath != null);
D.assert(clipBehavior != null);
D.assert(color != null);
D.assert(color != null);
D.assert(shadowColor != null);
bool enabled = true;

if (enabled) {
engineLayer = builder.pushPhysicalShape(
path: layerOffset == Offset.zero ? clipPath : clipPath.shift(layerOffset),
elevation: elevation,
elevation: elevation.Value,
color: color,
shadowColor: shadowColor,
clipBehavior: clipBehavior,

正在加载...
取消
保存