浏览代码

more material components: support material button

/main
xingwei.zhu 6 年前
当前提交
36c1fd37
共有 51 个文件被更改,包括 5833 次插入45 次删除
  1. 5
      Runtime/animation/animation.cs
  2. 8
      Runtime/animation/tween.cs
  3. 2
      Runtime/material/colors.cs
  4. 697
      Runtime/material/theme_data.cs
  5. 73
      Runtime/material/utils.cs
  6. 158
      Runtime/painting/text_style.cs
  7. 408
      Runtime/rendering/proxy_box.cs
  8. 9
      Runtime/ui/geometry.cs
  9. 14
      Runtime/ui/painting/painting.cs
  10. 119
      Runtime/widgets/basic.cs
  11. 8
      Runtime/widgets/icon_theme_data.cs
  12. 325
      Runtime/widgets/implicit_animations.cs
  13. 75
      Samples/UIWidgetSample/UIWidgetSample.unity
  14. 8
      Runtime/material.meta
  15. 145
      Runtime/material/button.cs
  16. 11
      Runtime/material/button.cs.meta
  17. 499
      Runtime/material/button_theme.cs
  18. 11
      Runtime/material/button_theme.cs.meta
  19. 338
      Runtime/material/color_scheme.cs
  20. 11
      Runtime/material/color_scheme.cs.meta
  21. 11
      Runtime/material/colors.cs.meta
  22. 11
      Runtime/material/constants.cs.meta
  23. 51
      Runtime/material/debug.cs
  24. 11
      Runtime/material/debug.cs.meta
  25. 224
      Runtime/material/ink_decoration.cs
  26. 11
      Runtime/material/ink_decoration.cs.meta
  27. 129
      Runtime/material/ink_highlight.cs
  28. 11
      Runtime/material/ink_highlight.cs.meta
  29. 170
      Runtime/material/ink_splash.cs
  30. 11
      Runtime/material/ink_splash.cs.meta
  31. 359
      Runtime/material/ink_well.cs
  32. 11
      Runtime/material/ink_well.cs.meta
  33. 497
      Runtime/material/material.cs
  34. 11
      Runtime/material/material.cs.meta
  35. 133
      Runtime/material/material_button.cs
  36. 11
      Runtime/material/material_button.cs.meta
  37. 351
      Runtime/material/text_theme.cs
  38. 11
      Runtime/material/text_theme.cs.meta
  39. 134
      Runtime/material/theme.cs
  40. 11
      Runtime/material/theme.cs.meta
  41. 11
      Runtime/material/theme_data.cs.meta
  42. 451
      Runtime/material/typography.cs
  43. 11
      Runtime/material/typography.cs.meta
  44. 11
      Runtime/material/utils.cs.meta
  45. 11
      Runtime/painting/colors.cs.meta
  46. 11
      Runtime/service/system_chrome.cs.meta
  47. 11
      Runtime/widgets/implicit_animations.cs.meta
  48. 176
      Runtime/widgets/layout_builder.cs
  49. 11
      Runtime/widgets/layout_builder.cs.meta
  50. 70
      Samples/UIWidgetSample/MaterialCanvas.cs
  51. 11
      Samples/UIWidgetSample/MaterialCanvas.cs.meta

5
Runtime/animation/animation.cs


D.assert(icon != null);
return icon;
}
public Animation<U> drive<U>(Animatable<U> child) {
D.assert(this is Animation<double>);
return child.animate(this as Animation<double>);
}
}
}

8
Runtime/animation/tween.cs


}
public abstract class Tween<T> : Animatable<T>, IEquatable<Tween<T>> {
protected Tween(T begin, T end) {
public Tween(T begin, T end) {
D.assert(begin != null);
D.assert(end != null);

public readonly T begin;
public T begin;
public readonly T end;
public T end;
public abstract T lerp(double t);

}
public class DoubleTween : Tween<double> {
public DoubleTween(int begin, int end) : base(begin: begin, end: end) {
public DoubleTween(double begin, double end) : base(begin: begin, end: end) {
}
public override double lerp(double t) {

2
Runtime/material/colors.cs


public static Color white = new Color(0xFFFFFFFF);
public static Color while70 = new Color(0xB3FFFFFF);
public static Color white70 = new Color(0xB3FFFFFF);
public static Color white54 = new Color(0x8AFFFFFF);

697
Runtime/material/theme_data.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.service;
using UnityEngine;
using Unity.UIWidgets.widgets;
using Color = Unity.UIWidgets.ui.Color;
Brightness brightness,
MaterialColor primarySwatch,
Brightness? brightness = null,
MaterialColor primarySwatch = null,
Color primaryColor = null,
Brightness? primaryColorBrightness = null,
Color primaryColorLight = null,
Color primaryColorDark = null,
Color accentColor = null,
Brightness? accentColorBrightness = null,
Color canvasColor = null,
Color scaffoldBackgroundColor = null,
Color bottomAppBarColor = null,
Color cardColor = null,
Color dividerColor = null,
Color highlightColor = null,
Color splashColor = null,
InteractiveInkFeatureFactory splashFactory = null,
Color selectedRowColor = null,
Color unselectedWidgetColor = null,
Color disabledColor = null,
Color buttonColor = null,
ButtonThemeData buttonTheme = null,
Color secondaryHeaderColor = null,
Color textSelectionColor = null,
Color cursorColor = null,
Color textSelectionHandleColor = null,
Color backgroundColor = null,
Color dialogBackgroundColor = null,
Color indicatorColor = null,
Color hintColor = null,
Color errorColor = null,
Color toggleableActiveColor = null,
string fontFamily = null,
TextTheme textTheme = null,
TextTheme primaryTextTheme = null,
TextTheme accentTextTheme = null,
IconThemeData iconTheme = null,
IconThemeData primaryIconTheme = null,
IconThemeData accentIconTheme = null,
MaterialTapTargetSize? materialTapTargetSize = null,
ColorScheme colorScheme = null,
Typography typography = null
) {
brightness = brightness ?? Brightness.light;
bool isDark = brightness == Brightness.dark;
primarySwatch = primarySwatch ?? Colors.blue;
primaryColor = primaryColor ?? (isDark ? Colors.grey[900] : primarySwatch);
primaryColorBrightness = primaryColorBrightness ?? estimateBrightnessForColor(primaryColor);
primaryColorLight = primaryColorLight ?? (isDark ? Colors.grey[500] : primarySwatch[100]);
primaryColorDark = primaryColorDark ?? (isDark ? Colors.black : primarySwatch[700]);
bool primaryIsDark = primaryColorBrightness == Brightness.dark;
accentColor = accentColor ?? (isDark ? Colors.tealAccent[200] : primarySwatch[500]);
accentColorBrightness = accentColorBrightness ?? estimateBrightnessForColor(accentColor);
bool accentIsDark = accentColorBrightness == Brightness.dark;
canvasColor = canvasColor ?? (isDark ? Colors.grey[850] : Colors.grey[50]);
scaffoldBackgroundColor = scaffoldBackgroundColor ?? canvasColor;
bottomAppBarColor = bottomAppBarColor ?? (isDark ? Colors.grey[800] : Colors.white);
cardColor = cardColor ?? (isDark ? Colors.grey[800] : Colors.white);
dividerColor = dividerColor ?? (isDark ? new Color(0x1FFFFFFF) : new Color(0x1F000000));
colorScheme = colorScheme ?? ColorScheme.fromSwatch(
primarySwatch: primarySwatch,
primaryColorDark: primaryColorDark,
accentColor: accentColor,
cardColor: cardColor,
backgroundColor: backgroundColor,
errorColor: errorColor,
brightness: brightness);
highlightColor = highlightColor ??
(isDark
? ThemeDataUtils._kDarkThemeHighlightColor
: ThemeDataUtils._kLightThemeHighlightColor);
splashColor = splashColor ??
(isDark
? ThemeDataUtils._kDarkThemeSplashColor
: ThemeDataUtils._kLightThemeSplashColor);
splashFactory = splashFactory ?? InkSplash.splashFactory;
selectedRowColor = selectedRowColor ?? Colors.grey[100];
unselectedWidgetColor = unselectedWidgetColor ?? (isDark ? Colors.white70 : Colors.black54);
secondaryHeaderColor = secondaryHeaderColor ?? (isDark ? Colors.grey[700] : primarySwatch[50]);
textSelectionColor = textSelectionColor ?? (isDark ? accentColor : primarySwatch[200]);
cursorColor = cursorColor ?? Color.fromRGBO(66, 133, 244, 1.0);
textSelectionHandleColor =
textSelectionHandleColor ?? (isDark ? Colors.tealAccent[400] : primarySwatch[300]);
backgroundColor = backgroundColor ?? (isDark ? Colors.grey[700] : primarySwatch[200]);
dialogBackgroundColor = dialogBackgroundColor ?? (isDark ? Colors.grey[800] : Colors.white);
indicatorColor = indicatorColor ?? (accentColor == primaryColor ? Colors.white : accentColor);
hintColor = hintColor ?? (isDark ? new Color(0x80FFFFFF) : new Color(0x8A000000));
errorColor = errorColor ?? Colors.red[700];
iconTheme = iconTheme ??
(isDark ? new IconThemeData(color: Colors.white) : new IconThemeData(color: Colors.black87));
primaryIconTheme = primaryIconTheme ??
(isDark
? new IconThemeData(color: Colors.white)
: new IconThemeData(color: Colors.black));
accentIconTheme = accentIconTheme ?? (isDark
? new IconThemeData(color: Colors.white)
: new IconThemeData(color: Colors.black));
typography = typography ?? new Typography();
TextTheme defaultTextTheme = isDark ? typography.white : typography.black;
textTheme = defaultTextTheme.merge(textTheme);
TextTheme defaultPrimaryTextTheme = primaryIsDark ? typography.white : typography.black;
primaryTextTheme = defaultPrimaryTextTheme.merge(primaryTextTheme);
TextTheme defaultAccentTextTheme = accentIsDark ? typography.white : typography.black;
accentTextTheme = defaultAccentTextTheme.merge(accentTextTheme);
materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded;
if (fontFamily != null) {
textTheme = textTheme.apply(fontFamily: fontFamily);
primaryTextTheme = primaryTextTheme.apply(fontFamily: fontFamily);
accentTextTheme = accentTextTheme.apply(fontFamily: fontFamily);
}
buttonColor = buttonColor ?? (isDark ? primarySwatch[600] : Colors.grey[300]);
buttonTheme = buttonTheme ?? new ButtonThemeData(
colorScheme: colorScheme,
buttonColor: buttonColor,
disabledColor: disabledColor,
highlightColor: highlightColor,
splashColor: splashColor,
materialTapTargetSize: materialTapTargetSize);
disabledColor = disabledColor ?? (isDark ? Colors.white30 : Colors.black38);
toggleableActiveColor = toggleableActiveColor ??
(isDark ? Colors.tealAccent[200] : (accentColor ?? primarySwatch[600]));
D.assert(brightness != null);
D.assert(primaryColor != null);
D.assert(primaryColorBrightness != null);
D.assert(primaryColorLight != null);
D.assert(primaryColorDark != null);
D.assert(accentColor != null);
D.assert(accentColorBrightness != null);
D.assert(canvasColor != null);
D.assert(scaffoldBackgroundColor != null);
D.assert(bottomAppBarColor != null);
D.assert(cardColor != null);
D.assert(dividerColor != null);
D.assert(highlightColor != null);
D.assert(splashColor != null);
D.assert(splashFactory != null);
D.assert(selectedRowColor != null);
D.assert(unselectedWidgetColor != null);
D.assert(disabledColor != null);
D.assert(buttonColor != null);
D.assert(secondaryHeaderColor != null);
D.assert(textSelectionColor != null);
D.assert(cursorColor != null);
D.assert(textSelectionHandleColor != null);
D.assert(backgroundColor != null);
D.assert(dialogBackgroundColor != null);
D.assert(indicatorColor != null);
D.assert(hintColor != null);
D.assert(errorColor != null);
D.assert(toggleableActiveColor != null);
D.assert(buttonTheme != null);
D.assert(iconTheme != null);
D.assert(primaryIconTheme != null);
D.assert(accentIconTheme != null);
D.assert(textTheme != null);
D.assert(primaryTextTheme != null);
D.assert(accentTextTheme != null);
D.assert(colorScheme != null);
D.assert(materialTapTargetSize != null);
D.assert(typography != null);
this.brightness = brightness ?? Brightness.light;
this.primaryColor = primaryColor;
this.primaryColorBrightness = primaryColorBrightness ?? Brightness.light;
this.primaryColorLight = primaryColorLight;
this.primaryColorDark = primaryColorDark;
this.accentColor = accentColor;
this.accentColorBrightness = accentColorBrightness ?? Brightness.light;
this.canvasColor = canvasColor;
this.scaffoldBackgroundColor = scaffoldBackgroundColor;
this.bottomAppBarColor = bottomAppBarColor;
this.cardColor = cardColor;
this.dividerColor = dividerColor;
this.highlightColor = highlightColor;
this.splashColor = splashColor;
this.splashFactory = splashFactory;
this.selectedRowColor = selectedRowColor;
this.unselectedWidgetColor = unselectedWidgetColor;
this.disabledColor = disabledColor;
this.buttonTheme = buttonTheme;
this.buttonColor = buttonColor;
this.secondaryHeaderColor = secondaryHeaderColor;
this.textSelectionColor = textSelectionColor;
this.cursorColor = cursorColor;
this.textSelectionHandleColor = textSelectionHandleColor;
this.backgroundColor = backgroundColor;
this.dialogBackgroundColor = dialogBackgroundColor;
this.indicatorColor = indicatorColor;
this.hintColor = hintColor;
this.errorColor = errorColor;
this.toggleableActiveColor = toggleableActiveColor;
this.iconTheme = iconTheme;
this.primaryIconTheme = primaryIconTheme;
this.accentIconTheme = accentIconTheme;
this.textTheme = textTheme;
this.primaryTextTheme = primaryTextTheme;
this.accentTextTheme = accentTextTheme;
this.materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded;
this.colorScheme = colorScheme;
this.typography = typography;
}
public static ThemeData raw(
Brightness? brightness,
Brightness primaryColorBrightness,
Brightness? primaryColorBrightness,
Brightness accentColorBrightness,
Brightness? accentColorBrightness,
Color canvasColor,
Color scaffoldBackgroundColor,
Color bottomAppBarColor,

Color splashColor
Color splashColor,
InteractiveInkFeatureFactory splashFactory,
Color selectedRowColor,
Color unselectedWidgetColor,
Color disabledColor,
ButtonThemeData buttonTheme,
Color buttonColor,
Color secondaryHeaderColor,
Color textSelectionColor,
Color cursorColor,
Color textSelectionHandleColor,
Color backgroundColor,
Color dialogBackgroundColor,
Color indicatorColor,
Color hintColor,
Color errorColor,
TextTheme textTheme,
TextTheme primaryTextTheme,
TextTheme accentTextTheme,
Color toggleableActiveColor,
IconThemeData iconTheme,
IconThemeData primaryIconTheme,
IconThemeData accentIconTheme,
MaterialTapTargetSize materialTapTargetSize,
ColorScheme colorScheme,
Typography typography
return new ThemeData(
brightness: brightness,
primaryColor: primaryColor,
primaryColorBrightness: primaryColorBrightness,
primaryColorLight: primaryColorLight,
primaryColorDark: primaryColorDark,
accentColor: accentColor,
accentColorBrightness: accentColorBrightness,
canvasColor: canvasColor,
scaffoldBackgroundColor: scaffoldBackgroundColor,
bottomAppBarColor: bottomAppBarColor,
cardColor: cardColor,
dividerColor: dividerColor,
highlightColor: highlightColor,
splashColor: splashColor,
splashFactory: splashFactory,
selectedRowColor: selectedRowColor,
unselectedWidgetColor: unselectedWidgetColor,
disabledColor: disabledColor,
buttonTheme: buttonTheme,
buttonColor: buttonColor,
toggleableActiveColor: toggleableActiveColor,
secondaryHeaderColor: secondaryHeaderColor,
textSelectionColor: textSelectionColor,
cursorColor: cursorColor,
textSelectionHandleColor: textSelectionHandleColor,
backgroundColor: backgroundColor,
dialogBackgroundColor: dialogBackgroundColor,
indicatorColor: indicatorColor,
hintColor: hintColor,
errorColor: errorColor,
textTheme: textTheme,
primaryTextTheme: primaryTextTheme,
accentTextTheme: accentTextTheme,
iconTheme: iconTheme,
primaryIconTheme: primaryIconTheme,
accentIconTheme: accentIconTheme,
materialTapTargetSize: materialTapTargetSize,
colorScheme: colorScheme,
typography: typography);
public static ThemeData light() => new ThemeData(brightness: Brightness.light);
public static ThemeData dark() => new ThemeData(brightness: Brightness.dark);
public static ThemeData fallback() => ThemeData.light();
public readonly Brightness brightness;
public readonly Color primaryColor;
public readonly Brightness primaryColorBrightness;
public readonly Color primaryColorLight;
public readonly Color primaryColorDark;
readonly Brightness brightness;
public readonly Color accentColor;
public readonly Brightness accentColorBrightness;
public readonly Color canvasColor;
public readonly Color scaffoldBackgroundColor;
public readonly Color bottomAppBarColor;
public readonly Color cardColor;
public readonly Color dividerColor;
public readonly Color highlightColor;
public readonly Color splashColor;
public readonly InteractiveInkFeatureFactory splashFactory;
public readonly Color selectedRowColor;
public readonly Color unselectedWidgetColor;
public readonly Color disabledColor;
public readonly ButtonThemeData buttonTheme;
public readonly Color buttonColor;
public readonly Color secondaryHeaderColor;
public readonly Color textSelectionColor;
public readonly Color cursorColor;
public readonly Color textSelectionHandleColor;
public readonly Color backgroundColor;
public readonly Color dialogBackgroundColor;
public readonly Color indicatorColor;
readonly MaterialColor primarySwatch;
public readonly Color hintColor;
readonly Color primaryColor;
public readonly Color errorColor;
readonly Brightness primaryColorBrightness;
public readonly Color toggleableActiveColor;
readonly Color primaryColorLight;
public readonly TextTheme textTheme;
readonly Color primaryColorDark;
public readonly TextTheme primaryTextTheme;
readonly Color accentColor;
public readonly TextTheme accentTextTheme;
readonly Brightness accentColorBrightness;
public readonly IconThemeData iconTheme;
readonly Color canvasColor;
public readonly IconThemeData primaryIconTheme;
readonly Color scaffoldBackgroundColor;
public readonly IconThemeData accentIconTheme;
readonly Color bottomAppBarColor;
public readonly MaterialTapTargetSize materialTapTargetSize;
readonly Color cardColor;
public readonly ColorScheme colorScheme;
readonly Color dividerColor;
public readonly Typography typography;
readonly Color highlightColor;
public ThemeData copyWith(
Brightness? brightness,
Color primaryColor,
Brightness? primaryColorBrightness,
Color primaryColorLight,
Color primaryColorDark,
Color accentColor,
Brightness? accentColorBrightness,
Color canvasColor,
Color scaffoldBackgroundColor,
Color bottomAppBarColor,
Color cardColor,
Color dividerColor,
Color highlightColor,
Color splashColor,
InteractiveInkFeatureFactory splashFactory,
Color selectedRowColor,
Color unselectedWidgetColor,
Color disabledColor,
ButtonThemeData buttonTheme,
Color buttonColor,
Color secondaryHeaderColor,
Color textSelectionColor,
Color cursorColor,
Color textSelectionHandleColor,
Color backgroundColor,
Color dialogBackgroundColor,
Color indicatorColor,
Color hintColor,
Color errorColor,
TextTheme textTheme,
TextTheme primaryTextTheme,
TextTheme accentTextTheme,
Color toggleableActiveColor,
IconThemeData iconTheme,
IconThemeData primaryIconTheme,
IconThemeData accentIconTheme,
MaterialTapTargetSize? materialTapTargetSize,
ColorScheme colorScheme,
Typography typography
) {
return ThemeData.raw(
brightness: brightness ?? this.brightness,
primaryColor: primaryColor ?? this.primaryColor,
primaryColorBrightness: primaryColorBrightness ?? this.primaryColorBrightness,
primaryColorLight: primaryColorLight ?? this.primaryColorLight,
primaryColorDark: primaryColorDark ?? this.primaryColorDark,
accentColor: accentColor ?? this.accentColor,
accentColorBrightness: accentColorBrightness ?? this.accentColorBrightness,
canvasColor: canvasColor ?? this.canvasColor,
scaffoldBackgroundColor: scaffoldBackgroundColor ?? this.scaffoldBackgroundColor,
bottomAppBarColor: bottomAppBarColor ?? this.bottomAppBarColor,
cardColor: cardColor ?? this.cardColor,
dividerColor: dividerColor ?? this.dividerColor,
highlightColor: highlightColor ?? this.highlightColor,
splashColor: splashColor ?? this.splashColor,
splashFactory: splashFactory ?? this.splashFactory,
selectedRowColor: selectedRowColor ?? this.selectedRowColor,
unselectedWidgetColor: unselectedWidgetColor ?? this.unselectedWidgetColor,
disabledColor: disabledColor ?? this.disabledColor,
buttonTheme : buttonTheme ?? this.buttonTheme,
buttonColor: buttonColor ?? this.buttonColor,
secondaryHeaderColor: secondaryHeaderColor ?? this.secondaryHeaderColor,
textSelectionColor: textSelectionColor ?? this.textSelectionColor,
cursorColor: cursorColor ?? this.cursorColor,
textSelectionHandleColor: textSelectionHandleColor ?? this.textSelectionHandleColor,
backgroundColor: backgroundColor ?? this.backgroundColor,
dialogBackgroundColor: dialogBackgroundColor ?? this.dialogBackgroundColor,
indicatorColor: indicatorColor ?? this.indicatorColor,
hintColor: hintColor ?? this.hintColor,
errorColor: errorColor ?? this.errorColor,
textTheme: textTheme ?? this.textTheme,
primaryTextTheme: primaryTextTheme ?? this.primaryTextTheme,
accentTextTheme: accentTextTheme ?? this.accentTextTheme,
toggleableActiveColor: toggleableActiveColor ?? this.toggleableActiveColor,
iconTheme: iconTheme ?? this.iconTheme,
primaryIconTheme: primaryIconTheme ?? this.primaryIconTheme,
accentIconTheme: accentIconTheme ?? this.accentIconTheme,
materialTapTargetSize: materialTapTargetSize ?? this.materialTapTargetSize,
colorScheme : colorScheme ?? this.colorScheme,
typography: typography ?? this.typography
);
}
readonly Color splashColor;
public static Brightness estimateBrightnessForColor(Color color) {
double relativeLuminance = color.computeLuminance();
double kThreshold = 0.15;
if ((relativeLuminance + 0.05) * (relativeLuminance + 0.05) > kThreshold)
return Brightness.light;
return Brightness.dark;
}
public static ThemeData lerp(ThemeData a, ThemeData b, double t) {
return ThemeData.raw(
brightness: t < 0.5 ? a.brightness : b.brightness,
primaryColor: Color.lerp(a.primaryColor, b.primaryColor, t),
primaryColorBrightness: t < 0.5 ? a.primaryColorBrightness : b.primaryColorBrightness,
primaryColorLight: Color.lerp(a.primaryColorLight, b.primaryColorLight, t),
primaryColorDark: Color.lerp(a.primaryColorDark, b.primaryColorDark, t),
accentColor: Color.lerp(a.accentColor, b.accentColor, t),
accentColorBrightness: t < 0.5 ? a.accentColorBrightness : b.accentColorBrightness,
canvasColor: Color.lerp(a.canvasColor, b.canvasColor, t),
scaffoldBackgroundColor: Color.lerp(a.scaffoldBackgroundColor, b.scaffoldBackgroundColor, t),
bottomAppBarColor: Color.lerp(a.bottomAppBarColor, b.bottomAppBarColor, t),
cardColor: Color.lerp(a.cardColor, b.cardColor, t),
dividerColor: Color.lerp(a.dividerColor, b.dividerColor, t),
highlightColor: Color.lerp(a.highlightColor, b.highlightColor, t),
splashColor: Color.lerp(a.splashColor, b.splashColor, t),
splashFactory: t < 0.5 ? a.splashFactory : b.splashFactory,
selectedRowColor: Color.lerp(a.selectedRowColor, b.selectedRowColor, t),
unselectedWidgetColor: Color.lerp(a.unselectedWidgetColor, b.unselectedWidgetColor, t),
disabledColor: Color.lerp(a.disabledColor, b.disabledColor, t),
buttonTheme: t < 0.5 ? a.buttonTheme : b.buttonTheme,
buttonColor: Color.lerp(a.buttonColor, b.buttonColor, t),
secondaryHeaderColor: Color.lerp(a.secondaryHeaderColor, b.secondaryHeaderColor, t),
textSelectionColor: Color.lerp(a.textSelectionColor, b.textSelectionColor, t),
cursorColor: Color.lerp(a.cursorColor, b.cursorColor, t),
textSelectionHandleColor: Color.lerp(a.textSelectionHandleColor, b.textSelectionHandleColor, t),
backgroundColor: Color.lerp(a.backgroundColor, b.backgroundColor, t),
dialogBackgroundColor: Color.lerp(a.dialogBackgroundColor, b.dialogBackgroundColor, t),
indicatorColor: Color.lerp(a.indicatorColor, b.indicatorColor, t),
hintColor: Color.lerp(a.hintColor, b.hintColor, t),
errorColor: Color.lerp(a.errorColor, b.errorColor, t),
textTheme: TextTheme.lerp(a.textTheme, b.textTheme, t),
primaryTextTheme: TextTheme.lerp(a.primaryTextTheme, b.primaryTextTheme, t),
accentTextTheme: TextTheme.lerp(a.accentTextTheme, b.accentTextTheme, t),
toggleableActiveColor: Color.lerp(a.toggleableActiveColor, b.toggleableActiveColor, t),
iconTheme: IconThemeData.lerp(a.iconTheme, b.iconTheme, t),
primaryIconTheme: IconThemeData.lerp(a.primaryIconTheme, b.primaryIconTheme, t),
accentIconTheme: IconThemeData.lerp(a.accentIconTheme, b.accentIconTheme, t),
materialTapTargetSize: t < 0.5? a.materialTapTargetSize : b.materialTapTargetSize,
colorScheme: ColorScheme.lerp(a.colorScheme, b.colorScheme, t),
typography: Typography.lerp(a.typography, b.typography, t)
);
}
public bool Equals(ThemeData other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return other.brightness == this.brightness &&
other.primaryColor == this.primaryColor &&
other.primaryColorBrightness == this.primaryColorBrightness &&
other.primaryColorLight == this.primaryColorLight &&
other.primaryColorDark == this.primaryColorDark &&
other.accentColor == this.accentColor &&
other.accentColorBrightness == this.accentColorBrightness &&
other.canvasColor == this.canvasColor &&
other.scaffoldBackgroundColor == this.scaffoldBackgroundColor &&
other.bottomAppBarColor == this.bottomAppBarColor &&
other.cardColor == this.cardColor &&
other.dividerColor == this.dividerColor &&
other.highlightColor == this.highlightColor &&
other.splashColor == this.splashColor &&
other.splashFactory == this.splashFactory &&
other.selectedRowColor == this.selectedRowColor &&
other.unselectedWidgetColor == this.unselectedWidgetColor &&
other.disabledColor == this.disabledColor &&
other.buttonTheme == this.buttonTheme &&
other.buttonColor == this.buttonColor &&
other.secondaryHeaderColor == this.secondaryHeaderColor &&
other.textSelectionColor == this.textSelectionColor &&
other.cursorColor == this.cursorColor &&
other.textSelectionHandleColor == this.textSelectionHandleColor &&
other.backgroundColor == this.backgroundColor &&
other.dialogBackgroundColor == this.dialogBackgroundColor &&
other.indicatorColor == this.indicatorColor &&
other.hintColor == this.hintColor &&
other.errorColor == this.errorColor &&
other.textTheme == this.textTheme &&
other.primaryTextTheme == this.primaryTextTheme &&
other.accentTextTheme == this.accentTextTheme &&
other.toggleableActiveColor == this.toggleableActiveColor &&
other.iconTheme == this.iconTheme &&
other.primaryIconTheme == this.primaryIconTheme &&
other.accentIconTheme == this.accentIconTheme &&
other.materialTapTargetSize == this.materialTapTargetSize &&
other.colorScheme == this.colorScheme &&
other.typography == this.typography;
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((ThemeData) obj);
}
public static bool operator ==(ThemeData left, ThemeData right) {
return Equals(left, right);
}
public static bool operator !=(ThemeData left, ThemeData right) {
return !Equals(left, right);
}
public override int GetHashCode() {
unchecked {
var hashCode = this.brightness.GetHashCode();
hashCode = (hashCode * 397) ^ this.primaryColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.primaryColorBrightness.GetHashCode();
hashCode = (hashCode * 397) ^ this.primaryColorLight.GetHashCode();
hashCode = (hashCode * 397) ^ this.primaryColorDark.GetHashCode();
hashCode = (hashCode * 397) ^ this.accentColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.accentColorBrightness.GetHashCode();
hashCode = (hashCode * 397) ^ this.canvasColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.scaffoldBackgroundColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.bottomAppBarColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.cardColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.dividerColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.highlightColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.splashColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.splashFactory.GetHashCode();
hashCode = (hashCode * 397) ^ this.selectedRowColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.unselectedWidgetColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.disabledColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.buttonTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.buttonColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.secondaryHeaderColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.textSelectionColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.cursorColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.textSelectionHandleColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.backgroundColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.dialogBackgroundColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.indicatorColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.hintColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.errorColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.textTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.primaryTextTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.accentTextTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.toggleableActiveColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.iconTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.primaryIconTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.accentIconTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.materialTapTargetSize.GetHashCode();
hashCode = (hashCode * 397) ^ this.colorScheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.typography.GetHashCode();
return hashCode;
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
ThemeData defaultData = ThemeData.fallback();
properties.add(new EnumProperty<Brightness>("brightness", this.brightness,
defaultValue: defaultData.brightness));
properties.add(new DiagnosticsProperty<Color>("primaryColor", this.primaryColor,
defaultValue: defaultData.primaryColor));
properties.add(new EnumProperty<Brightness>("primaryColorBrightness", this.primaryColorBrightness,
defaultValue: defaultData.primaryColorBrightness));
properties.add(new DiagnosticsProperty<Color>("accentColor", this.accentColor,
defaultValue: defaultData.accentColor));
properties.add(new EnumProperty<Brightness>("accentColorBrightness", this.accentColorBrightness,
defaultValue: defaultData.accentColorBrightness));
properties.add(new DiagnosticsProperty<Color>("canvasColor", this.canvasColor,
defaultValue: defaultData.canvasColor));
properties.add(new DiagnosticsProperty<Color>("scaffoldBackgroundColor", this.scaffoldBackgroundColor,
defaultValue: defaultData.scaffoldBackgroundColor));
properties.add(new DiagnosticsProperty<Color>("bottomAppBarColor", this.bottomAppBarColor,
defaultValue: defaultData.bottomAppBarColor));
properties.add(new DiagnosticsProperty<Color>("cardColor", this.cardColor,
defaultValue: defaultData.cardColor));
properties.add(new DiagnosticsProperty<Color>("dividerColor", this.dividerColor,
defaultValue: defaultData.dividerColor));
properties.add(new DiagnosticsProperty<Color>("highlightColor", this.highlightColor,
defaultValue: defaultData.highlightColor));
properties.add(new DiagnosticsProperty<Color>("splashColor", this.splashColor,
defaultValue: defaultData.splashColor));
properties.add(new DiagnosticsProperty<Color>("selectedRowColor", this.selectedRowColor,
defaultValue: defaultData.selectedRowColor));
properties.add(new DiagnosticsProperty<Color>("unselectedWidgetColor", this.unselectedWidgetColor,
defaultValue: defaultData.unselectedWidgetColor));
properties.add(new DiagnosticsProperty<Color>("disabledColor", this.disabledColor,
defaultValue: defaultData.disabledColor));
properties.add(new DiagnosticsProperty<ButtonThemeData>("buttonTheme", this.buttonTheme));
properties.add(new DiagnosticsProperty<Color>("buttonColor", this.buttonColor,
defaultValue: defaultData.buttonColor));
properties.add(new DiagnosticsProperty<Color>("secondaryHeaderColor", this.secondaryHeaderColor,
defaultValue: defaultData.secondaryHeaderColor));
properties.add(new DiagnosticsProperty<Color>("textSelectionColor", this.textSelectionColor,
defaultValue: defaultData.textSelectionColor));
properties.add(new DiagnosticsProperty<Color>("cursorColor", this.cursorColor,
defaultValue: defaultData.cursorColor));
properties.add(new DiagnosticsProperty<Color>("textSelectionHandleColor", this.textSelectionHandleColor,
defaultValue: defaultData.textSelectionHandleColor));
properties.add(new DiagnosticsProperty<Color>("backgroundColor", this.backgroundColor,
defaultValue: defaultData.backgroundColor));
properties.add(new DiagnosticsProperty<Color>("dialogBackgroundColor", this.dialogBackgroundColor,
defaultValue: defaultData.dialogBackgroundColor));
properties.add(new DiagnosticsProperty<Color>("indicatorColor", this.indicatorColor,
defaultValue: defaultData.indicatorColor));
properties.add(new DiagnosticsProperty<Color>("hintColor", this.hintColor,
defaultValue: defaultData.hintColor));
properties.add(new DiagnosticsProperty<Color>("errorColor", this.errorColor,
defaultValue: defaultData.errorColor));
properties.add(new DiagnosticsProperty<TextTheme>("textTheme", this.textTheme));
properties.add(new DiagnosticsProperty<TextTheme>("primaryTextTheme", this.primaryTextTheme));
properties.add(new DiagnosticsProperty<TextTheme>("accentTextTheme", this.accentTextTheme));
properties.add(new DiagnosticsProperty<Color>("toggleableActiveColor", this.toggleableActiveColor,
defaultValue: defaultData.toggleableActiveColor));
properties.add(new DiagnosticsProperty<IconThemeData>("iconTheme", this.iconTheme));
properties.add(new DiagnosticsProperty<IconThemeData>("primaryIconTheme", this.primaryIconTheme));
properties.add(new DiagnosticsProperty<IconThemeData>("accentIconTheme", this.accentIconTheme));
properties.add(new DiagnosticsProperty<MaterialTapTargetSize>("materialTapTargetSize", this.materialTapTargetSize));
properties.add(new DiagnosticsProperty<ColorScheme>("colorScheme", this.colorScheme, defaultValue: defaultData.colorScheme));
properties.add(new DiagnosticsProperty<Typography>("typography", this.typography, defaultValue: defaultData.typography));
}
}
}

73
Runtime/material/utils.cs


using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
public readonly Color _kLightThemeHighlightColor = new Color(0x66BCBCBC);
public static readonly Color _kLightThemeHighlightColor = new Color(0x66BCBCBC);
public static readonly Color _kLightThemeSplashColor = new Color(0x66C8C8C8);
public readonly Color _kLightThemeSplashColor = new Color(0x66C8C8C8);
public static readonly Color _kDarkThemeHighlightColor = new Color(0x40CCCCCC);
public readonly Color _kDarkThemeHighlightColor = new Color(0x40CCCCCC);
public static readonly Color _kDarkThemeSplashColor = new Color(0x40CCCCCC);
}
public class ThemeUtils {
public static readonly TimeSpan kThemeAnimationDuration = new TimeSpan(0, 0, 0, 0, 200);
}
public class MaterialUtils {
public static Dictionary<MaterialType, BorderRadius> kMaterialEdges =
new Dictionary<MaterialType, BorderRadius>() {
{MaterialType.canvas, null},
{MaterialType.card, BorderRadius.all(2.0)},
{MaterialType.circle, null},
{MaterialType.button, BorderRadius.all(2.0)},
{MaterialType.transparency, null}
};
}
public class InkHighlightUtils {
public static readonly TimeSpan _kHighlightFadeDuration = new TimeSpan(0, 0, 0, 0, 200);
}
public class InkSplashUtils {
public static readonly TimeSpan _kUnconfirmedSplashDuration = new TimeSpan(0, 0, 0, 1, 0);
public readonly Color _kDarkThemeSplashColor = new Color(0x40CCCCCC);
public static readonly TimeSpan _kSplashFadeDuration = new TimeSpan(0, 0, 0, 0, 200);
public static double _kSplashInitialSize = 0.0;
public static double _kSplashConfirmedVelocity = 1.0;
public static RectCallback _getClipCallback(RenderBox referenceBox, bool containedInkWell,
RectCallback rectCallback) {
if (rectCallback != null) {
D.assert(containedInkWell);
return rectCallback;
}
if (containedInkWell)
return () => Offset.zero & referenceBox.size;
return null;
}
public static double _getTargetRadius(RenderBox referenceBox, bool containedInkWell, RectCallback rectCallback,
Offset position) {
if (containedInkWell) {
Size size = rectCallback != null ? rectCallback().size : referenceBox.size;
return _getSplashRadiusForPositionInSize(size, position);
}
return Material.defaultSplashRadius;
}
public static double _getSplashRadiusForPositionInSize(Size bounds, Offset position) {
double d1 = (position - bounds.topLeft(Offset.zero)).distance;
double d2 = (position - bounds.topRight(Offset.zero)).distance;
double d3 = (position - bounds.bottomLeft(Offset.zero)).distance;
double d4 = (position - bounds.bottomRight(Offset.zero)).distance;
return Math.Max(Math.Max(d1, d2), Math.Max(d3, d4)).ceil();
}
}
}

158
Runtime/painting/text_style.cs


using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.painting {

);
}
public TextStyle apply(
Color color = null,
TextDecoration decoration = null,
Color decorationColor = null,
TextDecorationStyle? decorationStyle = null,
String fontFamily = null,
double fontSizeFactor = 1.0,
double fontSizeDelta = 0.0,
int fontWeightDelta = 0,
double letterSpacingFactor = 1.0,
double letterSpacingDelta = 0.0,
double wordSpacingFactor = 1.0,
double wordSpacingDelta = 0.0,
double heightFactor = 1.0,
double heightDelta = 0.0
) {
D.assert(fontSizeFactor != null);
D.assert(fontSizeDelta != null);
D.assert(this.fontSize != null || (fontSizeFactor == 1.0 && fontSizeDelta == 0.0));
D.assert(fontWeightDelta != null);
D.assert(this.fontWeight != null || fontWeightDelta == 0.0);
D.assert(letterSpacingFactor != null);
D.assert(letterSpacingDelta != null);
D.assert(this.letterSpacing != null || (letterSpacingFactor == 1.0 && letterSpacingDelta == 0.0));
D.assert(wordSpacingFactor != null);
D.assert(wordSpacingDelta != null);
D.assert(this.wordSpacing != null || (wordSpacingFactor == 1.0 && wordSpacingDelta == 0.0));
D.assert(heightFactor != null);
D.assert(heightDelta != null);
D.assert(heightFactor != null || (heightFactor == 1.0 && heightDelta == 0.0));
String modifiedDebugLabel = "";
D.assert(() => {
if (this.debugLabel != null)
modifiedDebugLabel = this.debugLabel + ".apply";
return true;
});
return new TextStyle(
inherit: this.inherit,
color: color ?? this.color,
fontFamily: fontFamily ?? this.fontFamily,
fontSize: this.fontSize == null ? null : this.fontSize * fontSizeFactor + fontSizeDelta,
fontWeight: this.fontWeight == null ? null : this.fontWeight,
fontStyle: this.fontStyle,
letterSpacing: this.letterSpacing == null
? null
: this.letterSpacing * letterSpacingFactor + letterSpacingDelta,
wordSpacing: this.wordSpacing == null ? null : this.wordSpacing * wordSpacingFactor + wordSpacingDelta,
textBaseline: this.textBaseline,
height: this.height == null ? null : this.height * heightFactor + heightDelta,
background: this.background,
decoration: decoration ?? this.decoration,
decorationColor: decorationColor ?? this.decorationColor,
decorationStyle: decorationStyle ?? this.decorationStyle,
debugLabel: modifiedDebugLabel
);
}
public TextStyle merge(TextStyle other) {
if (other == null) {
return this;

);
}
public TextStyle copyWith(Color color,
string fontFamily,
double? fontSize,
FontWeight? fontWeight,
FontStyle? fontStyle,
double? letterSpacing,
double? wordSpacing,
public TextStyle copyWith(Color color = null,
string fontFamily = null,
double? fontSize = null,
FontWeight? fontWeight = null,
FontStyle? fontStyle = null,
double? letterSpacing = null,
double? wordSpacing = null,
TextBaseline? textBaseline = null,
double? height = null,
Paint background = null,

);
}
public static TextStyle lerp(TextStyle a, TextStyle b, double t) {
D.assert(t != null);
D.assert(a == null || b == null || a.inherit == b.inherit);
if (a == null && b == null) {
return null;
}
string lerpDebugLabel = "";
D.assert(() => {
lerpDebugLabel = "lerp" + (a?.debugLabel ?? _kDefaultDebugLabel) + "-" + t + "-" +
(b?.debugLabel ?? _kDefaultDebugLabel);
return true;
});
if (a == null) {
return new TextStyle(
inherit: b.inherit,
color: Color.lerp(null, b.color, t),
fontFamily: t < 0.5 ? null : b.fontFamily,
fontSize: t < 0.5 ? null : b.fontSize,
fontWeight: t < 0.5 ? null : b.fontWeight,
fontStyle: t < 0.5 ? null : b.fontStyle,
letterSpacing: t < 0.5 ? null : b.letterSpacing,
wordSpacing: t < 0.5 ? null : b.wordSpacing,
textBaseline: t < 0.5 ? null : b.textBaseline,
height: t < 0.5 ? null : b.height,
decoration: t < 0.5 ? null : b.decoration,
decorationColor: Color.lerp(null, b.decorationColor, t),
decorationStyle: t < 0.5 ? null : b.decorationStyle,
background: t < 0.5 ? null : b.background,
debugLabel: lerpDebugLabel
);
}
if (b == null) {
return new TextStyle(
inherit: a.inherit,
color: Color.lerp(a.color, null, t),
fontFamily: t < 0.5 ? a.fontFamily : null,
fontSize: t < 0.5 ? a.fontSize : null,
fontWeight: t < 0.5 ? a.fontWeight : null,
fontStyle: t < 0.5 ? a.fontStyle : null,
letterSpacing: t < 0.5 ? a.letterSpacing : null,
wordSpacing: t < 0.5 ? a.wordSpacing : null,
textBaseline: t < 0.5 ? a.textBaseline : null,
height: t < 0.5 ? a.height : null,
decoration: t < 0.5 ? a.decoration : null,
decorationColor: Color.lerp(a.decorationColor, null, t),
decorationStyle: t < 0.5 ? a.decorationStyle : null,
background: t < 0.5 ? a.background : null,
debugLabel: lerpDebugLabel
);
}
return new TextStyle(
inherit: b.inherit,
color: Color.lerp(a.color, b.color, t),
fontFamily: t < 0.5 ? a.fontFamily : b.fontFamily,
fontSize: MathUtils.lerpNullableDouble(a.fontSize ?? b.fontSize, b.fontSize ?? a.fontSize, t),
fontWeight: t < 0.5 ? a.fontWeight : b.fontWeight,
fontStyle: t < 0.5 ? a.fontStyle : b.fontStyle,
letterSpacing: MathUtils.lerpNullableDouble(a.letterSpacing ?? b.letterSpacing,
b.letterSpacing ?? a.letterSpacing, t),
wordSpacing: MathUtils.lerpNullableDouble(a.wordSpacing ?? b.wordSpacing,
b.wordSpacing ?? a.wordSpacing, t),
textBaseline: t < 0.5 ? a.textBaseline : b.textBaseline,
height: MathUtils.lerpNullableDouble(a.height ?? b.height, b.height ?? a.height, t),
decoration: t < 0.5 ? a.decoration : b.decoration,
decorationColor: Color.lerp(a.decorationColor, b.decorationColor, t),
decorationStyle: t < 0.5 ? a.decorationStyle : b.decorationStyle,
background: t < 0.5 ? a.background : b.background,
debugLabel: lerpDebugLabel
);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);

if (this.decoration != null) {
decorationDescription.Add("$decoration");
}
D.assert(decorationDescription.isNotEmpty);
styles.Add(new MessageProperty("decoration", string.Join(" ", decorationDescription.ToArray())));
}

if (ReferenceEquals(null, other)) {
return false;
}
return this.inherit == other.inherit && Equals(this.color, other.color) &&
this.fontSize.Equals(other.fontSize) && this.fontWeight == other.fontWeight &&
this.fontStyle == other.fontStyle && this.letterSpacing.Equals(other.letterSpacing) &&

if (ReferenceEquals(null, obj)) {
return false;
}
return this.Equals((TextStyle) obj);
}

return this.GetType().FullName;
}
}
}
}

408
Runtime/rendering/proxy_box.cs


