guanghuispark
3 年前
当前提交
3700e350
共有 30 个文件被更改,包括 813 次插入 和 127 次删除
-
21com.unity.uiwidgets.devtools/Editor/v2/src/CollapsibleAnimationMixin.mixin.gen.cs
-
23com.unity.uiwidgets.devtools/Editor/v2/src/CollapsibleAnimationMixin.mixin.njk
-
114com.unity.uiwidgets.devtools/Editor/v2/src/inspector/diagnostics_node.cs
-
29com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_controller.cs
-
52com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_service.cs
-
108com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_tree.cs
-
28com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_tree_flutter.cs
-
9com.unity.uiwidgets.devtools/Editor/v2/src/theme.cs
-
238com.unity.uiwidgets.devtools/Editor/v2/src/ui/icons.cs
-
8com.unity.uiwidgets.devtools/Editor/v2/src/utils.cs
-
206com.unity.uiwidgets.devtools/Editor/v2/src/inspector/diagnostics.cs
-
34com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_text_styles.cs
-
5Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/icons/custom/class.png
-
4Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/icons/custom/class@2x.png
-
3Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/icons/custom/class_abstract.png
-
3Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/icons/custom/class_abstract@2x.png
-
5Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/icons/custom/fields.png
-
4Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/icons/custom/fields@2x.png
-
5Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/icons/custom/info.png
-
5Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/icons/custom/info@2x.png
-
4Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/icons/custom/interface.png
-
5Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/icons/custom/interface@2x.png
-
5Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/icons/custom/method.png
-
5Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/icons/custom/method@2x.png
-
3Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/icons/custom/method_abstract.png
-
4Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/icons/custom/method_abstract@2x.png
-
5Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/icons/custom/property.png
-
5Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/icons/custom/property@2x.png
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.DevTools.ui; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace Unity.UIWidgets.DevTools.inspector |
|||
{ |
|||
|
|||
public static class DiagnosticsUtils |
|||
{ |
|||
public static ColorIconMaker _colorIconMaker = new ColorIconMaker(); |
|||
public static CustomIconMaker _customIconMaker = new CustomIconMaker(); |
|||
public static readonly bool _showRenderObjectPropertiesAsLinks = false; |
|||
public static CustomIcon defaultIcon = _customIconMaker.fromInfo("Default"); |
|||
} |
|||
|
|||
class DiagnosticsNodeDescription : StatelessWidget { |
|||
public DiagnosticsNodeDescription(RemoteDiagnosticsNode diagnostic) |
|||
{ |
|||
this.diagnostic = diagnostic; |
|||
} |
|||
|
|||
public readonly RemoteDiagnosticsNode diagnostic; |
|||
|
|||
Widget _paddedIcon(Widget icon) { |
|||
return new Padding( |
|||
padding: EdgeInsets.only(right: InspectorTreeUtils.iconPadding), |
|||
child: icon |
|||
); |
|||
} |
|||
|
|||
void _addDescription( |
|||
List<Widget> output, |
|||
String description, |
|||
TextStyle textStyle, |
|||
ColorScheme colorScheme, |
|||
bool isProperty = false |
|||
) { |
|||
if (diagnostic.isDiagnosticableValue) { |
|||
var match = InspectorTreeUtils.treeNodePrimaryDescriptionPattern.Match(description); |
|||
if (match != null) { |
|||
output.Add(new Text(match.Groups[1].Value, style: textStyle)); |
|||
if (match.Groups[2].Value.isNotEmpty()) { |
|||
output.Add(new Text( |
|||
match.Groups[2].Value, |
|||
style: inspector_text_styles.unimportant(colorScheme) |
|||
)); |
|||
} |
|||
return; |
|||
} |
|||
} else if (diagnostic.type == "ErrorDescription") { |
|||
var match = InspectorTreeUtils.assertionThrownBuildingError.Match(description); |
|||
if (match != null) { |
|||
output.Add(new Text(match.Groups[1].Value, style: textStyle)); |
|||
output.Add(new Text(match.Groups[3].Value, style: textStyle)); |
|||
return; |
|||
} |
|||
} |
|||
if (description?.isNotEmpty() == true) { |
|||
output.Add(new Text(description, style: textStyle)); |
|||
} |
|||
} |
|||
|
|||
|
|||
public override Widget build(BuildContext context) { |
|||
if (diagnostic == null) { |
|||
return new SizedBox(); |
|||
} |
|||
var colorScheme = Theme.of(context).colorScheme; |
|||
var icon = diagnostic.icon; |
|||
var children = new List<Widget>(); |
|||
|
|||
if (icon != null) { |
|||
children.Add(_paddedIcon(icon)); |
|||
} |
|||
string name = diagnostic.name; |
|||
TextStyle textStyle = InspectorControllerUtils.textStyleForLevel(diagnostic.level, colorScheme); |
|||
if (diagnostic.isProperty) |
|||
{ |
|||
// Display of inline properties.
|
|||
string propertyType = diagnostic.propertyType; |
|||
Dictionary<string, object> properties = diagnostic.valuePropertiesJson; |
|||
|
|||
if (name?.isNotEmpty() == true && diagnostic.showName) |
|||
{ |
|||
children.Add(new Text($"{name}{diagnostic.separator} ", style: textStyle)); |
|||
} |
|||
|
|||
if (diagnostic.isCreatedByLocalProject) { |
|||
textStyle = |
|||
textStyle.merge(inspector_text_styles.regularBold(colorScheme)); |
|||
} |
|||
|
|||
string description = diagnostic.description; |
|||
if (propertyType != null && properties != null) |
|||
{ |
|||
switch (propertyType) { |
|||
case "Color": |
|||
{ |
|||
int alpha = JsonUtils.getIntMember(properties, "alpha"); |
|||
int red = JsonUtils.getIntMember(properties, "red"); |
|||
int green = JsonUtils.getIntMember(properties, "green"); |
|||
int blue = JsonUtils.getIntMember(properties, "blue"); |
|||
// string radix(int chan) => chan.toRadixString(16).padLeft(2, '0');
|
|||
string radix(int chan) => chan.ToString(); |
|||
if (alpha == 255) { |
|||
description = $"#{radix(red)}{radix(green)}{radix(blue)}"; |
|||
} else { |
|||
description = |
|||
$"#{radix(alpha)}{radix(red)}{radix(green)}{radix(blue)}"; |
|||
} |
|||
|
|||
Color color = Color.fromARGB(alpha, red, green, blue); |
|||
children.Add(_paddedIcon(DiagnosticsUtils._colorIconMaker.getCustomIcon(color))); |
|||
break; |
|||
} |
|||
|
|||
case "IconData": |
|||
{ |
|||
int codePoint = |
|||
JsonUtils.getIntMember(properties, "codePoint"); |
|||
if (codePoint > 0) { |
|||
var icon_ = FlutterMaterialIcons.getIconForCodePoint( |
|||
codePoint, |
|||
colorScheme |
|||
); |
|||
if (icon_ != null) { |
|||
children.Add(_paddedIcon(icon_)); |
|||
} |
|||
} |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
if (DiagnosticsUtils._showRenderObjectPropertiesAsLinks |
|||
&& propertyType == "RenderObject") { |
|||
// textStyle = textStyle..merge(inspector_text_styles.link(colorScheme));
|
|||
} |
|||
|
|||
// TODO(jacobr): custom display for units, iterables, and padding.
|
|||
_addDescription( |
|||
children, |
|||
description, |
|||
textStyle, |
|||
colorScheme, |
|||
isProperty: true |
|||
); |
|||
|
|||
if (diagnostic.level == DiagnosticLevel.fine && |
|||
diagnostic.hasDefaultValue) { |
|||
children.Add(new Text(" ")); |
|||
children.Add(_paddedIcon(DiagnosticsUtils.defaultIcon)); |
|||
} |
|||
} else { |
|||
// Non property, regular node case.
|
|||
if (name?.isNotEmpty() == true && diagnostic.showName && name != "child") { |
|||
if (name.StartsWith("child ")) { |
|||
children.Add(new Text( |
|||
name, |
|||
style: inspector_text_styles.unimportant(colorScheme) |
|||
)); |
|||
} else { |
|||
children.Add(new Text(name, style: textStyle)); |
|||
} |
|||
|
|||
if (diagnostic.showSeparator) { |
|||
children.Add(new Text( |
|||
diagnostic.separator, |
|||
style: inspector_text_styles.unimportant(colorScheme) |
|||
)); |
|||
if (diagnostic.separator != " " && |
|||
diagnostic.description.isNotEmpty()) { |
|||
children.Add(new Text( |
|||
" ", |
|||
style: inspector_text_styles.unimportant(colorScheme) |
|||
)); |
|||
} |
|||
} |
|||
} |
|||
|
|||
if (!diagnostic.isSummaryTree && diagnostic.isCreatedByLocalProject) { |
|||
textStyle = |
|||
textStyle.merge(inspector_text_styles.regularBold(colorScheme)); |
|||
} |
|||
|
|||
_addDescription( |
|||
children, |
|||
diagnostic.description, |
|||
textStyle, |
|||
colorScheme, |
|||
isProperty: false |
|||
); |
|||
} |
|||
|
|||
return new Row(mainAxisSize: MainAxisSize.min, children: children); |
|||
} |
|||
} |
|||
|
|||
} |
|
|||
using uiwidgets; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.ui; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace Unity.UIWidgets.DevTools.inspector |
|||
{ |
|||
public static class inspector_text_styles |
|||
{ |
|||
public static TextStyle unimportant(ColorScheme colorScheme) => new TextStyle( |
|||
color: InspectorTreeUtils.isLight ? Colors.grey.shade500 : Colors.grey.shade600); |
|||
|
|||
public static TextStyle regular = new TextStyle(); |
|||
public static TextStyle warning(ColorScheme colorScheme) => new TextStyle( |
|||
color: |
|||
InspectorTreeUtils.isLight ? Colors.orange.shade900 : Colors.orange.shade400); |
|||
public static TextStyle error(ColorScheme colorScheme) => new TextStyle( |
|||
color: InspectorTreeUtils.isLight ? Colors.red.shade500 : Colors.red.shade400 |
|||
); |
|||
|
|||
public static TextStyle regularBold(ColorScheme colorScheme) => new TextStyle( |
|||
color: ThemeUtils.defaultForeground, |
|||
fontWeight: FontWeight.w700 |
|||
); |
|||
public static TextStyle regularItalic(ColorScheme colorScheme) => new TextStyle( |
|||
color: ThemeUtils.defaultForeground, |
|||
fontStyle: FontStyle.italic |
|||
); |
|||
public static TextStyle unimportantItalic(ColorScheme colorScheme) => |
|||
unimportant(colorScheme).merge(new TextStyle( |
|||
fontStyle: FontStyle.italic |
|||
)); |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue