浏览代码

update inspector

/zxw-devTools
guanghuispark 3 年前
当前提交
c1db5330
共有 25 个文件被更改,包括 1208 次插入126 次删除
  1. 50
      com.unity.uiwidgets.devtools/Editor/v2/dependencies/provider/deferred_inherited_provider.cs
  2. 26
      com.unity.uiwidgets.devtools/Editor/v2/dependencies/provider/inherited_provider.cs
  3. 1
      com.unity.uiwidgets.devtools/Editor/v2/main.cs
  4. 52
      com.unity.uiwidgets.devtools/Editor/v2/src/app.cs
  5. 54
      com.unity.uiwidgets.devtools/Editor/v2/src/banner_messages.cs
  6. 3
      com.unity.uiwidgets.devtools/Editor/v2/src/config_specific/framework_initialize/framework_initialize.cs
  7. 7
      com.unity.uiwidgets.devtools/Editor/v2/src/globals.cs
  8. 1
      com.unity.uiwidgets.devtools/Editor/v2/src/initializer.cs
  9. 186
      com.unity.uiwidgets.devtools/Editor/v2/src/inspector/diagnostics_node.cs
  10. 52
      com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_controller.cs
  11. 83
      com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_screen.cs
  12. 163
      com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_tree.cs
  13. 23
      com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_tree_flutter.cs
  14. 10
      com.unity.uiwidgets.devtools/Editor/v2/src/notifications.cs
  15. 169
      com.unity.uiwidgets.devtools/Editor/v2/src/scaffold.cs
  16. 248
      com.unity.uiwidgets.devtools/Editor/v2/src/split.cs
  17. 2
      com.unity.uiwidgets.devtools/Editor/v2/src/theme.cs
  18. 24
      com.unity.uiwidgets.devtools/Editor/v2/src/framework_controller.cs
  19. 48
      com.unity.uiwidgets.devtools/Editor/v2/src/utils.cs
  20. 65
      com.unity.uiwidgets.devtools/Editor/v2/src/config_specific/drag_and_drop/drag_and_drop.cs
  21. 55
      com.unity.uiwidgets.devtools/Editor/v2/src/config_specific/import_export/import_export.cs
  22. 12
      com.unity.uiwidgets.devtools/Editor/v2/src/framework/framework_core.cs

50
com.unity.uiwidgets.devtools/Editor/v2/dependencies/provider/deferred_inherited_provider.cs


bool? lazy = null,
TransitionBuilder builder = null,
Widget child = null
)
) : base(
key: key,
child: child,
lazy: lazy,
builder: builder,
_delegate: new _CreateDeferredInheritedProvider<T,R>(
create: create,
dispose: dispose,
updateShouldNotify: updateShouldNotify,
startListening: startListening
))
base._constructor(
key: key,
child: child,
lazy: lazy,
builder: builder,
_delegate: new _CreateDeferredInheritedProvider<T,R>(
create: create,
dispose: dispose,
updateShouldNotify: updateShouldNotify,
startListening: startListening
)
);
/// Listens to `value` and expose its content to `child` and its descendants.
public DeferredInheritedProvider(
Key key = null,
T value = default,

TransitionBuilder builder = null,
Widget child = null
)
): base(key: key,
lazy: lazy,
builder: builder,
_delegate: new _ValueDeferredInheritedProvider<T, R>(
value,
updateShouldNotify,
startListening
),
child: child)
base._constructor(
key: key,
lazy: lazy,
builder: builder,
_delegate: new _ValueDeferredInheritedProvider<T, R>(
value,
updateShouldNotify,
startListening
),
child: child
);
}
}

26
com.unity.uiwidgets.devtools/Editor/v2/dependencies/provider/inherited_provider.cs


public readonly bool? _lazy;
public readonly TransitionBuilder builder;
public InheritedProvider<T> _constructor(
public InheritedProvider(
)
):
base(key: key, child: child)
return new InheritedProvider<T>(key: key, child: child, lazy: lazy, _delegate: _delegate, builder: builder);
this._lazy = lazy;
this._delegate = _delegate;
this.builder = builder;
// D.assert(
// builder != null || child != null,
// () => $"runtimeType used outside of MultiProvider must specify a child"
// );
D.assert(
builder != null || child != null,
() => $"runtimeType used outside of MultiProvider must specify a child"
);
return new _InheritedProviderScope<T>(
owner: this,
child: builder != null

)
)
: new Container(child : new Text("child is null"))
: child
);
}
}

{
get
{
return _delegateState.value;
if (_delegateState != null)
{
return _delegateState.value;
}
return default;
}
}

1
com.unity.uiwidgets.devtools/Editor/v2/main.cs


protected override void main()
{
var preferences = new PreferencesController();
FrameworkInitializeUtils.initializeFramework();
ui_.runApp(
new DevToolsApp(AppUtils.defaultScreens, preferences)
);

52
com.unity.uiwidgets.devtools/Editor/v2/src/app.cs


using Unity.UIWidgets.DevTools.inspector;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.DevTools

// var path = uri.PathAndQuery.isEmpty() ? AppUtils.homeRoute : uri.PathAndQuery;
var args = (SnapshotArguments) settings.arguments;
var path = AppUtils.snapshotRoute;
var path = AppUtils.homeRoute;
// Provide the appropriate page route.
if (routes.ContainsKey(path))

null,
new Dictionary<string, string>(){{"uri","inspector"},{"embed","true"},{"page","inspector"}},
args
);
D.assert(() =>

settings: settings,
builder: (BuildContext context) => {
return DevToolsScaffold.withChild(
child: new Container()
child: new Container(child:new Text("_generateRoute error"))
);
}
);