using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEditor.Rendering;
using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;
using Color = Unity.UIWidgets.ui.Color;
using Gradient = Unity.UIWidgets.ui.Gradient;
using Rect = Unity.UIWidgets.ui.Rect;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.rendering {
public class RenderProxyBox : RenderProxyBoxMixinRenderObjectWithChildMixinRenderBox<RenderBox> {

base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Animation<double>>("opacity", this.opacity));
}
}
public abstract class CustomClipper<T> {
public CustomClipper(Listenable reclip = null) {
this._reclip = reclip;
}
public readonly Listenable _reclip;
public abstract T getClip(Size size);
public Rect getApproximateClipRect(Size size) => Offset.zero & size;
public abstract bool shouldReclip(CustomClipper<T> oldClipper);
public string toString() => this.GetType() + "";
}
public class ShapeBorderClipper : CustomClipper<Path> {
public ShapeBorderClipper(
ShapeBorder shape = null) {
D.assert(shape != null);
this.shape = shape;
}
public readonly ShapeBorder shape;
public override Path getClip(Size size) {
return this.shape.getOuterPath(Offset.zero & size);
}
public override bool shouldReclip(CustomClipper<Path> oldClipper) {
if (oldClipper.GetType() != this.GetType())
return true;
ShapeBorderClipper typedOldClipper = (ShapeBorderClipper)oldClipper;
return typedOldClipper.shape != this.shape;
}
}
public abstract class _RenderCustomClip<T> : RenderProxyBox where T : class{
protected _RenderCustomClip(
RenderBox child = null,
CustomClipper<T> clipper = null,
Clip clipBehavior = Clip.antiAlias) : base(child: child) {
D.assert(clipBehavior != null);
this.clipBehavior = clipBehavior;
this._clipper = clipper;
}
public CustomClipper<T> clipper {
get { return this._clipper; }
set {
if (this._clipper == value)
return;
CustomClipper<T> oldClipper = this._clipper;
this._clipper = value;
D.assert(value != null || oldClipper != null);
if (value == null || oldClipper == null ||
value.GetType() != oldClipper.GetType() ||
value.shouldReclip(oldClipper)) {
this._markNeedsClip();
}
if (this.attached) {
oldClipper?._reclip?.removeListener(this._markNeedsClip);
value?._reclip?.addListener(this._markNeedsClip);
}
}
}
protected CustomClipper<T> _clipper;
public override void attach(object owner) {
base.attach(owner);
this._clipper?._reclip?.addListener(this._markNeedsClip);
}
public override void detach() {
this._clipper?._reclip?.removeListener(this._markNeedsClip);
base.detach();
}
protected void _markNeedsClip() {
this._clip = null;
this.markNeedsPaint();
}
protected abstract T _defaultClip { get; }
protected T _clip;
protected Clip clipBehavior;
protected override void performLayout() {
Size oldSize = this.hasSize ? this.size : null;
base.performLayout();
if (oldSize != this.size)
this._clip = null;
}
protected void _updateClip() {
this._clip = this._clip ?? this._clipper?.getClip(this.size) ?? this._defaultClip;
}
public override Rect describeApproximatePaintClip(RenderObject child) {
return this._clipper?.getApproximateClipRect(this.size) ?? Offset.zero & this.size;
}
Paint _debugPaint;
TextPainter _debugText;
protected override void debugPaintSize(PaintingContext context, Offset offset) {
base.debugPaintSize(context, offset);
D.assert(() => {
// this._debugPaint = this._debugPaint ?? new Paint();
// this._debugPaint.shader = Gradient.linear(
// new Offset(0.0, 0.0),
// new Offset(10.0, 10.0),
// new Color(0x00000000),
// new Color(0xFFFF00FF),
// TileMode.repeated);
// this._debugPaint.strokeWidth = 2.0;
// this._debugPaint.style = PaintingStyle.stroke;
// this._debugText = this._debugText ?? new TextPainter(
// text: new TextSpan(
// text: "x",
// style: new TextStyle(
// color: new Color(0xFFFF00FF),
// fontSize: 14.0)
// ),
// textDirection: TextDirection.ltr);
// this._debugText.layout();
return true;
});
}
}
public abstract class _RenderPhysicalModelBase<T> : _RenderCustomClip<T> where T : class{
public _RenderPhysicalModelBase(
RenderBox child = null,
double? elevation = null,
Color color = null,
Color shadowColor = null,
Clip clipBehavior = Clip.none,
CustomClipper<T> clipper = null
) : base(child: child, clipBehavior: clipBehavior, clipper: clipper) {
D.assert(elevation != null);
D.assert(color != null);
D.assert(shadowColor != null);
D.assert(clipBehavior != null);
this._elevation = elevation ?? 0.0;
this._color = color;
this._shadowColor = shadowColor;
}
public double elevation {
get { return this._elevation; }
set {
D.assert(value != null);
if (this.elevation == value)
return;
bool didNeedCompositing = this.alwaysNeedsCompositing;
this._elevation = value;
if (didNeedCompositing != this.alwaysNeedsCompositing)
this.markNeedsCompositingBitsUpdate();
this.markNeedsPaint();
}
}
double _elevation;
public Color shadowColor {
get { return this._shadowColor; }
set {
D.assert(value != null);
if (this.shadowColor == value)
return;
this._shadowColor = value;
this.markNeedsPaint();
}
}
Color _shadowColor;
public Color color {
get { return this._color; }
set {
D.assert(value != null);
if (this.color == value)
return;
this._color = value;
this.markNeedsPaint();
}
}
Color _color;
public static Paint _transparentPaint {
get {
Paint paint = new Paint();
paint.color = new Color(0x00000000);
return paint;
}
}
protected override bool alwaysNeedsCompositing {
get { return this._elevation != 0.0; }
}
public override void debugFillProperties(DiagnosticPropertiesBuilder description) {
base.debugFillProperties(description);
description.add(new DoubleProperty("elevation", this.elevation));
description.add(new DiagnosticsProperty<Color>("color", this.color));
description.add(new DiagnosticsProperty<Color>("shadowColor", this.shadowColor));
}
}
public class RenderPhysicalModel : _RenderPhysicalModelBase<RRect> {
public RenderPhysicalModel(
RenderBox child = null,
BoxShape shape = BoxShape.rectangle,
Clip clipBehavior = Clip.none,
BorderRadius borderRadius = null,
double elevation = 0.0,
Color color = null,
Color shadowColor = null
) : base(clipBehavior: clipBehavior, child: child, elevation: elevation, color: color,
shadowColor: shadowColor ?? new Color(0xFF000000)) {
D.assert(shape != null);
D.assert(clipBehavior != null);
D.assert(color != null);
this._shape = shape;
this._borderRadius = borderRadius;
}
public BoxShape shape {
get { return this._shape; }
set {
D.assert(value != null);
if (this.shape == value)
return;
this._shape = value;
this._markNeedsClip();
}
}
BoxShape _shape;
public BorderRadius borderRadius {
get { return this._borderRadius; }
set {
if (this.borderRadius == value)
return;
this._borderRadius = value;
this._markNeedsClip();
}
}
BorderRadius _borderRadius;
protected override RRect _defaultClip {
get {
D.assert(this.hasSize);
D.assert(this._shape != null);
switch (this._shape) {
case BoxShape.rectangle:
return (this.borderRadius ?? BorderRadius.zero).toRRect(Offset.zero & this.size);
case BoxShape.circle:
Rect rect = Offset.zero & this.size;
return RRect.fromRectXY(rect, rect.width / 2, rect.height / 2);
}
return null;
}
}
public override bool hitTest(HitTestResult result, Offset position = null) {
if (this._clipper != null) {
this._updateClip();
D.assert(this._clip != null);
if (!this._clip.contains(position))
return false;
}
return base.hitTest(result, position: position);
}
//todo:xingwei.zhu: implementation shadow + compositeLayer
public override void paint(PaintingContext context, Offset offset) {
if (this.child != null) {
this._updateClip();
RRect offsetRRect = this._clip.shift(offset);
Rect offsetBounds = offsetRRect.outerRect;
Path offsetRRectAsPath = new Path();
offsetRRectAsPath.addRRect(offsetRRect);
Canvas canvas = context.canvas;
if (this.elevation != 0.0) {
//draw Shadow
/*canvas.drawRect(
offsetBounds.inflate(20.0),
_RenderPhysicalModelBase<RRect>._transparentPaint
);
canvas.drawShadow(
offsetRRectAsPath,
this.shadowColor,
this.elevation,
this.color.alpha != 0xFF
);*/
}
Paint paint = new Paint();
paint.color = this.color;
canvas.drawRRect(offsetRRect, paint);
context.clipRRectAndPaint(offsetRRect, this.clipBehavior, offsetBounds, () => base.paint(context, offset));
D.assert(context.canvas == canvas, "canvas changed even though needsCompositing was false");
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder description) {
base.debugFillProperties(description);
description.add(new DiagnosticsProperty<BoxShape>("shape", this.shape));
description.add(new DiagnosticsProperty<BorderRadius>("borderRadius", this.borderRadius));
}
}
public class RenderPhysicalShape : _RenderPhysicalModelBase<Path> {
public RenderPhysicalShape(
RenderBox child = null,
CustomClipper<Path> clipper = null,
Clip clipBehavior = Clip.none,
double elevation = 0.0,
Color color = null,
Color shadowColor = null
): base(child: child,
elevation = elevation,
color: color,
shadowColor: shadowColor ?? new Color(0xFF000000),
clipper: clipper,
clipBehavior: clipBehavior) {
D.assert(clipper != null);
D.assert(color != null);
}
protected override Path _defaultClip {
get {
Path path = new Path();
path.addRect(Offset.zero & this.size);
return path;
}
}
public override bool hitTest(HitTestResult result, Offset position = null) {
if (this._clipper != null) {
this._updateClip();
D.assert(this._clip != null);
if (!this._clip.contains(position))
return false;
}
return base.hitTest(result, position: position);
}
//todo:xingwei.zhu: implementation shadow + compositeLayer + Path.shift
public override void paint(PaintingContext context, Offset offset) {
if (this.child != null) {
this._updateClip();
Rect offsetBounds = offset & this.size;
//Path offsetPath = this._clip.shift(offset);
Path offsetPath = this._clip;
bool paintShadows = true;
Canvas canvas = context.canvas;
// if (this.elevation != 0.0 && paintShadows) {
// canvas.drawRect(
// offsetBounds.inflate(20.0),
// _RenderPhysicalModelBase<Path>._transparentPaint
// );
// canvas.drawShadow(
// offsetPath,
// this.shadowColor,
// this.elevation,
// this.color.alpha != 0xFF,
// );
// }
Paint paint = new Paint();
paint.color = this.color;
paint.style = PaintingStyle.fill;
canvas.drawPath(offsetPath, paint);
context.clipPathAndPaint(offsetPath, this.clipBehavior,
offsetBounds, () => base.paint(context, offset));
D.assert(context.canvas == canvas, "canvas changed even though needsCompositing was false");
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder description) {
base.debugFillProperties(description);
description.add(new DiagnosticsProperty<CustomClipper<Path>>("clipper", this.clipper));
}
}
public enum DecorationPosition {

9
Runtime/ui/geometry.cs


public static double lerpDouble(double a, double b, double t) {
return a + (b - a) * t;
}
public static double? lerpNullableDouble(double? a, double? b, double t) {
if (a == null && b == null) {
return null;
}
a = a ?? b;
b = b ?? a;
return (double) a + ((double) b - (double) a) * t;
}
public static float lerpFloat(float a, float b, float t) {
return a + (b - a) * t;

14
Runtime/ui/painting/painting.cs


using System;
using Unity.UIWidgets.painting;
using UnityEditor.OSXStandalone;
using UnityEngine;
namespace Unity.UIWidgets.ui {

public Color withBlue(int b) {
return fromARGB(this.alpha, this.red, this.green, b);
}
static double _linearizeColorComponent(double component) {
if (component <= 0.03928)
return component / 12.92;
return Math.Pow((component + 0.055) / 1.055, 2.4);
}
public double computeLuminance() {
double R = _linearizeColorComponent(this.red / 0xFF);
double G = _linearizeColorComponent(this.green / 0xFF);
double B = _linearizeColorComponent(this.blue / 0xFF);
return 0.2126 * R + 0.7152 * G + 0.0722 * B;
}
public static Color lerp(Color a, Color b, double t) {

119
Runtime/widgets/basic.cs


}
}
public class PhysicalModel : SingleChildRenderObjectWidget {
public PhysicalModel(
Key key = null,
BoxShape shape = BoxShape.rectangle,
Clip clipBehavior = Clip.none,
BorderRadius borderRadius = null,
double elevation = 0.0,
Color color = null,
Color shadowColor = null,
Widget child = null) : base(key: key, child: child) {
D.assert(shape != null);
D.assert(color != null);
this.shape = shape;
this.clipBehavior = clipBehavior;
this.borderRadius = borderRadius;
this.elevation = elevation;
this.color = color;
this.shadowColor = shadowColor ?? new Color(0xFF000000);
}
public readonly BoxShape shape;
public readonly Clip clipBehavior;
public readonly BorderRadius borderRadius;
public readonly double elevation;
public readonly Color color;
public readonly Color shadowColor;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderPhysicalModel(
shape: this.shape,
clipBehavior: this.clipBehavior,
borderRadius: this.borderRadius,
elevation: this.elevation,
color: this.color,
shadowColor: this.shadowColor);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
RenderPhysicalModel _renderObject = (RenderPhysicalModel) renderObject;
_renderObject.shape = this.shape;
_renderObject.borderRadius = this.borderRadius;
_renderObject.elevation = this.elevation;
_renderObject.color = this.color;
_renderObject.shadowColor = this.shadowColor;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new EnumProperty<BoxShape>("shape", this.shape));
properties.add(new DiagnosticsProperty<BorderRadius>("borderRadius", this.borderRadius));
properties.add(new DoubleProperty("elevation", this.elevation));
properties.add(new DiagnosticsProperty<Color>("color", this.color));
properties.add(new DiagnosticsProperty<Color>("shadowColor", this.shadowColor));
}
}
public class PhysicalShape : SingleChildRenderObjectWidget {
public PhysicalShape(
Key key = null,
CustomClipper<Path> clipper = null,
Clip clipBehavior = Clip.none,
double elevation = 0.0,
Color color = null,
Color shadowColor = null,
Widget child = null) : base(key : key, child: child){
D.assert(clipper != null);
D.assert(color != null);
this.clipper = clipper;
this.clipBehavior = clipBehavior;
this.elevation = elevation;
this.color = color;
this.shadowColor = shadowColor ?? new Color(0xFF000000);
}
public readonly CustomClipper<Path> clipper;
public readonly Clip clipBehavior;
public readonly double elevation;
public readonly Color color;
public readonly Color shadowColor;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderPhysicalShape(
clipper: this.clipper,
clipBehavior: this.clipBehavior,
elevation: this.elevation,
color: this.color,
shadowColor: this.shadowColor);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
RenderPhysicalShape _renderObject = (RenderPhysicalShape) renderObject;
_renderObject.clipper = this.clipper;
_renderObject.elevation = this.elevation;
_renderObject.color = this.color;
_renderObject.shadowColor = this.shadowColor;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<CustomClipper<Path>>("clipper", this.clipper));
properties.add(new DoubleProperty("elevation", this.elevation));
properties.add(new DiagnosticsProperty<Color>("color", this.color));
properties.add(new DiagnosticsProperty<Color>("shadowColor", this.shadowColor));
}
}
public class Padding : SingleChildRenderObjectWidget {
public Padding(
Key key = null,

8
Runtime/widgets/icon_theme_data.cs


public readonly double? size;
public static IconThemeData lerp(IconThemeData a, IconThemeData b, double t) {
D.assert(t != null);
return new IconThemeData(
color: Color.lerp(a.color, b.color, t),
opacity: MathUtils.lerpDouble(a.opacity ?? 1.0, b.opacity ?? 1.0, t),
size: MathUtils.lerpDouble(a.size ?? 24.0, b.size ?? 24.0, t));
}
public bool Equals(IconThemeData other) {
if (ReferenceEquals(null, other)) {

325
Runtime/widgets/implicit_animations.cs


using System;
using System.Linq.Expressions;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using UnityEngine.Experimental.PlayerLoop;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
class BoxConstraintsTween : Tween<BoxConstraints> {
public class BoxConstraintsTween : Tween<BoxConstraints> {
public BoxConstraintsTween(
BoxConstraints begin = null,
BoxConstraints end = null

public override BoxConstraints lerp(double t) => BoxConstraints.lerp(this.begin, this.end, t);
}
public class TextStyleTween : Tween<TextStyle> {
public TextStyleTween(
TextStyle begin = null,
TextStyle end = null) : base(begin: begin, end: end) {}
public override TextStyle lerp(double t) => TextStyle.lerp(this.begin, this.end, t);
}
public class BorderRadiusTween : Tween<BorderRadius> {
public BorderRadiusTween(
BorderRadius begin = null,
BorderRadius end = null) : base(begin: begin, end: end) {}
public override BorderRadius lerp(double t) => BorderRadius.lerp(this.begin, this.end, t);
}
public abstract class ImplicitlyAnimatedWidget : StatefulWidget {

this.duration = duration ?? TimeSpan.Zero;
}
readonly Curve curve;
public readonly Curve curve;
readonly TimeSpan duration;
public readonly TimeSpan duration;
}
}
public delegate Tween<T> TweenConstructor<T>(T targetValue);
public interface ITweenVisitor {
Tween<T> visit<T, T2>(ImplicitlyAnimatedWidgetState<T2> state, Tween<T> tween, T targetValue,
TweenConstructor<T> constructor) where T2 : ImplicitlyAnimatedWidget;
}
public class TweenVisitorUpdateTween : ITweenVisitor {
public Tween<T> visit<T, T2>(ImplicitlyAnimatedWidgetState<T2> state, Tween<T> tween, T targetValue, TweenConstructor<T> constructor)
where T2 : ImplicitlyAnimatedWidget{
state._updateTween(tween, targetValue);
return tween;
}
}
public class TweenVisitorCheckStartAnimation : ITweenVisitor {
public bool shouldStartAnimation;
public TweenVisitorCheckStartAnimation() {
this.shouldStartAnimation = false;
}
public Tween<T> visit<T, T2>(ImplicitlyAnimatedWidgetState<T2> state, Tween<T> tween, T targetValue, TweenConstructor<T> constructor)
where T2 : ImplicitlyAnimatedWidget{
if (targetValue != null) {
tween = tween == null ? constructor(targetValue) : tween;
if (state._shouldAnimateTween(tween, targetValue))
this.shouldStartAnimation = true;
}
else {
tween = null;
}
return tween;
}
}
public abstract class ImplicitlyAnimatedWidgetState<T> : SingleTickerProviderStateMixin<T>
where T : ImplicitlyAnimatedWidget {
protected AnimationController controller {
get { return this._controller; }
}
AnimationController _controller;
public Animation<double> animation {
get { return this._animation; }
}
Animation<double> _animation;
public override void initState() {
base.initState();
this._controller = new AnimationController(
duration: this.widget.duration,
debugLabel: "{" + this.widget.toStringShort() + "}",
vsync: this
);
this._updateCurve();
this._constructTweens();
this.didUpdateTweens();
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
base.didUpdateWidget(oldWidget);
if (this.widget.curve != ((ImplicitlyAnimatedWidget)oldWidget).curve) {
this._updateCurve();
}
this._controller.duration = this.widget.duration;
if (this._constructTweens()) {
var visitor = new TweenVisitorUpdateTween();
this.forEachTween(visitor);
this._controller.setValue(0.0);
this._controller.forward();
this.didUpdateTweens();
}
}
void _updateCurve() {
if (this.widget.curve != null)
this._animation = new CurvedAnimation(parent: this._controller, curve: this.widget.curve);
else
this._animation = this._controller;
}
public override void dispose() {
this._controller.dispose();
base.dispose();
}
public bool _shouldAnimateTween<T2>(Tween<T2> tween, T2 targetValue) {
return !targetValue.Equals(tween.end); //(tween.end ?? tween.begin);
}
public void _updateTween<T2>(Tween<T2> tween, T2 targetValue) {
if (tween == null)
return;
tween.begin = tween.evaluate(this._animation);
tween.end = targetValue;
}
bool _constructTweens() {
var visitor = new TweenVisitorCheckStartAnimation();
this.forEachTween(visitor);
return visitor.shouldStartAnimation;
}
protected abstract void forEachTween(ITweenVisitor visitor);
protected virtual void didUpdateTweens() {}
}
public abstract class AnimatedWidgetBaseState<T> : ImplicitlyAnimatedWidgetState<T>
where T : ImplicitlyAnimatedWidget {
public override void initState() {
base.initState();
this.controller.addListener(this._handleAnimationChanged);
}
void _handleAnimationChanged() {
this.setState(() => { });
}
}
public class AnimatedDefaultTextStyle : ImplicitlyAnimatedWidget {
public AnimatedDefaultTextStyle(
Key key = null,
Widget child = null,
TextStyle style = null,
TextAlign? textAlign = null,
bool softWrap = true,
TextOverflow? overflow = null,
int? maxLines = null,
Curve curve = null,
TimeSpan? duration = null
) : base(key : key, curve: curve ?? Curves.linear, duration: duration) {
D.assert(style != null);
D.assert(child != null);
D.assert(softWrap != null);
D.assert(maxLines == null || maxLines > 0);
this.child = child;
this.style = style;
this.textAlign = textAlign;
this.softWrap = softWrap;
this.overflow = overflow ?? TextOverflow.clip;
this.maxLines = maxLines;
}
public readonly Widget child;
public readonly TextStyle style;
public readonly bool softWrap;
public readonly TextAlign? textAlign;
public readonly TextOverflow overflow;
public readonly int? maxLines;
public override State createState() => new _AnimatedDefaultTextStyleState();
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
this.style?.debugFillProperties(properties);
properties.add(new EnumProperty<TextAlign>("textAlign", this.textAlign ?? TextAlign.center, defaultValue: null));
properties.add(new FlagProperty("softWrap", value: this.softWrap, ifTrue: "wrapping at box width", ifFalse: "no wrapping except at line break characters", showName: true));
properties.add(new EnumProperty<TextOverflow>("overflow", this.overflow, defaultValue: null));
properties.add(new IntProperty("maxLines", this.maxLines, defaultValue: null));
}
}
public class _AnimatedDefaultTextStyleState : AnimatedWidgetBaseState<AnimatedDefaultTextStyle> {
TextStyleTween _style;
protected override void forEachTween(ITweenVisitor visitor) {
this._style = (TextStyleTween) visitor.visit(this, this._style, this.widget.style,
(TextStyle value) => new TextStyleTween(begin: value));
}
public override Widget build(BuildContext context) {
return new DefaultTextStyle(
style: this._style.evaluate(this.animation),
textAlign: this.widget.textAlign,
softWrap: this.widget.softWrap,
overflow: this.widget.overflow,
maxLines: this.widget.maxLines,
child: this.widget.child);
}
}
public class AnimatedPhysicalModel : ImplicitlyAnimatedWidget {
public AnimatedPhysicalModel(
Key key = null,
Widget child = null,
BoxShape? shape = null,
Clip clipBehavior = Clip.none,
BorderRadius borderRadius = null,
double? elevation = null,
Color color = null,
bool animateColor = true,
Color shadowColor = null,
bool animateShadowColor = true,
Curve curve = null,
TimeSpan? duration = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration) {
borderRadius = borderRadius ?? BorderRadius.zero;
D.assert(child != null);
D.assert(shape != null);
D.assert(clipBehavior != null);
D.assert(elevation != null);
D.assert(color != null);
D.assert(shadowColor != null);
D.assert(animateColor != null);
D.assert(animateShadowColor != null);
D.assert(duration != null);
this.child = child;
this.shape = shape ?? BoxShape.circle;
this.clipBehavior = clipBehavior;
this.borderRadius = borderRadius;
this.elevation = elevation ?? 0.0;
this.color = color;
this.animateColor = animateColor;
this.shadowColor = shadowColor;
this.animateShadowColor = animateShadowColor;
}
public readonly Widget child;
public readonly BoxShape shape;
public readonly Clip clipBehavior;
public readonly BorderRadius borderRadius;
public readonly double elevation;
public readonly Color color;
public readonly bool animateColor;
public readonly Color shadowColor;
public readonly bool animateShadowColor;
public override State createState() => new _AnimatedPhysicalModelState();
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new EnumProperty<BoxShape>("shape", this.shape));
properties.add(new DiagnosticsProperty<BorderRadius>("borderRadius", this.borderRadius));
properties.add(new DoubleProperty("elevation", this.elevation));
properties.add(new DiagnosticsProperty<Color>("color", this.color));
properties.add(new DiagnosticsProperty<bool>("animateColor", this.animateColor));
properties.add(new DiagnosticsProperty<Color>("shadowColor", this.shadowColor));
properties.add(new DiagnosticsProperty<bool>("animateShadowColor", this.animateShadowColor));
}
}
public class _AnimatedPhysicalModelState : AnimatedWidgetBaseState<AnimatedPhysicalModel> {
BorderRadiusTween _borderRadius;
DoubleTween _elevation;
ColorTween _color;
ColorTween _shadowColor;
protected override void forEachTween(ITweenVisitor visitor) {
this._borderRadius = (BorderRadiusTween)visitor.visit(this, this._borderRadius, this.widget.borderRadius,
(BorderRadius value) => new BorderRadiusTween(begin: value));
this._elevation = (DoubleTween) visitor.visit(this, this._elevation, this.widget.elevation,
(double value) => new DoubleTween(begin: value, end: value));
this._color = (ColorTween) visitor.visit(this, this._color, this.widget.color,
(Color value) => new ColorTween(begin: value));
this._shadowColor = (ColorTween) visitor.visit(this, this._shadowColor, this.widget.shadowColor,
(Color value) => new ColorTween(begin: value));
}
public override Widget build(BuildContext context) {
return new PhysicalModel(
child: this.widget.child,
shape: this.widget.shape,
clipBehavior: this.widget.clipBehavior,
borderRadius: this.widget.borderRadius,
elevation: this.widget.elevation,
color: this.widget.animateColor ? this._color.evaluate(this.animation) : this.widget.color,
shadowColor: this.widget.animateShadowColor ? this._shadowColor.evaluate(this.animation) : this.widget.shadowColor);
}
}
}

