浏览代码

add and fix

/zgh-devtools
Shiyun Wen 4 年前
当前提交
0b580bd2
共有 9 个文件被更改,包括 55 次插入133 次删除
  1. 4
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/backdrop_demo.cs
  2. 8
      com.unity.uiwidgets/Runtime/material/app.cs
  3. 5
      com.unity.uiwidgets/Runtime/material/pickers/date_picker_head.cs
  4. 138
      com.unity.uiwidgets/Runtime/widgets/app.cs
  5. 6
      com.unity.uiwidgets/Runtime/widgets/focus_manager.cs
  6. 8
      com.unity.uiwidgets/Runtime/widgets/image.cs
  7. 2
      com.unity.uiwidgets/Runtime/widgets/navigator.cs
  8. 15
      com.unity.uiwidgets/Runtime/widgets/routes.cs
  9. 2
      engine/src/lib/ui/window/window.cc

4
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/backdrop_demo.cs


onTap: () => { this.onTap?.Invoke(); },
child: new Container(
height: 48.0f,
//TODO: uncomment this when fixes on EdgeInsetsDirectional lands
//padding: EdgeInsetsDirectional.only(start: 16.0f),
padding: EdgeInsets.only(left: 16.0f),
padding: EdgeInsetsDirectional.only(start: 16.0f),
alignment: AlignmentDirectional.centerStart,
child: new DefaultTextStyle(
style: theme.textTheme.subtitle1,

8
com.unity.uiwidgets/Runtime/material/app.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.foundation;

List<NavigatorObserver> navigatorObservers = null,
TransitionBuilder builder = null,
string title = "",
GenerateAppTitle onGenerateTitle = null,
Color color = null,
ThemeData theme = null,
ThemeData darkTheme = null,

this.navigatorObservers = navigatorObservers ?? new List<NavigatorObserver>();
this.builder = builder;
this.title = title;
this.onGenerateTitle = onGenerateTitle;
this.color = color;
this.theme = theme;
this.darkTheme = darkTheme;

public readonly string title;
public readonly GenerateAppTitle onGenerateTitle;
public readonly ThemeData theme;
public readonly ThemeData darkTheme;

);
},
textStyle: material_._errorTextStyle,
title: widget.title,
onGenerateTitle: widget.onGenerateTitle,
color: widget.color ?? widget.theme?.primaryColor ?? Colors.blue,
locale: widget.locale,
localizationsDelegates: _localizationsDelegates,
localeResolutionCallback: widget.localeResolutionCallback,

5
com.unity.uiwidgets/Runtime/material/pickers/date_picker_head.cs


new Container(
height: DatePickerHeaderUtils._datePickerHeaderPortraitHeight,
color: primarySurfaceColor,
//FixMe: uncomment this after EdgeInsetsGeometry is ready for use
/*padding: EdgeInsetsDirectional.only(
padding: EdgeInsetsDirectional.only(
),*/
),
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget> {

138
com.unity.uiwidgets/Runtime/widgets/app.cs


supportedLocales = supportedLocales ?? new List<Locale> {new Locale("en", "US")};
window = Window.instance;
D.assert(routes != null);
D.assert(color != null);
D.assert(supportedLocales != null && supportedLocales.isNotEmpty());
this.home = home;
this.navigatorKey = navigatorKey;
this.onGenerateRoute = onGenerateRoute;

}
}
public class WindowProvider : InheritedWidget {
public readonly Window window;
public WindowProvider(Key key = null, Window window = null, Widget child = null) :
base(key, child) {
D.assert(window != null);
this.window = window;
}
public static Window of(BuildContext context) {
var provider = (WindowProvider) context.inheritFromWidgetOfExactType(typeof(WindowProvider));
if (provider == null) {
throw new UIWidgetsError("WindowProvider is missing");
}
return provider.window;
}
public static Window of(GameObject gameObject) {
D.assert(false, () => "window.Of is not implemented yet!");
return null;
/*
var panel = gameObject.GetComponent<UIWidgetsPanel>();
return panel == null ? null : panel.window;
*/
}
public override bool updateShouldNotify(InheritedWidget oldWidget) {
D.assert(window == ((WindowProvider) oldWidget).window);
return false;
}
}
class _WidgetsAppState : State<WidgetsApp>, WidgetsBindingObserver {
public void didChangeMetrics() {
setState();

public override void initState() {
base.initState();
_updateNavigator();
//todo: xingwei.zhu: change the default locale to ui.Window.locale
/*D.assert(() => {
WidgetInspectorService.instance.inspectorShowCallback += inspectorShowChanged;
return true;
});*/
WidgetsBinding.instance.addObserver(this);
}

public override void dispose() {
WidgetsBinding.instance.removeObserver(this);
/*D.assert(() => {
WidgetInspectorService.instance.inspectorShowCallback -= inspectorShowChanged;
return true;
});*/
base.dispose();
}

}
/*bool _debugCheckLocalizations(Locale appLocale) {
bool _debugCheckLocalizations(Locale appLocale) {
foreach ( LocalizationsDelegate<dynamic> _delegate in _localizationsDelegates) {
foreach ( LocalizationsDelegate _delegate in _localizationsDelegates) {
if (!unsupportedTypes.Contains(_delegate.type))
continue;
if (_delegate.isSupported(appLocale))

if (unsupportedTypesList.SequenceEqual(list))
return true;
StringBuffer message = new StringBuffer();
message.writeln('\u2550' * 8);
message.writeln(
StringBuilder message = new StringBuilder();
message.Append('\u2550' * 8);
message.Append(
// Currently the Cupertino library only provides english localizations.
// Remove this when https://github.com/flutter/flutter/issues/23847
// is fixed.
message.writeln(
message.Append(
message.writeln(
message.Append(
message.writeln('\u2550' * 8);
//Debug.Log(message.toString());
message.Append('\u2550' * 8);
}*/
}
public override Widget build(BuildContext context) {
Widget navigator = null;

key: _navigator,
initialRoute: widget.initialRoute ?? Navigator.defaultRouteName,
/*WidgetsBinding.instance.window.defaultRouteName != Navigator.defaultRouteName
initialRoute:
WidgetsBinding.instance.window.defaultRouteName != Navigator.defaultRouteName
: widget.initialRoute ?? WidgetsBinding.instance.window.defaultRouteName,*/
: widget.initialRoute ?? WidgetsBinding.instance.window.defaultRouteName,
onGenerateRoute: _onGenerateRoute,
onGenerateInitialRoutes: widget.onGenerateInitialRoutes == null
? Navigator.defaultGenerateInitialRoutes

}
PerformanceOverlay performanceOverlay = null;
if (widget.showPerformanceOverlay) {
performanceOverlay = PerformanceOverlay.allEnabled();
}
/*if (widget.showPerformanceOverlay || WidgetsApp.showPerformanceOverlayOverride) {
if (widget.showPerformanceOverlay || WidgetsApp.showPerformanceOverlayOverride) {
performanceOverlay = PerformanceOverlay.allEnabled(
checkerboardRasterCacheImages: widget.checkerboardRasterCacheImages,
checkerboardOffscreenLayers: widget.checkerboardOffscreenLayers

checkerboardRasterCacheImages: widget.checkerboardRasterCacheImages,
checkerboardOffscreenLayers: widget.checkerboardOffscreenLayers
);
}*/
}
if (performanceOverlay != null) {
result = new Stack(

});
}
/*if (widget.showSemanticsDebugger) {
result = SemanticsDebugger(
child: result,
);
}*/
D.assert(() => {
if (widget.debugShowWidgetInspector || WidgetsApp.debugShowWidgetInspectorOverride) {
result = new WidgetInspector(

);
}
return true;
/*if (widget.debugShowWidgetInspector || WidgetsApp.debugShowWidgetInspectorOverride) {
result = new WidgetInspector(
child: result,
selectButtonBuilder: widget.inspectorSelectButtonBuilder
);
}
if (widget.debugShowCheckedModeBanner && WidgetsApp.debugAllowBannerOverride) {
result = new CheckedModeBanner(
child: result
);
}*/
return true;
result = new Directionality(child: result, TextDirection.ltr);
result = new WindowProvider(
window: widget.window,
child: result
);
/*Widget title = null;
Widget title = null;
if (widget.onGenerateTitle != null) {
title = new Builder(
builder: (BuildContext context1)=> {

color: widget.color,
child: result
);
}*/
}
//D.assert(_debugCheckLocalizations(appLocale));
result = new MediaQuery(
data: MediaQueryData.fromWindow(widget.window),
child: new Localizations(
locale: appLocale,
delegates: _localizationsDelegates,
child: result)
);
/////todo
///
/*result = new Shortcuts(
D.assert(_debugCheckLocalizations(appLocale));
result = new Shortcuts(
child: FocusTraversalGroup(
policy: ReadingOrderTraversalPolicy(),
child: _MediaQueryFromWindow(
child: new FocusTraversalGroup(
policy: new ReadingOrderTraversalPolicy(),
child: new _MediaQueryFromWindow(
delegates: _localizationsDelegates,
delegates: _localizationsDelegates.ToList(),
);*/
);
return result;
}

