finsi lakum points task
parent
98f660e29b
commit
35d0d3e441
@ -0,0 +1,270 @@
|
|||||||
|
import 'package:diplomaticquarterapp/core/model/pharmacies/PointsAmountPerMonth.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/lacum-viewmodel.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/pharmacies/widgets/lakum-point-table-row-widget.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class LakumPointMonthPage extends StatefulWidget {
|
||||||
|
final PointsAmountPerMonth pointsAmountPerMonth;
|
||||||
|
final int year;
|
||||||
|
int expandedItemIndex = -1;
|
||||||
|
|
||||||
|
LakumPointMonthPage(this.pointsAmountPerMonth, this.year);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_LakumPointsMonthPageState createState() => _LakumPointsMonthPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LakumPointsMonthPageState extends State<LakumPointMonthPage> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final mediaQuery = MediaQuery.of(context);
|
||||||
|
|
||||||
|
return BaseView<LacumViewModel>(
|
||||||
|
builder: (_, model, wi) => AppScaffold(
|
||||||
|
title: "Lakum points",
|
||||||
|
isShowAppBar: true,
|
||||||
|
isShowDecPage: false,
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
baseViewModel: model,
|
||||||
|
body: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
height: mediaQuery.size.height * 0.25,
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Image.asset(
|
||||||
|
"assets/images/pharmacy_module/lakum/lakum_card_front_bg.png",
|
||||||
|
fit: BoxFit.fill,
|
||||||
|
width: mediaQuery.size.width * 1.0,
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
height: mediaQuery.size.height * 0.06,
|
||||||
|
margin: EdgeInsets.symmetric(
|
||||||
|
vertical: 16, horizontal: 24),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Texts(
|
||||||
|
TranslationBase.of(context).month,
|
||||||
|
color: Colors.grey.shade600,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
Texts(
|
||||||
|
"${widget.pointsAmountPerMonth.month}, ${widget.year}",
|
||||||
|
color: Colors.grey.shade700,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceEvenly,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.end,
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Texts(
|
||||||
|
TranslationBase.of(context).point,
|
||||||
|
color: Colors.grey.shade600,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
Texts(
|
||||||
|
"${widget.pointsAmountPerMonth.pointsPerMonth}",
|
||||||
|
color: Colors.grey.shade700,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
child: Container(
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.end,
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Texts(
|
||||||
|
TranslationBase.of(context).riyal,
|
||||||
|
color: Colors.grey.shade600,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
Texts(
|
||||||
|
"${widget.pointsAmountPerMonth.amountPerMonth}",
|
||||||
|
color: Colors.grey.shade700,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
LakumPointTableRowWidget(true, "DAY", 0, 0, null, 0),
|
||||||
|
...List.generate(
|
||||||
|
widget.pointsAmountPerMonth.pointsAmountPerday.length,
|
||||||
|
(index) => LakumPointTableRowWidget(
|
||||||
|
false,
|
||||||
|
widget.pointsAmountPerMonth.pointsAmountPerday[index].day,
|
||||||
|
widget.pointsAmountPerMonth.pointsAmountPerday[index]
|
||||||
|
.pointsPerDay,
|
||||||
|
widget.pointsAmountPerMonth.pointsAmountPerday[index]
|
||||||
|
.amountPerDay,
|
||||||
|
() {
|
||||||
|
setState(() {
|
||||||
|
if (widget.expandedItemIndex == index) {
|
||||||
|
widget.expandedItemIndex = -1;
|
||||||
|
} else {
|
||||||
|
widget.expandedItemIndex = index;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
index,
|
||||||
|
expandFlag: widget.expandedItemIndex == index,
|
||||||
|
collapsed: Column(
|
||||||
|
children: [
|
||||||
|
...List.generate(
|
||||||
|
widget.pointsAmountPerMonth.pointsAmountPerday[index]
|
||||||
|
.pointsDetails.length,
|
||||||
|
(index) => DayPointsDetailWidget(
|
||||||
|
widget
|
||||||
|
.pointsAmountPerMonth
|
||||||
|
.pointsAmountPerday[index]
|
||||||
|
.pointsDetails[index]
|
||||||
|
.subTransactionTypeDescription,
|
||||||
|
widget
|
||||||
|
.pointsAmountPerMonth
|
||||||
|
.pointsAmountPerday[index]
|
||||||
|
.pointsDetails[index].purchasePoints,
|
||||||
|
widget
|
||||||
|
.pointsAmountPerMonth
|
||||||
|
.pointsAmountPerday[index]
|
||||||
|
.pointsDetails[index].amount),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DayPointsDetailWidget extends StatelessWidget {
|
||||||
|
final String rowTitle;
|
||||||
|
final double points;
|
||||||
|
final double riyal;
|
||||||
|
|
||||||
|
DayPointsDetailWidget(this.rowTitle, this.points, this.riyal);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
color: Color(0xffe4e4e4),
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 0, horizontal: 12),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Texts(
|
||||||
|
"TYPE",
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 4,
|
||||||
|
),
|
||||||
|
Texts(
|
||||||
|
rowTitle,
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.normal,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
child: Texts(
|
||||||
|
"$points",
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.normal,
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
child: Texts(
|
||||||
|
"$riyal",
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.normal,
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
Expanded(child: Container()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Divider(
|
||||||
|
color: Color(0xFFD6D6D6),
|
||||||
|
height: 1,
|
||||||
|
thickness: 1,
|
||||||
|
indent: 0,
|
||||||
|
endIndent: 0,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,77 @@
|
|||||||
|
import 'package:expandable/expandable.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class PointsExpandableNotifier extends StatefulWidget {
|
||||||
|
final Widget headerWidget;
|
||||||
|
final Widget bodyWidget;
|
||||||
|
final Widget collapsed;
|
||||||
|
final bool isExpand;
|
||||||
|
bool expandFlag = false;
|
||||||
|
var controller = new ExpandableController();
|
||||||
|
|
||||||
|
PointsExpandableNotifier(
|
||||||
|
{this.headerWidget, this.bodyWidget, this.collapsed, this.isExpand});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_PointsExpandableNotifierState createState() =>
|
||||||
|
_PointsExpandableNotifierState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PointsExpandableNotifierState extends State<PointsExpandableNotifier> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
setState(() {
|
||||||
|
if (widget.isExpand == true) {
|
||||||
|
widget.expandFlag = widget.isExpand;
|
||||||
|
widget.controller.expanded = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return ExpandableNotifier(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 0, right: 0),
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
SizedBox(
|
||||||
|
child: widget.headerWidget,
|
||||||
|
),
|
||||||
|
ScrollOnExpand(
|
||||||
|
scrollOnExpand: true,
|
||||||
|
scrollOnCollapse: false,
|
||||||
|
child: ExpandablePanel(
|
||||||
|
theme: const ExpandableThemeData(
|
||||||
|
headerAlignment: ExpandablePanelHeaderAlignment.center,
|
||||||
|
tapBodyToCollapse: true,
|
||||||
|
),
|
||||||
|
// header: widget.headerWidget,
|
||||||
|
/*
|
||||||
|
// setState(() {
|
||||||
|
// widget.expandFlag = !widget.expandFlag;
|
||||||
|
// if (widget.expandFlag == true) {
|
||||||
|
// widget.controller.expanded = true;
|
||||||
|
// } else {
|
||||||
|
// widget.controller.expanded = false;
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
*/
|
||||||
|
collapsed: Container(),
|
||||||
|
expanded: widget.bodyWidget,
|
||||||
|
builder: (_, collapsed, expanded) {
|
||||||
|
return Padding(
|
||||||
|
padding: EdgeInsets.only(left: 0, right: 0, bottom: 0),
|
||||||
|
child: Expandable(
|
||||||
|
controller: widget.controller,
|
||||||
|
collapsed: collapsed,
|
||||||
|
expanded: expanded,
|
||||||
|
theme: const ExpandableThemeData(crossFadePoint: 0),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue