import 'package:diplomaticquarterapp/core/model/prescriptions/prescriptions_order.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/widgets/buttons/BottomButton.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 PrescriptionsHistoryDetailsPage extends StatelessWidget {
  final PrescriptionsOrder prescriptionsOrder;

  PrescriptionsHistoryDetailsPage({Key key,this.prescriptionsOrder});

  @override
  Widget build(BuildContext context) {
    return BaseView<PrescriptionsViewModel>(
      onModelReady: (model) => model.getPrescriptionReportEnh(prescriptionsOrder: prescriptionsOrder),
      builder: (_,model,widget) => AppScaffold(
        isShowAppBar: true,
        appBarTitle: 'Order History',
        baseViewModel: model,
        body: SingleChildScrollView(
          physics: BouncingScrollPhysics(),
          child: Container(
            margin: EdgeInsets.all(15.0),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Table(
                  border: TableBorder.symmetric(
                      inside: BorderSide(width: 0.5),
                      outside: BorderSide(width: 0.5)),
                  children: [
                    TableRow(
                        children: [
                          Container(
                            height: 50,
                            color: Colors.white,
                            child: Center(child: Texts('Order No'),),
                          ),
                          Container(
                            height: 50,
                            color: Colors.white,
                            child: Center(child: Texts('Date'),),
                          ),
                        ]
                    ),
                    TableRow(
                        children: [
                          Container(
                            height: 50,
                            color: Colors.white,
                            child: Center(child: Texts('12655'),),
                          ),
                          Container(
                            height: 50,
                            color: Colors.white,
                            child: Center(child: Texts('2020-7-15'),),
                          ),
                        ]
                    )
                  ],
                ),
                SizedBox(height: 15,),
                ...List.generate(model.prescriptionReportEnhList.length, (index) => Container(
                  margin: EdgeInsets.all(8.0),
                  color: Colors.white,
                  child: Row(
                    children: <Widget>[
                      ClipRRect(
                        borderRadius: BorderRadius.all(Radius.circular(5)),
                        child: Image.network(
                          model.prescriptionReportEnhList[index].imageSRCUrl,
                          fit: BoxFit.cover,
                          width: 60,
                          height: 70,
                        ),
                      ),
                      Expanded(
                        child: Padding(
                          padding: const EdgeInsets.all(8.0),
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: <Widget>[
                              Texts(model.prescriptionReportEnhList[index]
                                  .itemDescription),
                            ],
                          ),
                        ),
                      ),

                    ],
                  ),
                ))
              ],
            ),
          ),
        ),
        bottomSheet: Container(
          //padding: EdgeInsets.all(8.0),
         // margin: EdgeInsets.all(8.0),
          child: BottomButton(label: 'Cancel order',color: Colors.red[300],),
        ),
      ),
    );
  }
}