75
Samples/UIWidgetSample/UIWidgetSample.unity


- {fileID: 895510406}
- {fileID: 1399904531}
- {fileID: 432951246}
- {fileID: 552752111}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &432951246
RectTransform:
m_ObjectHideFlags: 0

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 484983222}
m_CullTransparentMesh: 0
--- !u!1 &552752110
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 552752111}
- component: {fileID: 552752113}
- component: {fileID: 552752112}
m_Layer: 5
m_Name: Material
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &552752111
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 552752110}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 304189374}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &552752112
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 552752110}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d7c3be43dd8b94a349f26e3e7173c3f6, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
--- !u!222 &552752113
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 552752110}
m_CullTransparentMesh: 0
--- !u!1 &554372217
GameObject:

8
Runtime/material.meta


fileFormatVersion: 2
guid: 52a35ef46dd5544709a97aaf50d86159
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

145
Runtime/material/button.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.widgets;
using Unity.UIWidgets.ui;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
public class RawMaterialButton : StatefulWidget {
public RawMaterialButton(
Key key = null,
VoidCallback onPressed = null,
ValueChanged<bool> onHighlightChanged = null,
TextStyle textStyle = null,
Color fillColor = null,
Color highlightColor = null,
Color splashColor = null,
double elevation = 2.0,
double highlightElevation = 8.0,
double disabledElevation = 0.0,
EdgeInsets padding = null,
BoxConstraints constraints = null,
ShapeBorder shape = null,
TimeSpan? animationDuration = null,
Clip clipBehavior = Clip.none,
MaterialTapTargetSize? materialTapTargetSize = null,
Widget child = null) : base(key: key) {
D.assert(onPressed != null);
MaterialTapTargetSize _materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded;
shape = shape ?? new RoundedRectangleBorder();
padding = padding ?? EdgeInsets.zero;
constraints = constraints ?? new BoxConstraints(minWidth: 88.0, minHeight: 36.0);
TimeSpan _animationDuration = animationDuration ?? Constants.kThemeChangeDuration;
this.onPressed = onPressed;
this.onHighlightChanged = onHighlightChanged;
this.textStyle = textStyle;
this.fillColor = fillColor;
this.highlightColor = highlightColor;
this.splashColor = splashColor;
this.elevation = elevation;
this.highlightElevation = highlightElevation;
this.disabledElevation = disabledElevation;
this.padding = padding;
this.constraints = constraints;
this.shape = shape;
this.animationDuration = _animationDuration;
this.clipBehavior = clipBehavior;
this.materialTapTargetSize = _materialTapTargetSize;
this.child = child;
}
public readonly VoidCallback onPressed;
public readonly ValueChanged<bool> onHighlightChanged;
public readonly TextStyle textStyle;
public readonly Color fillColor;
public readonly Color highlightColor;
public readonly Color splashColor;
public readonly double elevation;
public readonly double highlightElevation;
public readonly double disabledElevation;
public readonly EdgeInsets padding;
public readonly BoxConstraints constraints;
public readonly ShapeBorder shape;
public readonly TimeSpan animationDuration;
public readonly Widget child;
public bool enabled => this.onPressed != null;
public readonly MaterialTapTargetSize materialTapTargetSize;
public readonly Clip clipBehavior;
public override State createState() => new _RawMaterialButtonState();
}
class _RawMaterialButtonState : State<RawMaterialButton> {
bool _highlight = false;
void _handleHighlightChanged(bool value) {
this.setState(() => {
this._highlight = value;
if (this.widget.onHighlightChanged != null) {
this.widget.onHighlightChanged(value);
}
});
}
public override Widget build(BuildContext context) {
double elevation = this.widget.enabled
? (this._highlight ? this.widget.highlightElevation : this.widget.elevation)
: this.widget.disabledElevation;
Widget result = new ConstrainedBox(
constraints: this.widget.constraints,
child: new Material(
elevation: elevation,
textStyle: this.widget.textStyle,
shape: this.widget.shape,
color: this.widget.fillColor,
type: this.widget.fillColor == null ? MaterialType.transparency : MaterialType.button,
animationDuration: this.widget.animationDuration,
clipBehavior: this.widget.clipBehavior,
child: new InkWell(
onHighlightChanged: this._handleHighlightChanged,
splashColor: this.widget.splashColor,
highlightColor: this.widget.highlightColor,
onTap: () => this.widget.onPressed(),
customBorder: this.widget.shape,
child: IconTheme.merge(
data: new IconThemeData(color: this.widget.textStyle?.color),
child: new Container(
padding: this.widget.padding,
child: new Center(
widthFactor: 1.0,
heightFactor: 1.0,
child: this.widget.child)
)
)
)
)
);
return result;
}
}
}

11
Runtime/material/button.cs.meta


fileFormatVersion: 2
guid: 5452e0dd1a19646fda9cc8dc0b388ee4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

499
Runtime/material/button_theme.cs