6
com.unity.uiwidgets/Runtime/widgets/focus_manager.cs


public void _setAsFocusedChildForScope() {
FocusNode scopeFocus = this;
foreach (FocusScopeNode ancestor in ancestors) {
foreach ( var ancestor in ancestors) {
ancestor._focusedChildren.Remove(scopeFocus);
((FocusScopeNode)ancestor)._focusedChildren.Remove(scopeFocus);
ancestor._focusedChildren.Add(scopeFocus);
((FocusScopeNode)ancestor)._focusedChildren.Add(scopeFocus);
scopeFocus = ancestor;
}
}

8
com.unity.uiwidgets/Runtime/widgets/image.cs


}
void _resolveImage() {
/*ScrollAwareImageProvider<object> provider = new ScrollAwareImageProvider<object>(
ScrollAwareImageProvider<object> provider = new ScrollAwareImageProvider<object>(
);*/
);
widget.image.resolve(ImageUtils.createLocalImageConfiguration(
provider.resolve(ImageUtils.createLocalImageConfiguration(
context,
size: widget.width != null && widget.height != null
? new Size(widget.width.Value, widget.height.Value)

base.debugFillProperties(description);
description.add(new DiagnosticsProperty<ImageStream>("stream", _imageStream));
description.add(new DiagnosticsProperty<ImageInfo>("pixels", _imageInfo));
//description.add(new DiagnosticsProperty<ImageChunkEvent>("loadingProgress", _loadingProgress));
description.add(new DiagnosticsProperty<ImageChunkEvent>("loadingProgress", _loadingProgress));
description.add(new DiagnosticsProperty<int>("frameNumber", _frameNumber));
description.add(new DiagnosticsProperty<bool>("wasSynchronouslyLoaded", _wasSynchronouslyLoaded));
}

2
com.unity.uiwidgets/Runtime/widgets/navigator.cs


public delegate List<Route> RouteListFactory(NavigatorState navigator, string initialRoute);
//public delegate bool RoutePredicate(Route route);
public delegate bool RoutePredicate(Route route);
public delegate bool PopPageCallback(Route route, object result);

15
com.unity.uiwidgets/Runtime/widgets/routes.cs


D.assert(!_transitionCompleter.isCompleted, () => $"Cannot reuse a {GetType()} after disposing it.");
_didPushOrReplace();
base.didAdd();
_controller.setValue(_controller.upperBound); //_controller.upperBound;
_controller.setValue(_controller.upperBound);
}
protected internal override void didReplace(Route oldRoute) {
D.assert(_controller != null,

entry._owner = null;
entry._notifyRemoved();
if (_localHistory.isEmpty()) {
//changedInternalState();
if (SchedulerBinding.instance.schedulerPhase == SchedulerPhase.persistentCallbacks) {
SchedulerBinding.instance.addPostFrameCallback((TimeSpan timestamp) =>{
changedInternalState();

animation: widget.route.navigator?.userGestureInProgressNotifier ?? new ValueNotifier<bool>(false),
builder: (BuildContext context1, Widget child1) =>{
bool ignoreEvents = _shouldIgnoreFocusRequest;
focusScopeNode.canRequestFocus = !ignoreEvents; // todo
focusScopeNode.canRequestFocus = !ignoreEvents;
return new IgnorePointer(
ignoring: ignoreEvents,
child: child1

animation.drive(new ColorTween(
begin: _kTransparent,
end: barrierColor // changedInternalState is called if this updates
).chain(new CurveTween(curve: barrierCurve)));//.animate(animation);
).chain(new CurveTween(curve: barrierCurve)));
//,semanticsLabel: barrierLabel, // changedInternalState is called if barrierLabel updates
//barrierSemanticsDismissible: semanticsDismissible
//semanticsLabel: barrierLabel, // changedInternalState is called if barrierLabel updates
//barrierSemanticsDismissible: semanticsDismissible,
);
}
if (_filter != null) {

BuildContext context,
Animation<float> animation,
Animation<float> secondaryAnimation) {
//TODO SEMANTICS
return _pageBuilder(context, animation, secondaryAnimation);
}

2
engine/src/lib/ui/window/window.cc


const std::string routeName = ptr->client()->DefaultRouteName();
size_t size = routeName.length() + 1;
char* result = static_cast<char*>(malloc(size));
routeName.copy(result, size);
strcpy(result, routeName.c_str());
return result;
}

正在加载...
取消
保存