import 'package:diplomaticquarterapp/core/model/contactus/get_hmg_locations.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:map_launcher/map_launcher.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; import 'avatar/large_avatar.dart'; import 'my_rich_text.dart'; class HospitalLocation extends StatelessWidget { final GetHMGLocationsModel location; final bool showCity; final String waitingTime; HospitalLocation(this.location, {Key key, this.showCity = false, this.waitingTime}) : super(key: key); @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); return Container( padding: const EdgeInsets.only(left: 12, right: 12, top: 12, bottom: 12), decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(10.0), ), boxShadow: [ BoxShadow( color: Color(0xff000000).withOpacity(.05), //spreadRadius: 5, blurRadius: 27, offset: Offset(0, -3), ), ], color: Colors.white), child: Row( children: [ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( location.locationName.trim(), style: TextStyle(fontSize: 16, letterSpacing: -0.64, fontWeight: FontWeight.w600, color: Color(0xff2E303A)), ), SizedBox(height: 10), Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ LargeAvatar( name: "", url: location?.projectImageURL?.toString() ?? 'https://hmgwebservices.com/Images/Hospitals/15.jpg', width: 48, height: 48, radius: 30, ), SizedBox(width: 10), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ if (showCity) MyRichText(TranslationBase.of(context).city + ":", location.cityName?.trim().toString(), projectViewModel.isArabic), MyRichText(TranslationBase.of(context).distance + ":", location.distanceInKilometers.toString() + " " + TranslationBase.of(context).km_ ?? "", projectViewModel.isArabic), if (waitingTime != null) MyRichText(TranslationBase.of(context).waitingTime, waitingTime, projectViewModel.isArabic), ], ), ) ], ), ], ), ), Column( children: [ contactButton( Icons.location_on, TranslationBase.of(context).locationa, () async { await MapLauncher.showMarker( mapType: MapType.google, coords: Coords(double.parse(location.latitude), double.parse(location.longitude)), title: location.locationName, ); }, ), SizedBox(height: 10), contactButton(Icons.call, TranslationBase.of(context).callNow, () { launch("tel://" + location.phoneNumber); }), ], ), ], ), ); } Widget contactButton(IconData _iconData, String title, VoidCallback callback) { return SizedBox( height: 32, width: 100.0, child: FlatButton.icon( color: Color(0xffF5F5F5), shape: StadiumBorder(side: BorderSide(color: Color(0xffF0F0F0), width: 1)), onPressed: callback, icon: Icon( _iconData, size: 12, color: Color(0xff2E303A), ), label: Text( title, style: TextStyle(fontSize: 12, letterSpacing: -0.48, fontWeight: FontWeight.w600, color: Color(0xff2E303A)), ), ), ); } }