1.Nuget引用AcrUserdialogs
其中版本兼容性注意事项,
2.最终集中控件的使用代码如下
1 public partial class MainPage : ContentPage 2 { 3 public MainPage() 4 { 5 InitializeComponent(); 6 7 } 8 //返回值 9 Action<LoginResult> OkAction = (LoginResult) => 10 { 11 if (LoginResult.Ok==false) 12 { 13 UserDialogs.Instance.Alert("退出", null, "确认"); //直接参数调用 14 } 15 else 16 { 17 if (LoginResult.LoginText=="1" && LoginResult.Password=="1") 18 { 19 UserDialogs.Instance.Alert("登陆成功", null, "确认"); 20 21 } 22 else 23 { 24 UserDialogs.Instance.Alert("登陆失败", null, "确认"); 25 } 26 } 27 }; 28 29 Action CancleAction = () => 30 { 31 UserDialogs.Instance.Alert("退出", null, "确认"); 32 }; 33 34 Action Action1 = () => 35 { 36 UserDialogs.Instance.Alert("CESHI", null, "确认"); 37 }; 38 39 private async void Button_Clicked(object sender, EventArgs e) 40 { 41 using (IProgressDialog progress = UserDialogs.Instance.Progress("Progress", null, null, true, MaskType.Black)) 42 { 43 for (int i = 0; i < 100; i++) 44 { 45 progress.PercentComplete = i; 46 await Task.Delay(60); 47 } 48 } 49 50 51 LoginConfig loginConfig = new LoginConfig(); 52 loginConfig.Message = "登陆操作"; 53 loginConfig.CancelText = "退出"; 54 loginConfig.OkText = "确认"; 55 loginConfig.Title = "提示"; 56 loginConfig.LoginPlaceholder = "123"; 57 loginConfig.PasswordPlaceholder = "2343"; 58 loginConfig.SetAction(OkAction); 59 UserDialogs.Instance.Login(loginConfig); 60
//actionsheet的使用 61 ActionSheetConfig actionSheetConfig = new ActionSheetConfig(); 62 actionSheetConfig.Add("测试1",Action1); 63 actionSheetConfig.Add("测试1",Action1); 64 actionSheetConfig.Add("测试1", Action1); 65 actionSheetConfig.Add("测试1", Action1); 66 actionSheetConfig.SetCancel("取消", CancleAction); 67 UserDialogs.Instance.ActionSheet(actionSheetConfig); 68 ////// 69 PromptConfig promptConfig = new PromptConfig(); 70 71 72 } 73 78 }