public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { // Override point for customization after application launch. // If not required for your application you can safely delete this method // create a new window instance based on the screen size Window = new UIWindow(UIScreen.MainScreen.Bounds); if (String.IsNullOrEmpty(UserUtil.GetCurrentToken())) { var loginViewController = new LoginViewController(); var navigationController = new UINavigationController(loginViewController); Window.RootViewController = navigationController; } else { var tabViewController = new TabViewController(); Window.RootViewController = tabViewController; } // make the window visible Window.MakeKeyAndVisible(); return(true); }
public override void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor = UIColor.White; var signOutButton = new UIButton(UIButtonType.RoundedRect) { BackgroundColor = UIColor.Red, Font = UIFont.BoldSystemFontOfSize(Constants.NormalFontSize), }; View.AddSubview(signOutButton); signOutButton.SetTitle("Sign Out", UIControlState.Normal); signOutButton.SetTitleColor(UIColor.White, UIControlState.Normal); signOutButton.Layer.CornerRadius = Constants.CornerRadius; signOutButton.TouchUpInside += async(sender, e) => { signOutButton.Enabled = false; UserUtil.LogOutUserByTokenAsync(UserUtil.GetCurrentToken()); var loginViewController = new LoginViewController(); UIApplication.SharedApplication.Windows[0].RootViewController = new UINavigationController(loginViewController); signOutButton.Enabled = true; }; View.ConstrainLayout(() => signOutButton.Frame.Left == View.Frame.Left + Constants.HorizontalPad && signOutButton.Frame.Right == View.Frame.Right - Constants.HorizontalPad && signOutButton.Frame.GetCenterY() == View.Frame.GetCenterY() && signOutButton.Frame.Height == Constants.ControlsHeight ); }