import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PointsAmountPerYear.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/lacum-viewmodel.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/lacum-setting-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/lacum-transfer-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/lakum-points-year-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/lacum-banner-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:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'lacum-activitaion-vida-page.dart'; class LakumMainPage extends StatelessWidget { @override Widget build(BuildContext context) { final mediaQuery = MediaQuery.of(context); return BaseView( onModelReady: (model) => model.getLacumData(), builder: (_, model, wi) => AppScaffold( title: "Lakum", isShowAppBar: true, isPharmacy: true, isShowDecPage: false, backgroundColor: Colors.white, baseViewModel: model, appBarIcons: _buildAppBarICons(context, model), // preferredSize: mediaQuery.size.height * 0.20, body: Container( width: double.infinity, child: SingleChildScrollView( child: (model.lacumGroupInformation != null && model.lacumGroupInformation .lakumInquiryInformationObjVersion != null) ? Column( children: [ Stack( children: [ Container( height: mediaQuery.size.height * 0.15, color: Colors.green, ), Column( children: [ SizedBox( height: mediaQuery.size.height * 0.05, ), Container( width: mediaQuery.size.width * 1, child: LakumBannerWidget( model, mediaQuery, true)), ], ) ], ), SizedBox( height: 20, ), LakumHomeButtons(mediaQuery, model), SizedBox( height: 20, ), Container( height: 100, margin: EdgeInsets.symmetric(horizontal: 16), child: ListView( scrollDirection: Axis.horizontal, children: [ LacumPointsWidget( mediaQuery, 1, TranslationBase.of(context).balance, model .lacumGroupInformation .lakumInquiryInformationObjVersion .pointsBalanceAmount, model .lacumGroupInformation .lakumInquiryInformationObjVersion .pointsBalance, null), SizedBox( width: 8, ), LacumPointsWidget( mediaQuery, 2, TranslationBase.of(context).gained, model .lacumGroupInformation .lakumInquiryInformationObjVersion .pointsBalanceAmount, model .lacumGroupInformation .lakumInquiryInformationObjVersion .gainedPoints, model .lacumGroupInformation .lakumInquiryInformationObjVersion .gainedPointsAmountPerYear), SizedBox( width: 8, ), LacumPointsWidget( mediaQuery, 3, TranslationBase.of(context).consumed, model .lacumGroupInformation .lakumInquiryInformationObjVersion .consumedPointsAmount != null ? int.parse(model .lacumGroupInformation .lakumInquiryInformationObjVersion .consumedPointsAmount) : 0, model .lacumGroupInformation .lakumInquiryInformationObjVersion .consumedPoints, model .lacumGroupInformation .lakumInquiryInformationObjVersion .consumedPointsAmountPerYear), SizedBox( width: 8, ), LacumPointsWidget( mediaQuery, 4, TranslationBase.of(context).transferred, 0, model .lacumGroupInformation .lakumInquiryInformationObjVersion .transferPoints, model .lacumGroupInformation .lakumInquiryInformationObjVersion .transferPointsAmountPerYear), ], ), ), SizedBox( height: 20, ), SizedBox( height: 8, width: double.infinity, child: Container( color: Color(0xffefefef), ), ), Container( margin: EdgeInsets.symmetric( vertical: 16, horizontal: 8), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Image.asset( "assets/images/pharmacy_module/lakum/expired_icon.png", fit: BoxFit.fill, width: 25, height: 25, ), Padding( padding: EdgeInsets.symmetric(horizontal: 8), child: Texts( "Expired", fontSize: 14, ), ) ], ), Texts( "${model.lacumGroupInformation.lakumInquiryInformationObjVersion.expiredPoints} Points", fontWeight: FontWeight.bold, fontSize: 14, ), ], ), ), SizedBox( height: 2, width: double.infinity, child: Container( color: Color(0xffefefef), ), ), Container( margin: EdgeInsets.symmetric( vertical: 16, horizontal: 8), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Image.asset( "assets/images/pharmacy_module/lakum/waiting_gained_icon.png", fit: BoxFit.fill, width: 20, height: 25, ), Padding( padding: EdgeInsets.symmetric(horizontal: 8), child: Texts( "Waiting gained", fontSize: 14, ), ) ], ), Texts( "${model.lacumGroupInformation.lakumInquiryInformationObjVersion.waitingPoints} Points", fontWeight: FontWeight.bold, fontSize: 14, ), ], ), ), SizedBox( height: 2, width: double.infinity, child: Container( color: Color(0xffefefef), ), ), Container( margin: EdgeInsets.symmetric( vertical: 16, horizontal: 8), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Image.asset( "assets/images/pharmacy_module/lakum/will_be_expired_icon.png", fit: BoxFit.fill, width: 25, height: 25, ), Padding( padding: EdgeInsets.symmetric(horizontal: 8), child: Texts( "Will Be Expired", fontSize: 14, ), ) ], ), Texts( "${model.lacumGroupInformation.lakumInquiryInformationObjVersion.pointsWillBeExpired} Points", fontWeight: FontWeight.bold, fontSize: 14, ), ], ), ), SizedBox( height: 2, width: double.infinity, child: Container( color: Color(0xffefefef), ), ), ], ) : Container(), ), ), )); } } List _buildAppBarICons(BuildContext context, LacumViewModel model) { return [ IconButton( icon: Icon(Icons.settings), color: Colors.white, onPressed: () { Navigator.push( context, FadePage( page: LakumSettingPage( model.lacumInformation, model.lacumGroupInformation))) .then((result) => {model.getLacumGroupData()}); }, ), ]; } class LakumHomeButtons extends StatelessWidget { final MediaQueryData mediaQuery; final LacumViewModel model; LakumHomeButtons(this.mediaQuery, this.model); @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.symmetric(horizontal: 16), child: Row( children: [ Expanded( child: InkWell( onTap: () { print("Account activate click"); Navigator.push( context, FadePage(page: LakumActivationVidaPage())) .then((result) => {model.getLacumGroupData()}); }, child: Container( padding: EdgeInsets.symmetric(horizontal: 8), decoration: BoxDecoration( shape: BoxShape.rectangle, borderRadius: BorderRadius.circular(8), border: Border.fromBorderSide(BorderSide( color: Color(0xffe1e1e1), width: 0.4, )), color: Color(0xffe1e1e1)), height: mediaQuery.size.height * 0.08, child: Row( children: [ Image.asset( "assets/images/pharmacy_module/lakum/Account_activation_icon.png", fit: BoxFit.fill, width: 30, height: 30, ), Expanded( child: Container( padding: EdgeInsets.symmetric(horizontal: 16), child: Texts( "Account Activation", fontSize: 14, fontWeight: FontWeight.bold, ), ), ) ], ), ), ), ), SizedBox( width: 8, ), Expanded( child: InkWell( onTap: () { print("Lacum transfer click"); Navigator.push( context, FadePage( page: LacumTransferPage(model.lacumInformation, model.lacumGroupInformation))) .then((result) => {model.getLacumGroupData()}); }, child: Container( padding: EdgeInsets.symmetric(horizontal: 8), decoration: BoxDecoration( shape: BoxShape.rectangle, borderRadius: BorderRadius.circular(8), border: Border.fromBorderSide(BorderSide( color: Color(0xffe1e1e1), width: 0.4, )), color: Color(0xffe1e1e1)), height: mediaQuery.size.height * 0.08, child: Row( children: [ Image.asset( "assets/images/pharmacy_module/lakum/Lakum_transfer_icon.png", fit: BoxFit.fill, width: 35, height: 30, ), Expanded( child: Container( padding: EdgeInsets.symmetric(horizontal: 16), child: Texts( "Lakum Transfer", fontSize: 14, fontWeight: FontWeight.bold, ), ), ) ], ), ), ), ), ], ), ); } } class LacumPointsWidget extends StatelessWidget { final MediaQueryData mediaQuery; final int pointType; // 1. balance, 2. gained, 3. consume, 4. transfer final String title; final int riyal; final int point; Color titleColor; final List pointsAmountPerYear; LacumPointsWidget(this.mediaQuery, this.pointType, this.title, this.riyal, this.point, this.pointsAmountPerYear) { if (pointType == 1) { titleColor = Color(0xffefefef); } else if (pointType == 2) { titleColor = Color(0xff004bcc); } else if (pointType == 3) { titleColor = Color(0xff339933); } else { titleColor = Color(0xffffa500); } } @override Widget build(BuildContext context) { return InkWell( onTap: () { if (pointType != 1) { if (pointsAmountPerYear != null && pointsAmountPerYear.length > 0) { Navigator.push(context, FadePage(page: LakumPointsYearPage(pointsAmountPerYear))); } else { // show snackBar No Details Points are there } } }, child: Container( width: mediaQuery.size.width / 2 - 16, padding: EdgeInsets.only(top: 12, left: 8, right: 8, bottom: 4), decoration: BoxDecoration( shape: BoxShape.rectangle, borderRadius: BorderRadius.circular(8), border: Border.fromBorderSide(BorderSide( color: Color(0xffe1e1e1), width: 0.4, )), color: pointType == 1 ? Color(0xff004bcc) : Color(0xffefefef), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( child: Texts( title, fontSize: 14, fontWeight: FontWeight.bold, color: titleColor, ), ), if (pointType != 1) Icon( Icons.arrow_forward, color: titleColor, ) ], ), ], ), ), Expanded( child: Row( children: [ if (pointType != 4) Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( "RIYAL", fontSize: 13, fontWeight: FontWeight.bold, color: pointType == 1 ? Colors.white : Colors.black, ), SizedBox( height: 4, ), Texts( "$riyal", fontSize: 13, fontWeight: FontWeight.bold, color: pointType == 1 ? Colors.white : Colors.black, ), ], ), ), if (pointType != 4) SizedBox( child: Container( color: pointType == 1 ? Colors.white : Colors.grey, ), width: 1, ), Expanded( child: Container( margin: EdgeInsets.only(left: 4), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( "POINT", fontSize: 12, fontWeight: FontWeight.bold, color: pointType == 1 ? Colors.white : Colors.black, ), SizedBox( height: 4, ), Texts( "$point", fontSize: 12, fontWeight: FontWeight.bold, color: pointType == 1 ? Colors.white : Colors.black, ), ], ), ), ), ], ), ) ], ), ), ); } }