浏览代码

add some other APIs

/zxw-devTools
guanghuispark 3 年前
当前提交
85039bd1
共有 10 个文件被更改,包括 321 次插入48 次删除
  1. 4
      com.unity.uiwidgets.devtools/Editor/v2/src/inspector/diagnostics_node.cs
  2. 22
      com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_controller.cs
  3. 146
      com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_screen_details_tab.cs
  4. 108
      com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_service.cs
  5. 1
      com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_tree.cs
  6. 4
      com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_tree_flutter.cs
  7. 34
      com.unity.uiwidgets.devtools/Editor/v2/src/inspector/layout_explorer/flex/flex.cs
  8. 50
      com.unity.uiwidgets.devtools/Editor/v2/src/inspector/layout_explorer/layout_explorer.cs

4
com.unity.uiwidgets.devtools/Editor/v2/src/inspector/diagnostics_node.cs


this.parent = parent;
}
RemoteDiagnosticsNode parent;
public RemoteDiagnosticsNode parent;
Future<string> propertyDocFuture;

List<RemoteDiagnosticsNode> _children;
static readonly CustomIconMaker iconMaker = new CustomIconMaker();
public bool isFlex => new List<string>{"Row", "Column", "Flex"}.Contains(widgetRuntimeType);
// Future<Dictionary<string, InstanceRef>> _valueProperties;
public readonly bool isProperty;

22
com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_controller.cs


}
}
class InspectorController
public class InspectorController
{
public InspectorController(
InspectorService inspectorService,

public readonly VoidCallback onLayoutExplorerSupported;
public InspectorTreeNode selectedNode;
bool isActive = false;
bool visibleToUser = true;

shutdownTree(false);
}
}
void _onExpand(InspectorTreeNode node) {
inspectorTree.maybePopulateChildren(node);

inspectorService.inferPubRootDirectoryIfNeeded();
// updateSelectionFromService(firstFrame: true);
} else {
// var ready = inspectorService.isWidgetTreeReady();
bool ready = true;
flutterAppFrameReady = ready;
if (isActive && ready) {
maybeLoadUI();
}
var ready = inspectorService.isWidgetTreeReady();
ready.then_<bool>((v) =>
{
flutterAppFrameReady = v;
if (isActive && v) {
maybeLoadUI();
}
return FutureOr.value(null);
});
}
}

146
com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_screen_details_tab.cs


using System.Collections.Generic;
using Unity.UIWidgets.material;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.DevTools.inspector.layout_explorer;
using Unity.UIWidgets.painting;
class InspectorDetailsTabController : StatefulWidget
class InspectorDetailsTabController : StatefulWidget
{
public InspectorDetailsTabController(
Widget detailsTree = null,
Widget actionButtons = null,
InspectorController controller = null,
bool? layoutExplorerSupported = null,
Key key = null
) : base(key: key)
public InspectorDetailsTabController(
Widget detailsTree = null,
Widget actionButtons = null,
InspectorController controller = null,
bool? layoutExplorerSupported = null,
Key key = null
) : base(key: key)
{
this.detailsTree = detailsTree;
this.actionButtons = actionButtons;
this.controller = controller;
this.layoutExplorerSupported = layoutExplorerSupported;
}
this.detailsTree = detailsTree;
this.actionButtons = actionButtons;
this.controller = controller;
this.layoutExplorerSupported = layoutExplorerSupported;
}
public readonly Widget detailsTree;
public readonly Widget actionButtons;
public readonly InspectorController controller;
public readonly bool? layoutExplorerSupported;
public readonly Widget detailsTree;
public readonly Widget actionButtons;
public readonly InspectorController controller;
public readonly bool? layoutExplorerSupported;
public override State createState()
{
return new _InspectorDetailsTabControllerState();
}
public override State createState()
{
return new _InspectorDetailsTabControllerState();
}
class _InspectorDetailsTabControllerState : State<InspectorDetailsTabController>
class _InspectorDetailsTabControllerState : State<InspectorDetailsTabController>
{
private static readonly int _detailsTreeTabIndex = 0;
TabController _tabControllerWithLayoutExplorer;
TabController _tabControllerWithoutLayoutExplorer;
public override Widget build(BuildContext context)
public override Widget build(BuildContext context)
{
return new Container(child: new Text("this is a text!"));
}
// var tabs = new List<Widget>();
// tabs.Add(_buildTab("Details Tree"));
// if (widget.layoutExplorerSupported.Value)
// {
// tabs.Add(_buildTab("Layout Explorer"));
// }
//
// var tabViews = new List<Widget>();
// tabViews.Add(widget.detailsTree);
// if (widget.layoutExplorerSupported.Value)
// {
// tabViews.Add(new LayoutExplorerTab(controller: widget.controller));
// }
//
// var _tabController = widget.layoutExplorerSupported.Value
// ? _tabControllerWithLayoutExplorer
// : _tabControllerWithoutLayoutExplorer;
//
// var theme = Theme.of(context);
// var focusColor = theme.focusColor;
// var borderSide = new BorderSide(color: focusColor);
// var hasActionButtons = widget.actionButtons != null &&
// _tabController.index == _detailsTreeTabIndex;
//
// return new Column(
// children: new List<Widget>
// {
// new SizedBox(
// height: 50.0f,
// child: new Row(
// crossAxisAlignment: CrossAxisAlignment.end,
// children: new List<Widget>
// {
// new Container(
// color: focusColor,
// child: new TabBar(
// controller: _tabController,
// labelColor: theme.textTheme.bodyText1.color,
// tabs: tabs,
// isScrollable: true
// )
// ),
// new Expanded(
// child: new Container(
// decoration: new BoxDecoration(border: new Border(bottom: borderSide)),
// child: hasActionButtons
// ? widget.actionButtons
// : new SizedBox()
// )
// ),
// }
// )
// ),
// new Expanded(
// child: new Container(
// decoration: new BoxDecoration(
// border: new Border(
// left: borderSide,
// bottom: borderSide,
// right: borderSide
// )
// ),
// child: new TabBarView(
// physics: ThemeUtils.defaultTabBarViewPhysics,
// controller: _tabController,
// children: tabViews
// )
// )
// )
// }
// );
//
// Widget _buildTab(string tabName)
// {
// return new Tab(
// child: new Text(
// tabName,
// overflow: TextOverflow.ellipsis
// )
// );
// }
return new Container(child: new Text("Not Implement yet"));
}
}

