Skip to content
Merged

Card #10

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 69 additions & 96 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,85 +52,39 @@ class _MyHomePageState extends State<MyHomePage> {
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[

// Card(
// child: Stack(
// alignment: AlignmentDirectional.center,
// children: <Widget>[
//// Container(
////// child: new Text(
////// 'Hello world',
////// style: Theme.of(context).textTheme.display4
////// ),
//// decoration: new BoxDecoration(
//// color: const Color(0xff7c94b6),
//// image: new DecorationImage(
//// fit: BoxFit.cover,
//// colorFilter: new ColorFilter.mode(Colors.black.withOpacity(0.2), BlendMode.dstATop),
//// image: new NetworkImage(
//// 'http://www.allwhitebackground.com/images/2/2582-190x190.jpg',
//// ),
//// ),
//// ),
//// ),
// Image.network(
// 'http://www.allwhitebackground.com/images/2/2582-190x190.jpg',
// ),
// Column(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: <Widget>[
// GFTitleBar(
// avatar: GFAvatar(
// child: Text("tb"),
// ),
// title: Text('title'),
// subTitle: Text('subtitle'),
// icon: GFIconButton(
// onPressed: null,
// type: GFType.transparent,
// icon: Icon(Icons.favorite_border),
// ),
// ),
// Text("Flutter "
// "Flutter is Google's mobile UI framework for crafting high-quality native interfaces on iOS and Android in "),
// GFButtonBar(
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// GFButton(onPressed: null, child: Text("favorite"), icon: Icon(Icons.favorite_border), type: GFType.transparent, ),
// GFButton(onPressed: null, child: Text("share"), icon: Icon(Icons.share), type: GFType.outline, ),
// ],
// ),
//
// ],
// ),
// ],
// ),
// ),
//
GFImageOverlay(
height: 200.0,
width: MediaQuery.of(context).size.width,
margin: EdgeInsets.all(16.0),
padding: EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,

GFCard(
boxFit: BoxFit.cover,
colorFilter: new ColorFilter.mode(Colors.black.withOpacity(0.67), BlendMode.darken),
image: Image.asset("lib/assets/pizza.jpeg"),
// imageOverlay: AssetImage("lib/assets/pizza.jpeg"),
titlePosition: GFPosition.end,
title: GFTitleBar(
avatar: GFAvatar(
child: Text("tb"),
),
title: Text('title', style: TextStyle(color: Colors.grey),),
subTitle: Text('subtitle', style: TextStyle(color: Colors.grey),),
icon: GFIconButton(
onPressed: null,
icon: Icon(Icons.favorite_border),
type: GFType.transparent,
),
),
content: Text("Flutter "
"Flutter is Google's mobile UI framework for crafting"
" high-quality native interfaces on iOS and Android in "
"Flutter ", style: TextStyle(color: Colors.grey), ),
buttonBar: GFButtonBar(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new Text(
'Hello world', style: TextStyle(color: Colors.white),
),new Text(
'Hello world', style: TextStyle(color: Colors.white),
),
GFButton(onPressed: null, child: Text("favorite"), icon: Icon(Icons.favorite_border), type: GFType.transparent, ),
GFButton(onPressed: null, child: Text("share"), icon: Icon(Icons.share), type: GFType.outline, ),
],
),
// color: Colors.orange,
image: AssetImage("lib/assets/pizza.jpeg"),
boxFit: BoxFit.cover,
colorFilter: new ColorFilter.mode(Colors.black.withOpacity(0.6), BlendMode.darken),
borderRadius: new BorderRadius.circular(5.0),
// border: Border.all(color: Colors.pink, width: 2.0),
),


// GFButtonBar(
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
Expand All @@ -153,33 +107,52 @@ class _MyHomePageState extends State<MyHomePage> {
// ),
// ),

GFCard(
GFImageOverlay(
width: MediaQuery.of(context).size.width,
margin: EdgeInsets.all(16.0),
// color: Colors.pink,
titlePosition: GFPosition.end,
avatar: GFAvatar(
child: Text("tb"),
),
title: Text('title'),
subTitle: Text('subtitle'),
icon: GFIconButton(
onPressed: null,
icon: Icon(Icons.favorite_border),
type: GFType.transparent,
),
// image: Image.asset("lib/assets/pizza.jpeg"),
// imageOverlay: Image.asset("lib/assets/pizza.jpeg"),
content: Text("Flutter "
"Flutter is Google's mobile UI framework for crafting high-quality native interfaces on iOS and Android in "),
buttonBar: GFButtonBar(
mainAxisSize: MainAxisSize.min,
padding: EdgeInsets.all(16.0),
child: Column(
children: <Widget>[
GFButton(onPressed: null, child: Text("favorite"), icon: Icon(Icons.favorite_border), type: GFType.transparent, ),
GFButton(onPressed: null, child: Text("share"), icon: Icon(Icons.share), type: GFType.outline, ),
new Text(
'Hello world', style: TextStyle(color: Colors.white),
),new Text(
'Hello world', style: TextStyle(color: Colors.white),
),
new Text(
'Hello world', style: TextStyle(color: Colors.white),
),new Text(
'Hello world', style: TextStyle(color: Colors.white),
),
new Text(
'Hello world', style: TextStyle(color: Colors.white),
),new Text(
'Hello world', style: TextStyle(color: Colors.white),
),
new Text(
'Hello world', style: TextStyle(color: Colors.white),
),new Text(
'Hello world', style: TextStyle(color: Colors.white),
),
new Text(
'Hello world', style: TextStyle(color: Colors.white),
),new Text(
'Hello world', style: TextStyle(color: Colors.white),
),
new Text(
'Hello world', style: TextStyle(color: Colors.white),
),new Text(
'Hello world', style: TextStyle(color: Colors.white),
),
],
),

// color: Colors.orange,
image: AssetImage("lib/assets/pizza.jpeg"),
boxFit: BoxFit.cover,
colorFilter: new ColorFilter.mode(Colors.black.withOpacity(0.6), BlendMode.darken),
borderRadius: new BorderRadius.circular(5.0),
// border: Border.all(color: Colors.pink, width: 2.0),
),

//
// GFAvatar(
//// radius: 40.0,
Expand Down
115 changes: 49 additions & 66 deletions lib/components/card/gf_card.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:ui_kit/components/avatar/gf_avatar.dart';
import 'package:ui_kit/components/button_bar/gf_button_bar.dart';
import 'package:ui_kit/components/header_bar/gf_title_bar.dart';
import 'package:ui_kit/components/image/gf_image_overlay.dart';
Expand All @@ -19,19 +18,17 @@ class GFCard extends StatelessWidget {
this.padding = const EdgeInsets.all(12.0),
this.margin,
this.clipBehavior,
this.child,
this.semanticContainer,
this.avatar,
this.title,
this.subTitle,
this.subTitleTextStyle,
this.titleTextStyle,
this.content,
this.image,
this.icon,
this.buttonBar,
this.imageOverlay,
this.titlePosition
this.titlePosition,
this.borderRadius,
this.border,
this.boxFit,
this.colorFilter
}) : assert(elevation == null || elevation >= 0.0),
assert(borderOnForeground != null),
super(key: key);
Expand All @@ -55,7 +52,6 @@ class GFCard extends StatelessWidget {
final Clip clipBehavior;

/// The empty space that surrounds the card. Defines the card's outer [Container.margin].

final EdgeInsetsGeometry margin;

/// The empty space that surrounds the card. Defines the card's outer [Container.margin]..
Expand All @@ -65,26 +61,8 @@ class GFCard extends StatelessWidget {
/// a collection of individual semantic nodes.
final bool semanticContainer;

/// The widget below this widget in the tree.
final Widget child;

/// gfAvatar used to create rounded user profile
final GFAvatar avatar;

/// The title to display inside the [GFTitleBar]. see [Text]
final Widget title;

/// The subTitle to display inside the [GFTitleBar]. see [Text]
final Widget subTitle;

/// The icon to display inside the [GFTitleBar]. see [Icon]
final Widget icon;

/// pass [style] as title's textStyle
final TextStyle titleTextStyle;

/// pass [style] as subTitle's textStyle
final TextStyle subTitleTextStyle;
/// The title to display inside the [GFTitleBar]. see [GFTitleBar]
final GFTitleBar title;

/// widget can be used to define content
final Widget content;
Expand All @@ -93,18 +71,58 @@ class GFCard extends StatelessWidget {
final Image image;

/// overlay image [GFImageOverlay] widget can be used
final Image imageOverlay;
final ImageProvider imageOverlay;

/// widget can be used to define buttons bar, see [GFButtonBar]
final GFButtonBar buttonBar;

/// How the image should be inscribed into the box.
/// The default is [BoxFit.scaleDown] if [centerSlice] is null, and
/// [BoxFit.fill] if [centerSlice] is not null.
final BoxFit boxFit;

/// A color filter to apply to the image before painting it.
final ColorFilter colorFilter;

/// The corners of this [GFCard] are rounded by this [BorderRadius].
final BorderRadiusGeometry borderRadius;

/// A border to draw above the [GFCard].
final Border border;

static const double _defaultElevation = 1.0;
static const Clip _defaultClipBehavior = Clip.none;

@override
Widget build(BuildContext context) {
final CardTheme cardTheme = CardTheme.of(context);

Widget cardChild = Column(
children: <Widget>[
titlePosition == GFPosition.start ? title != null ? title : Container() : image != null ? ClipRRect(
borderRadius: BorderRadius.vertical(top: Radius.circular(4.0)),
child: image,
): Container(),
titlePosition == GFPosition.start ? image != null ? image : Container(): title != null ? title : Container(),
Padding(
padding: padding,
child: content,
),
buttonBar,
],
);

Widget overlayImage = GFImageOverlay(
width: MediaQuery.of(context).size.width,
child: cardChild,
color: color ?? cardTheme.color ?? Theme.of(context).cardColor,
image: imageOverlay,
boxFit: boxFit,
colorFilter: colorFilter,
border: border,
borderRadius: borderRadius ?? BorderRadius.all(Radius.circular(4.0)),
);

return Container(
margin: margin ?? cardTheme.margin ?? const EdgeInsets.all(16.0),
child: Material(
Expand All @@ -116,42 +134,7 @@ class GFCard extends StatelessWidget {
),
borderOnForeground: borderOnForeground,
clipBehavior: clipBehavior ?? cardTheme.clipBehavior ?? _defaultClipBehavior,
child: Stack(
children: <Widget>[
// imageOverlay != null ? imageOverlay : null,
Column(
children: <Widget>[
// imageOverlay != null ? GFTitleBar(
// avatar: avatar,
// title: title,
// subTitle: subTitle,
// icon: icon,
// ) : null,
titlePosition == GFPosition.start ? GFTitleBar(
avatar: avatar,
title: title,
subTitle: subTitle,
icon: icon,
) : ClipRRect(
borderRadius: BorderRadius.vertical(top: Radius.circular(4.0)),
child: image,
),
titlePosition == GFPosition.start ?
image : GFTitleBar(
avatar: avatar,
title: title,
subTitle: subTitle,
icon: icon,
),
Padding(
padding: padding,
child: content,
),
buttonBar,
],
),
],
)
child: imageOverlay == null ? cardChild : overlayImage
),
);
}
Expand Down
Loading