//import 'package:diplomaticquarterapp/pages/BookAppointment/Search.dart';
import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/pages/BookAppointment/Search.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:flutter/material.dart';
import 'package:giffy_dialog/giffy_dialog.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:maps_launcher/maps_launcher.dart';


import '../NearestEr.dart';

class CardPosition extends StatelessWidget {
  final image;
  final text;
  final subText;
  final type;
  final telephone;
  final networkImage;
  final  latitude;
  final longitude;
  final projectname;
  final cardSize;
  final String waitingTime;

  const CardPosition(
      {
        @required this.image,
        @required this.text,
        @required this.subText,
        @required this.type,
        @required this.telephone,
        @required this.networkImage ,
        @required this.latitude,
        @required this.longitude,
        @required this.projectname ,
        @required this.cardSize,
        @required this.waitingTime ,
      });

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        navigateToSearch(context, this.type,this.telephone,this.networkImage,this.latitude,this.longitude,this.projectname);

      },
      child: Container(
        // width:MediaQuery.of(context).size.width * 0.47,//165,
        margin: EdgeInsets.fromLTRB(8.0, 8.0, 8.0, 8.0),
        decoration: BoxDecoration(boxShadow: [
          BoxShadow(color: Colors.grey[400], blurRadius: 2.0, spreadRadius: 0.0)
        ], borderRadius: BorderRadius.circular(10), color: Colors.white),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Container(
              height: cardSize * 0.2 - 8,
              margin: EdgeInsets.fromLTRB(8.0, 8.0, 8.0, 0.0),
              child: Text(this.text,
                  overflow: TextOverflow.clip,
                  style: TextStyle(
                      color: Colors.black,
                      letterSpacing: 1.0,
                      fontSize: 2 * SizeConfig.textMultiplier)),
            ),
            Container(
              height: cardSize * 0.5 - 8,
              alignment: Alignment.center,
              margin: EdgeInsets.fromLTRB(0.0, 0.0, 8.0, 8.0),
              child: Image.asset(this.image, width: 60.0, height: cardSize * 0.4),
            ),
            Container(
              margin: EdgeInsets.fromLTRB(8.0, 0.0, 8.0, 0.0),
              height: cardSize * 0.2 - 8,
              child: Text(this.subText,
                  overflow: TextOverflow.clip,
                  style: TextStyle(
                      color: Color(0xFFc5272d), letterSpacing: 1.0, fontSize: 15.0)),
            ),

          ],
        ),
      ),
    );
  }

  Future navigateToSearch(context, type,telephone,networkImage,latitude,longitude,projectname) async {
    var localize = TranslationBase.of(context);
    showDialog(
        context: context,builder: (_) => AssetGiffyDialog(
        entryAnimation: EntryAnimation.BOTTOM,
        image:Image.network(networkImage, fit: BoxFit.cover,),
        title: Text(projectname,
          style: TextStyle(
              fontSize: 22.0, fontWeight: FontWeight.w600),
        ),
        description: Text("${localize.averageWaitingTime}\n\n$waitingTime ${localize.minute}", textAlign: TextAlign.center,),
        buttonOkText:Text("LOCATION", style: TextStyle(color: Colors.white),),
        buttonOkColor: Colors.grey,
        buttonCancelText:Text('CAll', style: TextStyle(color: Colors.white),) ,
        buttonCancelColor: Colors.grey,
        onOkButtonPressed: () {  MapsLauncher.launchCoordinates(double.parse(latitude),double.parse(longitude),projectname);},
        onCancelButtonPressed :() {launch("tel://" +telephone);}
    ));

  }

}


