Esempio n. 1
0
        public PermissionTestPage()
        {
            InitializeComponent();
            AutomationId = pageName;
            Title        = "Convenient Cares";
            NavigationPage.SetBackButtonTitle(this, "");

            BindingContext = viewModel = new ConvenientCaresViewModel(this);

            ConvenientCareListView.ItemSelected += (sender, e) =>
            {
                if (ConvenientCareListView.SelectedItem == null)
                {
                    return;
                }

                ConvenientCare cCare = ConvenientCareListView.SelectedItem as ConvenientCare;
                if (cCare != null && !string.IsNullOrWhiteSpace(cCare.Address))
                {
                    MapHelper.NavigateToLocation(cCare.Address);
                }

                ConvenientCareListView.SelectedItem = null;
            };

            AddressSearchBar.TextChanged += async(sender, e) =>
            {
                if (string.IsNullOrWhiteSpace(e.NewTextValue))
                {
                    AddressSearchBar.Unfocus();

                    if (await PermissionsHelper.LocationPermissionGranted(this))
                    {
                        await CalculateCurrentLocation();
                    }
                    viewModel.CalculateDistance();
                }
            };

            AddressSearchBar.SearchButtonPressed += async(sender, e) =>
            {
                SearchBar searchBar = (SearchBar)sender;
                if (searchBar == null)
                {
                    return;
                }

                string address = searchBar.Text;
                if (string.IsNullOrWhiteSpace(address))
                {
                    return;
                }

                await CalculateLocationByAddress(address);
            };
        }
Esempio n. 2
0
        async void OnCallTapped(object sender)
        {
            ConvenientCare tappedLocation = sender as ConvenientCare;

            if (tappedLocation != null && !string.IsNullOrWhiteSpace(tappedLocation.PhoneNumber))
            {
                var phoneToCall = tappedLocation.PhoneNumber.SafeTrim();
                if (await page.DisplayAlert(tappedLocation.Name,
                                            String.Format(LocaleConstants.CALL_LOCATION_MESSAGE,
                                                          Regex.Replace(phoneToCall, @"(\d{3})(\d{3})(\d{4})", "($1) $2-$3")),
                                            LocaleConstants.ALERT_YES, LocaleConstants.ALERT_NO))
                {
                    var phoneCallTask = MessagingPlugin.PhoneDialer;
                    if (phoneCallTask.CanMakePhoneCall)
                    {
                        phoneCallTask.MakePhoneCall(phoneToCall);
                    }
                }
            }
        }