import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart';
import 'package:diplomaticquarterapp/pages/ToDoList/ToDo.dart';
import 'package:diplomaticquarterapp/pages/medical/balance/advance_payment_page.dart';
import 'package:diplomaticquarterapp/pages/medical/balance/my_balance_page.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.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/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart';

class PaymentService extends StatelessWidget {
  ToDoCountProviderModel model;
  ProjectViewModel projectViewModel;

  @override
  Widget build(BuildContext context) {
    projectViewModel = Provider.of(context);
    model = Provider.of<ToDoCountProviderModel>(context);
    return AppScaffold(
      isShowAppBar: true,
      isShowDecPage: false,
      appBarTitle: TranslationBase.of(context).paymentService,
      body: SingleChildScrollView(
        child: Container(
          margin: EdgeInsets.all(12),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Row(
                children: [
                  Expanded(
                    child: InkWell(
                      onTap: () => Navigator.push(
                          context, FadePage(page: AdvancePaymentPage())),
                      child: Container(
                        margin: EdgeInsets.all(5.0),
                        padding: EdgeInsets.all(9),
                        decoration: BoxDecoration(
                            color: Colors.white,
                            borderRadius: BorderRadius.circular(8.0),
                            shape: BoxShape.rectangle),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Texts(
                              TranslationBase.of(context).payment,
                              color: HexColor('#B61422'),
                              bold: true,
                            ),
                            Texts(
                              TranslationBase.of(context).paymentOnline,
                              fontSize: 14,
                              fontWeight: FontWeight.normal,
                            ),
                            SizedBox(
                              height: 12,
                            ),
                            Container(
                              margin: EdgeInsets.only(left: 10, right: 10),
                              child: Image.asset(
                                'assets/images/online_payment_icon.png',
                                fit: BoxFit.fill,
                                height: 55,
                                width: double.infinity,
                              ),
                            ),
                          ],
                        ),
                      ),
                    ),
                  ),
                  //if(!projectViewModel.havePrivilege(33))
                  Expanded(
                    child: InkWell(
                      onTap: () => navigateToToDoPage(context),
                      child: Container(
                        margin: EdgeInsets.all(5.0),
                        padding: EdgeInsets.all(9),
                        decoration: BoxDecoration(
                            color: Colors.white,
                            borderRadius: BorderRadius.circular(8.0),
                            shape: BoxShape.rectangle),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Texts(
                              TranslationBase.of(context).onlineCheckIn,
                              color: HexColor('#B61422'),
                              bold: true,
                            ),
                            Texts(
                              TranslationBase.of(context).appointment,
                              fontSize: 14,
                              fontWeight: FontWeight.normal,
                            ),
                            SizedBox(
                              height: 12,
                            ),
                            Align(
                              alignment: !projectViewModel.isArabic
                                  ? Alignment.centerRight
                                  : Alignment.centerLeft,
                              child: Image.asset(
                                'assets/images/device_icon.png',
                                height: 55,
                              ),
                            ),
                          ],
                        ),
                      ),
                    ),
                  )
                ],
              ),
             //if(!projectViewModel.havePrivilege(33))
              Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Expanded(
                    child: InkWell(
                      onTap: () => Navigator.push(
                          context, FadePage(page: MyBalancePage())),
                      child: Container(
                        margin: EdgeInsets.all(5.0),
                        padding: EdgeInsets.all(9),
                        decoration: BoxDecoration(
                            color: Colors.white,
                            borderRadius: BorderRadius.circular(8.0),
                            shape: BoxShape.rectangle),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Texts(
                              TranslationBase.of(context).hmg,
                              color: HexColor('#B61422'),
                              bold: true,
                            ),
                            Texts(
                              TranslationBase.of(context).wallet,
                              fontSize: 14,
                              fontWeight: FontWeight.normal,
                            ),
                            SizedBox(
                              height: 12,
                            ),
                            Align(
                              alignment: !projectViewModel.isArabic
                                  ? Alignment.centerRight
                                  : Alignment.centerLeft,
                              child: Image.asset(
                                'assets/images/new-design/check-in.png',
                                height: 55,
                              ),
                            ),
                          ],
                        ),
                      ),
                    ),
                  ),
                  Expanded(
                    child: Container(),
                  )
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }

  navigateToToDoPage(BuildContext context) {
    if (projectViewModel.isLogin) {
      if (model.count != 0) {
        Navigator.push(context, FadePage(page: ToDo(isShowAppBar: true)));
      } else {
        AppToast.showErrorToast(
            message: TranslationBase.of(context).upcomingEmpty);
      }
    } else {
      Navigator.push(context, FadePage(page: ToDo(isShowAppBar: true)));
    }
  }
}
