|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:ui_kit/colors/gf_color.dart'; |
| 3 | + |
| 4 | +class GFHeader extends StatelessWidget { |
| 5 | + const GFHeader( |
| 6 | + {Key key, |
| 7 | + this.child, |
| 8 | + this.text, |
| 9 | + this.icon, |
| 10 | + this.dividerBorderRadius, |
| 11 | + this.textColor, |
| 12 | + this.dividerAlignment, |
| 13 | + this.dividerColor, |
| 14 | + this.showDivider = true, |
| 15 | + this.dividerWidth, |
| 16 | + this.backgroundImage, |
| 17 | + this.backgroundImagecolorFilter}) |
| 18 | + : super(key: key); |
| 19 | + |
| 20 | + |
| 21 | + /// child of type [Widget] is alternative to text key. text will get priority over child |
| 22 | + final Widget child; |
| 23 | + |
| 24 | + /// text of type [String] is alternative to child. text will get priority over child |
| 25 | + final String text; |
| 26 | + |
| 27 | + ///icon of type [Widget] used to pass icon or image |
| 28 | + final Widget icon; |
| 29 | + |
| 30 | + /// Pass [GFColor] or [Color] for dividerColor |
| 31 | + final dynamic dividerColor; |
| 32 | + |
| 33 | + /// Pass [GFColor] or [Color] for textColor |
| 34 | + final dynamic textColor; |
| 35 | + |
| 36 | + /// dividerBorderRadius of type [BorderRadius] to alter the radius of the divider |
| 37 | + final BorderRadius dividerBorderRadius; |
| 38 | + |
| 39 | + ///dividerAlignment of type [Alignment] used for aligning the divider to required alignment |
| 40 | + final Alignment dividerAlignment; |
| 41 | + |
| 42 | + ///Pass [bool] value to show or hide the divider |
| 43 | + final bool showDivider; |
| 44 | + |
| 45 | + ///pass [double] type to increase or decrease the width of the divider |
| 46 | + final double dividerWidth; |
| 47 | + |
| 48 | + ///backgroundImage of type [ImageProvider] to set the background of [GFHeader] |
| 49 | + final ImageProvider backgroundImage; |
| 50 | + |
| 51 | + ///backgroundImagecolorFilter of type [ColorFilter] to set the background color of [GFHeader] only when backgroundImage is available |
| 52 | + final ColorFilter backgroundImagecolorFilter; |
| 53 | + |
| 54 | + @override |
| 55 | + Widget build(BuildContext context) { |
| 56 | + return Container( |
| 57 | + padding: EdgeInsets.all(backgroundImage != null ? 10 : 0), |
| 58 | + decoration: BoxDecoration( |
| 59 | + image: backgroundImage != null |
| 60 | + ? DecorationImage( |
| 61 | + image: backgroundImage, |
| 62 | + fit: BoxFit.cover, |
| 63 | + colorFilter: backgroundImagecolorFilter ?? |
| 64 | + ColorFilter.mode(Colors.black54, BlendMode.darken), |
| 65 | + ) |
| 66 | + : null, |
| 67 | + ), |
| 68 | + child: Column( |
| 69 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 70 | + children: <Widget>[ |
| 71 | + Row( |
| 72 | + children: <Widget>[ |
| 73 | + icon != null ? icon : Container(), |
| 74 | + icon != null |
| 75 | + ? Padding(padding: EdgeInsets.only(left: 10)) |
| 76 | + : Container(), |
| 77 | + 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 | + ) |
| 90 | + : child |
| 91 | + ], |
| 92 | + ), |
| 93 | + showDivider |
| 94 | + ? Container( |
| 95 | + margin: EdgeInsets.only(top: 5, bottom: 5), |
| 96 | + alignment: dividerAlignment, |
| 97 | + child: Container( |
| 98 | + width: dividerWidth != null ? dividerWidth : 70, |
| 99 | + height: 4, |
| 100 | + decoration: BoxDecoration( |
| 101 | + color: dividerColor != null |
| 102 | + ? getGFColor(dividerColor) |
| 103 | + : backgroundImage != null |
| 104 | + ? Colors.white |
| 105 | + : Colors.black, |
| 106 | + borderRadius: dividerBorderRadius != null |
| 107 | + ? dividerBorderRadius |
| 108 | + : BorderRadius.all(Radius.circular(5))), |
| 109 | + )) |
| 110 | + : Container() |
| 111 | + ], |
| 112 | + )); |
| 113 | + } |
| 114 | +} |
0 commit comments