Skip to content
Merged
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
148 changes: 148 additions & 0 deletions lib/components/accordian/gf_accordian.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
import 'package:flutter/material.dart';
import 'package:getflutter/colors/gf_color.dart';

class GFAccordion extends StatefulWidget {

const GFAccordion(
{Key key,
this.child,
this.content,
this.titlebackgroundColor,
this.collapsedIcon = const Icon(Icons.keyboard_arrow_down),
this.expandedIcon =
const Icon(Icons.keyboard_arrow_up, color: Colors.red),
this.title,
this.textStyle = const TextStyle(color: Colors.black, fontSize: 16),
this.titlePadding,
this.descriptionPadding,
this.descriptionbackgroundColor,
this.contentChild,
this.margin})
: super(key: key);

/// child of type [Widget]is alternative to title key. title will get priority over child
final Widget child;

/// content of type[String] which shows the messages after the [GFAccordion] is expanded
final String content;

/// contentChild of type [Widget]is alternative to content key. content will get priority over contentChild
final Widget contentChild;

/// type of [Color] or [GFColor] which is used to change the background color of the [GFAccordion] title
final dynamic titlebackgroundColor;

///collapsedIcon of type [Widget] which is used to show when the [GFAccordion] is collapsed
final Widget collapsedIcon;

///expandedIcon of type[Widget] which is used when the [GFAccordion] is expanded
final Widget expandedIcon;

/// text of type [String] is alternative to child. text will get priority over child
final String title;

/// textStyle of type [textStyle] will be applicable to text only and not for the child
final TextStyle textStyle;

///titlePadding of type [EdgeInsets] which is used to set the padding of the [GFAccordion] title
final EdgeInsets titlePadding;

///descriptionPadding of type [EdgeInsets] which is used to set the padding of the [GFAccordion] description
final EdgeInsets descriptionPadding;

/// type of [Color] or [GFColor] which is used to change the background color of the [GFAccordion] description
final dynamic descriptionbackgroundColor;

///margin of type [EdgeInsets] which is used to set the margin of the [GFAccordion]
final EdgeInsets margin;

@override
_GFAccordionState createState() => _GFAccordionState();
}

class _GFAccordionState extends State<GFAccordion>
with TickerProviderStateMixin {
AnimationController animationController;
AnimationController controller;
Animation<Offset> offset;

@override
void initState() {
super.initState();
animationController =
AnimationController(duration: Duration(seconds: 2), vsync: this);
controller =
AnimationController(vsync: this, duration: Duration(milliseconds: 300));
offset = Tween(begin: Offset(0.0, -0.06), end: Offset.zero).animate(
CurvedAnimation(
parent: controller,
curve: Curves.fastOutSlowIn,
),
);
}

bool showAccordion = false;

@override
Widget build(BuildContext context) {
return Container(
margin: widget.margin != null ? widget.margin : EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
GestureDetector(
onTap: () {
setState(() {
switch (controller.status) {
case AnimationStatus.completed:
controller.forward(from: 0);
break;
case AnimationStatus.dismissed:
controller.forward();
break;
default:
}
showAccordion = !showAccordion;
});
},
child: Container(
color: widget.titlebackgroundColor != null
? widget.titlebackgroundColor
: Colors.white,
padding: widget.titlePadding != null
? widget.titlePadding
: EdgeInsets.all(10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
child: widget.title != null
? Text(widget.title, style: widget.textStyle)
: (widget.child ?? Container()),
),
showAccordion ? widget.expandedIcon : widget.collapsedIcon
],
),
),
),
showAccordion
? Container(
width: MediaQuery.of(context).size.width,
color: widget.descriptionbackgroundColor != null
? widget.descriptionbackgroundColor
: Colors.white70,
padding: widget.descriptionPadding != null
? widget.descriptionPadding
: EdgeInsets.all(10),
child: SlideTransition(
position: offset,
child: widget.content != null
? Text(widget.content)
: (widget.contentChild ?? Container()),
))
: Container()
],
),
);
}
}
149 changes: 149 additions & 0 deletions lib/components/alert/gf_alert.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:getflutter/getflutter.dart';
import 'package:getflutter/types/gf_alert_type.dart';

class GFAlert extends StatefulWidget {

/// Alert has to be wrap inside the body like [GFFloatingWidget]. See [GFFloatingWidget]
GFAlert(
{Key key,
this.child,
this.backgroundColor,
this.content,
this.width,
this.type = GFAlertType.basic,
this.alignment,
this.contentChild,
this.title,
this.bottombar,
this.animationDuration = const Duration(milliseconds: 300),
this.textStyle = const TextStyle(color: Colors.black87),
this.titleTextStyle = const TextStyle(
color: Colors.black87, fontSize: 17, fontWeight: FontWeight.w500)})
: super(key: key);

/// child of type [Widget]is alternative to text key. text will get priority over child
final Widget child;

/// title of type [String] used to descripe the title of the [GFAlert]
final String title;

/// child of type [Widget]is alternative to title key. title will get priority over contentchild
final Widget contentChild;

/// title of type [String] used to describe the content of the [GFAlert]
final String content;

final TextStyle titleTextStyle;

///pass color of type [Color] or [GFColor] for background of [GFAlert]
final dynamic backgroundColor;

/// textStyle of type [textStyle] will be applicable to text only and not for the child
final TextStyle textStyle;

/// width of type [double] used to control the width of the [GFAlert]
final double width;

///type of [GFAlertType] which takes the type ie, basic, rounded and fullWidth for the [GFAlert]
final GFAlertType type;

///type of [Duration] which takes the duration of the fade in animation
final Duration animationDuration;

/// type of [Alignment] used to align the text inside the toast
final Alignment alignment;

///type of [Widget] used for the buttons ie, OK, Cancel for the action in [GFAlert]
final Widget bottombar;
@override
_GFAlertState createState() => _GFAlertState();
}

class _GFAlertState extends State<GFAlert> with TickerProviderStateMixin {
AnimationController animationController;
Animation<double> animation;

@override
void initState() {
animationController = AnimationController(
duration: const Duration(milliseconds: 300), vsync: this);
animation = CurvedAnimation(
parent: animationController, curve: Curves.fastOutSlowIn);

animationController.forward();
super.initState();
}

@override
void dispose() {
animationController.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
Container(
height: MediaQuery.of(context).size.height,
),
FadeTransition(
opacity: animation,
child: Column(
children: <Widget>[
Container(
width: widget.type == GFAlertType.fullWidth
? MediaQuery.of(context).size.width
: widget.width,
constraints: BoxConstraints(minHeight: 50.0),
margin: widget.type == GFAlertType.fullWidth
? EdgeInsets.only(left: 0, right: 0)
: EdgeInsets.only(left: 20, right: 20),
padding: EdgeInsets.all(15),
decoration: BoxDecoration(
borderRadius: widget.type == GFAlertType.basic
? BorderRadius.circular(3.0)
: widget.type == GFAlertType.rounded
? BorderRadius.circular(10.0)
: BorderRadius.zero,
color: widget.backgroundColor != null
? GFColors.getGFColor(widget.backgroundColor)
: GFColors.getGFColor(GFColor.white),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.40),
blurRadius: 3.0)
]),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
widget.title != null
? Text(widget.title, style: widget.titleTextStyle)
: (widget.child ?? Container()),
SizedBox(
height: 10,
),
Align(
alignment: widget.alignment != null
? widget.alignment
: Alignment.topLeft,
child: widget.content != null
? Text(widget.content, style: widget.textStyle)
: (widget.contentChild ?? Container()),
),
SizedBox(
height: 10,
),
widget.bottombar != null ? widget.bottombar : Container(),
],
),
),
],
),
),
],
);
}
}
53 changes: 40 additions & 13 deletions lib/components/toast/gf_floating_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class GFFloatingWidget extends StatefulWidget {
this.child,
this.horizontalPosition,
this.verticalPosition,
this.color,
this.blur=false,
this.body})
: super(key: key);

Expand All @@ -24,6 +26,17 @@ class GFFloatingWidget extends StatefulWidget {
/// verticalPosition of type [double] which aligns the child vertically across the body
final double verticalPosition;


final dynamic color;

final bool blur;







@override
_GFFloatingWidgetState createState() => _GFFloatingWidgetState();
}
Expand All @@ -39,19 +52,33 @@ class _GFFloatingWidgetState extends State<GFFloatingWidget> {
height: MediaQuery.of(context).size.height,
child: widget.body ?? Container(),
),
Positioned(
top:
widget.verticalPosition != null ? widget.verticalPosition : 0.0,
left: widget.horizontalPosition != null
? widget.horizontalPosition
: 0.0,
right: widget.horizontalPosition != null
? widget.horizontalPosition
: 0.0,
child: Container(
width: MediaQuery.of(context).size.width,
child: widget.child ?? Container(),
)),
Container(
// color: widget.child!=null? widget.color: null,
child: Stack(
children: <Widget>[
Positioned(
child:Container(
alignment: Alignment.topLeft,
// color: widget.child!=null? widget.color: null,
color: widget.blur?Colors.black38:null,
child: Stack(
children: <Widget>[
Positioned( top:
widget.verticalPosition != null ? widget.verticalPosition : 0.0,
left: widget.horizontalPosition != null
? widget.horizontalPosition
: 0.0,
right: widget.horizontalPosition != null
? widget.horizontalPosition
: 0.0,child: widget.child??Container(),)
],
)
)
),
],
)
)

],
);
}
Expand Down
1 change: 1 addition & 0 deletions lib/types/gf_alert_type.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enum GFAlertType { basic, rounded, fullWidth }