Esempio n. 1
0
        public async Task <string> ShowActionSheet(string title, string cancel, string destruction, CancellationToken cancellationToken, Action <string> afterHideCallback, params string[] buttons)
        {
            var result = await _userDialogs.ActionSheetAsync(title, cancel, destruction, cancellationToken, buttons);

            afterHideCallback?.Invoke(result);

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Handles the selection of a device by the user
        /// </summary>
        /// <param name="deviceViewModel">Device view model.</param>
        private async void HandleSelectedDevice()
        {
            _log.Info("Attempting to handle selected bluetooth device");
            // Check bluetooth status and if not on, exit
            if (!_bluetoothService.IsOn)
            {
                _log.Info("Bluetooth is not on");
                _userDialogs.Toast($"\tError: {_bluetoothService.StateText}");
                return;
            }

            // Device is already connected
            if (IsConnected)
            {
                _log.Info("Device is already connected. Attempting to disconnect.");
                Task.Run(async() => await TryToDisconnectDevice());
                _log.Debug("Disconnection task <TryToDisconnectDevice> has been spawned.");
                return;
            }

            // Device has not connected yet
            else
            {
                _log.Info("Connecting to device.");
                var slots   = _deviceSlotService.GetAvailableSlots();
                var buttons = new List <string>();
                if (slots.Count > 0)
                {
                    foreach (var slotIndex in slots)
                    {
                        try
                        {
                            string name = _deviceSlotService.SlotName[slotIndex];
                            buttons.Add(name);
                        }
                        catch (KeyNotFoundException)
                        {
                            _userDialogs.Alert("Invalid slot index value");
                            return;
                        }
                    }
                    var result = await _userDialogs.ActionSheetAsync("Which device?", "Cancel", null, null, buttons.ToArray());

                    if (result == "Cancel")
                    {
                        return;
                    }
                    var selected = _deviceSlotService.SlotName.IndexOf(result);
                    await Task.Run(async() => await TryToConnectDevice(selected));

                    return;
                }
                else
                {
                    _userDialogs.Alert("Please disconnect from a device before attempt to connect to another one");
                }
            }
        }
 public Task <string> ShowActionSheetAsync(
     string title,
     string cancel,
     string destructive,
     string[] buttons,
     CancellationToken cancelToken = default(CancellationToken))
 {
     return(_dialogs.ActionSheetAsync(
                title,
                cancel,
                destructive,
                cancelToken,
                buttons));
 }
        public async Task <string> DisplayAlertAsync(string title, string message, string cancel, params string[] buttons)
        {
            if (!string.IsNullOrWhiteSpace(message))
            {
                if (string.IsNullOrWhiteSpace(title))
                {
                    title = message;
                }
                else
                {
                    title = $"{title}: {message}";
                }
            }

            return(await _userDialogs.ActionSheetAsync(title, cancel, null, null, buttons.ToArray()));
        }
Esempio n. 5
0
        public IObservable <MediaFile> PickPhotoStream()
        {
            return(Observable
                   .Start(() => Observable.FromAsync <string>((_) => _userDialogs.ActionSheetAsync(
                                                                  AppResources.Profile_Select_Profile_Image,
                                                                  AppResources.Common_Cancel_Operation, null, null,
                                                                  new string[] { AppResources.Profile_Select_Profile_Image_From_Camera, AppResources.Profile_Select_Profile_Image_From_Galery })), RxApp.MainThreadScheduler)
                   .Select((action => !action.Equals(AppResources.Common_Cancel_Operation)))
                   .SelectMany((action) =>
            {
                Task <MediaFile> photoSelectedTask;
                if (action.Equals(AppResources.Profile_Select_Profile_Image_From_Camera))
                {
                    photoSelectedTask = _imagesService.TakePhotoFromFrontCamera();
                }
                else
                {
                    photoSelectedTask = _imagesService.PickPhoto();
                }


                return Observable.FromAsync <MediaFile>((_) => photoSelectedTask);
            }));
        }
Esempio n. 6
0
 public async Task <string> DisplayActionSheetAsync(string title, string cancel, string destruction, params string[] buttons)
 {
     return(await _dialogs.ActionSheetAsync(title, cancel, destruction, buttons : buttons));
 }
Esempio n. 7
0
 public async Task <string> ShowListActionsAsync(string title, string cancelButton, string destroyButton, params string[] otherButtons)
 {
     return(await userDialogs.ActionSheetAsync(title, cancelButton, destroyButton, null, otherButtons));
 }