Ejemplo n.º 1
0
        public async Task ShowActionSheet(string title, string cancel, DialogAction confirmAction = null, params DialogAction[] actions)
        {
            var buttons       = actions.Select(a => a.ButtonText).ToArray();
            var buttonPressed = await Application.Current.MainPage.DisplayActionSheet(title, cancel, confirmAction?.ButtonText, buttons);

            if (buttonPressed == null || buttonPressed.Equals(cancel))
            {
                return;
            }

            try
            {
                if (confirmAction != null && buttonPressed.Equals(confirmAction.ButtonText))
                {
                    confirmAction.Action.Invoke();
                }
                else
                {
                    actions?.Single(a => a.ButtonText.Equals(buttonPressed)).Action.Invoke();
                }
                m_profilerService.RaiseEvent($"User used {buttonPressed} action from action sheet");
            }
            catch (Exception exception)
            {
                await ShowAlert("Something went wrong", exception.Message, "Got it", "Cancel");

                m_profilerService.RaiseError(exception);
            }
        }
Ejemplo n.º 2
0
        public async Task NavigateTo <TViewModel>() where TViewModel : IViewModel
        {
            try
            {
                foreach (var keyValuePair in m_navigationRegister)
                {
                    var keyType    = keyValuePair.Key.GetType();
                    var interfaces = keyType.GetInterfaces();
                    if (interfaces.Contains(typeof(TViewModel)))
                    {
                        await Application.Current.MainPage.Navigation.PushAsync(keyValuePair.Value);
                    }
                }
            }
            catch (Exception exception)
            {
                await m_dialogService.ShowAlert("Something went wrong when navigating", exception.Message, "Got it!", "Cancel");

                m_profilerService.RaiseError(exception);
            }
        }