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
0e290946
Commit
0e290946
authored
Nov 23, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #550 from abarth/material_chip
Add basic support for material chips
parents
c675ec7d
cc423482
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
187 additions
and
0 deletions
+187
-0
flutter.yaml
examples/material_gallery/flutter.yaml
+3
-0
chip_demo.dart
examples/material_gallery/lib/chip_demo.dart
+51
-0
gallery_page.dart
examples/material_gallery/lib/gallery_page.dart
+20
-0
main.dart
examples/material_gallery/lib/main.dart
+24
-0
widget_demo.dart
examples/material_gallery/lib/widget_demo.dart
+13
-0
pubspec.yaml
examples/material_gallery/pubspec.yaml
+4
-0
material.dart
packages/flutter/lib/material.dart
+1
-0
chip.dart
packages/flutter/lib/src/material/chip.dart
+71
-0
No files found.
examples/material_gallery/flutter.yaml
0 → 100644
View file @
0e290946
name
:
material_gallery
material-design-icons
:
-
name
:
navigation/cancel
examples/material_gallery/lib/chip_demo.dart
0 → 100644
View file @
0e290946
// Copyright 2015 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
'widget_demo.dart'
;
class
ChipDemo
extends
StatefulComponent
{
_ChipDemoState
createState
()
=>
new
_ChipDemoState
();
}
class
_ChipDemoState
extends
State
<
ChipDemo
>
{
bool
_showBananas
=
true
;
void
_deleteBananas
()
{
setState
(()
{
_showBananas
=
false
;
});
}
Widget
build
(
BuildContext
context
)
{
List
<
Widget
>
chips
=
<
Widget
>[
new
Chip
(
label:
new
Text
(
'Apple'
)
)
];
if
(
_showBananas
)
{
chips
.
add
(
new
Chip
(
label:
new
Text
(
'Bananas'
),
onDeleted:
_deleteBananas
));
}
return
new
Block
(
chips
.
map
((
Widget
widget
)
{
return
new
Container
(
height:
100.0
,
child:
new
Center
(
child:
widget
)
);
}).
toList
());
}
}
final
WidgetDemo
kChipDemo
=
new
WidgetDemo
(
title:
'Chips'
,
route:
'/'
,
builder:
(
_
)
=>
new
ChipDemo
()
);
examples/material_gallery/lib/gallery_page.dart
0 → 100644
View file @
0e290946
// Copyright 2015 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
'widget_demo.dart'
;
class
GalleryPage
extends
StatelessComponent
{
GalleryPage
({
this
.
demo
});
final
WidgetDemo
demo
;
Widget
build
(
BuildContext
context
)
{
return
new
Scaffold
(
toolBar:
new
ToolBar
(
center:
new
Text
(
demo
.
title
)),
body:
demo
.
builder
(
context
)
);
}
}
examples/material_gallery/lib/main.dart
0 → 100644
View file @
0e290946
// Copyright 2015 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
'chip_demo.dart'
;
import
'gallery_page.dart'
;
import
'widget_demo.dart'
;
final
List
<
WidgetDemo
>
_kDemos
=
<
WidgetDemo
>[
kChipDemo
];
void
main
(
)
{
Map
<
String
,
RouteBuilder
>
routes
=
new
Map
<
String
,
RouteBuilder
>();
for
(
WidgetDemo
demo
in
_kDemos
)
routes
[
demo
.
route
]
=
(
_
)
=>
new
GalleryPage
(
demo:
demo
);
runApp
(
new
MaterialApp
(
title:
'Material Gallery'
,
routes:
routes
));
}
examples/material_gallery/lib/widget_demo.dart
0 → 100644
View file @
0e290946
// Copyright 2015 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'
;
class
WidgetDemo
{
WidgetDemo
({
this
.
title
,
this
.
route
,
this
.
builder
});
final
String
title
;
final
String
route
;
final
WidgetBuilder
builder
;
}
examples/material_gallery/pubspec.yaml
0 → 100644
View file @
0e290946
name
:
material_gallery
dependencies
:
flutter
:
path
:
../../packages/flutter
packages/flutter/lib/material.dart
View file @
0e290946
...
...
@@ -10,6 +10,7 @@ library material;
export
'src/material/bottom_sheet.dart'
;
export
'src/material/card.dart'
;
export
'src/material/checkbox.dart'
;
export
'src/material/chip.dart'
;
export
'src/material/circle_avatar.dart'
;
export
'src/material/colors.dart'
;
export
'src/material/constants.dart'
;
...
...
packages/flutter/lib/src/material/chip.dart
0 → 100644
View file @
0e290946
// Copyright 2015 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/widgets.dart'
;
import
'colors.dart'
;
import
'icon.dart'
;
const
TextStyle
_kLabelStyle
=
const
TextStyle
(
inherit:
false
,
fontSize:
13.0
,
fontWeight:
FontWeight
.
w400
,
color:
Colors
.
black87
,
textBaseline:
TextBaseline
.
alphabetic
);
final
ColorFilter
_kIconColorFilter
=
new
ColorFilter
.
mode
(
Colors
.
black54
,
TransferMode
.
dstIn
);
class
Chip
extends
StatelessComponent
{
const
Chip
({
Key
key
,
this
.
icon
,
this
.
label
,
this
.
onDeleted
})
:
super
(
key:
key
);
final
Widget
icon
;
final
Widget
label
;
final
VoidCallback
onDeleted
;
Widget
build
(
BuildContext
context
)
{
final
bool
deletable
=
onDeleted
!=
null
;
List
<
Widget
>
children
=
<
Widget
>[
new
DefaultTextStyle
(
style:
_kLabelStyle
,
child:
label
)
];
if
(
deletable
)
{
children
.
add
(
new
GestureDetector
(
onTap:
onDeleted
,
child:
new
Container
(
padding:
const
EdgeDims
.
symmetric
(
horizontal:
4.0
),
child:
new
Icon
(
icon:
'navigation/cancel'
,
size:
IconSize
.
s18
,
colorFilter:
_kIconColorFilter
)
)
));
}
EdgeDims
padding
=
deletable
?
new
EdgeDims
.
only
(
left:
12.0
)
:
new
EdgeDims
.
symmetric
(
horizontal:
12.0
);
return
new
Container
(
height:
32.0
,
padding:
padding
,
decoration:
new
BoxDecoration
(
backgroundColor:
Colors
.
grey
[
300
],
borderRadius:
16.0
),
child:
new
Row
(
children
,
justifyContent:
FlexJustifyContent
.
collapse
)
);
}
}
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