Dictionary<string, UrlParametersBuilder> builders = new Dictionary<string, UrlParametersBuilder>();
builders.Add(AppUtils.homeRoute, (_, _params, __) =>
{
if (_params.ContainsKey("uri"))
{
if (_params["uri"]?.isNotEmpty() ?? false) {
var temp = _visibleScreens();
var visibleScreens = new List<Screen>();
if (embed && page != null)
{
foreach (var screen in temp)
{
if (screen.screenId == page)
{
visibleScreens.Add(screen);
}
}
}
var tabs = embed && page != null ? visibleScreens : temp;
url: _params["uri"].ToString(),
url: _params["uri"],
builder: null
builder: (___) => _providedControllers(
child: new DevToolsScaffold(
embed: embed,
initialPage: page,
tabs: tabs,
actions: new List<Widget>()
{
new Text("ba ga"),
new Text("ya lu"),
}
)
)
// return DevToolsScaffold.withChild(child: ConnectScreenBody());
return new Container(child: new Text("this is a text!"));
return DevToolsScaffold.withChild(child: new Text("app.cs line 144"));
});
builders.Add(AppUtils.snapshotRoute, (_, __, args) =>
{

)
);
});
return builders;
}

Dictionary<string, UrlParametersBuilder> _routes;
List<Screen> _visibleScreens() {
var visibleScreens = new List<Screen>();
foreach (var screen in _screens) {
visibleScreens.Add(screen);
}
return visibleScreens;
}
Widget _providedControllers(Widget child = null, bool offline = false)
{
List<SingleChildWidgetMixinStatelessWidget> _providers = new List<SingleChildWidgetMixinStatelessWidget>();

54
com.unity.uiwidgets.devtools/Editor/v2/src/banner_messages.cs


public override Widget build(BuildContext context)
{
return new Container();
// var controller = Provider<object>.of<BannerMessagesController>(context);
// var messagesForScreen = controller?.messagesForScreen(screen.screenId);
// List<Widget> temp = new List<Widget>();
// if (messagesForScreen != null)
// {
// temp.Add(new ValueListenableBuilder<List<BannerMessage>>(
// valueListenable: messagesForScreen,
// builder: (context2, messages, _) => {
// return new Column(
// children: messages
// );
// }
// ));
// }
// temp.Add(new Expanded(
// child: screen.build(context)
// ));
//
//
// return new Column(
// children: temp
// );
// return new Container();
var controller = Provider<object>.of<BannerMessagesController>(context);
var messagesForScreen = controller?.messagesForScreen(screen.screenId);
List<Widget> temp = new List<Widget>();
if (messagesForScreen != null)
{
temp.Add(new ValueListenableBuilder<List<BannerMessage>>(
valueListenable: messagesForScreen,
builder: (context2, messages, _) =>
{
List<Widget> temp1 = new List<Widget>();
foreach (var msg in messages)
{
temp1.Add(msg);
}
return new Column(
children: temp1
);
}
));
}
temp.Add(new Expanded(
child: screen.build(context)
));
return new Column(
children: temp
);
}
}

screenId, () => new ValueNotifier<List<BannerMessage>>(null));
}
ValueListenable<List<BannerMessage>> messagesForScreen(string screenId) {
public ValueListenable<List<BannerMessage>> messagesForScreen(string screenId) {
return _messagesForScreen(screenId);
}
}

3
com.unity.uiwidgets.devtools/Editor/v2/src/config_specific/framework_initialize/framework_initialize.cs


using Unity.UIWidgets.DevTools.framework;
using UnityEngine;
namespace Unity.UIWidgets.DevTools.config_specific.framework_initialize

public static void initializeFramework()
{
Debug.Log("empty initializeFramework");
FrameworkCore.initGlobals();
}
}
}

7
com.unity.uiwidgets.devtools/Editor/v2/src/globals.cs


using System;
using System.Collections.Generic;
using NUnit.Framework.Api;
public static Dictionary<string, object> offlineDataJson = new Dictionary<string, object>(){};
public static FrameworkController frameworkController => globals[typeof(FrameworkController)] as FrameworkController;
public static void setGlobal(Type clazz, dynamic instance) {
globals[clazz] = instance;
}
}
}

1
com.unity.uiwidgets.devtools/Editor/v2/src/initializer.cs


{
public override Widget build(BuildContext context)
{
return widget.builder(context);
// return _checkLoaded() && _dependenciesLoaded
// ? widget.builder(context)
// : new Scaffold(

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


using System.Collections;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;

public RemoteDiagnosticsNode(
Dictionary<string, Object> json,
Dictionary<string, object> json,
FutureOr inspectorService,
bool isProperty,
RemoteDiagnosticsNode parent

public readonly FutureOr inspectorService; // FutureOr<ObjectGroup>
public readonly Dictionary<string, object> json;
List<RemoteDiagnosticsNode> _children;
bool hasCreationLocation {
get
{
return _creationLocation != null || json.ContainsKey("creationLocation");
}
}
string name
{
get
{
return getStringMember("name");
}
}
string getStringMember(string memberName) {
return JsonUtils.getStringMember(json, memberName);
}
public bool childrenReady {
get
{
return json.ContainsKey("children") || _children != null || !hasChildren;
}
}
InspectorSourceLocation _creationLocation;
InspectorSourceLocation creationLocation {
get
{
if (_creationLocation != null) {
return _creationLocation;
}
if (!hasCreationLocation) {
return null;
}
_creationLocation = new InspectorSourceLocation((Dictionary<string,object>)json["creationLocation"], null);
return _creationLocation;
}
set
{
_creationLocation = value;
}
}
public DiagnosticsTreeStyle? style {
get

}
}
public bool hasChildren {
get
{
List<object> children = json["children"] as List<object>;
if (children != null) {
return children.isNotEmpty();
}
return getBooleanMember("hasChildren", false);
}
}
bool getBooleanMember(string memberName, bool defaultValue) {
if (json[memberName] == null) {
return defaultValue;
}
return (bool)json[memberName];
}
public List<RemoteDiagnosticsNode> inlineProperties {
get
{
if (cachedProperties == null) {
cachedProperties = new List<RemoteDiagnosticsNode>();
if (json.ContainsKey("properties")) {
List<object> jsonArray = (List<object>)json["properties"];
foreach (Dictionary<string, object> element in jsonArray) {
cachedProperties.Add(
new RemoteDiagnosticsNode(element, inspectorService, true, parent));
}
trackPropertiesMatchingParameters(cachedProperties);
}
}
return cachedProperties;
}
}
List<RemoteDiagnosticsNode> trackPropertiesMatchingParameters(
List<RemoteDiagnosticsNode> nodes) {
List<InspectorSourceLocation> parameterLocations =
creationLocation?.getParameterLocations();
if (parameterLocations != null) {
Dictionary<string, InspectorSourceLocation> names = new Dictionary<string, InspectorSourceLocation>();
foreach (InspectorSourceLocation location in parameterLocations) {
string name = location.getName();
if (name != null) {
names[name] = location;
}
}
foreach (RemoteDiagnosticsNode node in nodes) {
node.parent = this;
string name = node.name;
if (name != null) {
InspectorSourceLocation parameterLocation = names[name];
if (parameterLocation != null) {
node.creationLocation = parameterLocation;
}
}
}
}
return nodes;
}
public List<RemoteDiagnosticsNode> childrenNow {
get
{
// _maybePopulateChildren();
return _children;
}
}
class InspectorSourceLocation {
public InspectorSourceLocation(Dictionary<string, object> json, InspectorSourceLocation parent)
{
this.json = json;
this.parent = parent;
}
public readonly Dictionary<string, object> json;
public readonly InspectorSourceLocation parent;
string path
{
get
{
return JsonUtils.getStringMember(json, "file");
}
}
string getFile() {
var fileName = path;
if (fileName == null) {
return parent != null ? parent.getFile() : null;
}
return fileName;
}
int getLine() => JsonUtils.getIntMember(json, "line");
public string getName() => JsonUtils.getStringMember(json, "name");
int getColumn() => JsonUtils.getIntMember(json, "column");
// SourcePosition getXSourcePosition() {
// var file = getFile();
// if (file == null) {
// return null;
// }
// int line = getLine();
// int column = getColumn();
// if (line < 0 || column < 0) {
// return null;
// }
// return SourcePosition(file: file, line: line - 1, column: column - 1);
// }
public List<InspectorSourceLocation> getParameterLocations() {
if (json.ContainsKey("parameterLocations")) {
List<object> parametersJson = (List<object>)json["parameterLocations"];
List<InspectorSourceLocation> ret = new List<InspectorSourceLocation>();
for (int i = 0; i < parametersJson.Count; ++i) {
ret.Add(new InspectorSourceLocation((Dictionary<string, object>)parametersJson[i], this));
}
return ret;
}
return null;
}
}
}

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


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
public InspectorController(
// @required this.inspectorService,
InspectorTreeController inspectorTree = null,
InspectorTreeController detailsTree = null,
// @required this.treeType,
InspectorController parent = null,
bool isSummaryTree = true,
VoidCallback onExpandCollapseSupported = null,
VoidCallback onLayoutExplorerSupported = null
)
{
this.inspectorTree = inspectorTree;
this.parent = parent;
this.isSummaryTree = isSummaryTree;
this.onExpandCollapseSupported = onExpandCollapseSupported;
this.onLayoutExplorerSupported = onLayoutExplorerSupported;
}
InspectorTreeController inspectorTree;
// public readonly FlutterTreeType treeType;
// public readonly InspectorService inspectorService;
bool _disposed = false;
InspectorController parent;
public readonly bool isSummaryTree;
public readonly VoidCallback onExpandCollapseSupported;
public readonly VoidCallback onLayoutExplorerSupported;
// public override void dispose() {
// D.assert(!_disposed);
// _disposed = true;
// flutterIsolateSubscription.cancel();
// if (inspectorService != null) {
// shutdownTree(false);
// }
// _treeGroups?.clear(false);
// _treeGroups = null;
// _selectionGroups?.clear(false);
// _selectionGroups = null;
// details?.dispose();
// base.dispose();
// }
}
}

