add new widget by Elham Rababah and Mohammad Aljammal
parent
19676549e1
commit
6d6c71655a
@ -0,0 +1,82 @@
|
|||||||
|
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class LargeAvatar extends StatelessWidget {
|
||||||
|
LargeAvatar(
|
||||||
|
{Key key,
|
||||||
|
this.name,
|
||||||
|
this.url,
|
||||||
|
this.disableProfileView: false,
|
||||||
|
this.radius = 60.0,
|
||||||
|
this.width = 90,
|
||||||
|
this.height = 90})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
final String name;
|
||||||
|
final String url;
|
||||||
|
final bool disableProfileView;
|
||||||
|
final double radius;
|
||||||
|
final double width;
|
||||||
|
final double height;
|
||||||
|
|
||||||
|
Widget _getAvatar() {
|
||||||
|
if (url != null && url.isNotEmpty && Uri.parse(url).isAbsolute) {
|
||||||
|
return Center(
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(radius)),
|
||||||
|
child: Image.network(
|
||||||
|
url.trim(),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
width: width,
|
||||||
|
height: height,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else if (name == null || name.isEmpty) {
|
||||||
|
return Center(
|
||||||
|
child: Texts(
|
||||||
|
'DR',
|
||||||
|
color: Colors.white,
|
||||||
|
));
|
||||||
|
} 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
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
begin: Alignment(-1, -1),
|
||||||
|
end: Alignment(1, 1),
|
||||||
|
colors: [
|
||||||
|
Colors.grey[100],
|
||||||
|
Colors.grey[800],
|
||||||
|
]),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Color.fromRGBO(0, 0, 0, 0.08),
|
||||||
|
offset: Offset(0.0, 5.0),
|
||||||
|
blurRadius: 16.0)
|
||||||
|
],
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(50.0)),
|
||||||
|
),
|
||||||
|
width: width,
|
||||||
|
height: height,
|
||||||
|
child: _getAvatar()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:charts_flutter/flutter.dart' as charts;
|
||||||
|
|
||||||
|
/// chart line
|
||||||
|
/// [seriesList] charts series
|
||||||
|
/// [chartTitle] the charts title
|
||||||
|
/// [animate] enable and disable animate on create chart
|
||||||
|
/// [includeArea] chart include Area
|
||||||
|
/// [stacked] stacked chart over the design
|
||||||
|
class AppLineChart extends StatelessWidget {
|
||||||
|
final List<charts.Series> seriesList;
|
||||||
|
final String chartTitle;
|
||||||
|
final bool animate;
|
||||||
|
final bool includeArea;
|
||||||
|
final bool stacked;
|
||||||
|
|
||||||
|
AppLineChart(
|
||||||
|
{Key key,
|
||||||
|
@required this.seriesList,
|
||||||
|
this.chartTitle,
|
||||||
|
this.animate = true,
|
||||||
|
this.includeArea = false,
|
||||||
|
this.stacked = true});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Text(
|
||||||
|
chartTitle,
|
||||||
|
style: TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: charts.LineChart(seriesList,
|
||||||
|
defaultRenderer: charts.LineRendererConfig(
|
||||||
|
includeArea: false, stacked: true),
|
||||||
|
animate: animate),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,64 @@
|
|||||||
|
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/text.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
/// App Time Series Chart
|
||||||
|
/// [seriesList] the series list
|
||||||
|
/// [chartName] the name of the chart
|
||||||
|
/// [startDate] the start date
|
||||||
|
/// [endDate] the end date
|
||||||
|
class AppTimeSeriesChart extends StatelessWidget {
|
||||||
|
AppTimeSeriesChart({
|
||||||
|
Key key,
|
||||||
|
@required this.seriesList,
|
||||||
|
this.chartName = '',
|
||||||
|
this.startDate,
|
||||||
|
this.endDate,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String chartName;
|
||||||
|
final List<Series<dynamic, DateTime>> seriesList;
|
||||||
|
final DateTime startDate;
|
||||||
|
final DateTime endDate;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListContainer(
|
||||||
|
heightFactor: 0.47,
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Texts(chartName, fontSize: SizeConfig.textMultiplier * 3),
|
||||||
|
Container(
|
||||||
|
height: SizeConfig.realScreenHeight * 0.37,
|
||||||
|
child: Center(
|
||||||
|
child: Container(
|
||||||
|
child: charts.TimeSeriesChart(
|
||||||
|
seriesList,
|
||||||
|
animate: true,
|
||||||
|
behaviors: [
|
||||||
|
charts.RangeAnnotation(
|
||||||
|
[
|
||||||
|
charts.RangeAnnotationSegment(startDate, endDate,
|
||||||
|
charts.RangeAnnotationAxisType.domain),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TimeSeriesSales {
|
||||||
|
final DateTime time;
|
||||||
|
final int sales;
|
||||||
|
|
||||||
|
TimeSeriesSales(this.time, this.sales);
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
/// [child] A widget that centers its child within itself.
|
||||||
|
/// [padding] The amount of space by which to inset the child.
|
||||||
|
/// [color] By default, the color is derived from the [type] of material.
|
||||||
|
/// [radius] radius value
|
||||||
|
class CardRoundedWidget extends StatelessWidget {
|
||||||
|
final Widget child;
|
||||||
|
final double padding;
|
||||||
|
final Color color;
|
||||||
|
final double radius;
|
||||||
|
|
||||||
|
CardRoundedWidget(
|
||||||
|
{@required this.child,
|
||||||
|
this.color = Colors.white,
|
||||||
|
this.radius = 10.0,
|
||||||
|
this.padding = 10.0});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
margin: EdgeInsets.symmetric(vertical: 10.0),
|
||||||
|
width: double.infinity,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.all(
|
||||||
|
Radius.circular(radius),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Material(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(radius)),
|
||||||
|
color: color,
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Center(
|
||||||
|
child: Container(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.all(padding),
|
||||||
|
child: Center(child: child),
|
||||||
|
)),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
///show App Embedded Error
|
||||||
|
/// [error] the message we show to the user
|
||||||
|
class AppEmbeddedError extends StatelessWidget {
|
||||||
|
const AppEmbeddedError({
|
||||||
|
Key key,
|
||||||
|
@required this.error,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final String error;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Center(
|
||||||
|
child: Texts(
|
||||||
|
error,
|
||||||
|
color: Theme.of(context).errorColor,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,65 @@
|
|||||||
|
import 'package:expandable/expandable.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
/// App Expandable Notifier with animation
|
||||||
|
/// [headerWidget] widget want to show in the header
|
||||||
|
/// [bodyWidget] widget want to show in the body
|
||||||
|
/// [title] the widget title
|
||||||
|
/// [collapsed] The widget shown in the collapsed state
|
||||||
|
class AppExpandableNotifier extends StatelessWidget {
|
||||||
|
final Widget headerWidget;
|
||||||
|
final Widget bodyWidget;
|
||||||
|
final String title;
|
||||||
|
final Widget collapsed;
|
||||||
|
|
||||||
|
AppExpandableNotifier(
|
||||||
|
{this.headerWidget, this.bodyWidget, this.title, this.collapsed});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ExpandableNotifier(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
child: Card(
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
SizedBox(
|
||||||
|
child: headerWidget,
|
||||||
|
),
|
||||||
|
ScrollOnExpand(
|
||||||
|
scrollOnExpand: true,
|
||||||
|
scrollOnCollapse: false,
|
||||||
|
child: ExpandablePanel(
|
||||||
|
theme: const ExpandableThemeData(
|
||||||
|
headerAlignment: ExpandablePanelHeaderAlignment.center,
|
||||||
|
tapBodyToCollapse: true,
|
||||||
|
),
|
||||||
|
header: Padding(
|
||||||
|
padding: EdgeInsets.all(10),
|
||||||
|
child: Text(
|
||||||
|
title,
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
collapsed: collapsed,
|
||||||
|
expanded: bodyWidget,
|
||||||
|
builder: (_, collapsed, expanded) {
|
||||||
|
return Padding(
|
||||||
|
padding: EdgeInsets.only(left: 10, right: 10, bottom: 10),
|
||||||
|
child: Expandable(
|
||||||
|
collapsed: collapsed,
|
||||||
|
expanded: expanded,
|
||||||
|
theme: const ExpandableThemeData(crossFadePoint: 0),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue