import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart';
import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_history_details_page.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.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 PrescriptionsHistoryPage extends StatelessWidget {
  final PrescriptionsViewModel prescriptionsViewModel;

  PrescriptionsHistoryPage({Key key, this.prescriptionsViewModel});

  @override
  Widget build(BuildContext context) {
    return AppScaffold(
      baseViewModel: prescriptionsViewModel,
      body: ListView.builder(
        physics: BouncingScrollPhysics(),
        itemBuilder: (context, index) => InkWell(
          onTap: () => Navigator.push(
            context,
            FadePage(
              page: PrescriptionsHistoryDetailsPage(
                prescriptionsOrder:
                    prescriptionsViewModel.prescriptionsHistory[index],
              ),
            ),
          ),
          child: Container(
            padding: EdgeInsets.all(15.0),
            margin: EdgeInsets.all(8.0),
            decoration:
                BoxDecoration(shape: BoxShape.rectangle, color: Colors.white),
            child: Row(
              children: <Widget>[
                Expanded(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Texts(
                        DateUtil.getDayMonthYearHourMinuteDateFormatted(
                            prescriptionsViewModel
                                .prescriptionsHistory[index].createdOn),
                        fontWeight: FontWeight.w300,
                      ),
                      SizedBox(
                        height: 5,
                      ),
                      Texts(
                          'Order No ${prescriptionsViewModel.prescriptionsHistory[index].iD}'),
                      SizedBox(
                        height: 5,
                      ),
                      Texts(
                          '${prescriptionsViewModel.prescriptionsHistory[index].descriptionN}'),
                      SizedBox(
                        height: 5,
                      ),
                      Texts(
                        'Order Details',
                        fontWeight: FontWeight.w300,
                      ),
                      SizedBox(
                        height: 5,
                      ),
                    ],
                  ),
                ),
                Icon(
                  Icons.arrow_forward_ios,
                  size: 25,
                )
              ],
            ),
          ),
        ),
        itemCount: prescriptionsViewModel.prescriptionsHistory.length,
      ),
    );
  }
}