83
com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_screen.cs


using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.widgets;
using UnityEngine;
namespace Unity.UIWidgets.DevTools.inspector
{

class _InspectorScreenBodyState : State<InspectorScreenBody>
{
bool _layoutExplorerSupported = false;
bool _expandCollapseSupported = false;
public override void initState() {
base.initState();
_handleConnectionStart();
}
void _onExpandCollapseSupported() {
setState(() => {
_expandCollapseSupported = true;
});
}
void _onLayoutExplorerSupported() {
setState(() => {
_layoutExplorerSupported = true;
});
}
void _handleConnectionStart()
{
setState(() => {
// inspectorController?.dispose();
summaryTreeController = new InspectorTreeControllerFlutter();
detailsTreeController = new InspectorTreeControllerFlutter();
inspectorController = new InspectorController(
inspectorTree: summaryTreeController,
detailsTree: detailsTreeController,
// inspectorService: inspectorService,
// treeType: FlutterTreeType.widget,
onExpandCollapseSupported: _onExpandCollapseSupported,
onLayoutExplorerSupported: _onLayoutExplorerSupported
);
});
}
public override Widget build(BuildContext context)
{
var summaryTree = new Container(

);
var splitAxis = Split.axisFor(context, 0.85f);
// return new Column(
// children: new List<Widget>
// {
// new Expanded(
// child: new Split(
// axis: splitAxis,
// initialFractions: new List<float?>{0.33f, 0.67f},
// children: new List<Widget>
// {
// summaryTree,
// new InspectorDetailsTabController(
// detailsTree: detailsTree,
// controller: inspectorController,
// actionButtons: null,
// layoutExplorerSupported: _layoutExplorerSupported
// )
// }
// )
// )
// }
// );
return new Container();
return new Column(
children: new List<Widget>
{
new Expanded(
child: new Split(
axis: splitAxis,
initialFractions: new List<float?>{0.33f, 0.67f},
children: new List<Widget>
{
summaryTree,
new InspectorDetailsTabController(
detailsTree: detailsTree,
controller: inspectorController,
actionButtons: null,
layoutExplorerSupported: _layoutExplorerSupported
)
}
)
)
}
);
}
}
}

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


using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.DevTools.inspector
{

abstract class InspectorTreeController
{
public abstract void setState(VoidCallback fn);
public abstract InspectorTreeNode createNode();
public float? lastContentWidth;
public int numRows
{

InspectorTreeNode _root;
// InspectorTreeConfig config
// {
// get
// {
// return _config;
// }
// }
//
// InspectorTreeConfig _config;
Debug.Log("getCachedRow");
// _maybeClearCache();
// while (cachedRows.length <= index) {
// cachedRows.add(null);

return (depth.Value + 1) * InspectorTreeUtils.columnWidth + horizontalPadding;
}
void removeNodeFromParent(InspectorTreeNode node) {
setState(() => {
node.parent?.removeChild(node);
});
}
void appendChild(InspectorTreeNode node, InspectorTreeNode child) {
setState(() => {
node.appendChild(child);
});
}
InspectorTreeNode setupInspectorTreeNode(
InspectorTreeNode node,
RemoteDiagnosticsNode diagnosticsNode,
bool expandChildren = false,
bool expandProperties = false
) {
D.assert(expandChildren != null);
D.assert(expandProperties != null);
node.diagnostic = diagnosticsNode;
// if (config.onNodeAdded != null) {
// config.onNodeAdded(node, diagnosticsNode);
// }
if (diagnosticsNode.hasChildren ||
diagnosticsNode.inlineProperties.isNotEmpty()) {
if (diagnosticsNode.childrenReady || !diagnosticsNode.hasChildren) {
bool styleIsMultiline =
expandPropertiesByDefault(diagnosticsNode.style.Value);
setupChildren(
diagnosticsNode,
node,
node.diagnostic.childrenNow,
expandChildren: expandChildren && styleIsMultiline,
expandProperties: expandProperties && styleIsMultiline
);
} else {
node.clearChildren();
node.appendChild(createNode());
}
}
return node;
}
bool expandPropertiesByDefault(DiagnosticsTreeStyle style) {
// This code matches the text style defaults for which styles are
// by default and which aren't.
switch (style) {
case DiagnosticsTreeStyle.none:
case DiagnosticsTreeStyle.singleLine:
case DiagnosticsTreeStyle.errorProperty:
return false;
case DiagnosticsTreeStyle.sparse:
case DiagnosticsTreeStyle.offstage:
case DiagnosticsTreeStyle.dense:
case DiagnosticsTreeStyle.transition:
case DiagnosticsTreeStyle.error:
case DiagnosticsTreeStyle.whitespace:
case DiagnosticsTreeStyle.flat:
case DiagnosticsTreeStyle.shallow:
case DiagnosticsTreeStyle.truncateChildren:
return true;
}
return true;
}
void setupChildren(
RemoteDiagnosticsNode parent,
InspectorTreeNode treeNode,
List<RemoteDiagnosticsNode> children,
bool expandChildren = false,
bool expandProperties = false
) {
D.assert(expandChildren != null);
D.assert(expandProperties != null);
treeNode.isExpanded = expandChildren;
if (treeNode.children.isNotEmpty()) {
// Only case supported is this is the loading node.
D.assert(treeNode.children.Count == 1);
removeNodeFromParent(treeNode.children.first());
}
var inlineProperties = parent.inlineProperties;
if (inlineProperties != null) {
foreach (RemoteDiagnosticsNode property in inlineProperties) {
appendChild(
treeNode,
setupInspectorTreeNode(
createNode(),
property,
// We are inside a property so only expand children if
// expandProperties is true.
expandChildren: expandProperties,
expandProperties: expandProperties
)
);
}
}
if (children != null) {
foreach (RemoteDiagnosticsNode child in children) {
appendChild(
treeNode,
setupInspectorTreeNode(
createNode(),
child,
expandChildren: expandChildren,
expandProperties: expandProperties
)
);
}
}
}
}
class InspectorTreeNode

return _children.Count > 1 && !_children.Last().isProperty;
}
}
InspectorTreeNode parent
public InspectorTreeNode parent
{
get
{

}
}
List<InspectorTreeNode> children
public List<InspectorTreeNode> children
{
get
{

}
}
}
bool isExpanded
public bool isExpanded
{
get
{

int? _childrenCount;
public int subtreeSize => childrenCount.GetValueOrDefault(0) + 1;
RemoteDiagnosticsNode diagnostic
public RemoteDiagnosticsNode diagnostic
set
{
_diagnostic = value;
}
}
public InspectorTreeRow getRow(int index) {

}
D.assert(false); // internal error.
return null;
}
public void removeChild(InspectorTreeNode child) {
child.parent = null;
var removed = _children.Remove(child);
D.assert(removed != null);
isDirty = true;
}
public void appendChild(InspectorTreeNode child) {
_children.Add(child);
child.parent = this;
isDirty = true;
}
public void clearChildren() {
_children.Clear();
isDirty = true;
}
}

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


