You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.8 KiB

1 year ago
  1. using GMCabsDriverAssistant.Services;
  2. using GMCabsDriverAssistant.UserControl.ViewModels;
  3. using GMCabsDriverAssistant.ViewModels;
  4. using GMCabsDriverAssistantSolution.Views;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Linq;
  9. using System.Runtime.CompilerServices;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. //using Xamarin.CommunityToolkit.Extensions;
  13. using Microsoft.Maui;
  14. using Microsoft.Maui.Controls;
  15. namespace GMCabsDriverAssistant.UserControl
  16. {
  17. [XamlCompilation(XamlCompilationOptions.Compile)]
  18. public partial class TripInformationPage : ContentView
  19. {
  20. [Browsable(true)]
  21. [Category("Action")]
  22. [Description("Invoked when user clicks button")]
  23. public event BluetoothStatusChanged BluetoothStatusUpdated;
  24. public string BluetoothConnectionStatusText
  25. {
  26. get => _viewModel.BluetoothConnectionStatusText;
  27. }
  28. private readonly TripInformationViewModel _viewModel;
  29. public TripInformationPage()
  30. {
  31. InitializeComponent();
  32. BindingContext = _viewModel = new TripInformationViewModel();
  33. _viewModel.BluetoothStatusChanged += _viewModel_BluetoothStatusChanged;
  34. }
  35. private void _viewModel_BluetoothStatusChanged()
  36. {
  37. BluetoothStatusUpdated?.Invoke();
  38. }
  39. void OnDuressPressed(object sender, EventArgs args)
  40. {
  41. _viewModel.StartDriverDuress();
  42. }
  43. void OnDuressReleased(object sender, EventArgs args)
  44. {
  45. _viewModel.EndDriverDuress();
  46. }
  47. private void BtnPlot_Clicked(object sender, EventArgs e)
  48. {
  49. //Navigation.PushAsync(new AvailablePlotTabletPage());
  50. }
  51. private void OnMapIconTapped(object sender, EventArgs e)
  52. {
  53. var location = new Location(33.8688, 151.2093); // Replace with desired coordinates
  54. var options = new MapLaunchOptions { Name = "Sydney" }; // Replace with desired location name
  55. Map.OpenAsync(location, options);
  56. }
  57. private async void OnWazeIconTapped(object sender, EventArgs e)
  58. {
  59. // if App Url doesnt work use Browser Url => "https://waze.com/ul?q=" + latLng.latitude + "," + latLng.longitude + "&navigate=yes&zoom=17";
  60. //string latitude = "33.8688";
  61. //string longitude = "151.2093";
  62. string wazeUri = "waze://";
  63. try
  64. {
  65. // Launch Waze app
  66. await Launcher.OpenAsync(wazeUri);
  67. }
  68. catch (Exception ex)
  69. {
  70. string errorMessage = "Waze is not installed in your device, Please install the app first";
  71. //Navigation.ShowPopup(new ErrorPopup(errorMessage));
  72. }
  73. }
  74. }
  75. }