import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/ActiveMedicationsViewModel.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/medical/active_medications/reminder_page.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.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';

class ActiveMedicationsPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return BaseView<ActiveMedicationsViewModel>(
      onModelReady: (model) => model.getActiveMedication(),
      builder: (_, model, w) => AppScaffold(
        baseViewModel: model,
        appBarTitle: TranslationBase.of(context).activeMedications,
        isShowAppBar: true,
        body: Container(
          child: ListView.builder(
            itemCount: model.activePrescriptionReport.length,
            itemBuilder: (context, index) => Container(
              padding: EdgeInsets.all(10),
              margin: EdgeInsets.all(10),
              decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(8), color: Colors.white),
              child: Row(
                children: [
                  Image.memory(
                    Utils.dataFromBase64String(model
                        .activePrescriptionReport[index].productImageBase64),
                    height: SizeConfig.imageSizeMultiplier * 19,
                    width: SizeConfig.imageSizeMultiplier * 18,
                    fit: BoxFit.cover,
                  ),
                  Expanded(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Texts(
                          model.activePrescriptionReport[index].itemDescription,
                          bold: true,
                        ),
                        SizedBox(
                          height: 5,
                        ),
                        Texts(
                            TranslationBase.of(context).expDate+' :' +
                              DateUtil.getDayMonthYearDateFormatted(model
                                  .activePrescriptionReport[index].orderDate),
                        ),
                        SizedBox(
                          height: 5,
                        ),
                        Texts(
                          TranslationBase.of(context).route+ ' :' +
                              model.activePrescriptionReport[index].route,
                        ),
                        SizedBox(
                          height: 5,
                        ),
                        Texts(
                          TranslationBase.of(context).frequency+ ' :' +
                              model.activePrescriptionReport[index].frequency,
                        ),
                        SizedBox(
                          height: 5,
                        ),
                        Texts(
                          TranslationBase.of(context).dailyQuantity + ' :${model.activePrescriptionReport[index].doseDailyQuantity}',
                        ),
                      ],
                    ),
                  ),
                  Container(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Icon(
                          Icons.notifications,
                          color: Colors.red,
                          size: 28,
                        ),
                        SizedBox(height: 25,),
                        InkWell(
                          onTap: (){
                            Navigator.push(
                              context,
                              FadePage(
                                page: ReminderPage(
                                  frequency: model.activePrescriptionReport[index]
                                      .frequencyNumber,
                                  days: model.activePrescriptionReport[index].days,
                                  itemDescription: model
                                      .activePrescriptionReport[index]
                                      .itemDescription,
                                ),
                              ),
                            );
                          },
                          child: Row(
                            children: [
                              Icon(
                                Icons.notifications_active,
                                color: Colors.red,
                                size: 28,
                              ),
                              Texts(
                                TranslationBase.of(context).addReminder,
                                color: Colors.red,
                              )
                            ],
                          ),
                        )
                      ],
                    ),
                  )
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}
