Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
8fe424f9
Unverified
Commit
8fe424f9
authored
Aug 09, 2019
by
rami-a
Committed by
GitHub
Aug 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Material] Create demo for material banner (#37631)
parent
526339b6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
119 additions
and
0 deletions
+119
-0
banner_demo.dart
examples/flutter_gallery/lib/demo/material/banner_demo.dart
+109
-0
material.dart
examples/flutter_gallery/lib/demo/material/material.dart
+1
-0
demos.dart
examples/flutter_gallery/lib/gallery/demos.dart
+9
-0
No files found.
examples/flutter_gallery/lib/demo/material/banner_demo.dart
0 → 100644
View file @
8fe424f9
// Copyright 2019 The Chromium 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
?
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}
'
),);
}),
);
}
}
examples/flutter_gallery/lib/demo/material/material.dart
View file @
8fe424f9
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
// found in the LICENSE file.
export
'backdrop_demo.dart'
;
export
'backdrop_demo.dart'
;
export
'banner_demo.dart'
;
export
'bottom_app_bar_demo.dart'
;
export
'bottom_app_bar_demo.dart'
;
export
'bottom_navigation_demo.dart'
;
export
'bottom_navigation_demo.dart'
;
export
'buttons_demo.dart'
;
export
'buttons_demo.dart'
;
...
...
examples/flutter_gallery/lib/gallery/demos.dart
View file @
8fe424f9
...
@@ -159,6 +159,15 @@ List<GalleryDemo> _buildGalleryDemos() {
...
@@ -159,6 +159,15 @@ List<GalleryDemo> _buildGalleryDemos() {
routeName:
BackdropDemo
.
routeName
,
routeName:
BackdropDemo
.
routeName
,
buildRoute:
(
BuildContext
context
)
=>
BackdropDemo
(),
buildRoute:
(
BuildContext
context
)
=>
BackdropDemo
(),
),
),
GalleryDemo
(
title:
'Banner'
,
subtitle:
'Displaying a banner within a list'
,
icon:
GalleryIcons
.
lists_leave_behind
,
category:
_kMaterialComponents
,
routeName:
BannerDemo
.
routeName
,
documentationUrl:
'https://api.flutter.dev/flutter/material/MaterialBanner-class.html'
,
buildRoute:
(
BuildContext
context
)
=>
const
BannerDemo
(),
),
GalleryDemo
(
GalleryDemo
(
title:
'Bottom app bar'
,
title:
'Bottom app bar'
,
subtitle:
'Optional floating action button notch'
,
subtitle:
'Optional floating action button notch'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment