import 'dart:ui';

import 'package:diplomaticquarterapp/core/viewModels/medical/reports_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/medical/reports/report_list_widget.dart';
import 'package:diplomaticquarterapp/pages/medical/reports/reports_page.dart';
import 'package:diplomaticquarterapp/widgets/buttons/button.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 HomeReportPage extends StatefulWidget {
  @override
  _HomeReportPageState createState() => _HomeReportPageState();
}

class _HomeReportPageState extends State<HomeReportPage>
    with SingleTickerProviderStateMixin {
  TabController _tabController;

  @override
  void initState() {
    super.initState();
    _tabController = TabController(length: 4, vsync: this);
  }

  @override
  void dispose() {
    super.dispose();
    _tabController.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return BaseView<ReportsViewModel>(
      onModelReady: (model) => model.getReports(), //model.getPrescriptions(),
      builder: (_, model, widget) => AppScaffold(
        isShowAppBar: true,
        appBarTitle: 'Request',
        baseViewModel: model,
        //bottomSheet: Container(),

        body: Scaffold(
          extendBodyBehindAppBar: true,
          appBar: PreferredSize(
            preferredSize: Size.fromHeight(65.0),
            child: Stack(
              children: <Widget>[
                Positioned(
                  bottom: 1,
                  left: 0,
                  right: 0,
                  child: BackdropFilter(
                    filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10),
                    child: Container(
                      color: Theme.of(context)
                          .scaffoldBackgroundColor
                          .withOpacity(0.8),
                      height: 70.0,
                    ),
                  ),
                ),
                Center(
                  child: Container(
                    height: 60.0,
                    margin: EdgeInsets.only(top: 10.0),
                    width: MediaQuery.of(context).size.width * 0.9,
                    decoration: BoxDecoration(
                        border: Border(
                          bottom: BorderSide(
                              color: Theme.of(context).dividerColor,
                              width: 0.7),
                        ),
                        color: Colors.white),
                    child: Center(
                      child: TabBar(
                        isScrollable: true,
                        controller: _tabController,
                        indicatorWeight: 5.0,
                        indicatorSize: TabBarIndicatorSize.label,
                        indicatorColor: Colors.red[800],
                        labelColor: Theme.of(context).primaryColor,
                        unselectedLabelColor: Colors.grey[800],
                        tabs: [
                          Container(
                            width: MediaQuery.of(context).size.width * 0.22,
                            child: Center(
                              child: Texts('Requested'),
                            ),
                          ),
                          Container(
                            width: MediaQuery.of(context).size.width * 0.22,
                            child: Center(
                              child: Texts('Ready'),
                            ),
                          ),
                          Container(
                            width: MediaQuery.of(context).size.width * 0.22,
                            child: Center(
                              child: Texts('Completed'),
                            ),
                          ),
                          Container(
                            width: MediaQuery.of(context).size.width * 0.22,
                            child: Center(
                              child: Texts('Cancelled'),
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
          body: Column(
            children: <Widget>[
              Expanded(
                child: TabBarView(
                  physics: BouncingScrollPhysics(),
                  controller: _tabController,
                  children: <Widget>[
                    ReportListWidget(
                      reportList: model.reportsOrderRequestList,
                    ),
                    ReportListWidget(
                      reportList: model.reportsOrderReadyList,
                    ),
                    ReportListWidget(
                      reportList: model.reportsOrderCompletedList,
                    ),
                    ReportListWidget(
                      reportList: model.reportsOrderCanceledList,
                    ),
                  ],
                ),
              ),
              SizedBox(height: 110,)
            ],
          ),
          bottomSheet: Container(
            width: double.infinity,
            height: 90,
            margin: EdgeInsets.all(8.0),
            child: Button(
              label: 'Resend order & deliver',
              backgroundColor: Colors.grey[800],
              onTap: () => Navigator.push(
                context,
                FadePage(
                  page: MedicalReports(),
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}