using System.Runtime.CompilerServices;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.widgets;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.service;
using System;
namespace Unity.UIWidgets.material {
public enum ButtonTextTheme {
normal,
accent,
primary
}
public enum ButtonBarLayoutBehavior {
constrained,
padded
}
public class ButtonTheme : InheritedWidget {
public ButtonTheme(
Key key = null,
ButtonTextTheme textTheme = ButtonTextTheme.normal,
ButtonBarLayoutBehavior layoutBehavior = ButtonBarLayoutBehavior.padded,
double minWidth = 88.0,
double height = 36.0,
EdgeInsets padding = null,
ShapeBorder shape = null,
bool alignedDropdown = false,
Color buttonColor = null,
Color disabledColor = null,
Color highlightColor = null,
Color splashColor = null,
ColorScheme colorScheme = null,
MaterialTapTargetSize? materialTapTargetSize = null,
Widget child = null) : base(key: key, child: child) {
D.assert(minWidth >= 0.0);
D.assert(height >= 0.0);
this.data = new ButtonThemeData(
textTheme: textTheme,
minWidth: minWidth,
height: height,
padding: padding,
shape: shape,
alignedDropdown: alignedDropdown,
layoutBehavior: layoutBehavior,
buttonColor: buttonColor,
disabledColor: disabledColor,
highlightColor: highlightColor,
splashColor: splashColor,
colorScheme: colorScheme,
materialTapTargetSize: materialTapTargetSize);
}
public ButtonTheme(
Key key = null,
ButtonThemeData data = null,
Widget child = null) : base(key: key, child: child) {
D.assert(data != null);
this.data = data;
}
public readonly ButtonThemeData data;
public static ButtonThemeData of(BuildContext context) {
ButtonTheme inheritedButtonTheme = (ButtonTheme) context.inheritFromWidgetOfExactType(typeof(ButtonTheme));
ButtonThemeData buttonTheme = inheritedButtonTheme?.data;
if (buttonTheme?.colorScheme == null) {
ThemeData theme = Theme.of(context);
buttonTheme = buttonTheme ?? theme.buttonTheme;
if (buttonTheme.colorScheme == null) {
buttonTheme = buttonTheme.copyWith(
colorScheme: theme.buttonTheme.colorScheme ?? theme.colorScheme);
D.assert(buttonTheme.colorScheme != null);
}
}
return buttonTheme;
}
public override bool updateShouldNotify(InheritedWidget oldWidget) => this.data != ((ButtonTheme)oldWidget).data;
}
public class ButtonThemeData : Diagnosticable {
public ButtonThemeData(
ButtonTextTheme textTheme = ButtonTextTheme.normal,
double minWidth = 88.0,
double height = 36.0,
EdgeInsets padding = null,
ShapeBorder shape = null,
ButtonBarLayoutBehavior layoutBehavior = ButtonBarLayoutBehavior.padded,
bool alignedDropdown = false,
Color buttonColor = null,
Color disabledColor = null,
Color highlightColor = null,
Color splashColor = null,
ColorScheme colorScheme = null,
MaterialTapTargetSize? materialTapTargetSize = null
) {
D.assert(textTheme != null);
D.assert(minWidth >= 0.0);
D.assert(height >= 0.0);
this.textTheme = textTheme;
this.minWidth = minWidth;
this.height = height;
this.layoutBehavior = layoutBehavior;
this.alignedDropdown = alignedDropdown;
this.colorScheme = colorScheme;
this._buttonColor = buttonColor;
this._disabledColor = disabledColor;
this._highlightColor = highlightColor;
this._splashColor = splashColor;
this._padding = padding;
this._shape = shape;
this._materialTapTargetSize = materialTapTargetSize;
}
public readonly double minWidth;
public readonly double height;
public readonly ButtonTextTheme textTheme;
public readonly ButtonBarLayoutBehavior layoutBehavior;
public BoxConstraints constraints {
get { return new BoxConstraints(minWidth: this.minWidth,
minHeight: this.height);}
}
public EdgeInsets padding {
get {
if (this._padding != null)
return this._padding;
switch (this.textTheme) {
case ButtonTextTheme.normal:
case ButtonTextTheme.accent:
return EdgeInsets.symmetric(horizontal: 16.0);
case ButtonTextTheme.primary:
return EdgeInsets.symmetric(horizontal: 24.0);
}
D.assert(false);
return EdgeInsets.zero;
}
}
readonly EdgeInsets _padding;
public ShapeBorder shape {
get {
if (this._shape != null)
return this._shape;
switch (this.textTheme) {
case ButtonTextTheme.normal:
case ButtonTextTheme.accent:
return new RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(2.0)));
case ButtonTextTheme.primary:
return new RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4.0)));
}
return new RoundedRectangleBorder();
}
}
readonly ShapeBorder _shape;
public readonly bool alignedDropdown;
readonly Color _buttonColor;
readonly Color _disabledColor;
readonly Color _highlightColor;
readonly Color _splashColor;
public readonly ColorScheme colorScheme;
readonly MaterialTapTargetSize? _materialTapTargetSize;
public Brightness getBrightness(MaterialButton button) {
return button.colorBrightness ?? this.colorScheme.brightness;
}
public ButtonTextTheme getTextTheme(MaterialButton button) {
return button.textTheme ?? this.textTheme;
}
Color _getDisabledColor(MaterialButton button) {
return this.getBrightness(button) == Brightness.dark
? this.colorScheme.onSurface.withOpacity(0.30)
: this.colorScheme.onSurface.withOpacity(0.38);
}
Color getDisabledTextColor(MaterialButton button) {
if (button.disabledTextColor != null)
return button.disabledTextColor;
return this._getDisabledColor(button);
}
Color getDisabledFillColor(MaterialButton button) {
if (button.disabledColor != null)
return button.disabledColor;
if (this._disabledColor != null)
return this._disabledColor;
return this._getDisabledColor(button);
}
Color getFillColor(MaterialButton button) {
Color fillColor = button.enabled ? button.color : button.disabledColor;
if (fillColor != null)
return fillColor;
// todo xingwei.zhu: uncomment these when FlatButton & OutlineButton & RaisedButton are ready
// if (button is FlatButton || button is OutlineButton)
// return null;
//
//
// if (button.enabled && button is RaisedButton && this._buttonColor != null)
// return this._buttonColor;
switch (this.getTextTheme(button)) {
case ButtonTextTheme.normal:
case ButtonTextTheme.accent:
return button.enabled ? this.colorScheme.primary : this.getDisabledFillColor(button);
case ButtonTextTheme.primary:
return button.enabled
? this._buttonColor ?? this.colorScheme.primary
: this.colorScheme.onSurface.withOpacity(0.12);
}
D.assert(false);
return null;
}
public Color getTextColor(MaterialButton button) {
if (!button.enabled)
return this.getDisabledTextColor(button);
if (button.textColor != null)
return button.textColor;
switch (this.getTextTheme(button)) {
case ButtonTextTheme.normal:
return this.getBrightness(button) == Brightness.dark ? Colors.white : Colors.black87;
case ButtonTextTheme.accent:
return this.colorScheme.secondary;
case ButtonTextTheme.primary: {
Color fillColor = this.getFillColor(button);
bool fillIsDark = fillColor != null
? ThemeData.estimateBrightnessForColor(fillColor) == Brightness.dark
: this.getBrightness(button) == Brightness.dark;
if (fillIsDark)
return Colors.white;
// todo xingwei.zhu: uncomment these when FlatButton & OutlineButton are ready
// if (button is FlatButton || button is OutlineButton)
// return this.colorScheme.primary;
return Colors.black;
}
}
D.assert(false);
return null;
}
public Color getSplashColor(MaterialButton button) {
if (button.splashColor != null)
return button.splashColor;
// todo xingwei.zhu: uncomment these when FlatButton & OutlineButton & RaisedButton are ready
// if (this._splashColor != null && (button is RaisedButton || button is OutlineButton)) {
// return this._splashColor;
// }
//
// if (this._splashColor != null && button is FlatButton) {
// switch (this.getTextTheme(button)) {
// case ButtonTextTheme.normal:
// case ButtonTextTheme.accent:
// return this._splashColor;
// case ButtonTextTheme.primary:
// break;
// }
// }
return this.getTextColor(button).withOpacity(0.12);
}
public Color getHighlightColor(MaterialButton button) {
if (button.highlightColor != null)
return button.highlightColor;
switch (this.getTextTheme(button)) {
case ButtonTextTheme.normal:
case ButtonTextTheme.accent:
return this._highlightColor ?? this.getTextColor(button).withOpacity(0.16);
case ButtonTextTheme.primary:
return Colors.transparent;
}
D.assert(false);
return Colors.transparent;
}
public double getElevation(MaterialButton button) {
if (button.elevation != null)
return button.elevation ?? 0.0;
// todo xingwei.zhu: uncomment these when FlatButton are ready
// if (button is FlatButton)
// return 0.0;
return 2.0;
}
public double getHighlightElevation(MaterialButton button) {
if (button.highlightElevation != null)
return button.highlightElevation ?? 0.0;
// todo xingwei.zhu: uncomment these when FlatButton & OutlineButton are ready
// if (button is FlatButton)
// return 0.0;
// if (button is OutlineButton)
// return 2.0;
return 8.0;
}
public double getDisabledElevation(MaterialButton button) {
if (button.disabledElevation != null)
return button.disabledElevation ?? 0.0;
return 0.0;
}
public EdgeInsets getPadding(MaterialButton button) {
if (button.padding != null)
return button.padding;
// todo xingwei.zhu: uncomment these when MaterialButtonWithIconMixin are ready
// if (button is MaterialButtonWithIconMixin)
// return const EdgeInsetsDirectional.only(start: 12.0, end: 16.0);
if (this._padding != null)
return this._padding;
switch (this.getTextTheme(button)) {
case ButtonTextTheme.normal:
case ButtonTextTheme.accent:
return EdgeInsets.symmetric(horizontal: 16.0);
case ButtonTextTheme.primary:
return EdgeInsets.symmetric(horizontal: 24.0);
}
D.assert(false);
return EdgeInsets.zero;
}
public ShapeBorder getShape(MaterialButton button) {
return button.shape ?? this.shape;
}
public TimeSpan getAnimationDuration(MaterialButton button) {
return button.animationDuration ?? Constants.kThemeChangeDuration;
}
public BoxConstraints getConstraints(MaterialButton button) => this.constraints;
public MaterialTapTargetSize getMaterialTapTargetSize(MaterialButton button) {
return button.materialTapTargetSize ?? this._materialTapTargetSize ?? MaterialTapTargetSize.padded;
}
public ButtonThemeData copyWith(
ButtonTextTheme? textTheme = null,
ButtonBarLayoutBehavior? layoutBehavior = null,
double? minWidth = null,
double? height = null,
EdgeInsets padding = null,
ShapeBorder shape = null,
bool? alignedDropdown = null,
Color buttonColor = null,
Color disabledColor = null,
Color highlightColor = null,
Color splashColor = null,
ColorScheme colorScheme = null,
MaterialTapTargetSize? materialTapTargetSize = null) {
return new ButtonThemeData(
textTheme: textTheme ?? this.textTheme,
layoutBehavior: layoutBehavior ?? this.layoutBehavior,
minWidth: minWidth ?? this.minWidth,
height: height ?? this.height,
padding: padding ?? this.padding,
shape: shape ?? this.shape,
alignedDropdown: alignedDropdown ?? this.alignedDropdown,
buttonColor: buttonColor ?? this._buttonColor,
disabledColor: disabledColor ?? this._disabledColor,
highlightColor: highlightColor ?? this._highlightColor,
splashColor: splashColor ?? this._splashColor,
colorScheme: colorScheme ?? this.colorScheme,
materialTapTargetSize: materialTapTargetSize ?? this._materialTapTargetSize);
}
public bool Equals(ButtonThemeData other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return this.textTheme == other.textTheme
&& this.minWidth == other.minWidth
&& this.height == other.height
&& this.padding == other.padding
&& this.shape == other.shape
&& this.alignedDropdown == other.alignedDropdown
&& this._buttonColor == other._buttonColor
&& this._disabledColor == other._disabledColor
&& this._highlightColor == other._highlightColor
&& this._splashColor == other._splashColor
&& this.colorScheme == other.colorScheme
&& this._materialTapTargetSize == other._materialTapTargetSize;
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((ButtonThemeData) obj);
}
public static bool operator ==(ButtonThemeData left, ButtonThemeData right) {
return Equals(left, right);
}
public static bool operator !=(ButtonThemeData left, ButtonThemeData right) {
return !Equals(left, right);
}
public override int GetHashCode() {
unchecked {
var hashCode = this.textTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.minWidth.GetHashCode();
hashCode = (hashCode * 397) ^ this.height.GetHashCode();
hashCode = (hashCode * 397) ^ this.padding.GetHashCode();
hashCode = (hashCode * 397) ^ this.shape.GetHashCode();
hashCode = (hashCode * 397) ^ this.alignedDropdown.GetHashCode();
hashCode = (hashCode * 397) ^ this._buttonColor.GetHashCode();
hashCode = (hashCode * 397) ^ this._disabledColor.GetHashCode();
hashCode = (hashCode * 397) ^ this._highlightColor.GetHashCode();
hashCode = (hashCode * 397) ^ this._splashColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.colorScheme.GetHashCode();
hashCode = (hashCode * 397) ^ this._materialTapTargetSize.GetHashCode();
return hashCode;
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
ButtonThemeData defaultTheme = new ButtonThemeData();
properties.add(new EnumProperty<ButtonTextTheme>("textTheme", this.textTheme, defaultValue: defaultTheme.textTheme));
properties.add(new DoubleProperty("minWidth", this.minWidth, defaultValue: defaultTheme.minWidth));
properties.add(new DoubleProperty("height", this.height, defaultValue: defaultTheme.height));
properties.add(new DiagnosticsProperty<EdgeInsets>("padding", this.padding, defaultValue: defaultTheme.padding));
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", this.shape, defaultValue: defaultTheme.shape));
properties.add(new FlagProperty("alignedDropdown",
value: this.alignedDropdown,
defaultValue: defaultTheme.alignedDropdown,
ifTrue: "dropdown width matches button"
));
properties.add(new DiagnosticsProperty<Color>("buttonColor", this._buttonColor, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("disabledColor", this._disabledColor, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("highlightColor", this._highlightColor, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("splashColor", this._splashColor, defaultValue: null));
properties.add(new DiagnosticsProperty<ColorScheme>("colorScheme", this.colorScheme, defaultValue: defaultTheme.colorScheme));
properties.add(new DiagnosticsProperty<MaterialTapTargetSize>("materialTapTargetSize", this._materialTapTargetSize ?? MaterialTapTargetSize.padded, defaultValue: null));
}
}
}

11
Runtime/material/button_theme.cs.meta


fileFormatVersion: 2
guid: c00e9535ad31f481cbe2b83d490d714d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

338
Runtime/material/color_scheme.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.material {
public class ColorScheme : Diagnosticable {
public ColorScheme(
Color primary,
Color primaryVariant,
Color secondary,
Color secondaryVariant,
Color surface,
Color background,
Color error,
Color onPrimary,
Color onSecondary,
Color onSurface,
Color onBackground,
Color onError,
Brightness brightness) {
D.assert(primary != null);
D.assert(primaryVariant != null);
D.assert(secondary != null);
D.assert(secondaryVariant != null);
D.assert(surface != null);
D.assert(background != null);
D.assert(error != null);
D.assert(onPrimary != null);
D.assert(onSecondary != null);
D.assert(onSurface != null);
D.assert(onBackground != null);
D.assert(onError != null);
D.assert(brightness != null);
this.primary = primary;
this.primaryVariant = primaryVariant;
this.secondary = secondary;
this.secondaryVariant = secondaryVariant;
this.surface = surface;
this.background = background;
this.error = error;
this.onPrimary = onPrimary;
this.onSecondary = onSecondary;
this.onSurface = onSurface;
this.onBackground = onBackground;
this.onError = onError;
this.brightness = brightness;
}
public static ColorScheme light(
Color primary = null,
Color primaryVariant = null,
Color secondary = null,
Color secondaryVariant = null,
Color surface = null,
Color background = null,
Color error = null,
Color onPrimary = null,
Color onSecondary = null,
Color onSurface = null,
Color onBackground = null,
Color onError = null,
Brightness brightness = Brightness.light
) {
primary = primary ?? new Color(0xFF6200EE);
primaryVariant = primaryVariant ?? new Color(0xFF3700B3);
secondary = secondary ?? new Color(0xFF03AC6);
secondaryVariant = secondaryVariant ?? new Color(0xFF018786);
surface = surface ?? Colors.white;
background = background ?? Colors.white;
error = error ?? new Color(0xFFB00020);
onPrimary = onPrimary ?? Colors.white;
onSecondary = onSecondary ?? Colors.black;
onSurface = onSurface ?? Colors.black;
onBackground = onBackground ?? Colors.black;
onError = onError ?? Colors.white;
return new ColorScheme(
primary: primary,
primaryVariant: primaryVariant,
secondary: secondary,
secondaryVariant: secondaryVariant,
surface: surface,
background: background,
error: error,
onPrimary: onPrimary,
onSecondary: onSecondary,
onSurface: onSurface,
onBackground: onBackground,
onError: onError,
brightness: brightness
);
}
public static ColorScheme dark(
Color primary = null,
Color primaryVariant = null,
Color secondary = null,
Color secondaryVariant = null,
Color surface = null,
Color background = null,
Color error = null,
Color onPrimary = null,
Color onSecondary = null,
Color onSurface = null,
Color onBackground = null,
Color onError = null,
Brightness brightness = Brightness.dark
) {
primary = primary ?? new Color(0xFFBB86FC);
primaryVariant = primaryVariant ?? new Color(0xFF4B01D0);
secondary = secondary ?? new Color(0xFF03DAC6);
secondaryVariant = secondaryVariant ?? new Color(0xFF03DAC6);
surface = surface ?? Colors.black;
background = background ?? Colors.black;
error = error ?? new Color(0xFFB00020);
onPrimary = onPrimary ?? Colors.black;
onSecondary = onSecondary ?? Colors.black;
onSurface = onSurface ?? Colors.white;
onBackground = onBackground ?? Colors.white;
onError = onError ?? Colors.black;
return new ColorScheme(
primary: primary,
primaryVariant: primaryVariant,
secondary: secondary,
secondaryVariant: secondaryVariant,
surface: surface,
background: background,
error: error,
onPrimary: onPrimary,
onSecondary: onSecondary,
onSurface: onSurface,
onBackground: onBackground,
onError: onError,
brightness: brightness
);
}
public static ColorScheme fromSwatch(
MaterialColor primarySwatch = null,
Color primaryColorDark = null,
Color accentColor = null,
Color cardColor = null,
Color backgroundColor = null,
Color errorColor = null,
Brightness? brightness = Brightness.light) {
primarySwatch = primarySwatch ?? Colors.blue;
bool isDark = brightness == Brightness.dark;
bool primaryIsDark = _brightnessFor(primarySwatch) == Brightness.dark;
Color secondary = accentColor ?? (isDark ? Colors.tealAccent[200] : primarySwatch);
bool secondaryIsDark = _brightnessFor(secondary) == Brightness.dark;
return new ColorScheme(
primary: primarySwatch,
primaryVariant: primaryColorDark ?? (isDark ? Colors.black : primarySwatch[700]),
secondary: secondary,
secondaryVariant: isDark ? Colors.tealAccent[700] : primarySwatch[700],
surface: cardColor ?? (isDark ? Colors.grey[800] : Colors.white),
background: backgroundColor ?? (isDark ? Colors.grey[700] : primarySwatch[200]),
error: errorColor ?? Colors.red[700],
onPrimary: primaryIsDark ? Colors.white : Colors.black,
onSecondary: secondaryIsDark ? Colors.white : Colors.black,
onSurface: isDark ? Colors.white : Colors.black,
onBackground: primaryIsDark ? Colors.white : Colors.black,
onError: isDark ? Colors.black : Colors.white,
brightness: brightness ?? Brightness.light
);
}
static Brightness _brightnessFor(Color color) => ThemeData.estimateBrightnessForColor(color);
public readonly Color primary;
public readonly Color primaryVariant;
public readonly Color secondary;
public readonly Color secondaryVariant;
public readonly Color surface;
public readonly Color background;
public readonly Color error;
public readonly Color onPrimary;
public readonly Color onSecondary;
public readonly Color onSurface;
public readonly Color onBackground;
public readonly Color onError;
public readonly Brightness brightness;
public ColorScheme copyWith(
Color primary = null,
Color primaryVariant = null,
Color secondary = null,
Color secondaryVariant = null,
Color surface = null,
Color background = null,
Color error = null,
Color onPrimary = null,
Color onSecondary = null,
Color onSurface = null,
Color onBackground = null,
Color onError = null,
Brightness? brightness = null) {
return new ColorScheme(
primary: primary ?? this.primary,
primaryVariant: primaryVariant ?? this.primaryVariant,
secondary: secondary ?? this.secondary,
secondaryVariant: secondaryVariant ?? this.secondaryVariant,
surface: surface ?? this.surface,
background: background ?? this.background,
error: error ?? this.error,
onPrimary: onPrimary ?? this.onPrimary,
onSecondary: onSecondary ?? this.onSecondary,
onSurface: onSurface ?? this.onSurface,
onBackground: onBackground ?? this.onBackground,
onError: onError ?? this.onError,
brightness: brightness ?? this.brightness
);
}
public static ColorScheme lerp(ColorScheme a, ColorScheme b, double t) {
return new ColorScheme(
primary: Color.lerp(a.primary, b.primary, t),
primaryVariant: Color.lerp(a.primaryVariant, b.primaryVariant, t),
secondary: Color.lerp(a.secondary, b.secondary, t),
secondaryVariant: Color.lerp(a.secondaryVariant, b.secondaryVariant, t),
surface: Color.lerp(a.surface, b.surface, t),
background: Color.lerp(a.background, b.background, t),
error: Color.lerp(a.error, b.error, t),
onPrimary: Color.lerp(a.onPrimary, b.onPrimary, t),
onSecondary: Color.lerp(a.onSecondary, b.onSecondary, t),
onSurface: Color.lerp(a.onSurface, b.onSurface, t),
onBackground: Color.lerp(a.onBackground, b.onBackground, t),
onError: Color.lerp(a.onError, b.onError, t),
brightness: t < 0.5 ? a.brightness : b.brightness
);
}
public bool Equals(ColorScheme other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return other.primary == this.primary
&& other.primaryVariant == this.primaryVariant
&& other.secondary == this.secondary
&& other.secondaryVariant == this.secondaryVariant
&& other.surface == this.surface
&& other.background == this.background
&& other.error == this.error
&& other.onPrimary == this.onPrimary
&& other.onSecondary == this.onSecondary
&& other.onSurface == this.onSurface
&& other.onBackground == this.onBackground
&& other.onError == this.onError
&& other.brightness == this.brightness;
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((ColorScheme) obj);
}
public static bool operator ==(ColorScheme left, ColorScheme right) {
return Equals(left, right);
}
public static bool operator !=(ColorScheme left, ColorScheme right) {
return !Equals(left, right);
}
public override int GetHashCode() {
unchecked {
var hashCode = this.primary.GetHashCode();
hashCode = (hashCode * 397) ^ this.primaryVariant.GetHashCode();
hashCode = (hashCode * 397) ^ this.secondary.GetHashCode();
hashCode = (hashCode * 397) ^ this.secondaryVariant.GetHashCode();
hashCode = (hashCode * 397) ^ this.surface.GetHashCode();
hashCode = (hashCode * 397) ^ this.background.GetHashCode();
hashCode = (hashCode * 397) ^ this.error.GetHashCode();
hashCode = (hashCode * 397) ^ this.onPrimary.GetHashCode();
hashCode = (hashCode * 397) ^ this.onSecondary.GetHashCode();
hashCode = (hashCode * 397) ^ this.onSurface.GetHashCode();
hashCode = (hashCode * 397) ^ this.onBackground.GetHashCode();
hashCode = (hashCode * 397) ^ this.onError.GetHashCode();
hashCode = (hashCode * 397) ^ this.brightness.GetHashCode();
return hashCode;
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
ColorScheme defaultScheme = ColorScheme.light();
properties.add(new DiagnosticsProperty<Color>("primary", this.primary, defaultValue: defaultScheme.primary));
properties.add(new DiagnosticsProperty<Color>("primaryVariant", this.primaryVariant, defaultValue: defaultScheme.primaryVariant));
properties.add(new DiagnosticsProperty<Color>("secondary", this.secondary, defaultValue: defaultScheme.secondary));
properties.add(new DiagnosticsProperty<Color>("secondaryVariant", this.secondaryVariant, defaultValue: defaultScheme.secondaryVariant));
properties.add(new DiagnosticsProperty<Color>("surface", this.surface, defaultValue: defaultScheme.surface));
properties.add(new DiagnosticsProperty<Color>("background", this.background, defaultValue: defaultScheme.background));
properties.add(new DiagnosticsProperty<Color>("error", this.error, defaultValue: defaultScheme.error));
properties.add(new DiagnosticsProperty<Color>("onPrimary", this.onPrimary, defaultValue: defaultScheme.onPrimary));
properties.add(new DiagnosticsProperty<Color>("onSecondary", this.onSecondary, defaultValue: defaultScheme.onSecondary));
properties.add(new DiagnosticsProperty<Color>("onSurface", this.onSurface, defaultValue: defaultScheme.onSurface));
properties.add(new DiagnosticsProperty<Color>("onBackground", this.onBackground, defaultValue: defaultScheme.onBackground));
properties.add(new DiagnosticsProperty<Color>("onError", this.onError, defaultValue: defaultScheme.onError));
properties.add(new DiagnosticsProperty<Brightness>("brightness", this.brightness, defaultValue: defaultScheme.brightness));
}
}
}

11
Runtime/material/color_scheme.cs.meta


fileFormatVersion: 2
guid: a610420b7a8ec44bfa84e81a1e5ff449
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
Runtime/material/colors.cs.meta


fileFormatVersion: 2
guid: dfc0e036c07e1441d8dbd3158bb6f923
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
Runtime/material/constants.cs.meta


fileFormatVersion: 2
guid: 0364fdae877454fb1babca8f67c2561e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

51
Runtime/material/debug.cs


using Unity.UIWidgets.widgets;
using Unity.UIWidgets.foundation;
using System.Collections.Generic;
namespace Unity.UIWidgets.material {
public class MaterialDebug {
public static bool debugCheckHasMaterial(BuildContext context) {
D.assert(() => {
if (!(context.widget is Material) && context.ancestorWidgetOfExactType(typeof(Material)) == null) {
string message = "No Material widget found.";
message += context.widget.GetType() + " widgets require a Material widget ancestor.";
message += "In material design, most widgets are conceptually \"printed\" on " +
"a sheet of material. In Flutter\'s material library, that " +
"material is represented by the Material widget. It is the " +
"Material widget that renders ink splashes, for instance. " +
"Because of this, many material library widgets require that " +
"there be a Material widget in the tree above them.";
message += "To introduce a Material widget, you can either directly " +
"include one, or use a widget that contains Material itself, " +
"such as a Card, Dialog, Drawer, or Scaffold.";
message += "The specific widget that could not find a Material ancestor was:";
message += context.widget.toString();
List<Widget> ancestors = new List<Widget>();
context.visitAncestorElements((Element element) => {
ancestors.Add(element.widget);
return true;
});
if (ancestors.isNotEmpty()) {
message += "The ancestors of this widget were:";
foreach (Widget ancestor in ancestors)
message += "\n $ancestor";
} else {
message +="This widget is the root of the tree, so it has no " +
"ancestors, let alone a \"Material\" ancestor.";
}
throw new UIWidgetsError(message);
}
return true;
});
return true;
}
}
}

11
Runtime/material/debug.cs.meta


fileFormatVersion: 2
guid: 353f6a1d0791640349fe94187f15ad33
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

224
Runtime/material/ink_decoration.cs


using System.Runtime.InteropServices.WindowsRuntime;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.widgets;
using Unity.UIWidgets.ui;
using ImageUtils = Unity.UIWidgets.widgets.ImageUtils;
namespace Unity.UIWidgets.material {
public class Ink : StatefulWidget {
public Ink(
Key key = null,
EdgeInsets padding = null,
Color color = null,
Decoration decoration = null,
double? width = null,
double? height = null,
Widget child = null) : base(key: key) {
D.assert(padding == null || padding.isNonNegative);
D.assert(decoration == null || decoration.debugAssertIsValid());
D.assert(color == null || decoration == null,
"Cannot provide both a color and a decoration\n" +
"The color argument is just a shorthand for \"decoration: new BoxDecoration(color: color)\".");
decoration = decoration ?? (color != null ? new BoxDecoration(color: color) : null);
this.padding = padding;
this.width = width;
this.height = height;
this.child = child;
this.decoration = decoration;
}
public static Ink image(
Key key = null,
EdgeInsets padding = null,
ImageProvider image = null,
ColorFilter colorFilter = null,
BoxFit? fit = null,
Alignment alignment = null,
Rect centerSlice = null,
ImageRepeat repeat = ImageRepeat.noRepeat,
double? width = null,
double? height = null,
Widget child = null
) {
D.assert(padding == null || padding.isNonNegative);
D.assert(image != null);
D.assert(repeat != null);
alignment = alignment ?? Alignment.center;
Decoration decoration = new BoxDecoration(
image: new DecorationImage(image,
colorFilter: colorFilter,
fit: fit,
alignment: alignment,
centerSlice: centerSlice,
repeat: repeat)
);
return new Ink(
key: key,
padding: padding,
decoration: decoration,
width: width,
height: height,
child: child);
}
public readonly Widget child;
public readonly EdgeInsets padding;
public readonly Decoration decoration;
public readonly double? width;
public readonly double? height;
public EdgeInsets _paddingIncludingDecoration {
get {
if (this.decoration == null || this.decoration.padding == null)
return this.padding;
EdgeInsets decorationPadding = this.decoration.padding;
if (this.padding == null) {
return decorationPadding;
}
return this.padding.add(decorationPadding);
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<EdgeInsets>("padding", this.padding, defaultValue: null));
properties.add(new DiagnosticsProperty<Decoration>("bg", this.decoration, defaultValue: null));
}
public override State createState() => new _InkState();
}
class _InkState : State<Ink> {
InkDecoration _ink;
void _handleRemoved() {
this._ink = null;
}
public override void deactivate() {
this._ink?.dispose();
D.assert(this._ink == null);
base.deactivate();
}
public Widget _build(BuildContext context, BoxConstraints contraints) {
if (this._ink == null) {
this._ink = new InkDecoration(
decoration: this.widget.decoration,
configuration: ImageUtils.createLocalImageConfiguration(context),
controller: Material.of(context),
referenceBox: (RenderBox)context.findRenderObject(),
onRemoved: this._handleRemoved);
}
else {
this._ink.decoration = this.widget.decoration;
this._ink.configuration = ImageUtils.createLocalImageConfiguration(context);
}
Widget current = this.widget.child;
EdgeInsets effectivePadding = this.widget._paddingIncludingDecoration;
if (effectivePadding != null)
current = new Padding(
padding: effectivePadding,
child: current);
return current;
}
public override Widget build(BuildContext context) {
D.assert(MaterialDebug.debugCheckHasMaterial(context));
Widget result = new LayoutBuilder(
builder: this._build);
if (this.widget.width != null || this.widget.height != null) {
result = new SizedBox(
width: this.widget.width,
height: this.widget.height,
child: result);
}
return result;
}
}
class InkDecoration : InkFeature {
public InkDecoration(
Decoration decoration = null,
ImageConfiguration configuration = null,
MaterialInkController controller = null,
RenderBox referenceBox = null,
VoidCallback onRemoved = null
) : base(controller: controller, referenceBox: referenceBox, onRemoved: onRemoved) {
D.assert(configuration != null);
D.assert(decoration != null);
D.assert(controller != null);
D.assert(referenceBox != null);
this.decoration = decoration;
this.controller.addInkFeature(this);
}
BoxPainter _painter;
public Decoration decoration {
get { return this._decoration; }
set {
if (value == this._decoration)
return;
this._decoration = value;
this._painter?.Dispose();
this._painter = this._decoration?.createBoxPainter(this._handleChanged);
this.controller.markNeedsPaint();
}
}
Decoration _decoration;
public ImageConfiguration configuration {
get { return this._configuration; }
set {
D.assert(value != null);
if (value == this._configuration)
return;
this._configuration = value;
this.controller.markNeedsPaint();
}
}
ImageConfiguration _configuration;
void _handleChanged() {
this.controller.markNeedsPaint();
}
public override void dispose() {
this._painter?.Dispose();
base.dispose();
}
protected override void paintFeature(Canvas canvas, Matrix3 transform) {
if (this._painter == null)
return;
Offset originOffset = transform.getAsTranslation();
ImageConfiguration sizedConfiguration = this.configuration.copyWith(
size: this.referenceBox.size);
if (originOffset == null) {
canvas.save();
canvas.concat(transform);
this._painter.paint(canvas, Offset.zero, sizedConfiguration);
canvas.restore();
}
else {
this._painter.paint(canvas, originOffset, sizedConfiguration);
}
}
}
}

11
Runtime/material/ink_decoration.cs.meta


fileFormatVersion: 2
guid: 2aa14ff76c10f4d459b55674f0a2b57f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

129
Runtime/material/ink_highlight.cs


using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Color = Unity.UIWidgets.ui.Color;
namespace Unity.UIWidgets.material {
public class InkHighlight : InteractiveInkFeature {
public InkHighlight(
MaterialInkController controller = null,
RenderBox referenceBox = null,
Color color = null,
BoxShape shape = BoxShape.rectangle,
BorderRadius borderRadius = null,
ShapeBorder customBorder = null,
RectCallback rectCallback = null,
VoidCallback onRemoved = null) : base(
controller: controller,
referenceBox: referenceBox,
color: color,
onRemoved: onRemoved) {
D.assert(color != null);
D.assert(controller != null);
D.assert(referenceBox != null);
this._shape = shape;
this._borderRadius = borderRadius ?? BorderRadius.zero;
this._customBorder = customBorder;
this._rectCallback = rectCallback;
this._alphaController = new AnimationController(
duration: InkHighlightUtils._kHighlightFadeDuration,
vsync: controller.vsync);
this._alphaController.addListener(controller.markNeedsPaint);
this._alphaController.addStatusListener(this._handleAlphaStatusChanged);
this._alphaController.forward();
this._alpha = this._alphaController.drive(new IntTween(
begin: 0, end: color.alpha));
this.controller.addInkFeature(this);
}
readonly BoxShape _shape;
readonly BorderRadius _borderRadius;
readonly ShapeBorder _customBorder;
readonly RectCallback _rectCallback;
Animation<int> _alpha;
AnimationController _alphaController;
public bool active {
get { return this._active; }
}
bool _active = true;
public void activate() {
this._active = true;
this._alphaController.forward();
}
public void deactivate() {
this._active = false;
this._alphaController.reverse();
}
void _handleAlphaStatusChanged(AnimationStatus status) {
if (status == AnimationStatus.dismissed && !this._active)
this.dispose();
}
public override void dispose() {
this._alphaController.dispose();
base.dispose();
}
void _paintHighlight(Canvas canvas, Rect rect, Paint paint) {
D.assert(this._shape != null);
canvas.save();
if (this._customBorder != null) {
canvas.clipPath(this._customBorder.getOuterPath(rect));
}
switch (this._shape) {
case BoxShape.circle: {
canvas.drawCircle(rect.center, Material.defaultSplashRadius, paint);
break;
}
case BoxShape.rectangle: {
if (this._borderRadius != BorderRadius.zero) {
RRect clipRRect = RRect.fromRectAndCorners(
rect,
topLeft: this._borderRadius.topLeft,
topRight: this._borderRadius.topRight,
bottomLeft: this._borderRadius.bottomLeft,
bottomRight: this._borderRadius.bottomRight);
canvas.drawRRect(clipRRect, paint);
}
else {
canvas.drawRect(rect, paint);
}
break;
}
}
canvas.restore();
}
protected override void paintFeature(Canvas canvas, Matrix3 transform) {
Paint paint = new Paint();
paint.color = this.color.withAlpha(this._alpha.value);
Offset originOffset = transform.getAsTranslation();
Rect rect = this._rectCallback != null ? this._rectCallback() : Offset.zero & this.referenceBox.size;
if (originOffset == null) {
canvas.save();
canvas.concat(transform);
this._paintHighlight(canvas, rect, paint);
canvas.restore();
}
else {
this._paintHighlight(canvas, rect.shift(originOffset), paint);
}
}
}
}

11
Runtime/material/ink_highlight.cs.meta


fileFormatVersion: 2
guid: 96f34a8540bb74c7687149b4b2514998
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

170
Runtime/material/ink_splash.cs


using System;
using System.Runtime.CompilerServices;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.material {
public class _InkSplashFactory : InteractiveInkFeatureFactory {
public _InkSplashFactory() {
}
public override InteractiveInkFeature create(
MaterialInkController controller = null,
RenderBox referenceBox = null,
Offset position = null,
Color color = null,
bool containedInkWell = false,
RectCallback rectCallback = null,
BorderRadius borderRadius = null,
ShapeBorder customBorder = null,
double? radius = null,
VoidCallback onRemoved = null
) {
return new InkSplash(
controller: controller,
referenceBox: referenceBox,
position: position,
color: color,
containedInkWell: containedInkWell,
rectCallback: rectCallback,
borderRadius: borderRadius,
customBorder: customBorder,
radius: radius,
onRemoved: onRemoved);
}
}
public class InkSplash : InteractiveInkFeature {
public InkSplash(
MaterialInkController controller = null,
RenderBox referenceBox = null,
Offset position = null,
Color color = null,
bool containedInkWell = false,
RectCallback rectCallback = null,
BorderRadius borderRadius = null,
ShapeBorder customBorder = null,
double? radius = null,
VoidCallback onRemoved = null) : base(
controller: controller,
referenceBox: referenceBox,
color: color,
onRemoved: onRemoved) {
D.assert(controller != null);
D.assert(referenceBox != null);
this._position = position;
this._borderRadius = borderRadius ?? BorderRadius.zero;
this._customBorder = customBorder;
this._targetRadius =
radius ?? InkSplashUtils._getTargetRadius(referenceBox, containedInkWell, rectCallback, position);
this._clipCallback = InkSplashUtils._getClipCallback(referenceBox, containedInkWell, rectCallback);
this._repositionToReferenceBox = !containedInkWell;
D.assert(this._borderRadius != null);
this._radiusController = new AnimationController(duration:
InkSplashUtils._kUnconfirmedSplashDuration,
vsync: controller.vsync);
this._radiusController.addListener(controller.markNeedsPaint);
this._radiusController.forward();
this._radius = this._radiusController.drive(new DoubleTween(
begin: InkSplashUtils._kSplashInitialSize,
end: this._targetRadius));
this._alphaController = new AnimationController(duration:
InkSplashUtils._kSplashFadeDuration,
vsync: controller.vsync);
this._alphaController.addListener(controller.markNeedsPaint);
this._alphaController.addStatusListener(this._handleAlphaStatusChanged);
this._alpha = this._alphaController.drive(new IntTween(
begin: color.alpha,
end: 0));
controller.addInkFeature(this);
}
readonly Offset _position;
readonly BorderRadius _borderRadius;
readonly ShapeBorder _customBorder;
readonly double _targetRadius;
readonly RectCallback _clipCallback;
readonly bool _repositionToReferenceBox;
Animation<double> _radius;
AnimationController _radiusController;
Animation<int> _alpha;
AnimationController _alphaController;
public static InteractiveInkFeatureFactory splashFactory = new _InkSplashFactory();
public override void confirm() {
int duration = (this._targetRadius / InkSplashUtils._kSplashConfirmedVelocity).floor();
this._radiusController.duration = new TimeSpan(0, 0, 0, 0, duration);
this._radiusController.forward();
this._alphaController.forward();
}
public override void cancel() {
this._alphaController?.forward();
}
void _handleAlphaStatusChanged(AnimationStatus status) {
if (status == AnimationStatus.completed)
this.dispose();
}
public override void dispose() {
this._radiusController.dispose();
this._alphaController.dispose();
this._alphaController = null;
base.dispose();
}
protected override void paintFeature(Canvas canvas, Matrix3 transform) {
Paint paint = new Paint();
paint.color = this.color.withAlpha(this._alpha.value);
Offset center = this._position;
if (this._repositionToReferenceBox)
center = Offset.lerp(center, this.referenceBox.size.center(Offset.zero), this._radiusController.value);
Offset originOffset = transform.getAsTranslation();
canvas.save();
if (originOffset == null) {
canvas.concat(transform);
}
else {
canvas.translate(originOffset.dx, originOffset.dy);
}
if (this._clipCallback != null) {
Rect rect = this._clipCallback();
if (this._customBorder != null) {
canvas.clipPath(this._customBorder.getOuterPath(rect));
}
else if (this._borderRadius != BorderRadius.zero) {
canvas.clipRRect(RRect.fromRectAndCorners(
rect,
topLeft: this._borderRadius.topLeft,
topRight: this._borderRadius.topRight,
bottomLeft: this._borderRadius.bottomLeft,
bottomRight: this._borderRadius.bottomRight));
}
else {
canvas.clipRect(rect);
}
}
//todo xingwei.zhu: remove this condition when drawCircle bug fixed (when radius.value == 0)
if (this._radius.value != 0)
canvas.drawCircle(center, this._radius.value, paint);
canvas.restore();
}
}
}

11
Runtime/material/ink_splash.cs.meta


fileFormatVersion: 2
guid: 068260026dcf947b0af4c9d7f706ab97
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

359
Runtime/material/ink_well.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using Color = Unity.UIWidgets.ui.Color;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace Unity.UIWidgets.material {
public abstract class InteractiveInkFeature : InkFeature {
public InteractiveInkFeature(
MaterialInkController controller = null,
RenderBox referenceBox = null,
Color color = null,
VoidCallback onRemoved = null
) : base(controller: controller, referenceBox: referenceBox, onRemoved: onRemoved) {
D.assert(controller != null);
D.assert(referenceBox != null);
this._color = color;
}
public virtual void confirm() {}
public virtual void cancel() {}
public Color color {
get { return this._color; }
set {
if (value == this._color) {
return;
}
this._color = value;
this.controller.markNeedsPaint();
}
}
Color _color;
}
public abstract class InteractiveInkFeatureFactory {
public InteractiveInkFeatureFactory() {}
public abstract InteractiveInkFeature create(
MaterialInkController controller = null,
RenderBox referenceBox = null,
Offset position = null,
Color color = null,
bool containedInkWell = false,
RectCallback rectCallback = null,
BorderRadius borderRadius = null,
ShapeBorder customBorder = null,
double? radius = null,
VoidCallback onRemoved = null);
}
public class InkResponse : StatefulWidget {
public InkResponse(
Key key = null,
Widget child = null,
GestureTapCallback onTap = null,
GestureTapDownCallback onTapDown = null,
GestureTapCancelCallback onTapCancel = null,
GestureTapCallback onDoubleTap = null,
GestureLongPressCallback onLongPress = null,
ValueChanged<bool> onHighlightChanged = null,
bool containedInkWell = false,
BoxShape highlightShape = BoxShape.circle,
double? radius = null,
BorderRadius borderRadius = null,
ShapeBorder customBorder = null,
Color highlightColor = null,
Color splashColor = null,
InteractiveInkFeatureFactory splashFactory = null) : base(key: key) {
this.child = child;
this.onTap = onTap;
this.onTapDown = onTapDown;
this.onTapCancel = onTapCancel;
this.onDoubleTap = onDoubleTap;
this.onLongPress = onLongPress;
this.onHighlightChanged = onHighlightChanged;
this.containedInkWell = containedInkWell;
this.highlightShape = highlightShape;
this.radius = radius;
this.borderRadius = borderRadius;
this.customBorder = customBorder;
this.highlightColor = highlightColor;
this.splashColor = splashColor;
this.splashFactory = splashFactory;
}
public readonly Widget child;
public readonly GestureTapCallback onTap;
public readonly GestureTapDownCallback onTapDown;
public readonly GestureTapCancelCallback onTapCancel;
public readonly GestureTapCallback onDoubleTap;
public readonly GestureLongPressCallback onLongPress;
public readonly ValueChanged<bool> onHighlightChanged;
public readonly bool containedInkWell;
public readonly BoxShape highlightShape;
public readonly double? radius;
public readonly BorderRadius borderRadius;
public readonly ShapeBorder customBorder;
public readonly Color highlightColor;
public readonly Color splashColor;
public readonly InteractiveInkFeatureFactory splashFactory;
public virtual RectCallback getRectCallback(RenderBox referenceBox) => null;
public virtual bool debugCheckContext(BuildContext context) {
D.assert(MaterialDebug.debugCheckHasMaterial(context));
return true;
}
public override State createState() => new _InkResponseState<InkResponse>();
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
List<string> gestures = new List<string>();
if (this.onTap != null)
gestures.Add("tap");
if (this.onDoubleTap != null)
gestures.Add("double tap");
if (this.onLongPress != null)
gestures.Add("long press");
if (this.onTapDown != null)
gestures.Add("tap down");
if (this.onTapCancel != null)
gestures.Add("tap cancel");
properties.add(new EnumerableProperty<string>("gestures", gestures, ifEmpty: "<none>"));
properties.add(new DiagnosticsProperty<bool>("containedInkWell", this.containedInkWell, level: DiagnosticLevel.fine));
properties.add(new DiagnosticsProperty<BoxShape>(
"highlightShape",
this.highlightShape,
description: (this.containedInkWell ? "clipped to" : "") + this.highlightShape,
showName: false
));
}
}
public class _InkResponseState<T> : AutomaticKeepAliveClientMixin<T> where T : InkResponse {
HashSet<InteractiveInkFeature> _splashes;
InteractiveInkFeature _currentSplash;
InkHighlight _lastHighlight;
protected override bool wantKeepAlive {
get { return this._lastHighlight != null || (this._splashes != null && this._splashes.isNotEmpty()); }
}
public void updateHighlight(bool value) {
if (value == (this._lastHighlight != null && this._lastHighlight.active))
return;
if (value) {
if (this._lastHighlight == null) {
RenderBox referenceBox = (RenderBox)this.context.findRenderObject();
this._lastHighlight = new InkHighlight(
controller: Material.of(this.context),
referenceBox: referenceBox,
color: this.widget.highlightColor ?? Theme.of(this.context).highlightColor,
shape: this.widget.highlightShape,
borderRadius: this.widget.borderRadius,
customBorder: this.widget.customBorder,
rectCallback: this.widget.getRectCallback(referenceBox),
onRemoved: this._handleInkHighlightRemoval);
this.updateKeepAlive();
}
else {
this._lastHighlight.activate();
}
}
else {
this._lastHighlight.deactivate();
}
D.assert(value == (this._lastHighlight != null && this._lastHighlight.active));
if (this.widget.onHighlightChanged != null)
this.widget.onHighlightChanged(value);
}
void _handleInkHighlightRemoval() {
D.assert(this._lastHighlight != null);
this._lastHighlight = null;
this.updateKeepAlive();
}
InteractiveInkFeature _createInkFeature(TapDownDetails details) {
MaterialInkController inkController = Material.of(this.context);
RenderBox referenceBox = (RenderBox) this.context.findRenderObject();
Offset position = referenceBox.globalToLocal(details.globalPosition);
Color color = this.widget.splashColor ?? Theme.of(this.context).splashColor;
RectCallback rectCallback = this.widget.containedInkWell ? this.widget.getRectCallback(referenceBox) : null;
BorderRadius borderRadius = this.widget.borderRadius;
ShapeBorder customBorder = this.widget.customBorder;
InteractiveInkFeature splash = null;
VoidCallback onRemoved = () => {
if (this._splashes != null) {
D.assert(this._splashes.Contains(splash));
this._splashes.Remove(splash);
if (this._currentSplash == splash)
this._currentSplash = null;
this.updateKeepAlive();
}
};
splash = (this.widget.splashFactory ?? Theme.of(this.context).splashFactory).create(
controller: inkController,
referenceBox: referenceBox,
position: position,
color: color,
containedInkWell: this.widget.containedInkWell,
rectCallback: rectCallback,
radius: this.widget.radius,
borderRadius: borderRadius,
customBorder: customBorder,
onRemoved: onRemoved);
return splash;
}
void _handleTapDown(TapDownDetails details) {
InteractiveInkFeature splash = this._createInkFeature(details);
this._splashes = this._splashes ?? new HashSet<InteractiveInkFeature>();
this._splashes.Add(splash);
this._currentSplash = splash;
if (this.widget.onTapDown != null) {
this.widget.onTapDown(details);
}
this.updateKeepAlive();
this.updateHighlight(true);
}
void _handleTap(BuildContext context) {
this._currentSplash?.confirm();
this._currentSplash = null;
this.updateHighlight(false);
if (this.widget.onTap != null) {
this.widget.onTap();
}
}
void _handleTapCancel() {
this._currentSplash?.cancel();
this._currentSplash = null;
if (this.widget.onTapCancel != null) {
this.widget.onTapCancel();
}
this.updateHighlight(false);
}
void _handleDoubleTap() {
this._currentSplash?.confirm();
this._currentSplash = null;
if (this.widget.onDoubleTap != null) {
this.widget.onDoubleTap();
}
}
void _handleLongPress(BuildContext context) {
this._currentSplash?.confirm();
this._currentSplash = null;
if (this.widget.onLongPress != null) {
this.widget.onLongPress();
}
}
public override void deactivate() {
if (this._splashes != null) {
HashSet<InteractiveInkFeature> splashes = this._splashes;
this._splashes = null;
foreach (InteractiveInkFeature splash in splashes)
splash.dispose();
this._currentSplash = null;
}
D.assert(this._currentSplash == null);
this._lastHighlight?.dispose();
this._lastHighlight = null;
base.deactivate();
}
public override Widget build(BuildContext context) {
D.assert(this.widget.debugCheckContext(context));
base.build(context);
ThemeData themeData = Theme.of(context);
if (this._lastHighlight != null)
this._lastHighlight.color = this.widget.highlightColor ?? themeData.highlightColor;
if (this._currentSplash != null)
this._currentSplash.color = this.widget.splashColor ?? themeData.splashColor;
bool enabled = this.widget.onTap != null || this.widget.onDoubleTap != null ||
this.widget.onLongPress != null;
return new GestureDetector(
onTapDown: enabled? (GestureTapDownCallback)this._handleTapDown : null,
onTap: enabled? (GestureTapCallback)(() => this._handleTap(context)) : null,
onTapCancel: enabled? (GestureTapCancelCallback)this._handleTapCancel : null,
onDoubleTap: this.widget.onDoubleTap != null ? (GestureDoubleTapCallback)this._handleDoubleTap : null,
onLongPress: this.widget.onLongPress != null ? (GestureLongPressCallback)(() => this._handleLongPress(context)) : null,
behavior: HitTestBehavior.opaque,
child: this.widget.child
);
}
}
public class InkWell : InkResponse {
public InkWell(
Key key = null,
Widget child = null,
GestureTapCallback onTap = null,
GestureTapCallback onDoubleTap = null,
GestureLongPressCallback onLongPress = null,
GestureTapDownCallback onTapDown = null,
GestureTapCancelCallback onTapCancel = null,
ValueChanged<bool> onHighlightChanged = null,
Color highlightColor = null,
Color splashColor = null,
InteractiveInkFeatureFactory splashFactory = null,
double? radius = null,
BorderRadius borderRadius = null,
ShapeBorder customBorder = null
) : base(key: key,
child: child,
onTap: onTap,
onDoubleTap: onDoubleTap,
onLongPress: onLongPress,
onTapDown: onTapDown,
onTapCancel: onTapCancel,
onHighlightChanged: onHighlightChanged,
containedInkWell: true,
highlightColor: highlightColor,
splashColor: splashColor,
splashFactory: splashFactory,
radius: radius,
borderRadius: borderRadius,
customBorder: customBorder){}
}
}

11
Runtime/material/ink_well.cs.meta


fileFormatVersion: 2
guid: 9a7302f1a187741b88618822daf7a657
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

497
Runtime/material/material.cs


using System.Collections.Generic;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.widgets;
using System;
using Unity.UIWidgets.animation;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
public delegate Rect RectCallback();
public enum MaterialType {
canvas,
card,
circle,
button,
transparency
}
public interface MaterialInkController {
Color color { get; set; }
TickerProvider vsync { get; }
void addInkFeature(InkFeature feature);
void markNeedsPaint();
}
public class Material : StatefulWidget {
public Material(
Key key = null,
MaterialType type = MaterialType.canvas,
double elevation = 0.0,
Color color = null,
Color shadowColor = null,
TextStyle textStyle = null,
BorderRadius borderRadius = null,
ShapeBorder shape = null,
Clip clipBehavior = Clip.none,
TimeSpan? animationDuration = null,
Widget child = null
) : base(key: key) {
D.assert(type != null);
D.assert(elevation != null);
D.assert(!(shape != null && borderRadius != null));
D.assert(type != MaterialType.circle && (borderRadius != null || shape != null));
D.assert(clipBehavior != null);
this.type = type;
this.elevation = elevation;
this.color = color;
this.shadowColor = shadowColor ?? new Color(0xFF000000);
this.textStyle = textStyle;
this.borderRadius = borderRadius;
this.shape = shape;
this.clipBehavior = clipBehavior;
this.animationDuration = animationDuration ?? Constants.kThemeChangeDuration;
this.child = child;
}
public readonly Widget child;
public readonly MaterialType type;
public readonly double elevation;
public readonly Color color;
public readonly Color shadowColor;
public readonly TextStyle textStyle;
public readonly ShapeBorder shape;
public readonly Clip clipBehavior;
public readonly TimeSpan animationDuration;
public readonly BorderRadius borderRadius;
public static MaterialInkController of(BuildContext context) {
_RenderInkFeatures result = (_RenderInkFeatures) context.ancestorRenderObjectOfType(new TypeMatcher<_RenderInkFeatures>());
return result;
}
public override State createState() => new _MaterialState();
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new EnumProperty<MaterialType>("type", this.type));
properties.add(new DoubleProperty("elevation", this.elevation, defaultValue: 0.0));
properties.add(new DiagnosticsProperty<Color>("color", this.color, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("shadowColor", this.shadowColor, defaultValue: new Color(0xFF000000)));
this.textStyle?.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", this.shape, defaultValue: null));
properties.add(new EnumProperty<BorderRadius>("borderRadius", this.borderRadius, defaultValue: null));
}
public static double defaultSplashRadius = 35.0;
}
class _MaterialState : TickerProviderStateMixin<Material> {
readonly GlobalKey _inkFeatureRenderer = GlobalKey.key(debugLabel:"ink renderer");
Color _getBackgroundColor(BuildContext context) {
if (this.widget.color != null)
return this.widget.color;
switch (this.widget.type) {
case MaterialType.canvas:
return Theme.of(context).canvasColor;
case MaterialType.card:
return Theme.of(context).cardColor;
default:
return null;
}
}
public override Widget build(BuildContext context) {
Color backgroundColor = this._getBackgroundColor(context);
D.assert(backgroundColor != null || this.widget.type == MaterialType.transparency);
Widget contents = this.widget.child;
if (contents != null) {
contents = new AnimatedDefaultTextStyle(
style: this.widget.textStyle ?? Theme.of(context).textTheme.body1,
duration: this.widget.animationDuration,
child: contents
);
}
contents = new NotificationListener<LayoutChangedNotification>(
onNotification: (LayoutChangedNotification notification) => {
_RenderInkFeatures renderer = (_RenderInkFeatures) this._inkFeatureRenderer.currentContext.findRenderObject();
renderer._didChangeLayout();
return true;
},
child: new _InkFeatures(
key: this._inkFeatureRenderer,
color: backgroundColor,
child: contents,
vsync: this
)
);
if (this.widget.type == MaterialType.canvas && this.widget.shape == null &&
this.widget.borderRadius == null) {
return new AnimatedPhysicalModel(
curve: Curves.fastOutSlowIn,
duration: this.widget.animationDuration,
shape: BoxShape.rectangle,
clipBehavior: this.widget.clipBehavior,
borderRadius: BorderRadius.zero,
elevation: this.widget.elevation,
color: backgroundColor,
shadowColor: this.widget.shadowColor,
animateColor: false,
child: contents
);
}
ShapeBorder shape = this._getShape();
if (this.widget.type == MaterialType.transparency) {
D.assert(false, "material widget is not completely implemented yet.");
return null;
// return this._transparentInterior(
// shape: shape,
// clipBehavior: this.widget.clipBehavior,
// contents: contents);
}
return new _MaterialInterior(
curve: Curves.fastOutSlowIn,
duration: this.widget.animationDuration,
shape: shape,
clipBehavior: this.widget.clipBehavior,
elevation: this.widget.elevation,
color: backgroundColor,
shadowColor: this.widget.shadowColor,
child: contents
);
}
ShapeBorder _getShape() {
if (this.widget.shape != null)
return this.widget.shape;
if (this.widget.borderRadius != null)
return new RoundedRectangleBorder(borderRadius: this.widget.borderRadius);
switch (this.widget.type) {
case MaterialType.canvas:
case MaterialType.transparency:
return new RoundedRectangleBorder();
case MaterialType.card:
case MaterialType.button:
return new RoundedRectangleBorder(
borderRadius: this.widget.borderRadius ?? MaterialUtils.kMaterialEdges[this.widget.type]);
case MaterialType.circle:
return new CircleBorder();
}
return new RoundedRectangleBorder();
}
}
public class _RenderInkFeatures : RenderProxyBox, MaterialInkController {
public _RenderInkFeatures(
RenderBox child = null,
TickerProvider vsync = null,
Color color = null) : base(child: child) {
D.assert(vsync != null);
this._vsync = vsync;
this._color = color;
}
public TickerProvider vsync {
get { return this._vsync; }
}
readonly TickerProvider _vsync;
public Color color {
get { return this._color; }
set { this._color = value; }
}
Color _color;
List<InkFeature> _inkFeatures;
public void addInkFeature(InkFeature feature) {
D.assert(!feature._debugDisposed);
D.assert(feature._controller == this);
this._inkFeatures = this._inkFeatures ?? new List<InkFeature>();
D.assert(!this._inkFeatures.Contains(feature));
this._inkFeatures.Add(feature);
this.markNeedsPaint();
}
public void _removeFeature(InkFeature feature) {
D.assert(this._inkFeatures != null);
this._inkFeatures.Remove(feature);
this.markNeedsPaint();
}
public void _didChangeLayout() {
if (this._inkFeatures != null && this._inkFeatures.isNotEmpty())
this.markNeedsPaint();
}
protected override bool hitTestSelf(Offset position) => true;
public override void paint(PaintingContext context, Offset offset) {
if (this._inkFeatures != null && this._inkFeatures.isNotEmpty()) {
Canvas canvas = context.canvas;
canvas.save();
canvas.translate(offset.dx, offset.dy);
canvas.clipRect(Offset.zero & this.size);
foreach (InkFeature inkFeature in this._inkFeatures)
inkFeature._paint(canvas);
canvas.restore();
}
base.paint(context, offset);
}
}
public class _InkFeatures : SingleChildRenderObjectWidget {
public _InkFeatures(
Key key = null,
Color color = null,
TickerProvider vsync = null,
Widget child = null) : base(key: key, child: child) {
D.assert(vsync != null);
this.color = color;
this.vsync = vsync;
}
public readonly Color color;
public readonly TickerProvider vsync;
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderInkFeatures(
color: this.color,
vsync: this.vsync);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
_RenderInkFeatures _renderObject = (_RenderInkFeatures) renderObject;
_renderObject.color = this.color;
D.assert(this.vsync == _renderObject.vsync);
}
}
public abstract class InkFeature {
public InkFeature(
MaterialInkController controller = null,
RenderBox referenceBox = null,
VoidCallback onRemoved = null) {
D.assert(controller != null);
D.assert(referenceBox != null);
this._controller = (_RenderInkFeatures)controller;
this.referenceBox = referenceBox;
this.onRemoved = onRemoved;
}
public MaterialInkController controller {
get { return this._controller; }
}
public _RenderInkFeatures _controller;
public readonly RenderBox referenceBox;
public readonly VoidCallback onRemoved;
public bool _debugDisposed = false;
public virtual void dispose() {
D.assert(!this._debugDisposed);
D.assert(() => {
this._debugDisposed = true;
return true;
});
this._controller._removeFeature(this);
if (this.onRemoved != null)
this.onRemoved();
}
public void _paint(Canvas canvas) {
D.assert(this.referenceBox.attached);
D.assert(!this._debugDisposed);
List<RenderObject> descendants = new List<RenderObject> { this.referenceBox };
RenderObject node = this.referenceBox;
while (node != this._controller) {
node = (RenderObject)node.parent;
D.assert(node != null);
descendants.Add(node);
}
Matrix3 transform = Matrix3.I();
D.assert(descendants.Count >= 2);
for(int index = descendants.Count - 1; index > 0; index -= 1)
descendants[index].applyPaintTransform(descendants[index - 1], transform);
this.paintFeature(canvas, transform);
}
protected abstract void paintFeature(Canvas canvas, Matrix3 transform);
public string toString() => this.GetType() + "";
}
public class ShapeBorderTween : Tween<ShapeBorder> {
public ShapeBorderTween(
ShapeBorder begin = null,
ShapeBorder end = null) : base(begin: begin, end: end) {}
public override ShapeBorder lerp(double t) {
return ShapeBorder.lerp(this.begin, this.end, t);
}
}
public class _MaterialInterior : ImplicitlyAnimatedWidget {
public _MaterialInterior(
Key key = null,
Widget child = null,
ShapeBorder shape = null,
Clip clipBehavior = Clip.none,
double? elevation = null,
Color color = null,
Color shadowColor = null,
Curve curve = null,
TimeSpan? duration = null
) : base(key : key, curve : curve ?? Curves.linear, duration : duration){
D.assert(child != null);
D.assert(shape != null);
D.assert(elevation != null);
D.assert(color != null);
D.assert(shadowColor != null);
D.assert(duration != null);
this.child = child;
this.shape = shape;
this.clipBehavior = clipBehavior;
this.elevation = elevation ?? 0.0;
this.color = color;
this.shadowColor = shadowColor;
}
public readonly Widget child;
public readonly ShapeBorder shape;
public readonly Clip clipBehavior;
public readonly double elevation;
public readonly Color color;
public readonly Color shadowColor;
public override State createState() => new _MaterialInteriorState();
public override void debugFillProperties(DiagnosticPropertiesBuilder description) {
base.debugFillProperties(description);
description.add(new DiagnosticsProperty<ShapeBorder>("shape", this.shape));
description.add(new DoubleProperty("elevation", this.elevation));
description.add(new DiagnosticsProperty<Color>("color", this.color));
description.add(new DiagnosticsProperty<Color>("shadowColor", this.shadowColor));
}
}
public class _MaterialInteriorState : AnimatedWidgetBaseState<_MaterialInterior> {
DoubleTween _elevation;
ColorTween _shadowColor;
ShapeBorderTween _border;
protected override void forEachTween(ITweenVisitor visitor) {
this._elevation = (DoubleTween) visitor.visit(this, this._elevation, this.widget.elevation,
(double value) => new DoubleTween(begin: value, end: value));
this._shadowColor = (ColorTween) visitor.visit(this, this._shadowColor, this.widget.shadowColor,
(Color value) => new ColorTween(begin: value));
this._border = (ShapeBorderTween) visitor.visit(this, this._border, this.widget.shape,
(ShapeBorder value) => new ShapeBorderTween(begin: value));
}
public override Widget build(BuildContext context) {
ShapeBorder shape = this._border.evaluate(this.animation);
return new PhysicalShape(
child : new _ShapeBorderPaint(
child : this.widget.child,
shape: shape),
clipper: new ShapeBorderClipper(
shape: shape),
clipBehavior: this.widget.clipBehavior,
elevation: this._elevation.evaluate(this.animation),
color: this.widget.color,
shadowColor: this._shadowColor.evaluate(this.animation)
);
}
}
class _ShapeBorderPaint : StatelessWidget {
public _ShapeBorderPaint(
Widget child = null,
ShapeBorder shape = null) {
D.assert(child != null);
D.assert(shape != null);
this.child = child;
this.shape = shape;
}
public readonly Widget child;
public readonly ShapeBorder shape;
public override Widget build(BuildContext context) {
return new CustomPaint(
child :this.child,
foregroundPainter: new _ShapeBorderPainter(this.shape));
}
}
class _ShapeBorderPainter : CustomPainter {
public _ShapeBorderPainter (
ShapeBorder border = null,
Listenable repaint = null) : base(repaint) {
this.border = border;
}
public readonly ShapeBorder border;
public override void paint(Canvas canvas, Size size) {
this.border.paint(canvas, Offset.zero & size);
}
public override bool shouldRepaint(CustomPainter oldDelegate) {
_ShapeBorderPainter _oldDelegate = (_ShapeBorderPainter) oldDelegate;
return _oldDelegate.border != this.border;
}
}
}

