mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-12 02:43:56 +00:00
Move Dialog classes under UI namespace
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using Acr.UserDialogs;
|
||||
using qController.Communication;
|
||||
|
||||
namespace qController.UI.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!");
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using Acr.UserDialogs;
|
||||
using Xamarin.Essentials;
|
||||
|
||||
namespace qController.UI.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"));
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using Acr.UserDialogs;
|
||||
|
||||
namespace qController.UI.Dialogs
|
||||
{
|
||||
public class NoWorkspacesConfig : ConfirmConfig
|
||||
{
|
||||
public NoWorkspacesConfig(Action<bool> action)
|
||||
{
|
||||
Message = "QLab doesn't have any workspaces open?";
|
||||
OkText = "Disconnect";
|
||||
OnAction = action;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Acr.UserDialogs;
|
||||
using qController.QItems;
|
||||
using Serilog;
|
||||
using QControlKit;
|
||||
|
||||
namespace qController.UI.Dialogs
|
||||
{
|
||||
public class WorkspacePromptArgs : EventArgs
|
||||
{
|
||||
public QOldWorkspace SelectedWorkspace
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
|
||||
public class WorkspacePrompt
|
||||
{
|
||||
public delegate void WorkspaceSelectedHandler(object source, WorkspacePromptArgs args);
|
||||
public event WorkspaceSelectedHandler WorkspaceSelected;
|
||||
|
||||
public WorkspacePrompt()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ActionSheetConfig getActionSheetConfigForWorkspaces(List<QWorkspaceInfo> workspaces)
|
||||
{
|
||||
ActionSheetConfig actionSheetConfig = new ActionSheetConfig();
|
||||
actionSheetConfig.SetTitle("Select Workspace");
|
||||
for (int i = 0; i < workspaces.Count; i++)
|
||||
{
|
||||
QWorkspaceInfo workspace = workspaces[i];
|
||||
actionSheetConfig.Add(workspace.displayName, new Action(() => {
|
||||
Log.Debug("WorkspacePrompt - Workspace Selected " + workspace.displayName);
|
||||
|
||||
|
||||
if (!workspace.hasPasscode)
|
||||
{
|
||||
OnWorkspaceSelected(new QOldWorkspace(workspace.uniqueID));
|
||||
}
|
||||
else
|
||||
{
|
||||
promptWorkspacePasscode(workspace.uniqueID);
|
||||
}
|
||||
}));
|
||||
}
|
||||
return actionSheetConfig;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void promptWorkspacePasscode(string workspace_id)
|
||||
{
|
||||
UserDialogs.Instance.Prompt(new PromptConfig
|
||||
{
|
||||
InputType = InputType.Number,
|
||||
MaxLength = 4,
|
||||
Title = "Enter Workspace Passcode",
|
||||
OkText = "Connect",
|
||||
IsCancellable = true,
|
||||
OnAction = (resp) =>
|
||||
{
|
||||
if (resp.Ok)
|
||||
{
|
||||
OnWorkspaceSelected(new QOldWorkspace(workspace_id,resp.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
OnWorkspaceSelected(null);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual void OnWorkspaceSelected(QOldWorkspace workspace)
|
||||
{
|
||||
if (WorkspaceSelected != null)
|
||||
WorkspaceSelected(this, new WorkspacePromptArgs() { SelectedWorkspace = workspace });
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user