import 'package:diplomaticquarterapp/core/viewModels/contactus/livechat_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; class HospitalsLiveChatPage extends StatefulWidget { @override _HospitalsLiveChatPageState createState() => _HospitalsLiveChatPageState(); } class _HospitalsLiveChatPageState extends State { int? tappedIndex; String? chat; @override void initState() { super.initState(); tappedIndex = -1; chat = ""; } @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getLiveChatRequestOrders(), builder: (_, model, widget) => AppScaffold( baseViewModel: model, isShowDecPage: false, body: Column( children: [ Expanded( child: SingleChildScrollView( physics: BouncingScrollPhysics(), padding: EdgeInsets.only(top: 16, bottom: 16, right: 21, left: 21), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ Text( TranslationBase.of(context).instructions, style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 23 / 16), ), SizedBox(height: 20), Text( TranslationBase.of(context).selectHospitalDec + " :", style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 23 / 16), ), SizedBox(height: 20), ListView.separated( shrinkWrap: true, physics: NeverScrollableScrollPhysics(), separatorBuilder: (context, index) => SizedBox(height: 14), itemCount: model.LiveChatModelList.length, itemBuilder: (context, index) => InkWell( onTap: () { setState(() { tappedIndex = index; chat = "http://chat.dshmg.com:7788/hmgchatapp/hmgchattest/Index.aspx?Name=${model.user!.firstName}&PatientID=${model.user!.patientID}&MobileNo=${model.user!.mobileNumber}&Language=${projectViewModel.currentLanguage}&WorkGroup=${model.LiveChatModelList[index].value}"; }); }, child: Container( padding: EdgeInsets.only(right: 12, left: 18, top: 16, bottom: 16), decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(10.0), ), boxShadow: [ BoxShadow( color: Color(0xff000000).withOpacity(.05), blurRadius: 27, offset: Offset(0, -3), ), ], color: tappedIndex == index ? Color(0xff28323A).withOpacity(.7) : Colors.white), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded( child: Text( model.LiveChatModelList[index].projectName.toString() + "\n" + model.LiveChatModelList[index].distanceInKilometers.toString() + " " + TranslationBase.of(context).km_ ?? "", style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: tappedIndex == index ? Colors.white : Color(0xff2B353E), letterSpacing: -0.64, height: 23 / 16), ), ), Icon( Icons.arrow_forward, color: tappedIndex == index ? Colors.white : Colors.black, ), ], ), ), ), ), ], ), ), ), Container( color: Colors.white, padding: EdgeInsets.only(top: 16, bottom: 16, right: 21, left: 21), child: DefaultButton( TranslationBase.of(context).start, //Changed By Aamir URL chat!.isEmpty ? null : () => {launch(chat!)}, color: Color(0xffD02127), textColor: chat!.isEmpty ? Color(0xff000000) : Colors.white, disabledColor: Color(0xffEAEAEA), ), ), ], ), ), ); } }