Merge pull request #2728 from Hixie/widgetsapp
Widgets App fixes and minor newton cleanup
This commit is contained in:
@@ -36,12 +36,12 @@ class MaterialApp extends WidgetsApp {
|
||||
bool showSemanticsDebugger: false,
|
||||
bool debugShowCheckedModeBanner: true
|
||||
}) : theme = theme,
|
||||
routes = routes,
|
||||
super(
|
||||
key: key,
|
||||
title: title,
|
||||
textStyle: _errorTextStyle,
|
||||
color: theme?.primaryColor ?? Colors.blue[500], // blue[500] is the primary color of the default theme
|
||||
routes: routes,
|
||||
onGenerateRoute: (RouteSettings settings) {
|
||||
WidgetBuilder builder = routes[settings.name];
|
||||
if (builder != null) {
|
||||
@@ -65,6 +65,8 @@ class MaterialApp extends WidgetsApp {
|
||||
/// The colors to use for the application's widgets.
|
||||
final ThemeData theme;
|
||||
|
||||
final Map<String, WidgetBuilder> routes;
|
||||
|
||||
/// Turns on a [GridPaper] overlay that paints a baseline grid
|
||||
/// Material apps:
|
||||
/// https://www.google.com/design/spec/layout/metrics-keylines.html
|
||||
|
||||
@@ -30,21 +30,28 @@ final AssetBundle _defaultBundle = _initDefaultBundle();
|
||||
|
||||
typedef Future<LocaleQueryData> LocaleChangedCallback(Locale locale);
|
||||
|
||||
/// A convenience class that wraps a number of widgets that are commonly
|
||||
/// required for an application.
|
||||
///
|
||||
/// See also: [CheckedModeBanner], [DefaultTextStyle], [MediaQuery],
|
||||
/// [LocaleQuery], [AssetVendor], [Title], [Navigator], [Overlay],
|
||||
/// [SemanticsDebugger] (the widgets wrapped by this one).
|
||||
///
|
||||
/// The [onGenerateRoute] argument is required, and corresponds to
|
||||
/// [Navigator.onGenerateRoute].
|
||||
class WidgetsApp extends StatefulWidget {
|
||||
WidgetsApp({
|
||||
Key key,
|
||||
this.title,
|
||||
this.textStyle,
|
||||
this.color,
|
||||
this.routes: const <String, WidgetBuilder>{},
|
||||
this.onGenerateRoute,
|
||||
this.onLocaleChanged,
|
||||
this.showPerformanceOverlay: false,
|
||||
this.showSemanticsDebugger: false,
|
||||
this.debugShowCheckedModeBanner: true
|
||||
}) : super(key: key) {
|
||||
assert(routes != null);
|
||||
assert(routes.containsKey(Navigator.defaultRouteName) || onGenerateRoute != null);
|
||||
assert(onGenerateRoute != null);
|
||||
assert(showPerformanceOverlay != null);
|
||||
assert(showSemanticsDebugger != null);
|
||||
}
|
||||
@@ -62,14 +69,8 @@ class WidgetsApp extends StatefulWidget {
|
||||
/// application switcher.
|
||||
final Color color;
|
||||
|
||||
/// The default table of routes for the application. When the
|
||||
/// [Navigator] is given a named route, the name will be looked up
|
||||
/// in this table first. If the name is not available, then
|
||||
/// [onGenerateRoute] will be called instead.
|
||||
final Map<String, WidgetBuilder> routes;
|
||||
|
||||
/// The route generator callback used when the app is navigated to a
|
||||
/// named route but the name is not in the [routes] table.
|
||||
/// named route.
|
||||
final RouteFactory onGenerateRoute;
|
||||
|
||||
/// Callback that is invoked when the operating system changes the
|
||||
@@ -179,25 +180,28 @@ class WidgetsAppState<T extends WidgetsApp> extends State<T> implements BindingO
|
||||
),
|
||||
child: new LocaleQuery(
|
||||
data: _localeData,
|
||||
child: new DefaultTextStyle(
|
||||
style: config.textStyle,
|
||||
child: new AssetVendor(
|
||||
bundle: _defaultBundle,
|
||||
devicePixelRatio: ui.window.devicePixelRatio,
|
||||
child: new Title(
|
||||
title: config.title,
|
||||
color: config.color,
|
||||
child: new Navigator(
|
||||
key: _navigator,
|
||||
initialRoute: ui.window.defaultRouteName,
|
||||
onGenerateRoute: config.onGenerateRoute,
|
||||
observer: navigatorObserver
|
||||
)
|
||||
child: new AssetVendor(
|
||||
bundle: _defaultBundle,
|
||||
devicePixelRatio: ui.window.devicePixelRatio,
|
||||
child: new Title(
|
||||
title: config.title,
|
||||
color: config.color,
|
||||
child: new Navigator(
|
||||
key: _navigator,
|
||||
initialRoute: ui.window.defaultRouteName,
|
||||
onGenerateRoute: config.onGenerateRoute,
|
||||
observer: navigatorObserver
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
if (config.textStyle != null) {
|
||||
new DefaultTextStyle(
|
||||
style: config.textStyle,
|
||||
child: result
|
||||
);
|
||||
}
|
||||
if (config.showPerformanceOverlay) {
|
||||
result = new Stack(
|
||||
children: <Widget>[
|
||||
|
||||
@@ -45,7 +45,7 @@ class ScrollSimulation extends SimulationGroup {
|
||||
if (_spring == null && (position > _trailingExtent || position < _leadingExtent))
|
||||
return false;
|
||||
|
||||
/// This simulation can only step forward.
|
||||
// This simulation can only step forward.
|
||||
if (!_isSpringing) {
|
||||
if (position > _trailingExtent) {
|
||||
_isSpringing = true;
|
||||
|
||||
@@ -14,7 +14,7 @@ abstract class Simulation {
|
||||
double x(double time);
|
||||
|
||||
/// The current velocity of the object in the simulation
|
||||
double dx(double time); // TODO(ianh): remove this; see https://github.com/flutter/flutter/issues/2092
|
||||
double dx(double time);
|
||||
|
||||
/// Returns if the simulation is done at a given time
|
||||
bool isDone(double time);
|
||||
|
||||
Reference in New Issue
Block a user