mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

* Update project.pbxproj files to say Flutter rather than Chromium Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright. * Update the copyright notice checker to require a standard notice on all files * Update copyrights on Dart files. (This was a mechanical commit.) * Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine. Some were already marked "The Flutter Authors", not clear why. Their dates have been normalized. Some were missing the blank line after the license. Some were randomly different in trivial ways for no apparent reason (e.g. missing the trailing period). * Clean up the copyrights in non-Dart files. (Manual edits.) Also, make sure templates don't have copyrights. * Fix some more ORGANIZATIONNAMEs
110 lines
3.3 KiB
Dart
110 lines
3.3 KiB
Dart
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../../gallery/demo.dart';
|
|
|
|
enum BannerDemoAction {
|
|
reset,
|
|
showMultipleActions,
|
|
showLeading,
|
|
}
|
|
|
|
class BannerDemo extends StatefulWidget {
|
|
const BannerDemo({ Key key }) : super(key: key);
|
|
|
|
static const String routeName = '/material/banner';
|
|
|
|
@override
|
|
_BannerDemoState createState() => _BannerDemoState();
|
|
}
|
|
|
|
class _BannerDemoState extends State<BannerDemo> {
|
|
static const int _numItems = 20;
|
|
bool _displayBanner = true;
|
|
bool _showMultipleActions = true;
|
|
bool _showLeading = true;
|
|
|
|
void handleDemoAction(BannerDemoAction action) {
|
|
setState(() {
|
|
switch (action) {
|
|
case BannerDemoAction.reset:
|
|
_displayBanner = true;
|
|
_showMultipleActions = true;
|
|
_showLeading = true;
|
|
break;
|
|
case BannerDemoAction.showMultipleActions:
|
|
_showMultipleActions = !_showMultipleActions;
|
|
break;
|
|
case BannerDemoAction.showLeading:
|
|
_showLeading = !_showLeading;
|
|
break;
|
|
}
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final Widget banner = MaterialBanner(
|
|
content: const Text('Your password was updated on your other device. Please sign in again.'),
|
|
leading: _showLeading ? const CircleAvatar(child: Icon(Icons.access_alarm)) : null,
|
|
actions: <Widget>[
|
|
FlatButton(
|
|
child: const Text('SIGN IN'),
|
|
onPressed: () {
|
|
setState(() {
|
|
_displayBanner = false;
|
|
});
|
|
},
|
|
),
|
|
if (_showMultipleActions)
|
|
FlatButton(
|
|
child: const Text('DISMISS'),
|
|
onPressed: () {
|
|
setState(() {
|
|
_displayBanner = false;
|
|
});
|
|
},
|
|
),
|
|
],
|
|
);
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Banner'),
|
|
actions: <Widget>[
|
|
MaterialDemoDocumentationButton(BannerDemo.routeName),
|
|
PopupMenuButton<BannerDemoAction>(
|
|
onSelected: handleDemoAction,
|
|
itemBuilder: (BuildContext context) => <PopupMenuEntry<BannerDemoAction>>[
|
|
const PopupMenuItem<BannerDemoAction>(
|
|
value: BannerDemoAction.reset,
|
|
child: Text('Reset the banner'),
|
|
),
|
|
const PopupMenuDivider(),
|
|
CheckedPopupMenuItem<BannerDemoAction>(
|
|
value: BannerDemoAction.showMultipleActions,
|
|
checked: _showMultipleActions,
|
|
child: const Text('Multiple actions'),
|
|
),
|
|
CheckedPopupMenuItem<BannerDemoAction>(
|
|
value: BannerDemoAction.showLeading,
|
|
checked: _showLeading,
|
|
child: const Text('Leading icon'),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
body: ListView.builder(itemCount: _displayBanner ? _numItems + 1 : _numItems, itemBuilder: (BuildContext context, int index) {
|
|
if (index == 0 && _displayBanner) {
|
|
return banner;
|
|
}
|
|
return ListTile(title: Text('Item ${_displayBanner ? index : index + 1}'),);
|
|
}),
|
|
);
|
|
}
|
|
}
|