@@ -2,49 +2,16 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/animation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PageSelectorDemo extends StatelessComponent {
|
||||
Widget _buildTabIndicator(BuildContext context, String iconName) {
|
||||
final Color color = Theme.of(context).primaryColor;
|
||||
final ColorTween _selectedColor = new ColorTween(begin: Colors.transparent, end: color);
|
||||
final ColorTween _previousColor = new ColorTween(begin: color, end: Colors.transparent);
|
||||
final TabBarSelectionState selection = TabBarSelection.of(context);
|
||||
|
||||
CurvedAnimation animation = new CurvedAnimation(parent: selection.animation, curve: Curves.ease);
|
||||
return new AnimatedBuilder(
|
||||
animation: animation,
|
||||
builder: (BuildContext context, Widget child) {
|
||||
Color background = selection.value == iconName ? _selectedColor.end : _selectedColor.begin;
|
||||
if (selection.valueIsChanging) {
|
||||
// Then the selection's animation is animating from previousValue to value.
|
||||
if (selection.value == iconName)
|
||||
background = _selectedColor.evaluate(animation);
|
||||
else if (selection.previousValue == iconName)
|
||||
background = _previousColor.evaluate(animation);
|
||||
}
|
||||
return new Container(
|
||||
width: 12.0,
|
||||
height: 12.0,
|
||||
margin: new EdgeDims.all(4.0),
|
||||
decoration: new BoxDecoration(
|
||||
backgroundColor: background,
|
||||
border: new Border.all(color: _selectedColor.end),
|
||||
shape: BoxShape.circle
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTabView(String iconName) {
|
||||
return new Container(
|
||||
key: new ValueKey<String>(iconName),
|
||||
padding: const EdgeDims.all(12.0),
|
||||
child: new Card(
|
||||
child: new Center(
|
||||
child: new Icon(icon: "action/$iconName", size:IconSize.s48)
|
||||
child: new Icon(icon: 'action/$iconName', size:IconSize.s48)
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -57,10 +24,10 @@ class PageSelectorDemo extends StatelessComponent {
|
||||
}
|
||||
|
||||
Widget build(BuildContext notUsed) { // Can't find the TabBarSelection from this context.
|
||||
final List<String> iconNames = <String>["event", "home", "android", "alarm", "face", "language"];
|
||||
final List<String> iconNames = <String>['event', 'home', 'android', 'alarm', 'face', 'language'];
|
||||
|
||||
return new Scaffold(
|
||||
toolBar: new ToolBar(center: new Text("Page Selector")),
|
||||
toolBar: new ToolBar(center: new Text('Page Selector')),
|
||||
body: new TabBarSelection(
|
||||
values: iconNames,
|
||||
child: new Builder(
|
||||
@@ -72,16 +39,13 @@ class PageSelectorDemo extends StatelessComponent {
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
new IconButton(
|
||||
icon: "navigation/arrow_back",
|
||||
icon: 'navigation/arrow_back',
|
||||
onPressed: () { _handleArrowButtonPress(context, -1); },
|
||||
tooltip: 'Back'
|
||||
),
|
||||
new Row(
|
||||
children: iconNames.map((String name) => _buildTabIndicator(context, name)).toList(),
|
||||
justifyContent: FlexJustifyContent.collapse
|
||||
),
|
||||
new TabPageSelector<String>(),
|
||||
new IconButton(
|
||||
icon: "navigation/arrow_forward",
|
||||
icon: 'navigation/arrow_forward',
|
||||
onPressed: () { _handleArrowButtonPress(context, 1); },
|
||||
tooltip: 'Forward'
|
||||
)
|
||||
|
||||
@@ -103,6 +103,7 @@ abstract class RenderSector extends RenderObject {
|
||||
}
|
||||
|
||||
Rect get paintBounds => new Rect.fromLTWH(0.0, 0.0, 2.0 * deltaRadius, 2.0 * deltaRadius);
|
||||
Rect get semanticBounds => new Rect.fromLTWH(-deltaRadius, -deltaRadius, 2.0 * deltaRadius, 2.0 * deltaRadius);
|
||||
|
||||
bool hitTest(HitTestResult result, { double radius, double theta }) {
|
||||
if (radius < parentData.radius || radius >= parentData.radius + deltaRadius ||
|
||||
|
||||
@@ -2,6 +2,7 @@ name: stocks
|
||||
version: 0.0.2
|
||||
update-url: http://localhost:9888/
|
||||
material-design-icons:
|
||||
- name: action/accessibility
|
||||
- name: action/account_balance
|
||||
- name: action/assessment
|
||||
- name: action/backup
|
||||
|
||||
@@ -43,7 +43,8 @@ class StocksAppState extends State<StocksApp> {
|
||||
backupMode: BackupMode.enabled,
|
||||
debugShowGrid: false,
|
||||
debugShowSizes: false,
|
||||
showPerformanceOverlay: false
|
||||
showPerformanceOverlay: false,
|
||||
showSemanticsDebugger: false
|
||||
);
|
||||
|
||||
void initState() {
|
||||
@@ -110,6 +111,7 @@ class StocksAppState extends State<StocksApp> {
|
||||
theme: theme,
|
||||
debugShowMaterialGrid: _configuration.debugShowGrid,
|
||||
showPerformanceOverlay: _configuration.showPerformanceOverlay,
|
||||
showSemanticsDebugger: _configuration.showSemanticsDebugger,
|
||||
routes: <String, RouteBuilder>{
|
||||
'/': (RouteArguments args) => new StockHome(_stocks, _symbols, _configuration, configurationUpdater),
|
||||
'/settings': (RouteArguments args) => new StockSettings(_configuration, configurationUpdater)
|
||||
|
||||
@@ -88,16 +88,16 @@ class StockHomeState extends State<StockHome> {
|
||||
content: new Text('This feature has not yet been implemented.'),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: new Text('USE IT'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, false);
|
||||
}
|
||||
},
|
||||
child: new Text('USE IT')
|
||||
),
|
||||
new FlatButton(
|
||||
child: new Text('OH WELL'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, false);
|
||||
}
|
||||
},
|
||||
child: new Text('OH WELL')
|
||||
),
|
||||
]
|
||||
)
|
||||
@@ -107,7 +107,16 @@ class StockHomeState extends State<StockHome> {
|
||||
),
|
||||
new DrawerItem(
|
||||
icon: 'device/dvr',
|
||||
onPressed: () { debugDumpApp(); debugDumpRenderTree(); debugDumpLayerTree(); },
|
||||
onPressed: () {
|
||||
try {
|
||||
debugDumpApp();
|
||||
debugDumpRenderTree();
|
||||
debugDumpLayerTree();
|
||||
debugDumpSemanticsTree();
|
||||
} catch (e, stack) {
|
||||
debugPrint('Exception while dumping app:\n$e\n$stack');
|
||||
}
|
||||
},
|
||||
child: new Text('Dump App to Console')
|
||||
),
|
||||
new DrawerDivider(),
|
||||
|
||||
@@ -35,6 +35,10 @@ class StockSettingsState extends State<StockSettings> {
|
||||
sendUpdates(config.configuration.copyWith(showPerformanceOverlay: value));
|
||||
}
|
||||
|
||||
void _handleShowSemanticsDebuggerChanged(bool value) {
|
||||
sendUpdates(config.configuration.copyWith(showSemanticsDebugger: value));
|
||||
}
|
||||
|
||||
void _confirmOptimismChange() {
|
||||
switch (config.configuration.stockMode) {
|
||||
case StockMode.optimistic:
|
||||
@@ -118,6 +122,19 @@ class StockSettingsState extends State<StockSettings> {
|
||||
]
|
||||
)
|
||||
),
|
||||
new DrawerItem(
|
||||
icon: 'action/accessibility',
|
||||
onPressed: () { _handleShowSemanticsDebuggerChanged(!config.configuration.showSemanticsDebugger); },
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
new Flexible(child: new Text('Show semantics overlay')),
|
||||
new Switch(
|
||||
value: config.configuration.showSemanticsDebugger,
|
||||
onChanged: _handleShowSemanticsDebuggerChanged
|
||||
),
|
||||
]
|
||||
)
|
||||
),
|
||||
];
|
||||
assert(() {
|
||||
// material grid and size construction lines are only available in checked mode
|
||||
|
||||
@@ -13,13 +13,15 @@ class StockConfiguration {
|
||||
this.backupMode,
|
||||
this.debugShowGrid,
|
||||
this.debugShowSizes,
|
||||
this.showPerformanceOverlay
|
||||
this.showPerformanceOverlay,
|
||||
this.showSemanticsDebugger
|
||||
}) {
|
||||
assert(stockMode != null);
|
||||
assert(backupMode != null);
|
||||
assert(debugShowGrid != null);
|
||||
assert(debugShowSizes != null);
|
||||
assert(showPerformanceOverlay != null);
|
||||
assert(showSemanticsDebugger != null);
|
||||
}
|
||||
|
||||
final StockMode stockMode;
|
||||
@@ -27,20 +29,23 @@ class StockConfiguration {
|
||||
final bool debugShowGrid;
|
||||
final bool debugShowSizes;
|
||||
final bool showPerformanceOverlay;
|
||||
final bool showSemanticsDebugger;
|
||||
|
||||
StockConfiguration copyWith({
|
||||
StockMode stockMode,
|
||||
BackupMode backupMode,
|
||||
bool debugShowGrid,
|
||||
bool debugShowSizes,
|
||||
bool showPerformanceOverlay
|
||||
bool showPerformanceOverlay,
|
||||
bool showSemanticsDebugger
|
||||
}) {
|
||||
return new StockConfiguration(
|
||||
stockMode: stockMode ?? this.stockMode,
|
||||
backupMode: backupMode ?? this.backupMode,
|
||||
debugShowGrid: debugShowGrid ?? this.debugShowGrid,
|
||||
debugShowSizes: debugShowSizes ?? this.debugShowSizes,
|
||||
showPerformanceOverlay: showPerformanceOverlay ?? this.showPerformanceOverlay
|
||||
showPerformanceOverlay: showPerformanceOverlay ?? this.showPerformanceOverlay,
|
||||
showSemanticsDebugger: showSemanticsDebugger ?? this.showSemanticsDebugger
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user