11
Runtime/material/material.cs.meta


fileFormatVersion: 2
guid: 7c1f7bd49df00452d9a3be75a9e7b213
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

133
Runtime/material/material_button.cs


using System;
using System.Runtime.CompilerServices;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
public class MaterialButton : StatelessWidget {
public MaterialButton(
Key key = null,
VoidCallback onPressed = null,
ValueChanged<bool> onHighlightChanged = null,
ButtonTextTheme? textTheme = null,
Color textColor = null,
Color disabledTextColor = null,
Color color = null,
Color disabledColor = null,
Color highlightColor = null,
Color splashColor = null,
Brightness? colorBrightness = null,
double? elevation = null,
double? highlightElevation = null,
double? disabledElevation = null,
EdgeInsets padding = null,
ShapeBorder shape = null,
Clip clipBehavior = Clip.none,
MaterialTapTargetSize? materialTapTargetSize = null,
TimeSpan? animationDuration = null,
double? minWidth = null,
double? height = null,
Widget child = null
) : base(key : key) {
D.assert(onPressed != null);
this.onPressed = onPressed;
this.onHighlightChanged = onHighlightChanged;
this.textTheme = textTheme;
this.textColor = textColor;
this.disabledTextColor = disabledTextColor;
this.color = color;
this.disabledColor = disabledColor;
this.highlightColor = highlightColor;
this.splashColor = splashColor;
this.colorBrightness = colorBrightness;
this.elevation = elevation;
this.highlightElevation = highlightElevation;
this.disabledElevation = disabledElevation;
this.padding = padding;
this.shape = shape;
this.clipBehavior = clipBehavior;
this.materialTapTargetSize = materialTapTargetSize;
this.animationDuration = animationDuration;
this.minWidth = minWidth;
this.height = height;
this.child = child;
}
public readonly VoidCallback onPressed;
public readonly ValueChanged<bool> onHighlightChanged;
public readonly ButtonTextTheme? textTheme;
public readonly Color textColor;
public readonly Color disabledTextColor;
public readonly Color color;
public readonly Color disabledColor;
public readonly Color splashColor;
public readonly Color highlightColor;
public readonly double? elevation;
public readonly double? highlightElevation;
public readonly double? disabledElevation;
public readonly Brightness? colorBrightness;
public readonly Widget child;
public bool enabled => this.onPressed != null;
public readonly EdgeInsets padding;
public readonly ShapeBorder shape;
public readonly Clip? clipBehavior;
public readonly TimeSpan? animationDuration;
public readonly MaterialTapTargetSize? materialTapTargetSize;
public readonly double? minWidth;
public readonly double? height;
public override Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
ButtonThemeData buttonTheme = ButtonTheme.of(context);
return new RawMaterialButton(
onPressed: this.onPressed,
fillColor: this.color,
textStyle: theme.textTheme.button.copyWith(color: buttonTheme.getTextColor(this)),
highlightColor: this.highlightColor ?? theme.highlightColor,
splashColor: this.splashColor ?? theme.splashColor,
elevation: buttonTheme.getElevation(this),
highlightElevation: buttonTheme.getHighlightElevation(this),
padding: buttonTheme.getPadding(this),
constraints: buttonTheme.getConstraints(this).copyWith(
minWidth: this.minWidth,
minHeight: this.height),
shape: buttonTheme.shape,
clipBehavior: this.clipBehavior ?? Clip.none,
animationDuration: buttonTheme.getAnimationDuration(this),
child: this.child,
materialTapTargetSize: this.materialTapTargetSize ?? theme.materialTapTargetSize);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FlagProperty("enabled", value: this.enabled, ifFalse: "disabled"));
}
}
}

