xingweizhu
4 年前
当前提交
2936da39
共有 54 个文件被更改,包括 1049 次插入 和 275 次删除
-
4com.unity.uiwidgets.devtools/Editor/analytics/provider.cs
-
4com.unity.uiwidgets.devtools/Editor/analytics/stub_provider.cs
-
306com.unity.uiwidgets.devtools/Editor/app.cs
-
4com.unity.uiwidgets.devtools/Editor/config_specific/ide_theme/ide_theme.cs
-
4com.unity.uiwidgets.devtools/Editor/enum_utils.cs
-
4com.unity.uiwidgets.devtools/Editor/globals.cs
-
4com.unity.uiwidgets.devtools/Editor/inspector/diagnostics.cs
-
53com.unity.uiwidgets.devtools/Editor/inspector/diagnostics_node.cs
-
4com.unity.uiwidgets.devtools/Editor/inspector/flutter_widget.cs
-
4com.unity.uiwidgets.devtools/Editor/inspector/inspector_controller.cs
-
4com.unity.uiwidgets.devtools/Editor/inspector/inspector_data_models.cs
-
4com.unity.uiwidgets.devtools/Editor/inspector/inspector_screen.cs
-
4com.unity.uiwidgets.devtools/Editor/inspector/inspector_screen_details_tab.cs
-
66com.unity.uiwidgets.devtools/Editor/inspector/inspector_service.cs
-
4com.unity.uiwidgets.devtools/Editor/inspector/inspector_text_style.cs
-
4com.unity.uiwidgets.devtools/Editor/inspector/inspector_tree.cs
-
4com.unity.uiwidgets.devtools/Editor/inspector/layout_explorer/box/box.cs
-
4com.unity.uiwidgets.devtools/Editor/inspector/layout_explorer/flex/flex.cs
-
4com.unity.uiwidgets.devtools/Editor/inspector/layout_explorer/flex/utils.cs
-
4com.unity.uiwidgets.devtools/Editor/inspector/layout_explorer/layout_explorer.cs
-
4com.unity.uiwidgets.devtools/Editor/inspector/layout_explorer/ui/arrow.cs
-
4com.unity.uiwidgets.devtools/Editor/inspector/layout_explorer/ui/dimension.cs
-
4com.unity.uiwidgets.devtools/Editor/inspector/layout_explorer/ui/free_space.cs
-
4com.unity.uiwidgets.devtools/Editor/inspector/layout_explorer/ui/layout_explorer_widget.cs
-
4com.unity.uiwidgets.devtools/Editor/inspector/layout_explorer/ui/overflow_indicator_painter.cs
-
4com.unity.uiwidgets.devtools/Editor/inspector/layout_explorer/ui/theme.cs
-
4com.unity.uiwidgets.devtools/Editor/inspector/layout_explorer/ui/utils.cs
-
4com.unity.uiwidgets.devtools/Editor/inspector/layout_explorer/ui/widget_constraints.cs
-
4com.unity.uiwidgets.devtools/Editor/listenable.cs
-
4com.unity.uiwidgets.devtools/Editor/main.cs
-
4com.unity.uiwidgets.devtools/Editor/screen.cs
-
4com.unity.uiwidgets.devtools/Editor/theme.cs
-
4com.unity.uiwidgets.devtools/Editor/ui/icons.cs
-
4com.unity.uiwidgets.devtools/Editor/utils.cs
-
303com.unity.uiwidgets.devtools/Editor/v2/dependencies/nested/nested.cs
-
18com.unity.uiwidgets.devtools/Editor/v2/dependencies/provider/inherited_provider.cs
-
7com.unity.uiwidgets.devtools/Editor/v2/dependencies/provider/provider.cs
-
7com.unity.uiwidgets.devtools/Editor/v2/devtools.cs
-
21com.unity.uiwidgets.devtools/Editor/v2/main.cs
-
216com.unity.uiwidgets.devtools/Editor/v2/src/app.cs
-
12com.unity.uiwidgets.devtools/Editor/v2/src/config_specific/framework_initialize/framework_initialize.cs
-
15com.unity.uiwidgets.devtools/Editor/v2/src/globals.cs
-
20com.unity.uiwidgets.devtools/Editor/v2/src/preferences.cs
-
61com.unity.uiwidgets.devtools/Editor/v2/src/screen.cs
-
18com.unity.uiwidgets.devtools/Editor/v2/src/service_manager.cs
-
11com.unity.uiwidgets.devtools/Editor/v2/src/snapshot_screen.cs
-
66com.unity.uiwidgets.devtools/Editor/v2/src/theme.cs
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.DevTools |
|||
{ |
|||
public class Nested : StatelessWidget |
|||
{ |
|||
public Nested( |
|||
Key key = null, |
|||
List<SingleChildWidget> children = null, |
|||
Widget child = null |
|||
) : base(key: key) |
|||
{ |
|||
D.assert(children != null && children.isNotEmpty()); |
|||
this._children = children; |
|||
this._child = child; |
|||
} |
|||
|
|||
public readonly List<SingleChildWidget> _children; |
|||
public readonly Widget _child; |
|||
|
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
throw new Exception("implemented internally"); |
|||
} |
|||
|
|||
public override Element createElement() |
|||
{ |
|||
return new _NestedElement(this); |
|||
} |
|||
} |
|||
|
|||
public class _NestedElement : StatelessElement { |
|||
public _NestedElement(Nested widget) : base(widget) |
|||
{ |
|||
} |
|||
|
|||
//SingleChildWidgetElementMixin
|
|||
_NestedHookElement _parent; |
|||
|
|||
public override void mount(Element parent, object newSlot) |
|||
{ |
|||
if (parent is _NestedHookElement) { |
|||
_parent = parent as _NestedHookElement; |
|||
} |
|||
base.mount(parent, newSlot); |
|||
} |
|||
|
|||
public override void activate() { |
|||
base.activate(); |
|||
visitAncestorElements((parent) => { |
|||
if (parent is _NestedHookElement) { |
|||
_parent = parent as _NestedHookElement; |
|||
} |
|||
return false; |
|||
}); |
|||
} |
|||
//end of SingleChildWidgetElementMixin
|
|||
|
|||
public readonly List<_NestedHookElement> nodes = new List<_NestedHookElement>(); |
|||
|
|||
Nested nested_widget => base.widget as Nested; |
|||
|
|||
protected override Widget build() |
|||
{ |
|||
_NestedHook nestedHook = null; |
|||
var nextNode = _parent?.injectedChild ?? nested_widget._child; |
|||
|
|||
for (int i= nested_widget._children.Count - 1; i >=0 ; i--) |
|||
{ |
|||
var child = nested_widget._children[i]; |
|||
nextNode = nestedHook = new _NestedHook( |
|||
owner: this, |
|||
wrappedWidget: child, |
|||
injectedChild: nextNode |
|||
); |
|||
} |
|||
|
|||
if (nestedHook != null) { |
|||
foreach (var node in nodes) { |
|||
node.wrappedChild = nestedHook.wrappedWidget; |
|||
node.injectedChild = nestedHook.injectedChild; |
|||
|
|||
var next = nestedHook.injectedChild; |
|||
if (next is _NestedHook) { |
|||
nestedHook = next as _NestedHook; |
|||
} else { |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
return nextNode; |
|||
} |
|||
} |
|||
|
|||
public class _NestedHook : StatelessWidget |
|||
{ |
|||
public _NestedHook( |
|||
Widget injectedChild = null, |
|||
SingleChildWidget wrappedWidget = null, |
|||
_NestedElement owner = null |
|||
) |
|||
{ |
|||
D.assert(wrappedWidget != null); |
|||
D.assert(owner != null); |
|||
this.injectedChild = injectedChild; |
|||
this.wrappedWidget = wrappedWidget; |
|||
this.owner = owner; |
|||
} |
|||
|
|||
public readonly SingleChildWidget wrappedWidget; |
|||
public readonly Widget injectedChild; |
|||
public readonly _NestedElement owner; |
|||
|
|||
public override Element createElement() => new _NestedHookElement(this); |
|||
|
|||
public override Widget build(BuildContext context) => throw new Exception("handled internally"); |
|||
} |
|||
|
|||
public class _NestedHookElement : StatelessElement { |
|||
public _NestedHookElement(_NestedHook widget) : base(widget){} |
|||
|
|||
_NestedHook nested_widget => base.widget as _NestedHook; |
|||
|
|||
Widget _injectedChild; |
|||
|
|||
internal Widget injectedChild |
|||
{ |
|||
get { return _injectedChild; } |
|||
set |
|||
{ |
|||
var previous = _injectedChild; |
|||
if (value is _NestedHook && |
|||
previous is _NestedHook && |
|||
Widget.canUpdate(((_NestedHook)value).wrappedWidget, ((_NestedHook)previous).wrappedWidget)) { |
|||
return; |
|||
} |
|||
if (previous != value) { |
|||
_injectedChild = value; |
|||
visitChildren((e) => e.markNeedsBuild()); |
|||
} |
|||
} |
|||
} |
|||
|
|||
SingleChildWidget _wrappedChild; |
|||
|
|||
internal SingleChildWidget wrappedChild |
|||
{ |
|||
get { return _wrappedChild; } |
|||
set |
|||
{ |
|||
if (_wrappedChild != value) { |
|||
_wrappedChild = value; |
|||
markNeedsBuild(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public override void mount(Element parent, object newSlot) { |
|||
nested_widget.owner.nodes.Add(this); |
|||
_wrappedChild = nested_widget.wrappedWidget; |
|||
_injectedChild = nested_widget.injectedChild; |
|||
base.mount(parent, newSlot); |
|||
} |
|||
|
|||
public override void unmount() { |
|||
nested_widget.owner.nodes.Remove(this); |
|||
base.unmount(); |
|||
} |
|||
|
|||
protected override Widget build() { |
|||
return wrappedChild; |
|||
} |
|||
} |
|||
|
|||
|
|||
public abstract class SingleChildWidget : Widget { |
|||
public abstract override Element createElement(); |
|||
} |
|||
|
|||
public abstract class SingleChildStatelessWidget : StatelessWidget |
|||
{ |
|||
public SingleChildStatelessWidget(Key key = null, Widget child = null) : base(key : key) |
|||
{ |
|||
_child = child; |
|||
} |
|||
|
|||
public readonly Widget _child; |
|||
|
|||
protected internal abstract Widget buildWithChild(BuildContext context, Widget child); |
|||
|
|||
public override Widget build(BuildContext context) => buildWithChild(context, _child); |
|||
|
|||
public override Element createElement() { |
|||
return new SingleChildStatelessElement(this); |
|||
} |
|||
} |
|||
|
|||
class SingleChildStatelessElement : StatelessElement { |
|||
public SingleChildStatelessElement(SingleChildStatelessWidget widget) |
|||
: base(widget) |
|||
{ |
|||
|
|||
} |
|||
|
|||
//SingleChildWidgetElementMixin
|
|||
_NestedHookElement _parent; |
|||
|
|||
public override void mount(Element parent, object newSlot) |
|||
{ |
|||
if (parent is _NestedHookElement) { |
|||
_parent = parent as _NestedHookElement; |
|||
} |
|||
base.mount(parent, newSlot); |
|||
} |
|||
|
|||
public override void activate() { |
|||
base.activate(); |
|||
visitAncestorElements((parent) => { |
|||
if (parent is _NestedHookElement) { |
|||
_parent = parent as _NestedHookElement; |
|||
} |
|||
return false; |
|||
}); |
|||
} |
|||
//end of SingleChildWidgetElementMixin
|
|||
|
|||
protected override Widget build() { |
|||
if (_parent != null) { |
|||
return nested_widget.buildWithChild(this, _parent.injectedChild); |
|||
} |
|||
return base.build(); |
|||
} |
|||
|
|||
SingleChildStatelessWidget nested_widget => |
|||
base.widget as SingleChildStatelessWidget; |
|||
} |
|||
|
|||
public abstract class SingleChildStatefulWidget : StatefulWidget { |
|||
public SingleChildStatefulWidget(Key key = null, Widget child = null) : base(key: key) |
|||
{ |
|||
_child = child; |
|||
} |
|||
|
|||
public readonly Widget _child; |
|||
|
|||
public override Element createElement() { |
|||
return new SingleChildStatefulElement(this); |
|||
} |
|||
} |
|||
|
|||
public abstract class SingleChildState<T> : State<T> where T : SingleChildStatefulWidget |
|||
{ |
|||
protected internal abstract Widget buildWithChild(BuildContext context, Widget child); |
|||
|
|||
public override Widget build(BuildContext context) => buildWithChild(context, widget._child); |
|||
} |
|||
|
|||
public class SingleChildStatefulElement : StatefulElement |
|||
{ |
|||
public SingleChildStatefulElement(SingleChildStatefulWidget widget) : base(widget) |
|||
{ |
|||
} |
|||
|
|||
//SingleChildWidgetElementMixin
|
|||
_NestedHookElement _parent; |
|||
|
|||
public override void mount(Element parent, object newSlot) |
|||
{ |
|||
if (parent is _NestedHookElement) { |
|||
_parent = parent as _NestedHookElement; |
|||
} |
|||
base.mount(parent, newSlot); |
|||
} |
|||
|
|||
public override void activate() { |
|||
base.activate(); |
|||
visitAncestorElements((parent) => { |
|||
if (parent is _NestedHookElement) { |
|||
_parent = parent as _NestedHookElement; |
|||
} |
|||
return false; |
|||
}); |
|||
} |
|||
//end of SingleChildWidgetElementMixin
|
|||
|
|||
SingleChildStatefulWidget nested_widget => |
|||
base.widget as SingleChildStatefulWidget; |
|||
|
|||
SingleChildState<SingleChildStatefulWidget> nested_state => |
|||
base.state as SingleChildState<SingleChildStatefulWidget>; |
|||
|
|||
protected override Widget build() { |
|||
if (_parent != null) { |
|||
return nested_state.buildWithChild(this, _parent.injectedChild); |
|||
} |
|||
return base.build(); |
|||
} |
|||
} |
|||
} |
|
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.DevTools |
|||
{ |
|||
delegate bool UpdateShouldNotify<T>(T previous, T current); |
|||
|
|||
delegate T Create<T>(BuildContext context); |
|||
|
|||
delegate void Dispose<T>(BuildContext context, T value); |
|||
|
|||
delegate VoidCallback StartListening<T>(InheritedContext<T> element, T value); |
|||
|
|||
public class InheritedProvider<T> : SingleChildStatelessWidget |
|||
{ |
|||
|
|||
} |
|||
} |
|
|||
namespace Unity.UIWidgets.DevTools |
|||
{ |
|||
public class Privoder<T> : InheritedProvider<T> |
|||
{ |
|||
|
|||
} |
|||
} |
|
|||
namespace Unity.UIWidgets.DevTools |
|||
{ |
|||
public static class DevtoolVersion |
|||
{ |
|||
public static string Version = "0.8.0+1"; |
|||
} |
|||
} |
|
|||
using Unity.UIWidgets.DevTools.config_specific.framework_initialize; |
|||
using Unity.UIWidgets.Editor; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.DevTools |
|||
{ |
|||
public class Devetool : UIWidgetsEditorPanel |
|||
{ |
|||
protected override void main() |
|||
{ |
|||
var preferences = new PreferencesController(); |
|||
|
|||
preferences.init(); |
|||
FrameworkInitializeUtils.initializeFramework(); |
|||
|
|||
ui_.runApp( |
|||
new DevToolsApp(defaultScreens, preferences) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.DevTools |
|||
{ |
|||
static class AppUtils |
|||
{ |
|||
public static string homeRoute = "/"; |
|||
public static string snapshotRoute = "/snapshot"; |
|||
} |
|||
|
|||
class DevToolsApp : StatefulWidget { |
|||
public DevToolsApp(List<DevToolsScreen<object>> screens, PreferencesController preferences) |
|||
{ |
|||
this.screens = screens; |
|||
this.preferences = preferences; |
|||
} |
|||
|
|||
public readonly List<DevToolsScreen<object>> screens; |
|||
public readonly PreferencesController preferences; |
|||
|
|||
public override State createState() => new DevToolsAppState(); |
|||
|
|||
public static DevToolsAppState of(BuildContext context) { |
|||
return context.findAncestorStateOfType<DevToolsAppState>(); |
|||
} |
|||
} |
|||
|
|||
class DevToolsAppState : State<DevToolsApp> { |
|||
List<Screen> _screens => widget.screens.Select(s => s.screen).ToList(); |
|||
|
|||
PreferencesController preferences => widget.preferences; |
|||
|
|||
public override void initState() { |
|||
base.initState(); |
|||
|
|||
Globals.serviceManager.isolateManager.onSelectedIsolateChanged.listen((_) => { |
|||
setState(() => { |
|||
_clearCachedRoutes(); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
public override void didUpdateWidget(StatefulWidget oldWidget) { |
|||
base.didUpdateWidget(oldWidget); |
|||
_clearCachedRoutes(); |
|||
} |
|||
|
|||
/// Generates routes, separating the path from URL query parameters.
|
|||
Route _generateRoute(RouteSettings settings) { |
|||
var uri = settings.name; |
|||
var path = uri.isEmpty() ? AppUtils.homeRoute : uri; |
|||
var args = settings.arguments as SnapshotArguments; |
|||
|
|||
// Provide the appropriate page route.
|
|||
if (routes.ContainsKey(path)) { |
|||
WidgetBuilder builder = (context) => routes[path]( |
|||
context, |
|||
uri.queryParameters, |
|||
args |
|||
); |
|||
D.assert(() => { |
|||
builder = (context) => new _AlternateCheckedModeBanner( |
|||
builder: (subContext) => routes[path]( |
|||
subContext, |
|||
uri.queryParameters, |
|||
args |
|||
) |
|||
); |
|||
return true; |
|||
}()); |
|||
|
|||
return new MaterialPageRoute(settings: settings, builder: builder); |
|||
} |
|||
|
|||
// Return a page not found.
|
|||
return new MaterialPageRoute( |
|||
settings: settings, |
|||
builder: (BuildContext context) => { |
|||
return DevToolsScaffold.withChild( |
|||
child: new CenteredMessage("'$uri' not found.") |
|||
); |
|||
} |
|||
); |
|||
} |
|||
|
|||
/// The routes that the app exposes.
|
|||
Dictionary<string, UrlParametersBuilder> routes => { |
|||
_routes = _routes ?? new Dictionary<string, UrlParametersBuilder>(){ |
|||
{AppUtils.homeRoute, (_, buildParam, __) => { |
|||
if (buildParam.getOrDefault("uri")?.isNotEmpty() ?? false) { |
|||
var embed = buildParam["embed"] == "true"; |
|||
var page = buildParam["page"]; |
|||
var tabs = embed && page != null |
|||
? _visibleScreens().Where((p) => p.screenId == page) |
|||
: _visibleScreens(); |
|||
return new Initializer( |
|||
url: buildParam["uri"], |
|||
allowConnectionScreenOnDisconnect: !embed, |
|||
builder: (_) => _providedControllers( |
|||
child: new DevToolsScaffold( |
|||
embed: embed, |
|||
initialPage: page, |
|||
tabs: tabs, |
|||
actions: [ |
|||
if (serviceManager.connectedApp.isFlutterAppNow) ...[ |
|||
HotReloadButton(), |
|||
HotRestartButton(), |
|||
], |
|||
OpenSettingsAction(), |
|||
OpenAboutAction(), |
|||
], |
|||
), |
|||
), |
|||
); |
|||
} else { |
|||
return DevToolsScaffold.withChild(child: ConnectScreenBody()); |
|||
} |
|||
}, |
|||
snapshotRoute: (_, __, args) => { |
|||
return DevToolsScaffold.withChild( |
|||
child: _providedControllers( |
|||
offline: true, |
|||
child: SnapshotScreenBody(args, _screens), |
|||
), |
|||
); |
|||
}, |
|||
}}; |
|||
|
|||
return _routes; |
|||
} |
|||
|
|||
Dictionary<string, UrlParametersBuilder> _routes; |
|||
|
|||
void _clearCachedRoutes() { |
|||
_routes = null; |
|||
} |
|||
|
|||
List<Screen> _visibleScreens() { |
|||
var visibleScreens = new List<Screen>(); |
|||
foreach (var screen in _screens) { |
|||
if (screen.conditionalLibrary != null) { |
|||
if (Globals.serviceManager.isServiceAvailable && |
|||
Globals.serviceManager |
|||
.isolateManager.selectedIsolateAvailable.isCompleted && |
|||
Globals.serviceManager.libraryUriAvailableNow(screen.conditionalLibrary)) { |
|||
visibleScreens.Add(screen); |
|||
} |
|||
} else { |
|||
visibleScreens.Add(screen); |
|||
} |
|||
} |
|||
return visibleScreens; |
|||
} |
|||
|
|||
Widget _providedControllers(Widget child, bool offline = false) |
|||
{ |
|||
var _providers = widget.screens |
|||
.Where((s) => |
|||
s.createController != null && (offline ? s.supportsOffline : true)) |
|||
.Select((s) => s.controllerProvider); |
|||
|
|||
return new MultiProvider( |
|||
providers: _providers, |
|||
child: child |
|||
); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new ValueListenableBuilder<bool>( |
|||
valueListenable: widget.preferences.darkModeTheme, |
|||
builder: (subContext, value, _) => { |
|||
return new MaterialApp( |
|||
debugShowCheckedModeBanner: false, |
|||
theme: ThemeUtils.themeFor(isDarkTheme: value), |
|||
builder: (subsubContext, child) => new Notifications(child: child), |
|||
onGenerateRoute: _generateRoute |
|||
); |
|||
} |
|||
); |
|||
} |
|||
} |
|||
|
|||
class DevToolsScreen<C> { |
|||
public DevToolsScreen( |
|||
Screen screen, |
|||
Func<C> createController, |
|||
bool supportsOffline = false |
|||
) |
|||
{ |
|||
this.screen = screen; |
|||
this.createController = createController; |
|||
this.supportsOffline = supportsOffline; |
|||
} |
|||
|
|||
public readonly Screen screen; |
|||
|
|||
public readonly Func<C> createController; |
|||
|
|||
public readonly bool supportsOffline; |
|||
|
|||
internal Provider<C> controllerProvider => { |
|||
D.assert(createController != null); |
|||
return new Provider<C>(create: (_) => createController()); |
|||
} |
|||
} |
|||
public delegate Widget UrlParametersBuilder( |
|||
BuildContext buildContext, |
|||
Dictionary<string, string> route, |
|||
SnapshotArguments args |
|||
); |
|||
} |
|
|||
using UnityEngine; |
|||
|
|||
namespace Unity.UIWidgets.DevTools.config_specific.framework_initialize |
|||
{ |
|||
public static class FrameworkInitializeUtils |
|||
{ |
|||
public static void initializeFramework() |
|||
{ |
|||
Debug.Log("empty initializeFramework"); |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Unity.UIWidgets.DevTools |
|||
{ |
|||
public static class Globals |
|||
{ |
|||
public static bool offlineMode = false; |
|||
|
|||
static Dictionary<Type, object> globals = new Dictionary<Type, object>(); |
|||
|
|||
public static ServiceConnectionManager serviceManager => |
|||
globals[typeof(ServiceConnectionManager)] as ServiceConnectionManager; |
|||
} |
|||
} |
|
|||
using Unity.UIWidgets.foundation; |
|||
using UnityEngine; |
|||
|
|||
namespace Unity.UIWidgets.DevTools |
|||
{ |
|||
public class PreferencesController |
|||
{ |
|||
readonly ValueNotifier<bool> _darkModeTheme = new ValueNotifier<bool>(true); |
|||
|
|||
public ValueListenable<bool> darkModeTheme => _darkModeTheme; |
|||
public void init() |
|||
{ |
|||
Debug.Log("PreferencesController: storage not initialized"); |
|||
} |
|||
|
|||
public void toggleDarkModeTheme(bool useDarkMode) { |
|||
_darkModeTheme.value = useDarkMode; |
|||
} |
|||
} |
|||
} |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.DevTools |
|||
{ |
|||
public abstract class Screen { |
|||
public Screen( |
|||
string screenId, |
|||
string title = null, |
|||
IconData icon = null, |
|||
Key tabKey = null, |
|||
string conditionalLibrary = null |
|||
) |
|||
{ |
|||
this.screenId = screenId; |
|||
this.title = title; |
|||
this.icon = icon; |
|||
this.tabKey = tabKey; |
|||
this.conditionalLibrary = conditionalLibrary; |
|||
} |
|||
|
|||
public readonly string screenId; |
|||
|
|||
public readonly string title; |
|||
|
|||
public readonly IconData icon; |
|||
|
|||
public readonly Key tabKey; |
|||
|
|||
public readonly string conditionalLibrary; |
|||
|
|||
|
|||
public bool showIsolateSelector => false; |
|||
|
|||
public string docPageId => null; |
|||
|
|||
Widget buildTab(BuildContext context) { |
|||
return new Tab( |
|||
key: tabKey, |
|||
child: new Row( |
|||
children: new List<Widget>{ |
|||
new Icon(icon, size: ThemeUtils.defaultIconSize), |
|||
new Padding( |
|||
padding: EdgeInsets.only(left: 8.0f), |
|||
child: new Text(title) |
|||
), |
|||
} |
|||
) |
|||
); |
|||
} |
|||
|
|||
protected abstract Widget build(BuildContext context); |
|||
|
|||
Widget buildStatus(BuildContext context, TextTheme textTheme) { |
|||
return null; |
|||
} |
|||
} |
|||
} |
|
|||
namespace Unity.UIWidgets.DevTools |
|||
{ |
|||
public class ServiceConnectionManager |
|||
{ |
|||
public ServiceConnectionManager() |
|||
{ |
|||
_isolateManager = new IsolateManager(); |
|||
} |
|||
|
|||
public IsolateManager isolateManager => _isolateManager; |
|||
IsolateManager _isolateManager; |
|||
} |
|||
|
|||
public class IsolateManager |
|||
{ |
|||
|
|||
} |
|||
} |
|
|||
namespace Unity.UIWidgets.DevTools |
|||
{ |
|||
public class SnapshotArguments { |
|||
public SnapshotArguments(string screenId) |
|||
{ |
|||
this.screenId = screenId; |
|||
} |
|||
|
|||
public readonly string screenId; |
|||
} |
|||
} |
|
|||
using System.Collections.Generic; |
|||
using uiwidgets; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.DevTools |
|||
{ |
|||
public class ThemeUtils |
|||
{ |
|||
public static ThemeData themeFor(bool isDarkTheme) { |
|||
return isDarkTheme ? _darkTheme() : _lightTheme(); |
|||
} |
|||
|
|||
|
|||
static ThemeData _darkTheme() { |
|||
var theme = ThemeData.dark(); |
|||
return theme.copyWith( |
|||
primaryColor: devtoolsGrey[900], |
|||
primaryColorDark: devtoolsBlue[700], |
|||
primaryColorLight: devtoolsBlue[400], |
|||
indicatorColor: devtoolsBlue[400], |
|||
accentColor: devtoolsBlue[400], |
|||
backgroundColor: devtoolsGrey[600], |
|||
toggleableActiveColor: devtoolsBlue[400], |
|||
selectedRowColor: devtoolsGrey[600], |
|||
buttonTheme: theme.buttonTheme.copyWith(minWidth: buttonMinWidth) |
|||
); |
|||
} |
|||
|
|||
static ThemeData _lightTheme() { |
|||
var theme = ThemeData.light(); |
|||
return theme.copyWith( |
|||
primaryColor: devtoolsBlue[600], |
|||
primaryColorDark: devtoolsBlue[700], |
|||
primaryColorLight: devtoolsBlue[400], |
|||
indicatorColor: Colors.yellowAccent[400], |
|||
accentColor: devtoolsBlue[400], |
|||
backgroundColor: devtoolsGrey[600], |
|||
toggleableActiveColor: devtoolsBlue[400], |
|||
selectedRowColor: devtoolsBlue[600], |
|||
buttonTheme: theme.buttonTheme.copyWith(minWidth: buttonMinWidth) |
|||
); |
|||
} |
|||
|
|||
public const float defaultIconSize = 16.0f; |
|||
public const float buttonMinWidth = 36.0f; |
|||
|
|||
static ColorSwatch<int> devtoolsGrey = new ColorSwatch<int>(0xFF202124, new Dictionary<int, Color>(){ |
|||
{900, new Color(0xFF202124)}, |
|||
{600, new Color(0xFF60646B)}, |
|||
{100, new Color(0xFFD5D7Da)}, |
|||
{50, new Color(0xFFEAEBEC)} |
|||
}); |
|||
|
|||
static ColorSwatch<int> devtoolsYellow = new ColorSwatch<int>(700, new Dictionary<int, Color>(){ |
|||
{700, new Color(0xFFFFC108)} |
|||
}); |
|||
|
|||
static ColorSwatch<int> devtoolsBlue = new ColorSwatch<int>(600, new Dictionary<int, Color>(){ |
|||
{700, new Color(0xFF02569B)}, |
|||
{600, new Color(0xFF0175C2)}, |
|||
{400, new Color(0xFF13B9FD)}, |
|||
}); |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue