import 'dart:convert';

import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/ErService/rapid-response-team/rrt-main-screen.dart';
import 'package:diplomaticquarterapp/uitl/location_util.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/pages/ErService/widgets/card_common.dart';

import 'AmbulanceReq.dart';
import 'EdOnline/DdServicesPage.dart';
import 'EdOnline/EdOnlineSelectedHospitalPage.dart';
import 'NearestEr.dart';

class ErOptions extends StatefulWidget {
  final bool isAppbar;

  const ErOptions({Key key, this.isAppbar}) : super(key: key);


  @override
  _ErOptionsState createState() => _ErOptionsState();
}

class _ErOptionsState extends State<ErOptions> {
  LocationUtils locationUtils;
  ProjectViewModel projectViewModel;

  @override
  void initState() {
    locationUtils =
    new LocationUtils(isShowConfirmDialog: true, context: context);
    WidgetsBinding.instance
        .addPostFrameCallback((_) => locationUtils.getCurrentLocation());

    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    projectViewModel = Provider.of<ProjectViewModel>(context);
    final rrtLocked = !projectViewModel.havePrivilege(68);

    return AppScaffold(
      isShowAppBar: widget.isAppbar,
      appBarTitle: TranslationBase.of(context).bookAppo,
      isShowDecPage: false,
      body: Container(
        margin: EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 10.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[

            Container(
              height: 170,
              margin: EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 10.0),
              child: Row(
                mainAxisSize: MainAxisSize.max,
                mainAxisAlignment: MainAxisAlignment.start,
                children: <Widget>[
                  Expanded(
                    child: CardCommonEr(
                      image: 'assets/images/new-design/AM.PNG',
                      text: TranslationBase.of(context).ambulancerequest,
                      subText: TranslationBase.of(context).requestA,
                      onTap: (){
                        Navigator.push(
                            context,
                            FadePage(
                                page: AmbulanceReq()));
                      },

                    ),
                  ),
                  Expanded(
                    child: CardCommonEr(
                        image: 'assets/images/new-design/emergency_icon.png',
                        text: TranslationBase.of(context).nearester,
                        subText: TranslationBase.of(context).locationa,
                        onTap:(){
                          Navigator.push(
                              context,
                              FadePage(
                                  page: NearestEr()));
                        }),

                  )
                ],
              ),
            ),
            Container(
              margin: EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 10.0),
              height: 170,
              child: Row(
                mainAxisSize: MainAxisSize.max,
                mainAxisAlignment: MainAxisAlignment.start,
                children: <Widget>[
                  Expanded(
                    child: CardCommonEr(
                      image: 'assets/images/new-design/AM.PNG',
                      text:'ED service',
                      subText: 'ED service',
                      onTap: (){
                        Navigator.push(
                            context,
                            FadePage(page: DdServicesPage())
                        );
                      },

                    ),
                  ),
                  Expanded(
                    child: CardCommonEr(
                        locked: rrtLocked,
                        image: 'assets/images/new-design/AM.PNG',
                        text: TranslationBase.of(context).rrtService,
                        subText: TranslationBase.of(context).rapidResponseTeam,
                        onTap:(){
                          Navigator.push(
                              context,
                              FadePage(
                                  page: RRTMainScreen()));
                        }),
                  )
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}

