Skip to content

Commit 1363bf3

Browse files
authored
Merge pull request #18 from shravyackm/listtile
Listtile
2 parents abd73ac + d4d6bcc commit 1363bf3

10 files changed

Lines changed: 290 additions & 152 deletions

File tree

example/lib/main.dart

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import 'package:ui_kit/components/image/gf_image_overlay.dart';
2121

2222
import 'package:ui_kit/components/button_bar/gf_button_bar.dart';
2323

24+
import 'package:ui_kit/components/list_tile/gf_list_tile.dart';
25+
2426
import 'package:ui_kit/types/gf_type.dart';
2527
import 'package:ui_kit/shape/gf_shape.dart';
2628
import 'package:ui_kit/components/slider/gf_slider.dart';
@@ -45,7 +47,6 @@ class MyApp extends StatelessWidget {
4547
title: 'UI_KIT_EXAMPLE',
4648
theme: ThemeData(
4749
primarySwatch: Colors.blue,
48-
4950
),
5051
debugShowCheckedModeBanner: false,
5152
home: MyHomePage(title: 'UI_KIT_EXAMPLE'),
@@ -135,7 +136,10 @@ class _MyHomePageState extends State<MyHomePage> {
135136
// },
136137
// ),
137138

138-
RawMaterialButton(onPressed: null, child: Text("fv"),),
139+
RawMaterialButton(
140+
onPressed: null,
141+
child: Text("fv"),
142+
),
139143
FlatButton(onPressed: null, child: Text("cds")),
140144

141145
// Container(
@@ -197,7 +201,10 @@ class _MyHomePageState extends State<MyHomePage> {
197201
mainAxisAlignment: MainAxisAlignment.center,
198202
crossAxisAlignment: CrossAxisAlignment.center,
199203
children: <Widget>[
200-
RawMaterialButton(onPressed: null, child: Text("fv"),),
204+
RawMaterialButton(
205+
onPressed: null,
206+
child: Text("fv"),
207+
),
201208
FlatButton(onPressed: null, child: Text("cds")),
202209
Icon(Icons.directions_railway),
203210
GFButton(
@@ -264,7 +271,7 @@ class _MyHomePageState extends State<MyHomePage> {
264271
image: Image.asset("lib/assets/food.jpeg"),
265272
// imageOverlay: AssetImage("lib/assets/food.jpeg"),
266273
titlePosition: GFPosition.end,
267-
title: GFListItem(
274+
title: GFListTile(
268275
avatar: GFAvatar(
269276
child: Text("tb"),
270277
),

lib/components/card/gf_card.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class GFCard extends StatelessWidget {
6262
final bool semanticContainer;
6363

6464
/// The title to display inside the [GFTitleBar]. see [GFTitleBar]
65-
final GFListItem title;
65+
final GFListTile title;
6666

6767
/// widget can be used to define content
6868
final Widget content;

lib/components/header/gf_header.dart

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import 'package:flutter/material.dart';
22
import 'package:ui_kit/colors/gf_color.dart';
3+
import 'package:ui_kit/types/gf_heading_type.dart';
34

45
class GFHeader extends StatelessWidget {
56
const GFHeader(
67
{Key key,
8+
this.type,
79
this.child,
810
this.text,
911
this.icon,
@@ -18,6 +20,8 @@ class GFHeader extends StatelessWidget {
1820
: super(key: key);
1921

2022

23+
24+
2125
/// child of type [Widget] is alternative to text key. text will get priority over child
2226
final Widget child;
2327

@@ -51,8 +55,29 @@ class GFHeader extends StatelessWidget {
5155
///backgroundImagecolorFilter of type [ColorFilter] to set the background color of [GFHeader] only when backgroundImage is available
5256
final ColorFilter backgroundImagecolorFilter;
5357

58+
59+
/// header type of [GFHeaderType] i.e, typo1, typo2, typo3, typo4, typo5, typo6
60+
final GFHeadingType type;
61+
5462
@override
5563
Widget build(BuildContext context) {
64+
65+
double fontSize;
66+
67+
if(type == GFHeadingType.typo1){
68+
fontSize = 25.0;
69+
}else if(type == GFHeadingType.typo2){
70+
fontSize = 22.0;
71+
}else if (type == GFHeadingType.typo3){
72+
fontSize = 19.0;
73+
}else if(type == GFHeadingType.typo4){
74+
fontSize = 17.0;
75+
}else if (type == GFHeadingType.typo5){
76+
fontSize = 15.0;
77+
}else if(type == GFHeadingType.typo6){
78+
fontSize = 13.0;
79+
}
80+
5681
return Container(
5782
padding: EdgeInsets.all(backgroundImage != null ? 10 : 0),
5883
decoration: BoxDecoration(
@@ -75,28 +100,28 @@ class GFHeader extends StatelessWidget {
75100
? Padding(padding: EdgeInsets.only(left: 10))
76101
: Container(),
77102
text != null
78-
? Text(
79-
text,
80-
style: TextStyle(
81-
color: textColor != null
82-
? getGFColor(textColor)
83-
: backgroundImage != null
84-
? Colors.white
85-
: Colors.black,
86-
fontSize: 16,
87-
letterSpacing: 0.3,
88-
fontWeight: FontWeight.w500),
89-
)
103+
? Expanded(child: Text(
104+
text,
105+
style: TextStyle(
106+
color: textColor != null
107+
? getGFColor(textColor)
108+
: backgroundImage != null
109+
? Colors.white
110+
: Colors.black,
111+
fontSize: fontSize,
112+
letterSpacing: 0.3,
113+
fontWeight: FontWeight.w500),
114+
))
90115
: child
91116
],
92117
),
93118
showDivider
94119
? Container(
95-
margin: EdgeInsets.only(top: 5, bottom: 5),
120+
margin: EdgeInsets.only(top: 3, bottom: 3),
96121
alignment: dividerAlignment,
97122
child: Container(
98123
width: dividerWidth != null ? dividerWidth : 70,
99-
height: 4,
124+
height: fontSize/5,
100125
decoration: BoxDecoration(
101126
color: dividerColor != null
102127
? getGFColor(dividerColor)
Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1+
import 'dart:ui';
2+
13
import 'package:flutter/cupertino.dart';
24
import 'package:flutter/material.dart';
35

46
class GFImageOverlay extends StatelessWidget {
5-
6-
const GFImageOverlay({
7-
Key key,
8-
this.height,
9-
this.width,
10-
this.color,
11-
this.padding,
12-
this.margin,
13-
this.image,
14-
this.child,
15-
this.alignment,
16-
this.borderRadius,
17-
this.colorFilter,
18-
this.boxFit,
19-
this.border
20-
}) : super(key: key);
7+
const GFImageOverlay(
8+
{Key key,
9+
this.height,
10+
this.width,
11+
this.color,
12+
this.padding,
13+
this.margin,
14+
this.image,
15+
this.child,
16+
this.alignment,
17+
this.borderRadius,
18+
this.colorFilter= const ColorFilter.mode(Colors.black26, BlendMode.colorBurn),
19+
this.boxFit,
20+
this.border})
21+
: super(key: key);
2122

2223
/// define image's [double] height
2324
final double height;
@@ -49,7 +50,7 @@ class GFImageOverlay extends StatelessWidget {
4950
final BoxFit boxFit;
5051

5152
/// A color filter to apply to the image before painting it.
52-
final ColorFilter colorFilter;
53+
final ColorFilter colorFilter ;
5354

5455
/// The corners of this [GFCard] are rounded by this [BorderRadius].
5556
final BorderRadiusGeometry borderRadius;
@@ -59,11 +60,10 @@ class GFImageOverlay extends StatelessWidget {
5960

6061
@override
6162
Widget build(BuildContext context) {
62-
6363
return Container(
6464
alignment: alignment,
65-
height: height,
66-
width: width,
65+
height: height ?? MediaQuery.of(context).size.height * 0.3,
66+
width: width ?? MediaQuery.of(context).size.width,
6767
margin: margin,
6868
padding: padding,
6969
child: child,
@@ -72,14 +72,8 @@ class GFImageOverlay extends StatelessWidget {
7272
border: border,
7373
color: color,
7474
image: new DecorationImage(
75-
fit: boxFit,
76-
colorFilter: colorFilter,
77-
image: image
78-
),
75+
fit: BoxFit.fill, colorFilter: child != null? colorFilter: null, image: image),
7976
),
8077
);
8178
}
8279
}
83-
84-
85-

lib/components/list_tile/gf_list_tile.dart

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,64 @@ import 'package:flutter/cupertino.dart';
22
import 'package:flutter/material.dart';
33
import 'package:ui_kit/components/avatar/gf_avatar.dart';
44

5-
class GFListItem extends StatelessWidget {
5+
class GFListTile extends StatelessWidget {
66
/// The card's background color.
77
final Color color;
88

9-
/// [GFAvatar] used to create rounded user profile
10-
final GFAvatar avatar;
9+
/// type of [Widget] or [GFAvatar] used to create rounded user profile
10+
final Widget avatar;
1111

12-
/// The title to display inside the [GFListItem]. see [Text]
12+
/// The title to display inside the [GFListTile]. see [Text]
1313
final Widget title;
1414

15-
/// The subTitle to display inside the [GFListItem]. see [Text]
15+
/// The subTitle to display inside the [GFListTile]. see [Text]
1616
final Widget subTitle;
1717

18-
/// The icon to display inside the [GFListItem]. see [Icon]
18+
/// The descriprion to display inside the [GFListTile]. see [Text]
19+
final Widget description;
20+
21+
/// The icon to display inside the [GFListTile]. see [Icon]
1922
final Widget icon;
2023

21-
const GFListItem(
24+
///type of [bool] corresponds to true or false to show or hide the divider
25+
final bool showDivider;
26+
27+
const GFListTile(
2228
{Key key,
2329
this.color,
2430
this.avatar,
2531
this.title,
2632
this.subTitle,
27-
this.icon})
33+
this.description,
34+
this.icon,
35+
this.showDivider = true
36+
})
2837
: super(key: key);
2938

3039
@override
3140
Widget build(BuildContext context) {
32-
return ListTile(
33-
leading: avatar,
34-
title: title,
35-
subtitle: subTitle,
36-
trailing: icon,
41+
return Column(
42+
crossAxisAlignment: CrossAxisAlignment.start,
43+
children: <Widget>[
44+
ListTile(
45+
leading: avatar,
46+
title: title,
47+
subtitle: subTitle != null || description != null ? Column(
48+
crossAxisAlignment: CrossAxisAlignment.start,
49+
children: <Widget>[
50+
subTitle ?? Container(),
51+
description ?? Container()
52+
],
53+
): null,
54+
trailing: icon != null ? Column(
55+
children: <Widget>[
56+
Padding(padding: EdgeInsets.only(top: description != null ? 0.0 : 8.0), child:
57+
icon )
58+
],
59+
): null
60+
),
61+
showDivider ? Divider() : Container()
62+
],
3763
);
3864
}
3965
}

0 commit comments

Comments
 (0)