11
Runtime/material/material_button.cs.meta


fileFormatVersion: 2
guid: ea3964e7af24d4b059ac6e10ec862a3b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

351
Runtime/material/text_theme.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
public class TextTheme : Diagnosticable {
public TextTheme(
TextStyle display4 = null,
TextStyle display3 = null,
TextStyle display2 = null,
TextStyle display1 = null,
TextStyle headline = null,
TextStyle title = null,
TextStyle subhead = null,
TextStyle body2 = null,
TextStyle body1 = null,
TextStyle caption = null,
TextStyle button = null,
TextStyle subtitle = null,
TextStyle overline = null
) {
this.display4 = display4;
this.display3 = display3;
this.display2 = display2;
this.display1 = display1;
this.headline = headline;
this.title = title;
this.subhead = subhead;
this.body2 = body2;
this.body1 = body1;
this.caption = caption;
this.button = button;
this.subtitle = subtitle;
this.overline = overline;
}
public readonly TextStyle display4;
public readonly TextStyle display3;
public readonly TextStyle display2;
public readonly TextStyle display1;
public readonly TextStyle headline;
public readonly TextStyle title;
public readonly TextStyle subhead;
public readonly TextStyle body2;
public readonly TextStyle body1;
public readonly TextStyle caption;
public readonly TextStyle button;
public readonly TextStyle subtitle;
public readonly TextStyle overline;
public TextTheme copyWith(
TextStyle display4,
TextStyle display3,
TextStyle display2,
TextStyle display1,
TextStyle headline,
TextStyle title,
TextStyle subhead,
TextStyle body2,
TextStyle body1,
TextStyle caption,
TextStyle button,
TextStyle subtitle,
TextStyle overline
) {
return new TextTheme(
display4: display4 ?? this.display4,
display3: display3 ?? this.display3,
display2: display2 ?? this.display2,
display1: display1 ?? this.display1,
headline: headline ?? this.headline,
title: title ?? this.title,
subhead: subhead ?? this.subhead,
body2: body2 ?? this.body2,
body1: body1 ?? this.body1,
caption: caption ?? this.caption,
button: button ?? this.button,
subtitle: subtitle ?? this.subtitle,
overline: overline ?? this.overline
);
}
public TextTheme merge(TextTheme other) {
if (other == null)
return this;
return this.copyWith(
display4: this.display4?.merge(other.display4) ?? other.display4,
display3: this.display3?.merge(other.display3) ?? other.display3,
display2: this.display2?.merge(other.display2) ?? other.display2,
display1: this.display1?.merge(other.display1) ?? other.display1,
headline: this.headline?.merge(other.headline) ?? other.headline,
title: this.title?.merge(other.title) ?? other.title,
subhead: this.subhead?.merge(other.subhead) ?? other.subhead,
body2: this.body2?.merge(other.body2) ?? other.body2,
body1: this.body1?.merge(other.body1) ?? other.body1,
caption: this.caption?.merge(other.caption) ?? other.caption,
button: this.button?.merge(other.button) ?? other.button,
subtitle: this.subtitle?.merge(other.subtitle) ?? other.subtitle,
overline: this.overline?.merge(other.overline) ?? other.overline
);
}
public TextTheme apply(
string fontFamily = null,
double fontSizeFactor = 1.0,
double fontSizeDelta = 0.0,
Color displayColor = null,
Color bodyColor = null,
TextDecoration decoration = null,
Color decorationColor = null,
TextDecorationStyle? decorationStyle = null
) {
return new TextTheme(
display4: this.display4?.apply(
color: displayColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
display3: this.display3?.apply(
color: displayColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
display2: this.display2?.apply(
color: displayColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
display1: this.display1?.apply(
color: displayColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
headline: this.headline?.apply(
color: bodyColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
title: this.title?.apply(
color: bodyColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
subhead: this.subhead?.apply(
color: bodyColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
body2: this.body2?.apply(
color: bodyColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
body1: this.body1?.apply(
color: bodyColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
caption: this.caption?.apply(
color: displayColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
button: this.button?.apply(
color: bodyColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
subtitle: this.subtitle?.apply(
color: bodyColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
overline: this.overline?.apply(
color: bodyColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
)
);
}
public static TextTheme lerp(TextTheme a, TextTheme b, double t) {
D.assert(a != null);
D.assert(b != null);
D.assert(t != null);
return new TextTheme(
display4: TextStyle.lerp(a.display4, b.display4, t),
display3: TextStyle.lerp(a.display3, b.display3, t),
display2: TextStyle.lerp(a.display2, b.display2, t),
display1: TextStyle.lerp(a.display1, b.display1, t),
headline: TextStyle.lerp(a.headline, b.headline, t),
title: TextStyle.lerp(a.title, b.title, t),
subhead: TextStyle.lerp(a.subhead, b.subhead, t),
body2: TextStyle.lerp(a.body2, b.body2, t),
body1: TextStyle.lerp(a.body1, b.body1, t),
caption: TextStyle.lerp(a.caption, b.caption, t),
button: TextStyle.lerp(a.button, b.button, t),
subtitle: TextStyle.lerp(a.subtitle, b.subtitle, t),
overline: TextStyle.lerp(a.overline, b.overline, t)
);
}
public bool Equals(TextTheme other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return this.display4 == other.display4
&& this.display3 == other.display3
&& this.display2 == other.display2
&& this.display1 == other.display1
&& this.headline == other.headline
&& this.title == other.title
&& this.subhead == other.subhead
&& this.body2 == other.body2
&& this.body1 == other.body1
&& this.caption == other.caption
&& this.button == other.button
&& this.subtitle == other.subtitle
&& this.overline == other.overline;
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((TextTheme) obj);
}
public static bool operator ==(TextTheme a, TextTheme b) {
return ReferenceEquals(a, null) ? ReferenceEquals(b, null) : a.Equals(b);
}
public static bool operator !=(TextTheme a, TextTheme b) {
return !(a == b);
}
public override int GetHashCode() {
unchecked {
var hashCode = this.display4.GetHashCode();
hashCode = (hashCode * 397) ^ this.display3.GetHashCode();
hashCode = (hashCode * 397) ^ this.display2.GetHashCode();
hashCode = (hashCode * 397) ^ this.display1.GetHashCode();
hashCode = (hashCode * 397) ^ this.headline.GetHashCode();
hashCode = (hashCode * 397) ^ this.title.GetHashCode();
hashCode = (hashCode * 397) ^ this.subhead.GetHashCode();
hashCode = (hashCode * 397) ^ this.body2.GetHashCode();
hashCode = (hashCode * 397) ^ this.body1.GetHashCode();
hashCode = (hashCode * 397) ^ this.caption.GetHashCode();
hashCode = (hashCode * 397) ^ this.button.GetHashCode();
hashCode = (hashCode * 397) ^ this.subtitle.GetHashCode();
hashCode = (hashCode * 397) ^ this.overline.GetHashCode();
return hashCode;
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
TextTheme defaultTheme = new Typography().black;
properties.add(new DiagnosticsProperty<TextStyle>("display4", this.display4, defaultValue: defaultTheme.display4));
properties.add(new DiagnosticsProperty<TextStyle>("display3", this.display3, defaultValue: defaultTheme.display3));
properties.add(new DiagnosticsProperty<TextStyle>("display2", this.display2, defaultValue: defaultTheme.display2));
properties.add(new DiagnosticsProperty<TextStyle>("display1", this.display1, defaultValue: defaultTheme.display1));
properties.add(new DiagnosticsProperty<TextStyle>("headline", this.headline, defaultValue: defaultTheme.headline));
properties.add(new DiagnosticsProperty<TextStyle>("title", this.title, defaultValue: defaultTheme.title));
properties.add(new DiagnosticsProperty<TextStyle>("subhead", this.subhead, defaultValue: defaultTheme.subhead));
properties.add(new DiagnosticsProperty<TextStyle>("body2", this.body2, defaultValue: defaultTheme.body2));
properties.add(new DiagnosticsProperty<TextStyle>("body1", this.body1, defaultValue: defaultTheme.body1));
properties.add(new DiagnosticsProperty<TextStyle>("caption", this.caption, defaultValue: defaultTheme.caption));
properties.add(new DiagnosticsProperty<TextStyle>("button", this.button, defaultValue: defaultTheme.button));
properties.add(new DiagnosticsProperty<TextStyle>("subtitle)", this.subtitle, defaultValue: defaultTheme.subtitle));
properties.add(new DiagnosticsProperty<TextStyle>("overline", this.overline, defaultValue: defaultTheme.overline));
}
}
}

11
Runtime/material/text_theme.cs.meta


fileFormatVersion: 2
guid: 48eff72daf6ec48e5805ff0698990499
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

134
Runtime/material/theme.cs


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
public class Theme : StatelessWidget {
public Theme(
Key key = null,
ThemeData data = null,
bool isMaterialAppTheme = false,
Widget child = null
) : base(key: key) {
D.assert(child != null);
D.assert(data != null);
this.data = data;
this.isMaterialAppTheme = isMaterialAppTheme;
this.child = child;
}
public readonly ThemeData data;
public readonly bool isMaterialAppTheme;
readonly Widget child;
static readonly ThemeData _kFallbackTheme = ThemeData.fallback();
public static ThemeData of(BuildContext context, bool shadowThemeOnly = false) {
_InheritedTheme inheritedTheme =
(_InheritedTheme) context.inheritFromWidgetOfExactType(typeof(_InheritedTheme));
if (shadowThemeOnly) {
if (inheritedTheme == null || inheritedTheme.theme.isMaterialAppTheme)
return null;
return inheritedTheme.theme.data;
}
//todo:xingwei.zhu: materialLocalizations
return inheritedTheme?.theme?.data ?? _kFallbackTheme;
}
public override Widget build(BuildContext context) {
return new _InheritedTheme(
theme: this,
child: new IconTheme(
data: this.data.iconTheme,
child: this.child
)
);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<ThemeData>("data", this.data, showName: false));
}
}
class _InheritedTheme : InheritedWidget {
public _InheritedTheme(
Key key = null,
Theme theme = null,
Widget child = null) : base(key: key, child: child) {
D.assert(theme != null);
D.assert(child != null);
this.theme = theme;
}
public readonly Theme theme;
public override bool updateShouldNotify(InheritedWidget old) =>
this.theme.data != ((_InheritedTheme) old).theme.data;
}
class ThemeDataTween : Tween<ThemeData> {
public ThemeDataTween(
ThemeData begin = null,
ThemeData end = null
) : base(begin: begin, end: end) {
}
public override ThemeData lerp(double t) => ThemeData.lerp(this.begin, this.end, t);
}
class AnimatedTheme : ImplicitlyAnimatedWidget {
public AnimatedTheme(
Key key = null,
ThemeData data = null,
bool isMaterialAppTheme = false,
Curve curve = null,
TimeSpan? duration = null,
Widget child = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration ?? ThemeUtils.kThemeAnimationDuration) {
D.assert(child != null);
D.assert(data != null);
this.data = data;
this.isMaterialAppTheme = isMaterialAppTheme;
this.child = child;
}
public readonly ThemeData data;
public readonly bool isMaterialAppTheme;
public readonly Widget child;
public override State createState() => new _AnimatedThemeState();
}
class _AnimatedThemeState : AnimatedWidgetBaseState<AnimatedTheme> {
ThemeDataTween _data;
protected override void forEachTween(ITweenVisitor visitor) {
this._data = (ThemeDataTween) visitor.visit<ThemeData, AnimatedTheme>(this, this._data, this.widget.data, (ThemeData value) => new ThemeDataTween(begin: value));
}
public override Widget build(BuildContext context) {
return new Theme(
isMaterialAppTheme: this.widget.isMaterialAppTheme,
child: this.widget.child,
data: this._data.evaluate(this.animation)
);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder description) {
base.debugFillProperties(description);
description.add(new DiagnosticsProperty<ThemeDataTween>("data", this._data, showName: false, defaultValue: null));
}
}
}

11
Runtime/material/theme.cs.meta


fileFormatVersion: 2
guid: 8aeba6b651be2405387572671ac527f6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
Runtime/material/theme_data.cs.meta


fileFormatVersion: 2
guid: 68fb5edae4e8440669205d4e5b27ea30
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

451
Runtime/material/typography.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using UnityEngine;
namespace Unity.UIWidgets.material {
public enum ScriptCategory {
englishLike,
dense,
tall
}
public class Typography : Diagnosticable {
public Typography(
TextTheme black = null,
TextTheme white = null,
TextTheme englishLike = null,
TextTheme dense = null,
TextTheme tall = null
) {
black = black ?? blackMountainView;
white = white ?? whiteMountainView;
englishLike = englishLike ?? englishLike2014;
dense = dense ?? dense2014;
tall = tall ?? tall2014;
D.assert(black != null);
D.assert(white != null);
D.assert(englishLike != null);
D.assert(dense != null);
D.assert(tall != null);
this.black = black;
this.white = white;
this.englishLike = englishLike;
this.dense = dense;
this.tall = tall;
}
public readonly TextTheme black;
public readonly TextTheme white;
public readonly TextTheme englishLike;
public readonly TextTheme dense;
public readonly TextTheme tall;
public TextTheme geometryThemeFor(ScriptCategory? category) {
D.assert(category != null);
switch (category) {
case ScriptCategory.englishLike:
return this.englishLike;
case ScriptCategory.dense:
return this.dense;
case ScriptCategory.tall:
return this.tall;
}
return null;
}
public Typography copyWith(
TextTheme black = null,
TextTheme white = null,
TextTheme englishLike = null,
TextTheme dense = null,
TextTheme tall = null) {
return new Typography(
black: black ?? this.black,
white: white ?? this.white,
englishLike: englishLike ?? this.englishLike,
dense: dense ?? this.dense,
tall: tall ?? this.tall);
}
public static Typography lerp(Typography a, Typography b, double t) {
return new Typography(
black: TextTheme.lerp(a.black, b.black, t),
white: TextTheme.lerp(a.white, b.white, t),
englishLike: TextTheme.lerp(a.englishLike, b.englishLike, t),
dense: TextTheme.lerp(a.dense, b.dense, t),
tall: TextTheme.lerp(a.tall, b.tall, t)
);
}
public bool Equals(Typography other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return this.black == other.black
&& this.white == other.white
&& this.englishLike == other.englishLike
&& this.dense == other.dense
&& this.tall == other.tall;
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((Typography) obj);
}
public static bool operator ==(Typography a, Typography b) {
return ReferenceEquals(a, null) ? ReferenceEquals(b, null) : a.Equals(b);
}
public static bool operator !=(Typography a, Typography b) {
return !(a == b);
}
public override int GetHashCode() {
unchecked {
var hashCode = this.black.GetHashCode();
hashCode = (hashCode * 397) ^ this.white.GetHashCode();
hashCode = (hashCode * 397) ^ this.englishLike.GetHashCode();
hashCode = (hashCode * 397) ^ this.dense.GetHashCode();
hashCode = (hashCode * 397) ^ this.tall.GetHashCode();
return hashCode;
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
Typography defaultTypography = new Typography();
properties.add(
new DiagnosticsProperty<TextTheme>("black", this.black, defaultValue: defaultTypography.black));
properties.add(
new DiagnosticsProperty<TextTheme>("white", this.white, defaultValue: defaultTypography.white));
properties.add(new DiagnosticsProperty<TextTheme>("englishLike", this.englishLike,
defaultValue: defaultTypography.englishLike));
properties.add(
new DiagnosticsProperty<TextTheme>("dense", this.dense, defaultValue: defaultTypography.dense));
properties.add(new DiagnosticsProperty<TextTheme>("tall", this.tall, defaultValue: defaultTypography.tall));
}
public static TextTheme blackMountainView = new TextTheme(
display4: new TextStyle(debugLabel: "blackMountainView display4", fontFamily: "Roboto", inherit: true,
color: Colors.black54, decoration: TextDecoration.none),
display3: new TextStyle(debugLabel: "blackMountainView display3", fontFamily: "Roboto", inherit: true,
color: Colors.black54, decoration: TextDecoration.none),
display2: new TextStyle(debugLabel: "blackMountainView display2", fontFamily: "Roboto", inherit: true,
color: Colors.black54, decoration: TextDecoration.none),
display1: new TextStyle(debugLabel: "blackMountainView display1", fontFamily: "Roboto", inherit: true,
color: Colors.black54, decoration: TextDecoration.none),
headline: new TextStyle(debugLabel: "blackMountainView headline", fontFamily: "Roboto", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
title: new TextStyle(debugLabel: "blackMountainView title", fontFamily: "Roboto", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
subhead: new TextStyle(debugLabel: "blackMountainView subhead", fontFamily: "Roboto", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
body2: new TextStyle(debugLabel: "blackMountainView body2", fontFamily: "Roboto", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
body1: new TextStyle(debugLabel: "blackMountainView body1", fontFamily: "Roboto", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
caption: new TextStyle(debugLabel: "blackMountainView caption", fontFamily: "Roboto", inherit: true,
color: Colors.black54, decoration: TextDecoration.none),
button: new TextStyle(debugLabel: "blackMountainView button", fontFamily: "Roboto", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
subtitle: new TextStyle(debugLabel: "blackMountainView subtitle", fontFamily: "Roboto", inherit: true,
color: Colors.black, decoration: TextDecoration.none),
overline: new TextStyle(debugLabel: "blackMountainView overline", fontFamily: "Roboto", inherit: true,
color: Colors.black, decoration: TextDecoration.none)
);
public static TextTheme whiteMountainView = new TextTheme(
display4: new TextStyle(debugLabel: "whiteMountainView display4", fontFamily: "Roboto", inherit: true,
color: Colors.white70, decoration: TextDecoration.none),
display3: new TextStyle(debugLabel: "whiteMountainView display3", fontFamily: "Roboto", inherit: true,
color: Colors.white70, decoration: TextDecoration.none),
display2: new TextStyle(debugLabel: "whiteMountainView display2", fontFamily: "Roboto", inherit: true,
color: Colors.white70, decoration: TextDecoration.none),
display1: new TextStyle(debugLabel: "whiteMountainView display1", fontFamily: "Roboto", inherit: true,
color: Colors.white70, decoration: TextDecoration.none),
headline: new TextStyle(debugLabel: "whiteMountainView headline", fontFamily: "Roboto", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
title: new TextStyle(debugLabel: "whiteMountainView title", fontFamily: "Roboto", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
subhead: new TextStyle(debugLabel: "whiteMountainView subhead", fontFamily: "Roboto", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
body2: new TextStyle(debugLabel: "whiteMountainView body2", fontFamily: "Roboto", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
body1: new TextStyle(debugLabel: "whiteMountainView body1", fontFamily: "Roboto", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
caption: new TextStyle(debugLabel: "whiteMountainView caption", fontFamily: "Roboto", inherit: true,
color: Colors.white70, decoration: TextDecoration.none),
button: new TextStyle(debugLabel: "whiteMountainView button", fontFamily: "Roboto", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
subtitle: new TextStyle(debugLabel: "whiteMountainView subtitle", fontFamily: "Roboto", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
overline: new TextStyle(debugLabel: "whiteMountainView overline", fontFamily: "Roboto", inherit: true,
color: Colors.white, decoration: TextDecoration.none)
);
public static TextTheme blackCupertino = new TextTheme(
display4: new TextStyle(debugLabel: "blackCupertino display4", fontFamily: ".SF UI Display", inherit: true,
color: Colors.black54, decoration: TextDecoration.none),
display3: new TextStyle(debugLabel: "blackCupertino display3", fontFamily: ".SF UI Display", inherit: true,
color: Colors.black54, decoration: TextDecoration.none),
display2: new TextStyle(debugLabel: "blackCupertino display2", fontFamily: ".SF UI Display", inherit: true,
color: Colors.black54, decoration: TextDecoration.none),
display1: new TextStyle(debugLabel: "blackCupertino display1", fontFamily: ".SF UI Display", inherit: true,
color: Colors.black54, decoration: TextDecoration.none),
headline: new TextStyle(debugLabel: "blackCupertino headline", fontFamily: ".SF UI Display", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
title: new TextStyle(debugLabel: "blackCupertino title", fontFamily: ".SF UI Display", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
subhead: new TextStyle(debugLabel: "blackCupertino subhead", fontFamily: ".SF UI Text", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
body2: new TextStyle(debugLabel: "blackCupertino body2", fontFamily: ".SF UI Text", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
body1: new TextStyle(debugLabel: "blackCupertino body1", fontFamily: ".SF UI Text", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
caption: new TextStyle(debugLabel: "blackCupertino caption", fontFamily: ".SF UI Text", inherit: true,
color: Colors.black54, decoration: TextDecoration.none),
button: new TextStyle(debugLabel: "blackCupertino button", fontFamily: ".SF UI Text", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
subtitle: new TextStyle(debugLabel: "blackCupertino subtitle", fontFamily: ".SF UI Text", inherit: true,
color: Colors.black, decoration: TextDecoration.none),
overline: new TextStyle(debugLabel: "blackCupertino overline", fontFamily: ".SF UI Text", inherit: true,
color: Colors.black, decoration: TextDecoration.none)
);
public static TextTheme whiteCupertino = new TextTheme(
display4: new TextStyle(debugLabel: "whiteCupertino display4", fontFamily: ".SF UI Display", inherit: true,
color: Colors.white70, decoration: TextDecoration.none),
display3: new TextStyle(debugLabel: "whiteCupertino display3", fontFamily: ".SF UI Display", inherit: true,
color: Colors.white70, decoration: TextDecoration.none),
display2: new TextStyle(debugLabel: "whiteCupertino display2", fontFamily: ".SF UI Display", inherit: true,
color: Colors.white70, decoration: TextDecoration.none),
display1: new TextStyle(debugLabel: "whiteCupertino display1", fontFamily: ".SF UI Display", inherit: true,
color: Colors.white70, decoration: TextDecoration.none),
headline: new TextStyle(debugLabel: "whiteCupertino headline", fontFamily: ".SF UI Display", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
title: new TextStyle(debugLabel: "whiteCupertino title", fontFamily: ".SF UI Display", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
subhead: new TextStyle(debugLabel: "whiteCupertino subhead", fontFamily: ".SF UI Text", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
body2: new TextStyle(debugLabel: "whiteCupertino body2", fontFamily: ".SF UI Text", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
body1: new TextStyle(debugLabel: "whiteCupertino body1", fontFamily: ".SF UI Text", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
caption: new TextStyle(debugLabel: "whiteCupertino caption", fontFamily: ".SF UI Text", inherit: true,
color: Colors.white70, decoration: TextDecoration.none),
button: new TextStyle(debugLabel: "whiteCupertino button", fontFamily: ".SF UI Text", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
subtitle: new TextStyle(debugLabel: "whiteCupertino subtitle", fontFamily: ".SF UI Text", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
overline: new TextStyle(debugLabel: "whiteCupertino overline", fontFamily: ".SF UI Text", inherit: true,
color: Colors.white, decoration: TextDecoration.none)
);
public static TextTheme englishLike2014 = new TextTheme(
display4: new TextStyle(debugLabel: "englishLike display4 2014", inherit: false, fontSize: 112.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
display3: new TextStyle(debugLabel: "englishLike display3 2014", inherit: false, fontSize: 56.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
display2: new TextStyle(debugLabel: "englishLike display2 2014", inherit: false, fontSize: 45.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
display1: new TextStyle(debugLabel: "englishLike display1 2014", inherit: false, fontSize: 34.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
headline: new TextStyle(debugLabel: "englishLike headline 2014", inherit: false, fontSize: 24.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
title: new TextStyle(debugLabel: "englishLike title 2014", inherit: false, fontSize: 20.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
subhead: new TextStyle(debugLabel: "englishLike subhead 2014", inherit: false, fontSize: 16.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
body2: new TextStyle(debugLabel: "englishLike body2 2014", inherit: false, fontSize: 14.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
body1: new TextStyle(debugLabel: "englishLike body1 2014", inherit: false, fontSize: 14.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
caption: new TextStyle(debugLabel: "englishLike caption 2014", inherit: false, fontSize: 12.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
button: new TextStyle(debugLabel: "englishLike button 2014", inherit: false, fontSize: 14.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
subtitle: new TextStyle(debugLabel: "englishLike subtitle 2014", inherit: false, fontSize: 14.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.1),
overline: new TextStyle(debugLabel: "englishLike overline 2014", inherit: false, fontSize: 10.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 1.5)
);
public static TextTheme englishLike2018 = new TextTheme(
display4: new TextStyle(debugLabel: "englishLike display4 2018", fontSize: 96.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: -1.5),
display3: new TextStyle(debugLabel: "englishLike display3 2018", fontSize: 60.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: -0.5),
display2: new TextStyle(debugLabel: "englishLike display2 2018", fontSize: 48.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.0),
display1: new TextStyle(debugLabel: "englishLike display1 2018", fontSize: 34.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.25),
headline: new TextStyle(debugLabel: "englishLike headline 2018", fontSize: 24.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.0),
title: new TextStyle(debugLabel: "englishLike title 2018", fontSize: 20.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.15),
subhead: new TextStyle(debugLabel: "englishLike subhead 2018", fontSize: 16.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.15),
body2: new TextStyle(debugLabel: "englishLike body2 2018", fontSize: 14.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.25),
body1: new TextStyle(debugLabel: "englishLike body1 2018", fontSize: 16.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.5),
button: new TextStyle(debugLabel: "englishLike button 2018", fontSize: 14.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.75),
caption: new TextStyle(debugLabel: "englishLike caption 2018", fontSize: 12.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.4),
subtitle: new TextStyle(debugLabel: "englishLike subtitle 2018", fontSize: 14.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.1),
overline: new TextStyle(debugLabel: "englishLike overline 2018", fontSize: 10.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 1.5)
);
public static TextTheme dense2014 = new TextTheme(
display4: new TextStyle(debugLabel: "dense display4 2014", inherit: false, fontSize: 112.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
display3: new TextStyle(debugLabel: "dense display3 2014", inherit: false, fontSize: 56.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
display2: new TextStyle(debugLabel: "dense display2 2014", inherit: false, fontSize: 45.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
display1: new TextStyle(debugLabel: "dense display1 2014", inherit: false, fontSize: 34.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
headline: new TextStyle(debugLabel: "dense headline 2014", inherit: false, fontSize: 24.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
title: new TextStyle(debugLabel: "dense title 2014", inherit: false, fontSize: 21.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
subhead: new TextStyle(debugLabel: "dense subhead 2014", inherit: false, fontSize: 17.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
body2: new TextStyle(debugLabel: "dense body2 2014", inherit: false, fontSize: 15.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
body1: new TextStyle(debugLabel: "dense body1 2014", inherit: false, fontSize: 15.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
caption: new TextStyle(debugLabel: "dense caption 2014", inherit: false, fontSize: 13.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
button: new TextStyle(debugLabel: "dense button 2014", inherit: false, fontSize: 15.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
subtitle: new TextStyle(debugLabel: "dense subtitle 2014", inherit: false, fontSize: 15.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
overline: new TextStyle(debugLabel: "dense overline 2014", inherit: false, fontSize: 11.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic)
);
public static TextTheme dense2018 = new TextTheme(
display4: new TextStyle(debugLabel: "dense display4 2018", fontSize: 96.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
display3: new TextStyle(debugLabel: "dense display3 2018", fontSize: 60.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
display2: new TextStyle(debugLabel: "dense display2 2018", fontSize: 48.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
display1: new TextStyle(debugLabel: "dense display1 2018", fontSize: 34.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
headline: new TextStyle(debugLabel: "dense headline 2018", fontSize: 24.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
title: new TextStyle(debugLabel: "dense title 2018", fontSize: 21.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
subhead: new TextStyle(debugLabel: "dense subhead 2018", fontSize: 17.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
body2: new TextStyle(debugLabel: "dense body2 2018", fontSize: 17.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
body1: new TextStyle(debugLabel: "dense body1 2018", fontSize: 15.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
caption: new TextStyle(debugLabel: "dense caption 2018", fontSize: 13.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
button: new TextStyle(debugLabel: "dense button 2018", fontSize: 15.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
subtitle: new TextStyle(debugLabel: "dense subtitle 2018", fontSize: 15.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
overline: new TextStyle(debugLabel: "dense overline 2018", fontSize: 11.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic)
);
public static TextTheme tall2014 = new TextTheme(
display4: new TextStyle(debugLabel: "tall display4 2014", inherit: false, fontSize: 112.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
display3: new TextStyle(debugLabel: "tall display3 2014", inherit: false, fontSize: 56.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
display2: new TextStyle(debugLabel: "tall display2 2014", inherit: false, fontSize: 45.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
display1: new TextStyle(debugLabel: "tall display1 2014", inherit: false, fontSize: 34.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
headline: new TextStyle(debugLabel: "tall headline 2014", inherit: false, fontSize: 24.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
title: new TextStyle(debugLabel: "tall title 2014", inherit: false, fontSize: 21.0,
fontWeight: FontWeight.w700, textBaseline: TextBaseline.alphabetic),
subhead: new TextStyle(debugLabel: "tall subhead 2014", inherit: false, fontSize: 17.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
body2: new TextStyle(debugLabel: "tall body2 2014", inherit: false, fontSize: 15.0,
fontWeight: FontWeight.w700, textBaseline: TextBaseline.alphabetic),
body1: new TextStyle(debugLabel: "tall body1 2014", inherit: false, fontSize: 15.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
caption: new TextStyle(debugLabel: "tall caption 2014", inherit: false, fontSize: 13.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
button: new TextStyle(debugLabel: "tall button 2014", inherit: false, fontSize: 15.0,
fontWeight: FontWeight.w700, textBaseline: TextBaseline.alphabetic),
subtitle: new TextStyle(debugLabel: "tall subtitle 2014", inherit: false, fontSize: 15.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
overline: new TextStyle(debugLabel: "tall overline 2014", inherit: false, fontSize: 11.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic)
);
public static TextTheme tall2018 = new TextTheme(
display4: new TextStyle(debugLabel: "tall display4 2018", fontSize: 96.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic),
display3: new TextStyle(debugLabel: "tall display3 2018", fontSize: 60.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic),
display2: new TextStyle(debugLabel: "tall display2 2018", fontSize: 48.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic),
display1: new TextStyle(debugLabel: "tall display1 2018", fontSize: 34.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic),
headline: new TextStyle(debugLabel: "tall headline 2018", fontSize: 24.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic),
title: new TextStyle(debugLabel: "tall title 2018", fontSize: 21.0, fontWeight: FontWeight.w700,
textBaseline: TextBaseline.alphabetic),
subhead: new TextStyle(debugLabel: "tall subhead 2018", fontSize: 17.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic),
body2: new TextStyle(debugLabel: "tall body2 2018", fontSize: 17.0, fontWeight: FontWeight.w700,
textBaseline: TextBaseline.alphabetic),
body1: new TextStyle(debugLabel: "tall body1 2018", fontSize: 15.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic),
caption: new TextStyle(debugLabel: "tall caption 2018", fontSize: 13.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic),
button: new TextStyle(debugLabel: "tall button 2018", fontSize: 15.0, fontWeight: FontWeight.w700,
textBaseline: TextBaseline.alphabetic),
subtitle: new TextStyle(debugLabel: "tall subtitle 2018", fontSize: 15.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic),
overline: new TextStyle(debugLabel: "tall overline 2018", fontSize: 11.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic)
);
}
}

11
Runtime/material/typography.cs.meta


fileFormatVersion: 2
guid: a7dbdefd2b4fd44dd9ff8d23eb224a31
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
Runtime/material/utils.cs.meta


fileFormatVersion: 2
guid: 39236c38160ee4c0e928e3658102fd71
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
Runtime/painting/colors.cs.meta


fileFormatVersion: 2
guid: 8589f247e5dcd4f4e8cc22eee9fdbf36
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
Runtime/service/system_chrome.cs.meta


fileFormatVersion: 2
guid: 7dec1d416078846ec89141bd833cb550
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
Runtime/widgets/implicit_animations.cs.meta


fileFormatVersion: 2
guid: ecf39d43bfae547a7ba543edafc67b19
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

176
Runtime/widgets/layout_builder.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.widgets {
public delegate Widget LayoutWidgetBuilder(BuildContext context, BoxConstraints constraints);
class LayoutBuilder : RenderObjectWidget {
public LayoutBuilder(
Key key = null,
LayoutWidgetBuilder builder = null) : base(key: key) {
D.assert(builder != null);
this.builder = builder;
}
public readonly LayoutWidgetBuilder builder;
public override Element createElement() => new _LayoutBuilderElement(this);
public override RenderObject createRenderObject(BuildContext context) => new _RenderLayoutBuilder();
}
class _LayoutBuilderElement : RenderObjectElement {
public _LayoutBuilderElement(
LayoutBuilder widget) : base(widget){}
new LayoutBuilder widget => (LayoutBuilder) base.widget;
new _RenderLayoutBuilder renderObject => (_RenderLayoutBuilder) base.renderObject;
Element _child;
public override void visitChildren(ElementVisitor visitor) {
if (this._child != null)
visitor(this._child);
}
protected override void forgetChild(Element child) {
D.assert(child == this._child);
this._child = null;
}
public override void mount(Element parent, object newSlot) {
base.mount(parent, newSlot);
this.renderObject.callback = this._layout;
}
public override void update(Widget newWidget) {
D.assert(this.widget != newWidget);
base.update(newWidget);
D.assert(this.widget == newWidget);
this.renderObject.callback = this._layout;
this.renderObject.markNeedsLayout();
}
protected override void performRebuild() {
this.renderObject.markNeedsLayout();
base.performRebuild();
}
public override void unmount() {
this.renderObject.callback = null;
base.unmount();
}
void _layout(BoxConstraints constraints) {
this.owner.buildScope(this, () => {
Widget built = null;
if (this.widget.builder != null) {
built = this.widget.builder(this, constraints);
WidgetsD.debugWidgetBuilderValue(this.widget, built);
}
this._child = this.updateChild(this._child, built, null);
D.assert(this._child != null);
});
}
protected override void insertChildRenderObject(RenderObject child, object slot) {
_RenderLayoutBuilder renderObject = (_RenderLayoutBuilder) this.renderObject;
D.assert(slot == null);
D.assert(renderObject.debugValidateChild(child));
renderObject.child = (RenderBox) child;
D.assert(renderObject == this.renderObject);
}
protected override void moveChildRenderObject(RenderObject child, object slot) {
D.assert(false);
}
protected override void removeChildRenderObject(RenderObject child) {
_RenderLayoutBuilder renderObject = (_RenderLayoutBuilder) this.renderObject;
D.assert(renderObject.child == child);
renderObject.child = null;
D.assert(renderObject == this.renderObject);
}
}
public class _RenderLayoutBuilder : RenderObjectWithChildMixinRenderBox<RenderBox> {
public _RenderLayoutBuilder(
LayoutCallback<BoxConstraints> callback = null) {
this._callback = callback;
}
public LayoutCallback<BoxConstraints> callback {
get { return this._callback; }
set {
if (value == this._callback)
return;
this._callback = value;
this.markNeedsLayout();
}
}
LayoutCallback<BoxConstraints> _callback;
bool _debugThrowIfNotCheckingIntrinsics() {
D.assert(() => {
if (!RenderObject.debugCheckingIntrinsics) {
throw new UIWidgetsError(
"LayoutBuilder does not support returning intrinsic dimensions.\n" +
"Calculating the intrinsic dimensions would require running the layout " +
"callback speculatively, which might mutate the live render object tree."
);
}
return true;
});
return true;
}
protected override double computeMinIntrinsicWidth(double height) {
D.assert(this._debugThrowIfNotCheckingIntrinsics());
return 0.0;
}
protected override double computeMaxIntrinsicWidth(double height) {
D.assert(this._debugThrowIfNotCheckingIntrinsics());
return 0.0;
}
protected override double computeMinIntrinsicHeight(double width) {
D.assert(this._debugThrowIfNotCheckingIntrinsics());
return 0.0;
}
protected override double computeMaxIntrinsicHeight(double width) {
D.assert(this._debugThrowIfNotCheckingIntrinsics());
return 0.0;
}
protected override void performLayout() {
D.assert(this.callback != null);
this.invokeLayoutCallback(this.callback);
if (this.child != null) {
this.child.layout(this.constraints, parentUsesSize: true);
this.size = this.constraints.constrain(this.child.size);
}
else {
this.size = this.constraints.biggest;
}
}
protected override bool hitTestChildren(HitTestResult result, Offset position = null) {
return this.child?.hitTest(result, position: position) ?? false;
}
public override void paint(PaintingContext context, Offset offset) {
if (this.child != null)
context.paintChild(this.child, offset);
}
}
}

11
Runtime/widgets/layout_builder.cs.meta


fileFormatVersion: 2
guid: d29b34cdfd63d4edb97960beede8a990
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

70
Samples/UIWidgetSample/MaterialCanvas.cs


using System.Collections.Generic;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
namespace UIWidgetsSample {
public class MaterialCanvas : WidgetCanvas {
protected override Widget getWidget() {
return new MaterialApp();
}
class MaterialApp : StatefulWidget {
public MaterialApp(Key key = null) : base(key) {
}
public override State createState() {
return new MaterialWidgetState();
}
}
class MaterialWidget : StatefulWidget {
public MaterialWidget(Key key = null) : base(key) {
}
public override State createState() {
return new MaterialWidgetState();
}
}
// test-case: material button
class MaterialWidgetState : State<MaterialWidget> {
public override Widget build(BuildContext context) {
return new Material(
child : new Center(
child : new Container(
width: 30,
height : 30,
child: new MaterialButton(
color: Colors.blue,
splashColor: new Color(0xFFFF0011),
highlightColor: new Color(0x88000011),
onPressed : () => { }))));
}
}
// // test-case: ink well
// class MaterialWidgetState : State<MaterialWidget> {
// public override Widget build(BuildContext context) {
// return new Material(
// child: new Center(
// child: new Container(
// width: 30,
// height: 30,
// child : new InkWell(
// borderRadius: BorderRadius.circular(2.0),
// highlightColor: new Color(0xAAFF0000),
// splashColor: new Color(0xAA0000FF),
// //radius : 20,
// onTap: () => { }
// ))
// )
// );
// }
// }
}
}

11
Samples/UIWidgetSample/MaterialCanvas.cs.meta


fileFormatVersion: 2
guid: d7c3be43dd8b94a349f26e3e7173c3f6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存