private SingleClick OnFakeGateway() => new SingleClick((o, args) => { RunOnUiThread(() => { EditText input = new EditText(this); InputFilterLengthFilter inputFilterLengthFilter = new InputFilterLengthFilter(2); input.SetFilters(new IInputFilter[] { inputFilterLengthFilter }); input.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); new AlertDialog.Builder(this) .SetMessage("Enter region code (2 chars country code)") .SetTitle("Fake Gateway") .SetView(input) .SetPositiveButton("OK", async(sender, eventArgs) => { ApiResponse response = await _viewModel.FakeGateway(input.Text); if (response != null) { UpdateText($"Pushed keys to region: {input.Text}\n" + $"isSuccessful: {response.IsSuccessfull}\n" + $"StatusCode: {response.StatusCode}\n" + $"Error Message: {response.ErrorLogMessage}\n\n"); } else { UpdateText($"Pushing of keys failed with unknown error"); } }) .SetNegativeButton("Cancel", (sender, eventArgs) => { /* ignore */ }) .Show(); }); });
void ShowModalAlertView(string title, string message) { UIAlertController alert = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert); string region = "no"; alert.AddTextField(textField => { region = textField.Text; }); alert.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, obj => { })); alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, async obj => { ApiResponse response = await _enDeveloperViewModel.FakeGateway(alert.TextFields[0].Text); ENDevOutput.Text = $"Pushed keys to region: {alert.TextFields[0].Text}\n" + $"isSuccessful: {response.IsSuccessfull}\n" + $"StatusCode: {response.StatusCode}\n" + $"Error Message: {response.ErrorLogMessage}\n\n"; })); PresentViewController(alert, true, null); }