merge-requests/3/head
Sultan Khan 4 years ago
commit d897463b42

@ -3,37 +3,52 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class CupertinoPickerUtils{
class CupertinoPickerUtils {
int cupertinoPickerIndex = 0;
/// show Cupertino Picker for any list [context] the page BuildContext
/// [items] the list of items we need to show
/// [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.
/// [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(
{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(
isDismissible: isDismissible,
context: context,
builder: (BuildContext builder) {
return Container(
height: SizeConfig.realScreenHeight * 0.4,
color: Color(0xfff7f7f7),
color: backgroundColor,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Container(
color: Color(0xfff7f7f7),
color: backgroundColor,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
CupertinoButton(
child: Text(TranslationBase.of(context).cancel,
style:
TextStyle(color: Theme.of(context).primaryColor)),
TextStyle(color: Theme.of(context).primaryColor)),
onPressed: () {
Navigator.pop(context);
},
@ -53,8 +68,14 @@ class CupertinoPickerUtils{
),
Container(
height: SizeConfig.realScreenHeight * 0.3,
color: Color(0xfff7f7f7),
child: buildPickerItems(context, items, decKey, onSelectFun))
color: backgroundColor,
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
/// [onSelectFun] the call function on select event
/// [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(
magnification: 1.5,
scrollController:
FixedExtentScrollController(initialItem: cupertinoPickerIndex),
FixedExtentScrollController(initialItem: cupertinoPickerIndex),
children: items.map((item) {
return Text(
'${item["$decKey"]}',
style: TextStyle(fontSize: SizeConfig.textMultiplier * 2),
);
}).toList(),
itemExtent: 25,
looping: true,
itemExtent: itemExtent,
looping: looping,
onSelectedItemChanged: (int index) {
cupertinoPickerIndex = index;
},
);
}
}
}

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

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

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

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

@ -1,7 +1,7 @@
import 'package:charts_flutter/flutter.dart' as charts;
import 'package:charts_flutter/flutter.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:flutter/material.dart';
@ -26,7 +26,7 @@ class AppTimeSeriesChart extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ListContainer(
return FlexibleContainer(
heightFactor: 0.47,
child: Column(
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';
/// 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 heightFactor;
final EdgeInsets padding;
final Widget child;
ListContainer({
FlexibleContainer({
Key key,
this.widthFactor = 0.9,
this.heightFactor = 1,

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

@ -1,6 +1,6 @@
import 'package:diplomaticquarterapp/routes.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:flutter/material.dart';
import '../../config/size_config.dart';
@ -14,8 +14,7 @@ class AppDrawer extends StatefulWidget {
class _AppDrawerState extends State<AppDrawer> {
@override
Widget build(BuildContext context) {
return ListContainer(
widthFactor: SizeConfig.widthMultiplier * .18,
return FlexibleContainer(
child: Container(
color: Colors.white,
child: Drawer(

@ -2,6 +2,11 @@ import 'package:flutter/animation.dart';
import 'package:flutter/foundation.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 {
final bool value;
final AsyncCallback onChanged;

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

@ -1,38 +1,43 @@
import 'package:flutter/material.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 {
final Widget widget;
final bool fullscreenDialog;
final bool opaque;
SlideUpPageRoute({this.widget, this.fullscreenDialog=false, this.opaque=true})
: super(pageBuilder: (
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
) {
return widget;
},
fullscreenDialog: fullscreenDialog,
opaque: opaque,
barrierColor: Color.fromRGBO(0, 0, 0, 0.5),
barrierDismissible: true,
transitionDuration: Duration(milliseconds: 800),
transitionsBuilder: ((BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
var begin = Offset(0.0, 1.0);
var end = Offset.zero;
var curve = Curves.easeInOutQuint;
SlideUpPageRoute(
{this.widget, this.fullscreenDialog = false, this.opaque = true})
: super(
pageBuilder: (
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
) {
return widget;
},
fullscreenDialog: fullscreenDialog,
opaque: opaque,
barrierColor: Color.fromRGBO(0, 0, 0, 0.5),
barrierDismissible: true,
transitionDuration: Duration(milliseconds: 800),
transitionsBuilder: ((BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
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(
position: animation.drive(tween),
child: child
);
}));
}
return SlideTransition(
position: animation.drive(tween), child: child);
}),
);
}

Loading…
Cancel
Save