diff --git a/qController.Standard/Classes/Dialogs/AddInstancePrompt.cs b/qController.Standard/Classes/Dialogs/AddInstancePrompt.cs new file mode 100644 index 0000000..2e08604 --- /dev/null +++ b/qController.Standard/Classes/Dialogs/AddInstancePrompt.cs @@ -0,0 +1,40 @@ +using Acr.UserDialogs; +using qController.Communication; + +namespace qController.Dialogs +{ + public class AddInstancePrompt : PromptConfig + { + public AddInstancePrompt() + { + + Title = "Enter IP of QLab Computer"; + Message = "Enter an IP Address to save"; + OkText = "Next"; + OnTextChanged = args => + { + //IPAddress ugh + args.IsValid = IPHelper.IsValidAddress(args.Value); + }; + OnAction = (qAddress) => + { + if (!qAddress.Ok) + return; + + UserDialogs.Instance.Prompt(new PromptConfig + { + Title = "Enter Name", + Message = "Enter a Name for " + qAddress.Text, + OkText = "Save", + OnAction = (qName) => { + if (!qName.Ok) + return; + QStorage.AddInstance(qName.Text, qAddress.Text); + App.showToast("Manual Workspace Added!"); + } + + }); + }; + } + } +} diff --git a/qController.Standard/Classes/Dialogs/DonatePrompt.cs b/qController.Standard/Classes/Dialogs/DonatePrompt.cs new file mode 100644 index 0000000..790a37e --- /dev/null +++ b/qController.Standard/Classes/Dialogs/DonatePrompt.cs @@ -0,0 +1,22 @@ +using System; +using Acr.UserDialogs; +using Xamarin.Essentials; + +namespace qController.Dialogs +{ + public class DonatePrompt : ConfirmConfig + { + public DonatePrompt() + { + + Title = "Support the Project"; + Message = "This application will never be a paid app or contain any sort of ads, but if you choose to show your support you may do so by clicking the Donate button below. Thank you!"; + OkText = "Donate"; + OnAction = (response) => + { + if (response) + Launcher.OpenAsync(new Uri("https://linktr.ee/JoelWetzell")); + }; + } + } +} diff --git a/qController.Standard/Classes/Dialogs/NoWorkspacesConfig.cs b/qController.Standard/Classes/Dialogs/NoWorkspacesConfig.cs index 34406f7..cc21a6e 100644 --- a/qController.Standard/Classes/Dialogs/NoWorkspacesConfig.cs +++ b/qController.Standard/Classes/Dialogs/NoWorkspacesConfig.cs @@ -5,10 +5,11 @@ namespace qController.Dialogs { public class NoWorkspacesConfig : ConfirmConfig { - public NoWorkspacesConfig() + public NoWorkspacesConfig(Action action) { Message = "QLab doesn't have any workspaces open?"; OkText = "Disconnect"; + OnAction = action; } } } diff --git a/qController.Standard/Pages/ControlPage.xaml.cs b/qController.Standard/Pages/ControlPage.xaml.cs index 00b52a6..277c783 100644 --- a/qController.Standard/Pages/ControlPage.xaml.cs +++ b/qController.Standard/Pages/ControlPage.xaml.cs @@ -95,13 +95,7 @@ namespace qController } else { - NoWorkspacesConfig noWorkspacesConfig = new NoWorkspacesConfig(); - noWorkspacesConfig.OnAction = (resp) => - { - if (resp) - Back(); - }; - + NoWorkspacesConfig noWorkspacesConfig = new NoWorkspacesConfig(NoWorkspaceDetected); UserDialogs.Instance.Confirm(noWorkspacesConfig); } } @@ -237,6 +231,11 @@ namespace qController }); } + public void NoWorkspaceDetected(bool resp) + { + if (resp) + Back(); + } public void WorkspaceDisconnected(object sender, EventArgs e) { Back(); diff --git a/qController.Standard/Pages/qConnectionPage.xaml.cs b/qController.Standard/Pages/qConnectionPage.xaml.cs index 171b9ff..07c4802 100644 --- a/qController.Standard/Pages/qConnectionPage.xaml.cs +++ b/qController.Standard/Pages/qConnectionPage.xaml.cs @@ -5,7 +5,7 @@ using Zeroconf; using System.Collections.Generic; using Serilog; using qController.QItems; -using qController.Communication; +using qController.Dialogs; using qController.Cell; using Xamarin.Essentials; @@ -37,17 +37,7 @@ namespace qController } else if(args.Command == "support") { - UserDialogs.Instance.Confirm(new ConfirmConfig - { - Title = "Support the Project", - Message = "This application will never be a paid app or contain any sort of ads, but if you choose to show your support you may do so by clicking the Donate button below. Thank you!", - OkText = "Donate", - OnAction = (response) => - { - if (response) - Launcher.OpenAsync(new Uri("https://linktr.ee/JoelWetzell")); - } - }); + UserDialogs.Instance.Confirm(new DonatePrompt()); } } @@ -91,37 +81,7 @@ namespace qController } void AddWorkspace(){ - - UserDialogs.Instance.Prompt(new PromptConfig - { - Title = "Enter IP of QLab Computer", - Message = "Enter an IP Address to save", - OkText = "Next", - OnTextChanged = args => - { - //IPAddress ugh - args.IsValid = IPHelper.IsValidAddress(args.Value); - }, - OnAction = (qAddress) => - { - if (!qAddress.Ok) - return; - - UserDialogs.Instance.Prompt(new PromptConfig - { - Title="Enter Name", - Message = "Enter a Name for " + qAddress.Text, - OkText="Save", - OnAction = (qName) => { - if (!qName.Ok) - return; - QStorage.AddInstance(qName.Text,qAddress.Text); - App.showToast("Manual Workspace Added!"); - } - - }); - } - }); + UserDialogs.Instance.Prompt(new AddInstancePrompt()); } async void Scan(){