using Unity.UIWidgets.painting;
using Unity.UIWidgets.service;
using Unity.UIWidgets.services;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;

{
public readonly float rowWidth = 1200;
float _maxIndent;
// InspectorControllerClient client
// {
// get
// {
// return _client;
// }
// }
// InspectorControllerClient _client;
public float maxRowIndent {
get
{

}
return _maxIndent;
}
}
public override void setState(VoidCallback fn)
{
fn();
// client?.onChanged();
}
public override InspectorTreeNode createNode()
{
return new InspectorTreeNode();
}
}

10
com.unity.uiwidgets.devtools/Editor/v2/src/notifications.cs


this.child = child;
}
public static NotificationsState of(BuildContext context) {
var provider =
context.dependOnInheritedWidgetOfExactType<_InheritedNotifications>();
return provider?.data;
}
public readonly Widget child;
public override Widget build(BuildContext context)
{

}
class _NotificationsProvider : StatefulWidget {
public class _NotificationsProvider : StatefulWidget {
public _NotificationsProvider(Key key = null, Widget child = null) : base(key: key)
{
this.child = child;

}
}
class NotificationsState : State<_NotificationsProvider>
public class NotificationsState : State<_NotificationsProvider>
{
public override Widget build(BuildContext context)
{

169
com.unity.uiwidgets.devtools/Editor/v2/src/scaffold.cs


using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using Unity.UIWidgets.DevTools.config_specific.drag_and_drop;
using Unity.UIWidgets.DevTools.config_specific.import_export;
using Unity.UIWidgets.material;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler;
namespace Unity.UIWidgets.DevTools
{

base(key: key)
{
D.assert(tabs != null);
this.tabs = tabs;
this.initialPage = initialPage;
this.actions = actions;
this.embed = embed;
}
public static readonly EdgeInsets appPadding =

public readonly bool embed;
public readonly List<Widget> actions;
public override State createState()
{
return new DevToolsScaffoldState();

{
return new DevToolsScaffold(key: key, tabs: new List<Screen>(){new SimpleScreen(child)});
return new DevToolsScaffold(key: key, tabs: new List<Screen>() {new SimpleScreen(child)});
class DevToolsScaffoldState : State<DevToolsScaffold>
class DevToolsScaffoldState : TickerProviderStateMixin<DevToolsScaffold>
ImportController _importController;
TabController _tabController;
List<Ticker> _tickers;
public override void didChangeDependencies() {
base.didChangeDependencies();
_importController = new ImportController(
Notifications.of(context),
_pushSnapshotScreenForImport
);
}
public override void initState() {
base.initState();
_setupTabController();
// _connectVmSubscription =
// frameworkController.onConnectVmEvent.listen(_connectVm);
// _showPageSubscription =
// frameworkController.onShowPageId.listen(_showPageById);
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
base.didUpdateWidget(oldWidget);
if (widget.tabs.Count != ((DevToolsScaffold)oldWidget).tabs.Count) {
var newIndex = 0;
if (_tabController != null &&
widget.tabs.Contains(((DevToolsScaffold)oldWidget).tabs[_tabController.index])) {
newIndex = widget.tabs.IndexOf(((DevToolsScaffold)oldWidget).tabs[_tabController.index]);
}
_setupTabController();
_tabController.index = newIndex;
}
}
void _setupTabController() {
_tabController?.dispose();
_tabController = new TabController(length: widget.tabs.Count, vsync: this);
if (widget.initialPage != null) {
int initialIndex = -1;
for (int i = 0; i< widget.tabs.Count; i++)
{
if (widget.tabs[i].screenId == widget.initialPage)
{
initialIndex = i;
}
}
if (initialIndex != -1) {
_tabController.index = initialIndex;
}
}
_currentScreen.value = widget.tabs[_tabController.index];
_tabController.addListener(() => {
var screen = widget.tabs[_tabController.index];
if (_currentScreen.value != screen) {
_currentScreen.value = screen;
Globals.frameworkController.notifyPageChange(screen?.screenId);
}
});
Globals.frameworkController.notifyPageChange(_currentScreen.value.screenId);
}
public void _pushSnapshotScreenForImport(string screenId) {
// var args = new SnapshotArguments(screenId);
// if (offlineMode) {
// if (ModalRoute.of(context).settings.name == snapshotRoute) {
// Navigator.popAndPushNamed(context, snapshotRoute, arguments: args);
// }
// } else {
// Navigator.pushNamed(context, snapshotRoute, arguments: args);
// }
// setState(() => {
// enterOfflineMode();
// });
}
public override Widget build(BuildContext context)
{

));
};
}
child: new Container(height:100,width:100,color:Color.white)
// child: DragAndDrop(
// // TODO(kenz): we are handling drops from multiple scaffolds. We need
// // to make sure we are only handling drops from the active scaffold.
// handleDrop: _importController.importData,
// child: Scaffold(
// appBar: widget.embed ? null : _buildAppBar(),
// body: TabBarView(
// physics: defaultTabBarViewPhysics,
// controller: _tabController,
// children: tabBodies
// ),
// bottomNavigationBar:
// widget.embed ? null : _buildStatusLine(context)
// )
// )
// child: new Container(height:100,width:200,color:Color.white)
child: new DragAndDrop(
handleDrop: null,
child: new Scaffold(
appBar: null, // widget.embed ? null : _buildAppBar(),
body: new TabBarView(
physics: ThemeUtils.defaultTabBarViewPhysics,
controller: _tabController,
children: tabBodies
),
bottomNavigationBar:
widget.embed ? null : _buildStatusLine(context)
)
)
return new Container(child:new Text("enter here"));
}
Widget _buildStatusLine(BuildContext context) {
var appPadding = DevToolsScaffold.appPadding;
return new Container(
height: 48.0f,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: new List<Widget>{
// new PaddedDivider(padding: EdgeInsets.zero), [attention]
new Padding(
padding: EdgeInsets.only(
left: appPadding.left,
right: appPadding.right,
bottom: appPadding.bottom
),
child: new Container()// StatusLine()
),
}
)
);
}
public Ticker createTicker(TickerCallback onTick)
{
// if (_tickers == null)
// {
// _tickers = new List<Ticker>();
// }
// _WidgetTicker<DevToolsScaffold> result = new _WidgetTicker<DevToolsScaffold>(onTick, this, debugLabel: $"created by {this}");
// _tickers.Add(result);
// return result;
return null;
}
}

