Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Unified Diff: sky/sdk/example/stocks/lib/stock_home.dart

Issue 1216613004: Initial implementation of SnackBar (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: abarth cr feedback Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/sdk/BUILD.gn ('k') | sky/sdk/lib/rendering/box.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/example/stocks/lib/stock_home.dart
diff --git a/sky/sdk/example/stocks/lib/stock_home.dart b/sky/sdk/example/stocks/lib/stock_home.dart
index f8b686d334f6218728a0fdea2998bc3aac4463f6..9f4e697f4478cf0dddc5c9939f76a80d55118c66 100644
--- a/sky/sdk/example/stocks/lib/stock_home.dart
+++ b/sky/sdk/example/stocks/lib/stock_home.dart
@@ -15,6 +15,7 @@ import 'package:sky/widgets/modal_overlay.dart';
import 'package:sky/widgets/navigator.dart';
import 'package:sky/widgets/popup_menu.dart';
import 'package:sky/widgets/radio.dart';
+import 'package:sky/widgets/snack_bar.dart';
import 'package:sky/widgets/scaffold.dart';
import 'package:sky/widgets/tabs.dart';
import 'package:sky/widgets/theme.dart';
@@ -51,6 +52,8 @@ class StockHome extends Component {
bool _isSearching = false;
String _searchQuery;
+ bool _isShowingSnackBar = false;
+
void _handleSearchBegin() {
setState(() {
_isSearching = true;
@@ -223,6 +226,34 @@ class StockHome extends Component {
);
}
+ void _handleUndo() {
+ setState(() {
+ _isShowingSnackBar = false;
+ });
+ }
+
+ Widget buildSnackBar() {
+ if (!_isShowingSnackBar)
+ return null;
+ return new SnackBar(
+ content: new Text("Stock purchased!"),
+ actions: [new SnackBarAction(label: "UNDO", onPressed: _handleUndo)]
+ );
+ }
+
+ void _handleStockPurchased() {
+ setState(() {
+ _isShowingSnackBar = true;
+ });
+ }
+
+ Widget buildFloatingActionButton() {
+ return new FloatingActionButton(
+ child: new Icon(type: 'content/add_white', size: 24),
+ onPressed: _handleStockPurchased
+ );
+ }
+
void addMenuToOverlays(List<Widget> overlays) {
if (_menuController == null)
return;
@@ -240,9 +271,8 @@ class StockHome extends Component {
new Scaffold(
toolbar: _isSearching ? buildSearchBar() : buildToolBar(),
body: buildTabNavigator(),
- floatingActionButton: new FloatingActionButton(
- child: new Icon(type: 'content/add_white', size: 24)
- ),
+ snackBar: buildSnackBar(),
+ floatingActionButton: buildFloatingActionButton(),
drawer: _drawerShowing ? buildDrawer() : null
),
];
« no previous file with comments | « sky/sdk/BUILD.gn ('k') | sky/sdk/lib/rendering/box.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698