108
com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_service.cs


using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.widgets;
using UnityEngine;
namespace Unity.UIWidgets.DevTools.inspector
{

if (methodName == "getRootWidgetSummaryTree")
{
return _callServiceExtensionLocal();
return getRootWidgetSummaryTreeFake();
if (methodName == "getRootRenderObject")
{
return getRootRenderObjectFake();
}
var callMethodName = $"ext.flutter.inspector.{methodName}";
if (!Globals.serviceManager.serviceExtensionManager

// });
}
public Future<object> _callServiceExtensionLocal()
public Future<object> getRootWidgetSummaryTreeFake()
{
Dictionary<string, object> widgetTree = new Dictionary<string, object>();
widgetTree["hasChildren"] = true;

widgetTree["description"] = "root widget";
widgetTree["widgetRuntimeType"] = "class";
widgetTree["propertyType"] = "Widget";
widgetTree["creationLocation"] = new Dictionary<string, object>()
{
{"name", "inspector2"},

{
{"name", "inspector3"},
{"type", "class"},
{"widgetRuntimeType", "class"},
{"propertyType", "RenderObject"},
{"description","second level widget"},
{
"text", new List<Dictionary<string,object>>()

{"hasChildren", true},
{"name","inspector4"},
{"propertyType", "RenderObject"},
{"description","third level widget"},
{"creationLocation", new Dictionary<string, object>()
{

{
{"name", "inspector5"},
{"type", "class"},
{"propertyType", "RenderObject"},
{"widgetRuntimeType", "class"},
{"description","second level widget"},
{"te1",new Text("text1a")},
{"te2",new Text("text2a")},

{
{"name","properties1"},
{"type", "property"},
{"propertyType", "RenderObject"},
{"description","this is a description"},
},
new Dictionary<string, object>()

{"propertyType", "RenderObject"},
{"description","this is a description"},
}
};

Future<object> getRootRenderObjectFake()
{
Debug.Log("At getRootRenderObjectFake : not implement yet");
return new SynchronousFuture<object>("At getRootRenderObjectFake : not implement yet");
}
Future<RemoteDiagnosticsNode> parseDiagnosticsNodeDaemon(
Future<object> json) {

Future<RemoteDiagnosticsNode> getRootWidget() {
return invokeServiceMethodReturningNode("getRootWidgetSummaryTree");
}
Future<RemoteDiagnosticsNode> getRootWidgetFullTree() {
return invokeServiceMethodReturningNode("getRootWidget");
Future<RemoteDiagnosticsNode> getSummaryTreeWithoutIds() {
return parseDiagnosticsNodeDaemon(
invokeServiceMethodDaemon("getRootWidgetSummaryTree"));
}
Future<RemoteDiagnosticsNode> getRootRenderObject()
{
return Future.value(FutureOr.value(null)).to<RemoteDiagnosticsNode>();
Future<RemoteDiagnosticsNode> getRootRenderObject() {
D.assert(!disposed);
return invokeServiceMethodReturningNode("getRootRenderObject");
public Future<RemoteDiagnosticsNode> getDetailsSubtree(

public class InspectorService
{
// VmService vmService;
public static int nextGroupId = 0;
public Future<string> inferPubRootDirectoryIfNeeded()
{

}
}
public Future<bool> isWidgetTreeReady() {
return invokeBoolServiceMethodNoArgs("isWidgetTreeReady");
}
Future<bool> invokeBoolServiceMethodNoArgs(string methodName) {
if (useDaemonApi) {
return invokeServiceMethodDaemonNoGroupArgs(methodName).then_<bool>((v)=>
{
if (v == null)
{
return false;
}
return (bool)v;
});
}
else {
// return (invokeServiceMethodObservatoryNoGroup(methodName))
// ?.valueAsString ==
// "true";
return null;
}
}
Future<object> invokeServiceMethodDaemonNoGroupArgs(string methodName,
List<string> args = null) {
Dictionary<string, object> _params = new Dictionary<string, object>();
if (args != null) {
for (int i = 0; i < args.Count; ++i) {
_params[$"arg{i}"] = args[i];
}
}
return invokeServiceMethodDaemonNoGroup(methodName, _params);
}
Future<object> invokeServiceMethodDaemonNoGroup(
string methodName, Dictionary<string, object> args) {
if (methodName == "isWidgetTreeReady")
{
return new SynchronousFuture<object>(true);
}
Debug.Log("Function invokeServiceMethodDaemonNoGroup : not implement yet");
return new SynchronousFuture<object>(false);
// string callMethodName = $"ext.flutter.inspector.{methodName}";
// if (!Globals.serviceManager.serviceExtensionManager
// .isServiceExtensionAvailable(callMethodName)) {
// return new SynchronousFuture<object>(new Dictionary<string,object>()
// {
// {"result", null}
// });
// }
//
// var r = vmService.callServiceExtension(
// callMethodName,
// isolateId: inspectorLibrary.isolateId,
// args: args
// );
// var json = r.json;
// if (json["errorMessage"] != null) {
// throw new Exception($"{methodName} -- {json["errorMessage"]}");
// }
// return json["result"];
}
// static Future<InspectorService> create(VmService vmService) async {
// assert(_inspectorDependenciesLoaded);

1
com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_tree.cs


}
public InspectorTreeRow getCachedRow(int index) {
Debug.Log("getCachedRow: " + index);
_maybeClearCache();
while (cachedRows.Count <= index) {
cachedRows.Add(null);

4
com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_tree_flutter.cs


public override void setState(VoidCallback fn)
{
fn();
Debug.Log("setState here");
if (client != null)
{
client.onChanged();

public Ticker createTicker(TickerCallback onTick)
{
Debug.Log("CreateTicker");
return null;
return new Ticker(null);
}
}

34
com.unity.uiwidgets.devtools/Editor/v2/src/inspector/layout_explorer/flex/flex.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.DevTools.inspector.layout_explorer.flex
{
public class FlexLayoutExplorerWidget : StatefulWidget {
public FlexLayoutExplorerWidget(
InspectorController inspectorController,
Key key = null
) : base(key: key)
{
this.inspectorController = inspectorController;
}
public readonly InspectorController inspectorController;
public static bool shouldDisplay(RemoteDiagnosticsNode node) {
return (node?.isFlex ?? false) || (node?.parent?.isFlex ?? false);
}
public override State createState()
{
return new _FlexLayoutExplorerWidgetState();
}
}
public class _FlexLayoutExplorerWidgetState : State<FlexLayoutExplorerWidget>
{
public override Widget build(BuildContext context)
{
return new Container(child: new Text("asdfafafa dakfiwejo"));
}
}
}

50
com.unity.uiwidgets.devtools/Editor/v2/src/inspector/layout_explorer/layout_explorer.cs


using Unity.UIWidgets.DevTools.inspector.layout_explorer.flex;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.DevTools.inspector.layout_explorer
{
public class LayoutExplorerTab : StatefulWidget {
public LayoutExplorerTab(Key key = null, InspectorController controller = null) : base(key: key)
{
this.controller = controller;
}
public readonly InspectorController controller;
public override State createState()
{
return new _LayoutExplorerTabState();
}
}
public class _LayoutExplorerTabState : State<LayoutExplorerTab>
{
InspectorController controller => widget.controller;
RemoteDiagnosticsNode selected => controller?.selectedNode?.diagnostic;
Widget rootWidget(RemoteDiagnosticsNode node) {
if (FlexLayoutExplorerWidget.shouldDisplay(node))
return new FlexLayoutExplorerWidget(controller);
return new Center(
child: new Text(
"Currently, Layout Explorer only supports Flex-based widgets" +
"(e.g., Row, Column, Flex) or their direct children.",
textAlign: TextAlign.center,
overflow: TextOverflow.clip
)
);
}
public override Widget build(BuildContext context)
{
return rootWidget(selected);
}
}
}
正在加载...
取消
保存