Add managed UIKit iOS client
.NET port / test (macos-latest) (push) Canceled after 0s
.NET port / test (ubuntu-24.04) (push) Canceled after 0s
.NET port / test (windows-latest) (push) Canceled after 0s
.NET port / apple-client (push) Canceled after 0s
.NET port / cpp-conformance (push) Canceled after 0s
.NET port / test (macos-latest) (push) Canceled after 0s
.NET port / test (ubuntu-24.04) (push) Canceled after 0s
.NET port / test (windows-latest) (push) Canceled after 0s
.NET port / apple-client (push) Canceled after 0s
.NET port / cpp-conformance (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using VoiceCat.Core;
|
||||
using UIKit;
|
||||
|
||||
namespace VoiceCat.iOS;
|
||||
|
||||
internal sealed class RootViewController : UIViewController
|
||||
{
|
||||
private readonly AppModel model;
|
||||
private UIViewController? current;
|
||||
internal RootViewController(AppModel model) { this.model = model; model.Changed += Refresh; model.IdentityRequested += ShowIdentity; }
|
||||
public override void ViewDidLoad() { base.ViewDidLoad(); View!.BackgroundColor = UIColor.SystemBackground; Refresh(); }
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
bool main = model.IsConnected;
|
||||
if (current is MainTabController && main || current is UINavigationController && !main) return;
|
||||
UIViewController next = main ? new MainTabController(model) : new UINavigationController(new ServerListController(model));
|
||||
if (current is not null) { current.WillMoveToParentViewController(null); current.View.RemoveFromSuperview(); current.RemoveFromParentViewController(); }
|
||||
AddChildViewController(next); next.View.Frame = View!.Bounds; next.View.AutoresizingMask = UIViewAutoresizing.All; View.AddSubview(next.View); next.DidMoveToParentViewController(this); current = next;
|
||||
}
|
||||
|
||||
private void ShowIdentity(ServerIdentityChallenge challenge)
|
||||
{
|
||||
UIAlertController alert = UIAlertController.Create(challenge.Status == VoiceCat.Crypto.TofuStatus.Mismatch ? "Server Identity Changed" : "New Server Identity",
|
||||
$"{challenge.Host}:{challenge.Port}\n\nSHA-256\n{challenge.CertificateFingerprint}", UIAlertControllerStyle.Alert);
|
||||
alert.AddAction(UIAlertAction.Create("Reject", UIAlertActionStyle.Destructive, _ => model.ResolveIdentity(false)));
|
||||
alert.AddAction(UIAlertAction.Create("Trust", UIAlertActionStyle.Default, _ => model.ResolveIdentity(true)));
|
||||
PresentViewController(alert, true, null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user