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
b823e47f
Commit
b823e47f
authored
Nov 23, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add avatars to material chips
Fixes #464
parent
0e290946
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
15 deletions
+31
-15
chip_demo.dart
examples/material_gallery/lib/chip_demo.dart
+5
-1
chip.dart
packages/flutter/lib/src/material/chip.dart
+26
-14
No files found.
examples/material_gallery/lib/chip_demo.dart
View file @
b823e47f
...
...
@@ -23,7 +23,11 @@ class _ChipDemoState extends State<ChipDemo> {
List
<
Widget
>
chips
=
<
Widget
>[
new
Chip
(
label:
new
Text
(
'Apple'
)
)
),
new
Chip
(
avatar:
new
CircleAvatar
(
label:
'B'
),
label:
new
Text
(
'Blueberry'
)
),
];
if
(
_showBananas
)
{
...
...
packages/flutter/lib/src/material/chip.dart
View file @
b823e47f
...
...
@@ -7,6 +7,9 @@ import 'package:flutter/widgets.dart';
import
'colors.dart'
;
import
'icon.dart'
;
const
double
_kChipHeight
=
32.0
;
const
double
_kAvatarDiamater
=
_kChipHeight
;
const
TextStyle
_kLabelStyle
=
const
TextStyle
(
inherit:
false
,
fontSize:
13.0
,
...
...
@@ -21,26 +24,39 @@ final ColorFilter _kIconColorFilter = new ColorFilter.mode(
class
Chip
extends
StatelessComponent
{
const
Chip
({
Key
key
,
this
.
icon
,
this
.
avatar
,
this
.
label
,
this
.
onDeleted
})
:
super
(
key:
key
);
final
Widget
icon
;
final
Widget
avatar
;
final
Widget
label
;
final
VoidCallback
onDeleted
;
Widget
build
(
BuildContext
context
)
{
final
bool
deletable
=
onDeleted
!=
null
;
double
leftPadding
=
12.0
;
double
rightPadding
=
12.0
;
List
<
Widget
>
children
=
<
Widget
>[];
if
(
avatar
!=
null
)
{
leftPadding
=
0.0
;
children
.
add
(
new
Container
(
margin:
const
EdgeDims
.
only
(
right:
8.0
),
width:
_kAvatarDiamater
,
height:
_kAvatarDiamater
,
child:
avatar
));
}
List
<
Widget
>
children
=
<
Widget
>[
new
DefaultTextStyle
(
style:
_kLabelStyle
,
child:
label
)
];
children
.
add
(
new
DefaultTextStyle
(
style:
_kLabelStyle
,
child:
label
));
if
(
deletable
)
{
rightPadding
=
0.0
;
children
.
add
(
new
GestureDetector
(
onTap:
onDeleted
,
child:
new
Container
(
...
...
@@ -54,13 +70,9 @@ class Chip extends StatelessComponent {
));
}
EdgeDims
padding
=
deletable
?
new
EdgeDims
.
only
(
left:
12.0
)
:
new
EdgeDims
.
symmetric
(
horizontal:
12.0
);
return
new
Container
(
height:
32.0
,
padding:
padding
,
height:
_kChipHeight
,
padding:
new
EdgeDims
.
only
(
left:
leftPadding
,
right:
rightPadding
)
,
decoration:
new
BoxDecoration
(
backgroundColor:
Colors
.
grey
[
300
],
borderRadius:
16.0
...
...
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