add documentation Mohammad Aljammal and Elham Rababah

merge-requests/1/head
Mohammad Aljammal 4 years ago
parent 6d6c71655a
commit 198a1854a9

@ -3,37 +3,52 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class CupertinoPickerUtils {
class CupertinoPickerUtils{
int cupertinoPickerIndex = 0; int cupertinoPickerIndex = 0;
/// show Cupertino Picker for any list [context] the page BuildContext /// show Cupertino Picker for any list [context] the page BuildContext
/// [items] the list of items we need to show /// [items] the list of items we need to show
/// [onSelectFun] the call function on select event /// [onSelectFun] the call function on select event
///The [isDismissible] parameter specifies whether the bottom sheet will be /// [isDismissible] parameter specifies whether the bottom sheet will be
/// dismissed when user taps on the scrim. /// dismissed when user taps on the scrim.
/// [itemExtent] All children will be given the [BoxConstraints] to match this exact
/// height. Must not be null and must be positive.
/// The [looping] argument decides whether the child list loops and can be
/// scrolled infinitely. If set to true, scrolling past the end of the list
/// will loop the list back to the beginning. If set to false, the list will
/// stop scrolling when you reach the end or the beginning.
/// [backgroundColor] background color
showCupertinoPicker( showCupertinoPicker(
{context, items, decKey, onSelectFun, bool isDismissible = false}) { {BuildContext context,
List items,
String decKey,
Function onSelectFun,
bool isDismissible = false,
double itemExtent = 25,
bool looping = true,
Color backgroundColor = const Color(0xfff7f7f7)}) {
showModalBottomSheet( showModalBottomSheet(
isDismissible: isDismissible, isDismissible: isDismissible,
context: context, context: context,
builder: (BuildContext builder) { builder: (BuildContext builder) {
return Container( return Container(
height: SizeConfig.realScreenHeight * 0.4, height: SizeConfig.realScreenHeight * 0.4,
color: Color(0xfff7f7f7), color: backgroundColor,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[ children: <Widget>[
Container( Container(
color: Color(0xfff7f7f7), color: backgroundColor,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[ children: <Widget>[
CupertinoButton( CupertinoButton(
child: Text(TranslationBase.of(context).cancel, child: Text(TranslationBase.of(context).cancel,
style: style:
TextStyle(color: Theme.of(context).primaryColor)), TextStyle(color: Theme.of(context).primaryColor)),
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
}, },
@ -53,8 +68,14 @@ class CupertinoPickerUtils{
), ),
Container( Container(
height: SizeConfig.realScreenHeight * 0.3, height: SizeConfig.realScreenHeight * 0.3,
color: Color(0xfff7f7f7), color: backgroundColor,
child: buildPickerItems(context, items, decKey, onSelectFun)) child: buildPickerItems(
context: context,
decKey: decKey,
itemExtent: itemExtent,
items: items,
looping: looping,
onSelectFun: onSelectFun))
], ],
), ),
); );
@ -67,22 +88,28 @@ class CupertinoPickerUtils{
/// [items] the list of items we need to show /// [items] the list of items we need to show
/// [onSelectFun] the call function on select event /// [onSelectFun] the call function on select event
/// [decKey] the key we show for user /// [decKey] the key we show for user
buildPickerItems(context, List items, decKey, onSelectFun) { buildPickerItems(
{BuildContext context,
List items,
String decKey,
Function onSelectFun,
double itemExtent,
bool looping}) {
return CupertinoPicker( return CupertinoPicker(
magnification: 1.5, magnification: 1.5,
scrollController: scrollController:
FixedExtentScrollController(initialItem: cupertinoPickerIndex), FixedExtentScrollController(initialItem: cupertinoPickerIndex),
children: items.map((item) { children: items.map((item) {
return Text( return Text(
'${item["$decKey"]}', '${item["$decKey"]}',
style: TextStyle(fontSize: SizeConfig.textMultiplier * 2), style: TextStyle(fontSize: SizeConfig.textMultiplier * 2),
); );
}).toList(), }).toList(),
itemExtent: 25, itemExtent: itemExtent,
looping: true, looping: looping,
onSelectedItemChanged: (int index) { onSelectedItemChanged: (int index) {
cupertinoPickerIndex = index; cupertinoPickerIndex = index;
}, },
); );
} }
} }

@ -2,15 +2,24 @@ import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// LargeAvatar
/// [name] the user name
/// [url] the image url
/// [disableProfileView] disable user profile view
/// [radius] the avatar radius
/// [width] the avatar width
/// [height] the avatar height
/// [onTap] on tap function
class LargeAvatar extends StatelessWidget { class LargeAvatar extends StatelessWidget {
LargeAvatar( LargeAvatar(
{Key key, {Key key,
this.name, @required this.name,
this.url, this.url,
this.disableProfileView: false, this.disableProfileView: false,
this.radius = 60.0, this.radius = 60.0,
this.width = 90, this.width = 90,
this.height = 90}) this.height = 90,
this.onTap})
: super(key: key); : super(key: key);
final String name; final String name;
@ -19,6 +28,7 @@ class LargeAvatar extends StatelessWidget {
final double radius; final double radius;
final double width; final double width;
final double height; final double height;
final GestureTapCallback onTap;
Widget _getAvatar() { Widget _getAvatar() {
if (url != null && url.isNotEmpty && Uri.parse(url).isAbsolute) { if (url != null && url.isNotEmpty && Uri.parse(url).isAbsolute) {
@ -33,30 +43,19 @@ class LargeAvatar extends StatelessWidget {
), ),
), ),
); );
} else if (name == null || name.isEmpty) { } else
return Center(
child: Texts(
'DR',
color: Colors.white,
));
} else {
return Center( return Center(
child: Texts( child: Texts(
name[0].toUpperCase(), name[0].toUpperCase(),
color: Colors.white, color: Colors.white,
fontSize: 18, fontSize: 18,
)); ));
}
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return InkWell( return InkWell(
onTap: disableProfileView onTap: disableProfileView ? null : onTap,
? null
: () {
//TODO when we need that
},
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(

@ -1,16 +1,21 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// Button widget
/// [label] button label
/// [icon] button icon its optional
/// [onTap] button function
/// [loading] show the progress indicator
/// [elevation] color elevation value
class Button extends StatefulWidget { class Button extends StatefulWidget {
Button( Button(
{Key key, {Key key,
this.title: "", this.label: "",
this.icon, this.icon,
this.onTap, this.onTap,
this.loading: false, this.loading: false,
this.elevation: true}) this.elevation: true})
: super(key: key); : super(key: key);
final String title; final String label;
final Widget icon; final Widget icon;
final VoidCallback onTap; final VoidCallback onTap;
final bool loading; final bool loading;
@ -51,7 +56,7 @@ class _ButtonState extends State<Button> with TickerProviderStateMixin {
} }
Widget _buildIcon() { Widget _buildIcon() {
if (widget.icon != null && (widget.title != null && widget.title != "")) { if (widget.icon != null && (widget.label != null && widget.label != "")) {
return Container( return Container(
margin: EdgeInsets.only(right: 12.0), margin: EdgeInsets.only(right: 12.0),
height: 24.0, height: 24.0,
@ -86,12 +91,12 @@ class _ButtonState extends State<Button> with TickerProviderStateMixin {
child: AnimatedContainer( child: AnimatedContainer(
duration: Duration(milliseconds: 150), duration: Duration(milliseconds: 150),
margin: margin:
EdgeInsets.only(bottom: widget.title.isNotEmpty ? 14.0 : 0.0), EdgeInsets.only(bottom: widget.label.isNotEmpty ? 14.0 : 0.0),
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
vertical: widget.title != null && widget.title.isNotEmpty vertical: widget.label != null && widget.label.isNotEmpty
? 12.0 ? 12.0
: 15.0, : 15.0,
horizontal: widget.title != null && widget.title.isNotEmpty horizontal: widget.label != null && widget.label.isNotEmpty
? 22.0 ? 22.0
: 19), : 19),
decoration: BoxDecoration( decoration: BoxDecoration(
@ -138,7 +143,7 @@ class _ButtonState extends State<Button> with TickerProviderStateMixin {
) )
: Padding( : Padding(
padding: EdgeInsets.only(bottom: 3.0), padding: EdgeInsets.only(bottom: 3.0),
child: Text(widget.title, child: Text(widget.label,
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 17.0, fontSize: 17.0,

@ -3,16 +3,21 @@ import 'package:flutter/material.dart';
enum MINI_BUTTON { Secondary, Primary } enum MINI_BUTTON { Secondary, Primary }
/// Button widget
/// [label] button label
/// [icon] button icon its optional
/// [onTap] button function
/// [variant] determine the color button
class MiniButton extends StatefulWidget { class MiniButton extends StatefulWidget {
MiniButton( MiniButton(
{Key key, {Key key,
this.title: "", this.label: "",
this.icon, this.icon,
this.onTap, this.onTap,
this.variant: MINI_BUTTON.Secondary}) this.variant: MINI_BUTTON.Secondary})
: super(key: key); : super(key: key);
final String title; final String label;
final IconData icon; final IconData icon;
final VoidCallback onTap; final VoidCallback onTap;
final MINI_BUTTON variant; final MINI_BUTTON variant;
@ -29,10 +34,11 @@ class _MiniButtonState extends State<MiniButton> with TickerProviderStateMixin {
@override @override
void initState() { void initState() {
_animationController = AnimationController( _animationController = AnimationController(
vsync: this, vsync: this,
lowerBound: 0.7, lowerBound: 0.7,
upperBound: 1.0, upperBound: 1.0,
duration: Duration(milliseconds: 120)); duration: Duration(milliseconds: 120),
);
_animation = CurvedAnimation( _animation = CurvedAnimation(
parent: _animationController, parent: _animationController,
curve: Curves.easeOutQuad, curve: Curves.easeOutQuad,
@ -52,7 +58,7 @@ class _MiniButtonState extends State<MiniButton> with TickerProviderStateMixin {
} }
Widget _buildIcon() { Widget _buildIcon() {
if (widget.icon != null && (widget.title != null && widget.title != "")) { if (widget.icon != null && (widget.label != null && widget.label != "")) {
return Container( return Container(
margin: EdgeInsets.only(right: 8.0), margin: EdgeInsets.only(right: 8.0),
child: Icon( child: Icon(
@ -99,7 +105,7 @@ class _MiniButtonState extends State<MiniButton> with TickerProviderStateMixin {
_buildIcon(), _buildIcon(),
Padding( Padding(
padding: EdgeInsets.only(bottom: 1.5), padding: EdgeInsets.only(bottom: 1.5),
child: Texts(widget.title, child: Texts(widget.label,
color: widget.variant == MINI_BUTTON.Primary color: widget.variant == MINI_BUTTON.Primary
? Colors.white ? Colors.white
: Theme.of(context).primaryColor, : Theme.of(context).primaryColor,

@ -1,10 +1,20 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// SecondaryButton widget
/// [label] button label
/// [icon] button icon its optional
/// [iconOnly] just show the icon
/// [color] the background color
/// [textColor] the text color
/// [onTap] button function
/// [loading] show the progress indicator
/// [disabled] disabled the button
/// [borderColor] the button border color
/// [noBorderRadius] remove border radius
class SecondaryButton extends StatefulWidget { class SecondaryButton extends StatefulWidget {
SecondaryButton( SecondaryButton(
{Key key, {Key key,
this.title = "", this.label = "",
this.borderColor,
this.icon, this.icon,
this.iconOnly = false, this.iconOnly = false,
this.color, this.color,
@ -13,10 +23,11 @@ class SecondaryButton extends StatefulWidget {
this.loading: false, this.loading: false,
this.small = false, this.small = false,
this.disabled = false, this.disabled = false,
this.borderColor,
this.noBorderRadius = false}) this.noBorderRadius = false})
: super(key: key); : super(key: key);
final String title; final String label;
final Widget icon; final Widget icon;
final VoidCallback onTap; final VoidCallback onTap;
final bool loading; final bool loading;
@ -87,10 +98,10 @@ class _SecondaryButtonState extends State<SecondaryButton>
} }
Widget _buildIcon() { Widget _buildIcon() {
if (widget.icon != null && (widget.title != null && widget.title != "")) { if (widget.icon != null && (widget.label != null && widget.label != "")) {
return Container(height: 25.0, child: widget.icon); return Container(height: 25.0, child: widget.icon);
} else if (widget.icon != null && } else if (widget.icon != null &&
(widget.title == null || widget.title == "")) { (widget.label == null || widget.label == "")) {
return Container(height: 25.0, width: 25, child: widget.icon); return Container(height: 25.0, width: 25, child: widget.icon);
} else { } else {
return Container(); return Container();
@ -133,18 +144,19 @@ class _SecondaryButtonState extends State<SecondaryButton>
scale: _buttonSize, scale: _buttonSize,
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
border: widget.borderColor != null border: widget.borderColor != null
? Border.all( ? Border.all(
color: widget.borderColor.withOpacity(0.1), width: 2.0) color: widget.borderColor.withOpacity(0.1), width: 2.0)
: null, : null,
borderRadius: BorderRadius.all(Radius.circular(100.0)), borderRadius: BorderRadius.all(Radius.circular(100.0)),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: Color.fromRGBO(0, 0, 0, 0.04), color: Color.fromRGBO(0, 0, 0, 0.04),
spreadRadius: -0.0, spreadRadius: -0.0,
offset: Offset(0, 4.0), offset: Offset(0, 4.0),
blurRadius: 18.0) blurRadius: 18.0)
]), ],
),
child: ClipRRect( child: ClipRRect(
borderRadius: widget.noBorderRadius borderRadius: widget.noBorderRadius
? BorderRadius.all(Radius.circular(0.0)) ? BorderRadius.all(Radius.circular(0.0))
@ -185,43 +197,46 @@ class _SecondaryButtonState extends State<SecondaryButton>
bottom: widget.small ? 6.0 : 14.0, bottom: widget.small ? 6.0 : 14.0,
left: 18.0, left: 18.0,
right: 18.0), right: 18.0),
child: Stack(children: <Widget>[ child: Stack(
Positioned( children: <Widget>[
child: _buildIcon(), Positioned(
), child: _buildIcon(),
Row( ),
crossAxisAlignment: CrossAxisAlignment.center, Row(
mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ mainAxisSize: MainAxisSize.max,
widget.loading children: <Widget>[
? Padding( widget.loading
padding: EdgeInsets.all(2.6), ? Padding(
child: SizedBox( padding: EdgeInsets.all(2.6),
height: 19.0, child: SizedBox(
width: 19.0, height: 19.0,
child: CircularProgressIndicator( width: 19.0,
child: CircularProgressIndicator(
backgroundColor: backgroundColor:
Color.fromRGBO(140, 130, 255, 1.0), Color.fromRGBO(140, 130, 255, 1.0),
valueColor: valueColor:
AlwaysStoppedAnimation<Color>( AlwaysStoppedAnimation<Color>(
Color.fromRGBO( Color.fromRGBO(255, 255, 255, 1.0),
255, 255, 255, 1.0))), ),
), ),
) ),
: Padding( )
padding: EdgeInsets.only( : Padding(
bottom: widget.small ? 4.0 : 3.0), padding: EdgeInsets.only(
child: Text(widget.title, bottom: widget.small ? 4.0 : 3.0),
style: TextStyle( child: Text(widget.label,
color: widget.textColor, style: TextStyle(
fontSize: 17.0, color: widget.textColor,
fontWeight: FontWeight.w800, fontSize: 17.0,
fontFamily: "HKGrotesk")), fontWeight: FontWeight.w800,
) fontFamily: "HKGrotesk")),
], )
) ],
]), )
],
),
), ),
], ],
), ),

@ -1,7 +1,7 @@
import 'package:charts_flutter/flutter.dart' as charts; import 'package:charts_flutter/flutter.dart' as charts;
import 'package:charts_flutter/flutter.dart'; import 'package:charts_flutter/flutter.dart';
import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/widgets/data_display/list/ListContainer.dart'; import 'package:diplomaticquarterapp/widgets/data_display/list/flexible_container.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -26,7 +26,7 @@ class AppTimeSeriesChart extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ListContainer( return FlexibleContainer(
heightFactor: 0.47, heightFactor: 0.47,
child: Column( child: Column(
children: <Widget>[ children: <Widget>[

@ -1,73 +0,0 @@
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/material.dart';
class ListItem extends StatelessWidget {
final IconData icon;
final Function onTap;
final Color color;
final Color iconColor;
final bool disabled;
final bool arrowIcon;
final double arrowIconSize;
final Color arrowIconColor;
final EdgeInsets padding;
final Widget itemContent;
final BoxDecoration decoration;
ListItem(
{Key key,
this.icon,
this.iconColor,
this.disabled: false,
this.onTap,
this.color,
this.arrowIcon = false,
this.padding,
this.itemContent,
this.arrowIconColor,
this.arrowIconSize = 20,
this.decoration})
: super(key: key);
@override
Widget build(BuildContext context) {
return IgnorePointer(
ignoring: disabled,
child: Container(
decoration: decoration != null ? decoration : BoxDecoration(),
child: InkWell(
onTap: () {
if (onTap != null) onTap();
},
child: Padding(
padding: padding != null
? padding
: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 16.0),
child: Row(
children: <Widget>[
if (icon != null)
Icon(
icon,
color:
iconColor ?? (color ?? Theme.of(context).primaryColor),
size: 19,
),
if (icon != null) SizedBox(width: 18.0),
Opacity(opacity: 0.8, child: itemContent),
if (arrowIcon) Expanded(child: Container()),
if (arrowIcon)
Icon(
EvaIcons.chevronRight,
color: arrowIconColor != null
? arrowIconColor
: Colors.grey[500],
size: arrowIconSize,
)
],
),
),
),
),
);
}
}

@ -0,0 +1,93 @@
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/material.dart';
/// Custom Item widget
/// [startIcon] icon at the start of the widget
/// [startIconSize] icon size of start icon
/// [startIconColor] icon color of start icon
/// [endIcon] icon at the end of the widget
/// [endIconSize] icon size of end icon
/// [endIconColor] icon color of end icon
/// [disabled] disabled on tap function
/// [onTap] opTap function
/// [padding] padding of the widget
/// [child] child of the widget
/// [decoration] decoration of the widget
class CustomItem extends StatelessWidget {
final IconData startIcon;
final double startIconSize;
final Color startIconColor;
final IconData endIcon;
final double endIconSize;
final Color endIconColor;
final bool disabled;
final Function onTap;
final EdgeInsets padding;
final Widget child;
final BoxDecoration decoration;
CustomItem(
{Key key,
this.startIcon,
this.disabled: false,
this.onTap,
this.startIconColor,
this.endIcon = EvaIcons.chevronRight,
this.padding,
this.child,
this.endIconColor,
this.endIconSize = 20,
this.decoration,
this.startIconSize = 19})
: super(key: key);
@override
Widget build(BuildContext context) {
return IgnorePointer(
ignoring: disabled,
child: Container(
decoration: decoration != null ? decoration : BoxDecoration(),
child: InkWell(
onTap: () {
if (onTap != null) onTap();
},
child: Padding(
padding: padding != null
? padding
: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 16.0),
child: Row(
children: <Widget>[
if (startIcon != null)
Expanded(
flex: 1,
child: Icon(
startIcon,
color: startIconColor ?? Theme.of(context).primaryColor,
size: startIconSize,
),
),
if (startIcon != null) SizedBox(width: 18.0),
Expanded(
child: child,
flex: 10,
),
endIcon == null
? Expanded(child: Container())
: Expanded(
flex: 1,
child: Icon(
endIcon,
color: endIconColor != null
? endIconColor
: Colors.grey[500],
size: endIconSize,
),
)
],
),
),
),
),
);
}
}

@ -1,12 +1,23 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// Flexible container widget
/// [widthFactor] If non-null, the fraction of the incoming width given to the child.
/// If non-null, the child is given a tight width constraint that is the max
/// incoming width constraint multiplied by this factor.
/// If null, the incoming width constraints are passed to the child
class ListContainer extends StatelessWidget { /// [heightFactor]If non-null, the fraction of the incoming height given to the child.
/// If non-null, the child is given a tight height constraint that is the max
/// incoming height constraint multiplied by this factor.
/// If null, the incoming height constraints are passed to the child
/// [padding] add padding to the container
/// [child] child widget inside the container
class FlexibleContainer extends StatelessWidget {
final double widthFactor; final double widthFactor;
final double heightFactor; final double heightFactor;
final EdgeInsets padding; final EdgeInsets padding;
final Widget child; final Widget child;
ListContainer({ FlexibleContainer({
Key key, Key key,
this.widthFactor = 0.9, this.widthFactor = 0.9,
this.heightFactor = 1, this.heightFactor = 1,

@ -247,7 +247,7 @@ class _TextsState extends State<Texts> {
style: _getFontStyle().copyWith( style: _getFontStyle().copyWith(
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
fontWeight: FontWeight.w800, fontWeight: FontWeight.w800,
fontFamily: "HKGrotesk")), fontFamily: "WorkSans")),
), ),
), ),
], ],

@ -1,5 +1,5 @@
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/list/ListContainer.dart'; import 'package:diplomaticquarterapp/widgets/data_display/list/flexible_container.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../config/size_config.dart'; import '../../config/size_config.dart';
@ -15,7 +15,7 @@ class AppDrawer extends StatefulWidget {
class _AppDrawerState extends State<AppDrawer> { class _AppDrawerState extends State<AppDrawer> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ListContainer( return FlexibleContainer(
child: Container( child: Container(
color: Colors.white, color: Colors.white,
child: Drawer( child: Drawer(

@ -2,6 +2,11 @@ import 'package:flutter/animation.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// Custom switch widget
/// [value] switch is active or not
/// [onChanged] function to be executed after sometime
/// [activeColor] color of active status
/// [inactiveColor] color of inactive status
class CustomSwitch extends StatefulWidget { class CustomSwitch extends StatefulWidget {
final bool value; final bool value;
final AsyncCallback onChanged; final AsyncCallback onChanged;

@ -1,5 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// FadePage animation
/// [page]
class FadePage extends PageRouteBuilder { class FadePage extends PageRouteBuilder {
final Widget page; final Widget page;
FadePage({this.page}) FadePage({this.page})

@ -1,38 +1,43 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
///Slide Up Page Route
/// [widget] widget we need to slide up
/// [fullscreenDialog] show the widget as full screen dialog
/// [opaque] When an opaque route's entrance transition is complete, the routes behind the opaque route will not be built to save resources.
class SlideUpPageRoute extends PageRouteBuilder { class SlideUpPageRoute extends PageRouteBuilder {
final Widget widget; final Widget widget;
final bool fullscreenDialog; final bool fullscreenDialog;
final bool opaque; final bool opaque;
SlideUpPageRoute({this.widget, this.fullscreenDialog=false, this.opaque=true}) SlideUpPageRoute(
: super(pageBuilder: ( {this.widget, this.fullscreenDialog = false, this.opaque = true})
BuildContext context, : super(
Animation<double> animation, pageBuilder: (
Animation<double> secondaryAnimation, BuildContext context,
) { Animation<double> animation,
return widget; Animation<double> secondaryAnimation,
}, ) {
fullscreenDialog: fullscreenDialog, return widget;
opaque: opaque, },
barrierColor: Color.fromRGBO(0, 0, 0, 0.5), fullscreenDialog: fullscreenDialog,
barrierDismissible: true, opaque: opaque,
transitionDuration: Duration(milliseconds: 800), barrierColor: Color.fromRGBO(0, 0, 0, 0.5),
transitionsBuilder: ((BuildContext context, barrierDismissible: true,
Animation<double> animation, transitionDuration: Duration(milliseconds: 800),
Animation<double> secondaryAnimation, transitionsBuilder: ((BuildContext context,
Widget child) { Animation<double> animation,
var begin = Offset(0.0, 1.0); Animation<double> secondaryAnimation,
var end = Offset.zero; Widget child) {
var curve = Curves.easeInOutQuint; var begin = Offset(0.0, 1.0);
var end = Offset.zero;
var curve = Curves.easeInOutQuint;
var tween = Tween(begin: begin, end: end).chain(CurveTween(curve: curve)); var tween =
Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
return SlideTransition( return SlideTransition(
position: animation.drive(tween), position: animation.drive(tween), child: child);
child: child }),
); );
})); }
}

Loading…
Cancel
Save