private void CreateActions(List <string> actions, MaterialSimpleDialogConfiguration configuration) { if (actions == null || actions.Count <= 0) { throw new ArgumentException("Parameter actions should not be null or empty"); } var actionModels = new List <ActionModel>(); actions.ForEach(a => { var preferredConfig = configuration ?? GlobalConfiguration; var actionModel = new ActionModel { Text = a }; actionModel.TextColor = preferredConfig != null ? preferredConfig.TextColor : Color.FromHex("#DE000000"); actionModel.FontFamily = preferredConfig != null ? preferredConfig.TextFontFamily : Material.FontFamily.Body1; actionModel.SelectedCommand = new Command <int>(async(position) => { if (this.InputTaskCompletionSource?.Task.Status == TaskStatus.WaitingForActivation) { actionModel.IsSelected = true; await this.DismissAsync(); this.InputTaskCompletionSource?.SetResult(position); } }); actionModels.Add(actionModel); actionModel.Index = actionModels.IndexOf(actionModel); }); DialogActionList.SetValue(BindableLayout.ItemsSourceProperty, actionModels); }
private void CreateActions(List <string> actions, MaterialSimpleDialogConfiguration configuration) { if (actions == null || actions.Count <= 0) { throw new ArgumentException("Parameter actions should not be null or empty"); } var actionModels = new List <ActionModel>(); actions.ForEach(a => { var preferredConfig = configuration ?? GlobalConfiguration; var actionModel = new ActionModel { Text = a, TextColor = preferredConfig?.TextColor ?? Color.FromHex("#DE000000"), FontFamily = preferredConfig != null ? preferredConfig.TextFontFamily : Material.FontFamily.Body1 }; actionModel.SelectedCommand = new Command <int>(async(position) => { // Prevent any parrallel execution when clicking fast on the element await SemaphoreSlim.WaitAsync(); try { if (InputTaskCompletionSource?.Task.Status != TaskStatus.WaitingForActivation) { return; } actionModel.IsSelected = true; await DismissAsync(); InputTaskCompletionSource?.SetResult(position); } catch (Exception ex) { throw ex; } finally { SemaphoreSlim.Release(); } }); actionModels.Add(actionModel); actionModel.Index = actionModels.IndexOf(actionModel); }); DialogActionList.SetValue(BindableLayout.ItemsSourceProperty, actionModels); }
private void SetList(ICollection <ActionModel> actionModels) { DialogActionList.HeightRequest = RowHeight * actionModels.Count; DialogActionList.SetValue(BindableLayout.ItemsSourceProperty, actionModels); _itemCount = actionModels.Count; }