248
com.unity.uiwidgets.devtools/Editor/v2/src/split.cs


using System;
using NUnit.Framework;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.material;
using Unity.UIWidgets.ui;
using UnityEngine;
using Transform = Unity.UIWidgets.widgets.Transform;
public static class SplitUtils
{
const float defaultEpsilon = 1.0f / 1000;
public static void _verifyFractionsSumTo1(List<float?> fractions) {
var sumFractions = 0.0f;
foreach (var fraction in fractions) {
sumFractions += fraction.Value;
}
D.assert(
(1.0f - sumFractions).abs() < defaultEpsilon,
()=>$"Fractions should sum to 1.0, but instead sum to {sumFractions}:\n{fractions}"
);
}
}
class Split : StatefulWidget
{
/// Builds a split oriented along [axis].

D.assert(children != null && children.Count >= 2);
D.assert(initialFractions != null && initialFractions.Count >= 2);
D.assert(children?.Count == initialFractions?.Count);
// _verifyFractionsSumTo1(initialFractions);
SplitUtils._verifyFractionsSumTo1(initialFractions);
if (minSizes != null)
{
D.assert(minSizes.Count == children?.Count);

public readonly List<float?> minSizes;
public readonly List<SizedBox> splitters;
public Key dividerKey(int index) => Key.key($"{this} dividerKey {index}");
public override State createState()
{
return new _SplitState();

class _SplitState : State<Split>
{
List<float?> fractions;
bool isHorizontal
{
get
{
return widget.axis == Axis.horizontal;
}
}
public override void initState() {
base.initState();
fractions = widget.initialFractions;
}
// return new LayoutBuilder(builder: _buildLayout);
return new Container(child: new Text("this is a text!"));
return new LayoutBuilder(builder: _buildLayout);
Widget _buildLayout(BuildContext context, BoxConstraints constraints)
{
var width = constraints.maxWidth;
var height = constraints.maxHeight;
var axisSize = isHorizontal ? width : height;
var availableSize = axisSize - _totalSplitterSize();
float _sizeForIndex(int index) => availableSize * fractions[index].Value;
List<float> sizes = new List<float>();
for (int i = 0; i < fractions.Count; i++)
{
sizes.Add(_sizeForIndex(i));
}
float _minSizeForIndex(int index) {
if (widget.minSizes == null) return 0.0f;
float totalMinSize = 0;
foreach (var minSize in widget.minSizes) {
totalMinSize += minSize.Value;
}
// Reduce the min sizes gracefully if the total required min size for all
// children is greater than the available size for children.
if (totalMinSize > availableSize) {
return widget.minSizes[index].Value * availableSize / totalMinSize;
}
return widget.minSizes[index].Value;
}
float _minFractionForIndex(int index) =>
_minSizeForIndex(index) / availableSize;
void _clampFraction(int index) {
fractions[index] =
fractions[index].Value.clamp(_minFractionForIndex(index), 1.0f);
}
void updateSpacing(DragUpdateDetails dragDetails, int splitterIndex) {
var dragDelta =
isHorizontal ? dragDetails.delta.dx : dragDetails.delta.dy;
var fractionalDelta = dragDelta / axisSize;
float updateSpacingBeforeSplitterIndex(float delta) {
var startingDelta = delta;
var index = splitterIndex;
while (index >= 0) {
fractions[index] += delta;
var minFractionForIndex = _minFractionForIndex(index);
if (fractions[index] >= minFractionForIndex) {
_clampFraction(index);
return startingDelta;
}
delta = fractions[index].Value - minFractionForIndex;
_clampFraction(index);
index--;
}
return startingDelta - delta;
}
float updateSpacingAfterSplitterIndex(float delta) {
var startingDelta = delta;
var index = splitterIndex + 1;
while (index < fractions.Count) {
fractions[index] += delta;
var minFractionForIndex = _minFractionForIndex(index);
if (fractions[index] >= minFractionForIndex) {
_clampFraction(index);
return startingDelta;
}
delta = fractions[index].Value - minFractionForIndex;
_clampFraction(index);
index++;
}
return startingDelta - delta;
}
setState(() => {
if (fractionalDelta <= 0.0f)
{
var appliedDelta =
updateSpacingBeforeSplitterIndex(fractionalDelta);
updateSpacingAfterSplitterIndex(-appliedDelta);
} else {
var appliedDelta =
updateSpacingAfterSplitterIndex(-fractionalDelta);
updateSpacingBeforeSplitterIndex(-appliedDelta);
}
});
SplitUtils._verifyFractionsSumTo1(fractions);
}
List<Widget> children = new List<Widget>();
for (int i = 0; i < widget.children.Count; i++) {
children.Add(
new SizedBox(
width: isHorizontal ? sizes[i] : width,
height: isHorizontal ? height : sizes[i],
child: widget.children[i]
)
);
if (i < widget.children.Count - 1)
{
if (isHorizontal)
{
children.Add(
new MouseRegion(
// cursor: SystemMouseCursors.grab,
child: new GestureDetector(
key: widget.dividerKey(i),
behavior: HitTestBehavior.translucent,
onHorizontalDragUpdate: (details) => updateSpacing(details, i),
onVerticalDragUpdate: (details) =>
{
return;
},
dragStartBehavior: DragStartBehavior.down,
child: widget.splitters != null
? widget.splitters[i]
: new SizedBox(child:new DefaultSplitter(isHorizontal: isHorizontal))
)
)
);
}
else
{
children.Add(
new MouseRegion(
// cursor: SystemMouseCursors.grab,
child: new GestureDetector(
key: widget.dividerKey(i),
behavior: HitTestBehavior.translucent,
onHorizontalDragUpdate: (details) =>
{
return;
},
onVerticalDragUpdate: (details) => updateSpacing(details, i),
dragStartBehavior: DragStartBehavior.down,
child: widget.splitters != null
? widget.splitters[i]
: new SizedBox(child:new DefaultSplitter(isHorizontal: isHorizontal))
)
)
);
}
}
}
return new Flex(direction: widget.axis.Value, children: children);
}
float _totalSplitterSize() {
var numSplitters = widget.children.Count - 1;
if (widget.splitters == null) {
return numSplitters * DefaultSplitter.splitterWidth;
} else {
var totalSize = 0.0f;
foreach (var splitter in widget.splitters) {
totalSize += isHorizontal ? splitter.width.Value : splitter.height.Value;
}
return totalSize;
}
}
class DefaultSplitter : StatelessWidget {
public DefaultSplitter(bool isHorizontal = true)
{
this.isHorizontal = isHorizontal;
}
public static readonly float iconSize = 24.0f;
public static readonly float splitterWidth = 12.0f;
bool isHorizontal;
public override Widget build(BuildContext context)
{
return Transform.rotate(
angle: isHorizontal ? utils.degToRad(90.0f) : utils.degToRad(0.0f),
child: new Align(
widthFactor: 0.5f,
heightFactor: 0.5f,
child: new Icon(
Icons.drag_handle,
size: iconSize,
color: Theme.of(context).focusColor
)
)
);
}
}
}

2
com.unity.uiwidgets.devtools/Editor/v2/src/theme.cs


using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.DevTools
{

public const float buttonMinWidth = 36.0f;
public const float denseRowSpacing = 6.0f;
public const float defaultSpacing = 16.0f;
public static readonly NeverScrollableScrollPhysics defaultTabBarViewPhysics = new NeverScrollableScrollPhysics();
static ColorSwatch<int> devtoolsGrey = new ColorSwatch<int>(0xFF202124, new Dictionary<int, Color>(){
{900, new Color(0xFF202124)},

24
com.unity.uiwidgets.devtools/Editor/v2/src/framework_controller.cs


namespace Unity.UIWidgets.DevTools
{
public class FrameworkController
{
public FrameworkController()
{
_init();
}
// StreamController<string> _pageChangeController =
// StreamController.broadcast();
void _init()
{
}
public void notifyPageChange(string pageId) {
// _pageChangeController.add(pageId);
}
}
}

48
com.unity.uiwidgets.devtools/Editor/v2/src/utils.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.DevTools
{
public class utils
{
public static readonly float pi = 3.1415926535897932f;
public static float degToRad(float deg) => deg * (pi / 180.0f);
}
class JsonUtils {
// JsonUtils._();
public static string getStringMember(Dictionary<string, object> json, string memberName) {
// TODO(jacobr): should we handle non-string values with a reasonable
// toString differently?
return json[memberName] as string;
}
public static int getIntMember(Dictionary<string, object> json, string memberName) {
if (json.ContainsKey(memberName))
{
return (int) json[memberName];
}
return -1;
}
public static List<string> getValues(Dictionary<string, object> json, string member) {
List<object> values = (List<object>)json[member];
if (values == null || values.isEmpty()) {
return new List<string>();
}
List<string> res = new List<string>();
foreach (var value in values)
{
res.Add(value.ToString());
}
return res;
}
static bool hasJsonData(String data) {
return data != null && data.isNotEmpty() && data != "null";
}
}
}

65
com.unity.uiwidgets.devtools/Editor/v2/src/config_specific/drag_and_drop/drag_and_drop.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.widgets;
using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.DevTools.config_specific.drag_and_drop
{
public delegate void HandleDrop(Dictionary<string, object> data);
public class DragAndDrop : StatefulWidget {
public DragAndDrop(
HandleDrop handleDrop= null,
Widget child = null
)
{
this.handleDrop = handleDrop;
this.child = child;
}
public readonly HandleDrop handleDrop;
public readonly Widget child;
public override State createState() => new DragAndDropState();
}
public class DragAndDropState : State<DragAndDrop> {
ValueNotifier<bool> _dragging = new ValueNotifier<bool>(false);
NotificationsState notifications;
public override void didChangeDependencies() {
notifications = Notifications.of(context);
base.didChangeDependencies();
}
public override Widget build(BuildContext context) {
return new ValueListenableBuilder<bool>(
valueListenable: _dragging,
builder: (context2, dragging, _) => {
// TODO(kenz): use AnimatedOpacity instead.
return new Opacity(
opacity: dragging ? 0.5f : 1.0f,
child: widget.child
);
}
);
}
void dragOver() {
_dragging.value = true;
}
void dragLeave() {
_dragging.value = false;
}
void drop() {
_dragging.value = false;
}
}
}

55
com.unity.uiwidgets.devtools/Editor/v2/src/config_specific/import_export/import_export.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.DevTools.config_specific.import_export
{
public delegate void PushSnapshotScreenForImport(string screenId);
public static class ImportExportUtils{
public static readonly string devToolsSnapshotKey = "devToolsSnapshot";
public static readonly string activeScreenIdKey = "activeScreenId";
}
public class ImportController
{
// public ImportController(
// this._notifications,
// this._pushSnapshotScreenForImport
// );
public readonly PushSnapshotScreenForImport _pushSnapshotScreenForImport;
// public readonly NotificationService _notifications;
public static readonly int repeatImportTimeBufferMs = 500;
DateTime previousImportTime;
public ImportController(NotificationsState of, Action<string> pushSnapshotScreenForImport)
{
this._pushSnapshotScreenForImport = _pushSnapshotScreenForImport;
}
public void importData(Dictionary<string, object> json) {
var now = DateTime.Now;
if (previousImportTime != null &&
(now.Millisecond - previousImportTime.Millisecond)
.abs() <
repeatImportTimeBufferMs) {
return;
}
previousImportTime = now;
var isDevToolsSnapshot = json[ImportExportUtils.devToolsSnapshotKey];
if (isDevToolsSnapshot == null) {
Debug.Log("isDevToolsSnapshot == null");
return;
}
var activeScreenId = json[ImportExportUtils.activeScreenIdKey];
Globals.offlineDataJson = json;
// _notifications.push(attemptingToImportMessage(activeScreenId));
// _pushSnapshotScreenForImport(activeScreenId);
}
}
}

12
com.unity.uiwidgets.devtools/Editor/v2/src/framework/framework_core.cs


namespace Unity.UIWidgets.DevTools.framework
{
public class FrameworkCore
{
public static void initGlobals()
{
// setGlobal(ServiceConnectionManager, ServiceConnectionManager());
// setGlobal(MessageBus, MessageBus());
Globals.setGlobal(typeof(FrameworkController), new FrameworkController());
}
}
}
正在加载...
取消
保存