Auto-format Framework (#160545)
This auto-formats all *.dart files in the repository outside of the `engine` subdirectory and enforces that these files stay formatted with a presubmit check. **Reviewers:** Please carefully review all the commits except for the one titled "formatted". The "formatted" commit was auto-generated by running `dev/tools/format.sh -a -f`. The other commits were hand-crafted to prepare the repo for the formatting change. I recommend reviewing the commits one-by-one via the "Commits" tab and avoiding Github's "Files changed" tab as it will likely slow down your browser because of the size of this PR. --------- Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -88,18 +88,19 @@ abstract class StockStrings {
|
||||
/// Additional delegates can be added by appending to this list in
|
||||
/// MaterialApp. This list does not have to be used at all if a custom list
|
||||
/// of delegates is preferred or required.
|
||||
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates = <LocalizationsDelegate<dynamic>>[
|
||||
delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
];
|
||||
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates =
|
||||
<LocalizationsDelegate<dynamic>>[
|
||||
delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
];
|
||||
|
||||
/// A list of this localizations delegate's supported locales.
|
||||
static const List<Locale> supportedLocales = <Locale>[
|
||||
Locale('en'),
|
||||
Locale('en', 'US'),
|
||||
Locale('es')
|
||||
Locale('es'),
|
||||
];
|
||||
|
||||
/// Title for the Stocks application
|
||||
@@ -137,27 +138,30 @@ class _StockStringsDelegate extends LocalizationsDelegate<StockStrings> {
|
||||
}
|
||||
|
||||
StockStrings lookupStockStrings(Locale locale) {
|
||||
|
||||
// Lookup logic when language+country codes are specified.
|
||||
switch (locale.languageCode) {
|
||||
case 'en': {
|
||||
switch (locale.countryCode) {
|
||||
case 'US': return StockStringsEnUs();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'en':
|
||||
{
|
||||
switch (locale.countryCode) {
|
||||
case 'US':
|
||||
return StockStringsEnUs();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Lookup logic when only language code is specified.
|
||||
switch (locale.languageCode) {
|
||||
case 'en': return StockStringsEn();
|
||||
case 'es': return StockStringsEs();
|
||||
case 'en':
|
||||
return StockStringsEn();
|
||||
case 'es':
|
||||
return StockStringsEs();
|
||||
}
|
||||
|
||||
throw FlutterError(
|
||||
'StockStrings.delegate failed to load unsupported locale "$locale". This is likely '
|
||||
'an issue with the localizations generation tool. Please file an issue '
|
||||
'on GitHub with a reproducible sample app and the gen-l10n configuration '
|
||||
'that was used.'
|
||||
'that was used.',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
// THE FOLLOWING FILES WERE GENERATED BY `flutter gen-l10n`.
|
||||
|
||||
|
||||
// ignore: unused_import
|
||||
import 'package:intl/intl.dart' as intl;
|
||||
import 'stock_strings.dart';
|
||||
@@ -27,7 +26,7 @@ class StockStringsEn extends StockStrings {
|
||||
|
||||
/// The translations for English, as used in the United States (`en_US`).
|
||||
class StockStringsEnUs extends StockStringsEn {
|
||||
StockStringsEnUs(): super('en_US');
|
||||
StockStringsEnUs() : super('en_US');
|
||||
|
||||
@override
|
||||
String get title => 'Stocks';
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
// THE FOLLOWING FILES WERE GENERATED BY `flutter gen-l10n`.
|
||||
|
||||
|
||||
// ignore: unused_import
|
||||
import 'package:intl/intl.dart' as intl;
|
||||
import 'stock_strings.dart';
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart' show
|
||||
debugPaintBaselinesEnabled,
|
||||
debugPaintLayerBordersEnabled,
|
||||
debugPaintPointersEnabled,
|
||||
debugPaintSizeEnabled,
|
||||
debugRepaintRainbowEnabled;
|
||||
import 'package:flutter/rendering.dart'
|
||||
show
|
||||
debugPaintBaselinesEnabled,
|
||||
debugPaintLayerBordersEnabled,
|
||||
debugPaintPointersEnabled,
|
||||
debugPaintSizeEnabled,
|
||||
debugRepaintRainbowEnabled;
|
||||
|
||||
import 'i18n/stock_strings.dart';
|
||||
import 'stock_data.dart';
|
||||
@@ -88,8 +89,8 @@ class StocksAppState extends State<StocksApp> {
|
||||
showPerformanceOverlay: _configuration.showPerformanceOverlay,
|
||||
showSemanticsDebugger: _configuration.showSemanticsDebugger,
|
||||
routes: <String, WidgetBuilder>{
|
||||
'/': (BuildContext context) => StockHome(stocks, _configuration, configurationUpdater),
|
||||
'/settings': (BuildContext context) => StockSettings(_configuration, configurationUpdater),
|
||||
'/': (BuildContext context) => StockHome(stocks, _configuration, configurationUpdater),
|
||||
'/settings': (BuildContext context) => StockSettings(_configuration, configurationUpdater),
|
||||
},
|
||||
onGenerateRoute: _getRoute,
|
||||
);
|
||||
|
||||
@@ -7,10 +7,7 @@ import 'dart:math' as math;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class StockArrowPainter extends CustomPainter {
|
||||
StockArrowPainter({
|
||||
required this.color,
|
||||
required this.percentChange,
|
||||
});
|
||||
StockArrowPainter({required this.color, required this.percentChange});
|
||||
|
||||
final Color color;
|
||||
final double percentChange;
|
||||
@@ -50,13 +47,12 @@ class StockArrowPainter extends CustomPainter {
|
||||
|
||||
@override
|
||||
bool shouldRepaint(StockArrowPainter oldDelegate) {
|
||||
return oldDelegate.color != color
|
||||
|| oldDelegate.percentChange != percentChange;
|
||||
return oldDelegate.color != color || oldDelegate.percentChange != percentChange;
|
||||
}
|
||||
}
|
||||
|
||||
class StockArrow extends StatelessWidget {
|
||||
const StockArrow({ super.key, required this.percentChange });
|
||||
const StockArrow({super.key, required this.percentChange});
|
||||
|
||||
final double percentChange;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class Stock {
|
||||
lastSale = 0.0;
|
||||
try {
|
||||
lastSale = double.parse(fields[2]);
|
||||
} catch (_) { }
|
||||
} catch (_) {}
|
||||
symbol = fields[0];
|
||||
name = fields[1];
|
||||
marketCap = fields[4];
|
||||
@@ -68,8 +68,8 @@ class StockData extends ChangeNotifier {
|
||||
static const int _chunkCount = 30;
|
||||
int _nextChunk = 0;
|
||||
|
||||
Uri _urlToFetch(int chunk) => Uri.https(
|
||||
'domokit.github.io', 'examples/stocks/data/stock_data_$chunk.json');
|
||||
Uri _urlToFetch(int chunk) =>
|
||||
Uri.https('domokit.github.io', 'examples/stocks/data/stock_data_$chunk.json');
|
||||
|
||||
http.Client? _httpClient;
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
import 'package:flutter/gestures.dart' show DragStartBehavior;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart' show debugDumpLayerTree, debugDumpRenderTree, debugDumpSemanticsTree;
|
||||
import 'package:flutter/rendering.dart'
|
||||
show debugDumpLayerTree, debugDumpRenderTree, debugDumpSemanticsTree;
|
||||
import 'package:flutter/scheduler.dart' show timeDilation;
|
||||
|
||||
import 'i18n/stock_strings.dart';
|
||||
@@ -16,6 +17,7 @@ import 'stock_types.dart';
|
||||
typedef ModeUpdater = void Function(StockMode mode);
|
||||
|
||||
enum _StockMenuItem { autorefresh, refresh, speedUp, speedDown }
|
||||
|
||||
enum StockHomeTab { market, portfolio }
|
||||
|
||||
class _NotImplementedDialog extends StatelessWidget {
|
||||
@@ -31,13 +33,8 @@ class _NotImplementedDialog extends StatelessWidget {
|
||||
onPressed: debugDumpApp,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
const Icon(
|
||||
Icons.dvr,
|
||||
size: 18.0,
|
||||
),
|
||||
Container(
|
||||
width: 8.0,
|
||||
),
|
||||
const Icon(Icons.dvr, size: 18.0),
|
||||
Container(width: 8.0),
|
||||
const Text('DUMP APP TO CONSOLE'),
|
||||
],
|
||||
),
|
||||
@@ -71,14 +68,16 @@ class StockHomeState extends State<StockHome> {
|
||||
bool _autorefresh = false;
|
||||
|
||||
void _handleSearchBegin() {
|
||||
ModalRoute.of(context)!.addLocalHistoryEntry(LocalHistoryEntry(
|
||||
onRemove: () {
|
||||
setState(() {
|
||||
_isSearching = false;
|
||||
_searchQuery.clear();
|
||||
});
|
||||
},
|
||||
));
|
||||
ModalRoute.of(context)!.addLocalHistoryEntry(
|
||||
LocalHistoryEntry(
|
||||
onRemove: () {
|
||||
setState(() {
|
||||
_isSearching = false;
|
||||
_searchQuery.clear();
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
setState(() {
|
||||
_isSearching = true;
|
||||
});
|
||||
@@ -196,26 +195,29 @@ class StockHomeState extends State<StockHome> {
|
||||
tooltip: 'Search',
|
||||
),
|
||||
PopupMenuButton<_StockMenuItem>(
|
||||
onSelected: (_StockMenuItem value) { _handleStockMenu(context, value); },
|
||||
itemBuilder: (BuildContext context) => <PopupMenuItem<_StockMenuItem>>[
|
||||
CheckedPopupMenuItem<_StockMenuItem>(
|
||||
value: _StockMenuItem.autorefresh,
|
||||
checked: _autorefresh,
|
||||
child: const Text('Autorefresh'),
|
||||
),
|
||||
const PopupMenuItem<_StockMenuItem>(
|
||||
value: _StockMenuItem.refresh,
|
||||
child: Text('Refresh'),
|
||||
),
|
||||
const PopupMenuItem<_StockMenuItem>(
|
||||
value: _StockMenuItem.speedUp,
|
||||
child: Text('Increase animation speed'),
|
||||
),
|
||||
const PopupMenuItem<_StockMenuItem>(
|
||||
value: _StockMenuItem.speedDown,
|
||||
child: Text('Decrease animation speed'),
|
||||
),
|
||||
],
|
||||
onSelected: (_StockMenuItem value) {
|
||||
_handleStockMenu(context, value);
|
||||
},
|
||||
itemBuilder:
|
||||
(BuildContext context) => <PopupMenuItem<_StockMenuItem>>[
|
||||
CheckedPopupMenuItem<_StockMenuItem>(
|
||||
value: _StockMenuItem.autorefresh,
|
||||
checked: _autorefresh,
|
||||
child: const Text('Autorefresh'),
|
||||
),
|
||||
const PopupMenuItem<_StockMenuItem>(
|
||||
value: _StockMenuItem.refresh,
|
||||
child: Text('Refresh'),
|
||||
),
|
||||
const PopupMenuItem<_StockMenuItem>(
|
||||
value: _StockMenuItem.speedUp,
|
||||
child: Text('Increase animation speed'),
|
||||
),
|
||||
const PopupMenuItem<_StockMenuItem>(
|
||||
value: _StockMenuItem.speedDown,
|
||||
child: Text('Decrease animation speed'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
bottom: TabBar(
|
||||
@@ -228,9 +230,10 @@ class StockHomeState extends State<StockHome> {
|
||||
}
|
||||
|
||||
static Iterable<Stock> _getStockList(StockData stocks, Iterable<String> symbols) {
|
||||
return symbols.map<Stock?>((String symbol) => stocks[symbol])
|
||||
.where((Stock? stock) => stock != null)
|
||||
.cast<Stock>();
|
||||
return symbols
|
||||
.map<Stock?>((String symbol) => stocks[symbol])
|
||||
.where((Stock? stock) => stock != null)
|
||||
.cast<Stock>();
|
||||
}
|
||||
|
||||
Iterable<Stock> _filterBySearchQuery(Iterable<Stock> stocks) {
|
||||
@@ -246,15 +249,17 @@ class StockHomeState extends State<StockHome> {
|
||||
stock.percentChange = 100.0 * (1.0 / stock.lastSale);
|
||||
stock.lastSale += 1.0;
|
||||
});
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text('Purchased ${stock.symbol} for ${stock.lastSale}'),
|
||||
action: SnackBarAction(
|
||||
label: 'BUY MORE',
|
||||
onPressed: () {
|
||||
_buyStock(stock);
|
||||
},
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Purchased ${stock.symbol} for ${stock.lastSale}'),
|
||||
action: SnackBarAction(
|
||||
label: 'BUY MORE',
|
||||
onPressed: () {
|
||||
_buyStock(stock);
|
||||
},
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStockList(BuildContext context, Iterable<Stock> stocks, StockHomeTab tab) {
|
||||
@@ -265,7 +270,9 @@ class StockHomeState extends State<StockHome> {
|
||||
Navigator.pushNamed(context, '/stock', arguments: stock.symbol);
|
||||
},
|
||||
onShow: (Stock stock) {
|
||||
_scaffoldKey.currentState!.showBottomSheet((BuildContext context) => StockSymbolBottomSheet(stock: stock));
|
||||
_scaffoldKey.currentState!.showBottomSheet(
|
||||
(BuildContext context) => StockSymbolBottomSheet(stock: stock),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -275,24 +282,31 @@ class StockHomeState extends State<StockHome> {
|
||||
key: ValueKey<StockHomeTab>(tab),
|
||||
animation: Listenable.merge(<Listenable>[_searchQuery, widget.stocks]),
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
return _buildStockList(context, _filterBySearchQuery(_getStockList(widget.stocks, stockSymbols)).toList(), tab);
|
||||
return _buildStockList(
|
||||
context,
|
||||
_filterBySearchQuery(_getStockList(widget.stocks, stockSymbols)).toList(),
|
||||
tab,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
static const List<String> portfolioSymbols = <String>['AAPL','FIZZ', 'FIVE', 'FLAT', 'ZINC', 'ZNGA'];
|
||||
static const List<String> portfolioSymbols = <String>[
|
||||
'AAPL',
|
||||
'FIZZ',
|
||||
'FIVE',
|
||||
'FLAT',
|
||||
'ZINC',
|
||||
'ZNGA',
|
||||
];
|
||||
|
||||
AppBar buildSearchBar() {
|
||||
return AppBar(
|
||||
leading: BackButton(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
leading: BackButton(color: Theme.of(context).colorScheme.secondary),
|
||||
title: TextField(
|
||||
controller: _searchQuery,
|
||||
autofocus: true,
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Search stocks',
|
||||
),
|
||||
decoration: const InputDecoration(hintText: 'Search stocks'),
|
||||
),
|
||||
backgroundColor: Theme.of(context).canvasColor,
|
||||
);
|
||||
@@ -343,12 +357,7 @@ class _CreateCompanySheet extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return const Column(
|
||||
children: <Widget>[
|
||||
TextField(
|
||||
autofocus: true,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Company Name',
|
||||
),
|
||||
),
|
||||
TextField(autofocus: true, decoration: InputDecoration(hintText: 'Company Name')),
|
||||
Text('(This demo is not yet complete.)'),
|
||||
// For example, we could add a button that actually updates the list
|
||||
// and then contacts the server, etc.
|
||||
|
||||
@@ -10,12 +10,8 @@ import 'stock_data.dart';
|
||||
typedef StockRowActionCallback = void Function(Stock stock);
|
||||
|
||||
class StockRow extends StatelessWidget {
|
||||
StockRow({
|
||||
required this.stock,
|
||||
this.onPressed,
|
||||
this.onDoubleTap,
|
||||
this.onLongPressed,
|
||||
}) : super(key: ObjectKey(stock));
|
||||
StockRow({required this.stock, this.onPressed, this.onDoubleTap, this.onLongPressed})
|
||||
: super(key: ObjectKey(stock));
|
||||
|
||||
final Stock stock;
|
||||
final StockRowActionCallback? onPressed;
|
||||
@@ -43,42 +39,22 @@ class StockRow extends StatelessWidget {
|
||||
child: Container(
|
||||
padding: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 20.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Theme.of(context).dividerColor)
|
||||
)
|
||||
border: Border(bottom: BorderSide(color: Theme.of(context).dividerColor)),
|
||||
),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
margin: const EdgeInsets.only(right: 5.0),
|
||||
child: Hero(
|
||||
tag: stock,
|
||||
child: StockArrow(percentChange: stock.percentChange),
|
||||
),
|
||||
child: Hero(tag: stock, child: StockArrow(percentChange: stock.percentChange)),
|
||||
),
|
||||
Expanded(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||
textBaseline: DefaultTextStyle.of(context).style.textBaseline,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
stock.symbol
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
lastSale,
|
||||
textAlign: TextAlign.right,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
changeInPrice,
|
||||
textAlign: TextAlign.right,
|
||||
),
|
||||
),
|
||||
Expanded(flex: 2, child: Text(stock.symbol)),
|
||||
Expanded(child: Text(lastSale, textAlign: TextAlign.right)),
|
||||
Expanded(child: Text(changeInPrice, textAlign: TextAlign.right)),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -19,11 +19,17 @@ class StockSettings extends StatefulWidget {
|
||||
class StockSettingsState extends State<StockSettings> {
|
||||
void _handleOptimismChanged(bool? value) {
|
||||
value ??= false;
|
||||
sendUpdates(widget.configuration.copyWith(stockMode: value ? StockMode.optimistic : StockMode.pessimistic));
|
||||
sendUpdates(
|
||||
widget.configuration.copyWith(
|
||||
stockMode: value ? StockMode.optimistic : StockMode.pessimistic,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _handleBackupChanged(bool value) {
|
||||
sendUpdates(widget.configuration.copyWith(backupMode: value ? BackupMode.enabled : BackupMode.disabled));
|
||||
sendUpdates(
|
||||
widget.configuration.copyWith(backupMode: value ? BackupMode.enabled : BackupMode.disabled),
|
||||
);
|
||||
}
|
||||
|
||||
void _handleShowGridChanged(bool value) {
|
||||
@@ -50,7 +56,6 @@ class StockSettingsState extends State<StockSettings> {
|
||||
sendUpdates(widget.configuration.copyWith(debugShowRainbow: value));
|
||||
}
|
||||
|
||||
|
||||
void _handleShowPerformanceOverlayChanged(bool value) {
|
||||
sendUpdates(widget.configuration.copyWith(showPerformanceOverlay: value));
|
||||
}
|
||||
@@ -69,7 +74,9 @@ class StockSettingsState extends State<StockSettings> {
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Change mode?'),
|
||||
content: const Text('Optimistic mode means everything is awesome. Are you sure you can handle that?'),
|
||||
content: const Text(
|
||||
'Optimistic mode means everything is awesome. Are you sure you can handle that?',
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('NO THANKS'),
|
||||
@@ -95,9 +102,7 @@ class StockSettingsState extends State<StockSettings> {
|
||||
}
|
||||
|
||||
AppBar buildAppBar(BuildContext context) {
|
||||
return AppBar(
|
||||
title: const Text('Settings'),
|
||||
);
|
||||
return AppBar(title: const Text('Settings'));
|
||||
}
|
||||
|
||||
Widget buildSettingsPane(BuildContext context) {
|
||||
@@ -114,7 +119,9 @@ class StockSettingsState extends State<StockSettings> {
|
||||
ListTile(
|
||||
leading: const Icon(Icons.backup),
|
||||
title: const Text('Back up stock list to the cloud'),
|
||||
onTap: () { _handleBackupChanged(!(widget.configuration.backupMode == BackupMode.enabled)); },
|
||||
onTap: () {
|
||||
_handleBackupChanged(!(widget.configuration.backupMode == BackupMode.enabled));
|
||||
},
|
||||
trailing: Switch(
|
||||
value: widget.configuration.backupMode == BackupMode.enabled,
|
||||
onChanged: _handleBackupChanged,
|
||||
@@ -123,7 +130,9 @@ class StockSettingsState extends State<StockSettings> {
|
||||
ListTile(
|
||||
leading: const Icon(Icons.picture_in_picture),
|
||||
title: const Text('Show rendering performance overlay'),
|
||||
onTap: () { _handleShowPerformanceOverlayChanged(!widget.configuration.showPerformanceOverlay); },
|
||||
onTap: () {
|
||||
_handleShowPerformanceOverlayChanged(!widget.configuration.showPerformanceOverlay);
|
||||
},
|
||||
trailing: Switch(
|
||||
value: widget.configuration.showPerformanceOverlay,
|
||||
onChanged: _handleShowPerformanceOverlayChanged,
|
||||
@@ -132,7 +141,9 @@ class StockSettingsState extends State<StockSettings> {
|
||||
ListTile(
|
||||
leading: const Icon(Icons.accessibility),
|
||||
title: const Text('Show semantics overlay'),
|
||||
onTap: () { _handleShowSemanticsDebuggerChanged(!widget.configuration.showSemanticsDebugger); },
|
||||
onTap: () {
|
||||
_handleShowSemanticsDebuggerChanged(!widget.configuration.showSemanticsDebugger);
|
||||
},
|
||||
trailing: Switch(
|
||||
value: widget.configuration.showSemanticsDebugger,
|
||||
onChanged: _handleShowSemanticsDebuggerChanged,
|
||||
@@ -145,7 +156,9 @@ class StockSettingsState extends State<StockSettings> {
|
||||
ListTile(
|
||||
leading: const Icon(Icons.border_clear),
|
||||
title: const Text('Show material grid (for debugging)'),
|
||||
onTap: () { _handleShowGridChanged(!widget.configuration.debugShowGrid); },
|
||||
onTap: () {
|
||||
_handleShowGridChanged(!widget.configuration.debugShowGrid);
|
||||
},
|
||||
trailing: Switch(
|
||||
value: widget.configuration.debugShowGrid,
|
||||
onChanged: _handleShowGridChanged,
|
||||
@@ -154,7 +167,9 @@ class StockSettingsState extends State<StockSettings> {
|
||||
ListTile(
|
||||
leading: const Icon(Icons.border_all),
|
||||
title: const Text('Show construction lines (for debugging)'),
|
||||
onTap: () { _handleShowSizesChanged(!widget.configuration.debugShowSizes); },
|
||||
onTap: () {
|
||||
_handleShowSizesChanged(!widget.configuration.debugShowSizes);
|
||||
},
|
||||
trailing: Switch(
|
||||
value: widget.configuration.debugShowSizes,
|
||||
onChanged: _handleShowSizesChanged,
|
||||
@@ -163,7 +178,9 @@ class StockSettingsState extends State<StockSettings> {
|
||||
ListTile(
|
||||
leading: const Icon(Icons.format_color_text),
|
||||
title: const Text('Show baselines (for debugging)'),
|
||||
onTap: () { _handleShowBaselinesChanged(!widget.configuration.debugShowBaselines); },
|
||||
onTap: () {
|
||||
_handleShowBaselinesChanged(!widget.configuration.debugShowBaselines);
|
||||
},
|
||||
trailing: Switch(
|
||||
value: widget.configuration.debugShowBaselines,
|
||||
onChanged: _handleShowBaselinesChanged,
|
||||
@@ -172,7 +189,9 @@ class StockSettingsState extends State<StockSettings> {
|
||||
ListTile(
|
||||
leading: const Icon(Icons.filter_none),
|
||||
title: const Text('Show layer boundaries (for debugging)'),
|
||||
onTap: () { _handleShowLayersChanged(!widget.configuration.debugShowLayers); },
|
||||
onTap: () {
|
||||
_handleShowLayersChanged(!widget.configuration.debugShowLayers);
|
||||
},
|
||||
trailing: Switch(
|
||||
value: widget.configuration.debugShowLayers,
|
||||
onChanged: _handleShowLayersChanged,
|
||||
@@ -181,7 +200,9 @@ class StockSettingsState extends State<StockSettings> {
|
||||
ListTile(
|
||||
leading: const Icon(Icons.mouse),
|
||||
title: const Text('Show pointer hit-testing (for debugging)'),
|
||||
onTap: () { _handleShowPointersChanged(!widget.configuration.debugShowPointers); },
|
||||
onTap: () {
|
||||
_handleShowPointersChanged(!widget.configuration.debugShowPointers);
|
||||
},
|
||||
trailing: Switch(
|
||||
value: widget.configuration.debugShowPointers,
|
||||
onChanged: _handleShowPointersChanged,
|
||||
@@ -190,7 +211,9 @@ class StockSettingsState extends State<StockSettings> {
|
||||
ListTile(
|
||||
leading: const Icon(Icons.gradient),
|
||||
title: const Text('Show repaint rainbow (for debugging)'),
|
||||
onTap: () { _handleShowRainbowChanged(!widget.configuration.debugShowRainbow); },
|
||||
onTap: () {
|
||||
_handleShowRainbowChanged(!widget.configuration.debugShowRainbow);
|
||||
},
|
||||
trailing: Switch(
|
||||
value: widget.configuration.debugShowRainbow,
|
||||
onChanged: _handleShowRainbowChanged,
|
||||
@@ -199,17 +222,11 @@ class StockSettingsState extends State<StockSettings> {
|
||||
]);
|
||||
return true;
|
||||
}());
|
||||
return ListView(
|
||||
padding: const EdgeInsets.symmetric(vertical: 20.0),
|
||||
children: rows,
|
||||
);
|
||||
return ListView(padding: const EdgeInsets.symmetric(vertical: 20.0), children: rows);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: buildAppBar(context),
|
||||
body: buildSettingsPane(context),
|
||||
);
|
||||
return Scaffold(appBar: buildAppBar(context), body: buildSettingsPane(context));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,7 @@ import 'stock_arrow.dart';
|
||||
import 'stock_data.dart';
|
||||
|
||||
class _StockSymbolView extends StatelessWidget {
|
||||
const _StockSymbolView({
|
||||
required this.stock,
|
||||
required this.arrow,
|
||||
});
|
||||
const _StockSymbolView({required this.stock, required this.arrow});
|
||||
|
||||
final Stock stock;
|
||||
final Widget arrow;
|
||||
@@ -43,14 +40,10 @@ class _StockSymbolView extends StatelessWidget {
|
||||
),
|
||||
Text('Last Sale', style: headings),
|
||||
Text('$lastSale ($changeInPrice)'),
|
||||
Container(
|
||||
height: 8.0
|
||||
),
|
||||
Container(height: 8.0),
|
||||
Text('Market Cap', style: headings),
|
||||
Text(stock.marketCap),
|
||||
Container(
|
||||
height: 8.0
|
||||
),
|
||||
Container(height: 8.0),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: DefaultTextStyle.of(context).style.merge(const TextStyle(fontSize: 8.0)),
|
||||
@@ -68,11 +61,7 @@ class _StockSymbolView extends StatelessWidget {
|
||||
}
|
||||
|
||||
class StockSymbolPage extends StatelessWidget {
|
||||
const StockSymbolPage({
|
||||
super.key,
|
||||
required this.symbol,
|
||||
required this.stocks,
|
||||
});
|
||||
const StockSymbolPage({super.key, required this.symbol, required this.stocks});
|
||||
|
||||
final String symbol;
|
||||
final StockData stocks;
|
||||
@@ -84,9 +73,7 @@ class StockSymbolPage extends StatelessWidget {
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
final Stock? stock = stocks[symbol];
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(stock?.name ?? symbol),
|
||||
),
|
||||
appBar: AppBar(title: Text(stock?.name ?? symbol)),
|
||||
body: SingleChildScrollView(
|
||||
child: Container(
|
||||
margin: const EdgeInsets.all(20.0),
|
||||
@@ -97,18 +84,23 @@ class StockSymbolPage extends StatelessWidget {
|
||||
padding: EdgeInsets.all(20.0),
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
secondChild: stock != null
|
||||
? _StockSymbolView(
|
||||
stock: stock,
|
||||
arrow: Hero(
|
||||
tag: stock,
|
||||
child: StockArrow(percentChange: stock.percentChange),
|
||||
),
|
||||
) : Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Center(child: Text('$symbol not found')),
|
||||
),
|
||||
crossFadeState: stock == null && stocks.loading ? CrossFadeState.showFirst : CrossFadeState.showSecond,
|
||||
secondChild:
|
||||
stock != null
|
||||
? _StockSymbolView(
|
||||
stock: stock,
|
||||
arrow: Hero(
|
||||
tag: stock,
|
||||
child: StockArrow(percentChange: stock.percentChange),
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Center(child: Text('$symbol not found')),
|
||||
),
|
||||
crossFadeState:
|
||||
stock == null && stocks.loading
|
||||
? CrossFadeState.showFirst
|
||||
: CrossFadeState.showSecond,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -120,10 +112,7 @@ class StockSymbolPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
class StockSymbolBottomSheet extends StatelessWidget {
|
||||
const StockSymbolBottomSheet({
|
||||
super.key,
|
||||
required this.stock,
|
||||
});
|
||||
const StockSymbolBottomSheet({super.key, required this.stock});
|
||||
|
||||
final Stock stock;
|
||||
|
||||
@@ -131,13 +120,8 @@ class StockSymbolBottomSheet extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(top: BorderSide(color: Colors.black26))
|
||||
),
|
||||
child: _StockSymbolView(
|
||||
stock: stock,
|
||||
arrow: StockArrow(percentChange: stock.percentChange),
|
||||
),
|
||||
);
|
||||
decoration: const BoxDecoration(border: Border(top: BorderSide(color: Colors.black26))),
|
||||
child: _StockSymbolView(stock: stock, arrow: StockArrow(percentChange: stock.percentChange)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
enum StockMode { optimistic, pessimistic }
|
||||
|
||||
enum BackupMode { enabled, disabled }
|
||||
|
||||
class StockConfiguration {
|
||||
|
||||
@@ -14,6 +14,7 @@ Element? findElementOfExactWidgetTypeGoingDown(Element node, Type targetType) {
|
||||
}
|
||||
child.visitChildElements(walker);
|
||||
}
|
||||
|
||||
try {
|
||||
walker(node);
|
||||
} on Element catch (result) {
|
||||
@@ -31,12 +32,14 @@ Element? findElementOfExactWidgetTypeGoingUp(Element node, Type targetType) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
node.visitAncestorElements(walker);
|
||||
return result;
|
||||
}
|
||||
|
||||
void checkIconColor(WidgetTester tester, String label, Color color) {
|
||||
final Element listTile = findElementOfExactWidgetTypeGoingUp(tester.element(find.text(label)), ListTile)!;
|
||||
final Element listTile =
|
||||
findElementOfExactWidgetTypeGoingUp(tester.element(find.text(label)), ListTile)!;
|
||||
final Element asset = findElementOfExactWidgetTypeGoingDown(listTile, RichText)!;
|
||||
final RichText richText = asset.widget as RichText;
|
||||
expect(richText.text.style!.color, equals(color));
|
||||
@@ -58,8 +61,14 @@ void main() {
|
||||
expect(find.text('Account Balance'), findsNothing);
|
||||
|
||||
// drag the drawer out
|
||||
final Offset left = Offset(0.0, (tester.view.physicalSize / tester.view.devicePixelRatio).height / 2.0);
|
||||
final Offset right = Offset((tester.view.physicalSize / tester.view.devicePixelRatio).width, left.dy);
|
||||
final Offset left = Offset(
|
||||
0.0,
|
||||
(tester.view.physicalSize / tester.view.devicePixelRatio).height / 2.0,
|
||||
);
|
||||
final Offset right = Offset(
|
||||
(tester.view.physicalSize / tester.view.devicePixelRatio).width,
|
||||
left.dy,
|
||||
);
|
||||
final TestGesture gesture = await tester.startGesture(left);
|
||||
await tester.pump();
|
||||
await gesture.moveTo(right);
|
||||
|
||||
@@ -18,7 +18,9 @@ void main() {
|
||||
expect(find.text('AAPL'), findsNothing);
|
||||
expect(find.text('BANA'), findsNothing);
|
||||
|
||||
final stocks.StocksAppState app = tester.state<stocks.StocksAppState>(find.byType(stocks.StocksApp));
|
||||
final stocks.StocksAppState app = tester.state<stocks.StocksAppState>(
|
||||
find.byType(stocks.StocksApp),
|
||||
);
|
||||
app.stocks.add(<List<String>>[
|
||||
// "Symbol","Name","LastSale","MarketCap","IPOyear","Sector","industry","Summary Quote"
|
||||
<String>['AAPL', 'Apple', '', '', '', '', '', ''],
|
||||
|
||||
@@ -24,23 +24,25 @@ void main() {
|
||||
expect(stockList, isNotNull);
|
||||
}, timeout: Timeout.none);
|
||||
|
||||
test('open AAPL stock', () async {
|
||||
final SerializableFinder stockList = find.byValueKey('stock-list');
|
||||
expect(stockList, isNotNull);
|
||||
test(
|
||||
'open AAPL stock',
|
||||
() async {
|
||||
final SerializableFinder stockList = find.byValueKey('stock-list');
|
||||
expect(stockList, isNotNull);
|
||||
|
||||
final SerializableFinder aaplStockRow = find.byValueKey('AAPL');
|
||||
await driver.scrollUntilVisible(stockList, aaplStockRow);
|
||||
final SerializableFinder aaplStockRow = find.byValueKey('AAPL');
|
||||
await driver.scrollUntilVisible(stockList, aaplStockRow);
|
||||
|
||||
await driver.tap(aaplStockRow);
|
||||
await Future<void>.delayed(const Duration(milliseconds: 500));
|
||||
await driver.tap(aaplStockRow);
|
||||
await Future<void>.delayed(const Duration(milliseconds: 500));
|
||||
|
||||
final SerializableFinder stockOption =
|
||||
find.byValueKey('AAPL_symbol_name');
|
||||
final String symbol = await driver.getText(stockOption);
|
||||
final SerializableFinder stockOption = find.byValueKey('AAPL_symbol_name');
|
||||
final String symbol = await driver.getText(stockOption);
|
||||
|
||||
expect(symbol, 'AAPL');
|
||||
},
|
||||
skip: 'Needs to be fixed on Fuchsia.', // https://github.com/flutter/flutter/issues/87069
|
||||
timeout: Timeout.none);
|
||||
expect(symbol, 'AAPL');
|
||||
},
|
||||
skip: 'Needs to be fixed on Fuchsia.', // https://github.com/flutter/flutter/issues/87069
|
||||
timeout: Timeout.none,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user