void _onFollow(UserType userType, string userId) { if (this.isLoggedIn) { if (userType == UserType.follow) { ActionSheetUtils.showModalActionSheet( new ActionSheet( title: "确定不再关注?", items: new List <ActionSheetItem> { new ActionSheetItem("确定", type: ActionType.normal, () => this.unFollowUser?.Invoke(text: userId)), new ActionSheetItem("取消", type: ActionType.cancel) } ) ); } if (userType == UserType.unFollow) { this.followUser?.Invoke(text: userId); } } else { this.pushToLogin?.Invoke(); } }
void _pickImage() { var imageUrl = this.widget.urls[index : this.currentIndex]; var imagePath = SQLiteDBManager.instance.GetCachedFilePath(url: imageUrl); if (imagePath.isEmpty()) { return; } var items = new List <ActionSheetItem> { new ActionSheetItem( "保存图片", onTap: () => { var imageStr = CImageUtils.readImage(path: imagePath); PickImagePlugin.SaveImage(imagePath: imagePath, image: imageStr); } ), new ActionSheetItem("取消", type: ActionType.cancel) }; ActionSheetUtils.showModalActionSheet(new ActionSheet( items: items )); }
static Widget _buildButtons(List <ActionSheetItem> items) { if (items == null || items.Count <= 0) { return(new Container()); } List <Widget> widgets = new List <Widget>(); List <Widget> normalWidgets = new List <Widget>(); List <Widget> destructiveWidgets = new List <Widget>(); List <Widget> cancelWidgets = new List <Widget>(); items.ForEach(item => { Color titleColor; switch (item.type) { case ActionType.normal: titleColor = CColors.TextBody; break; case ActionType.cancel: titleColor = CColors.Cancel; break; case ActionType.destructive: titleColor = CColors.Error; break; default: titleColor = CColors.TextBody; break; } Widget widget = new GestureDetector( onTap: () => { ActionSheetUtils.hiddenModalPopup(); item.onTap?.Invoke(); }, child: new Container( alignment: Alignment.center, height: 49, color: CColors.White, child: new Text( data: item.title, style: CTextStyle.PLargeBody.copyWith(color: titleColor) ) ) ); var divider = new CustomDivider( height: 1, color: CColors.Separator2 ); if (item.type == ActionType.destructive) { destructiveWidgets.Add(item: widget); destructiveWidgets.Add(item: divider); } else if (item.type == ActionType.cancel) { cancelWidgets.Add(new CustomDivider(height: 4, color: CColors.Separator2)); cancelWidgets.Add(item: widget); } else { normalWidgets.Add(item: widget); normalWidgets.Add(item: divider); } }); widgets.AddRange(collection: normalWidgets); widgets.AddRange(collection: destructiveWidgets); widgets.AddRange(collection: cancelWidgets); return(new Column( children: widgets )); }
public static void showShareView( Widget child ) { ActionSheetUtils.showModalActionSheet(child: child); }
static Widget _buildButtons(List <ActionSheetItem> items) { if (items == null || items.Count <= 0) { return(new Container()); } List <Widget> widgets = new List <Widget>(); List <Widget> normalWidgets = new List <Widget>(); List <Widget> destructiveWidgets = new List <Widget>(); List <Widget> cancelWidgets = new List <Widget>(); items.ForEach(item => { ActionType type = item.type; Color titleColor = CColors.TextBody; if (type == ActionType.destructive) { titleColor = CColors.Error; } if (type == ActionType.cancel) { titleColor = CColors.Cancel; } Widget widget = new Column( children: new List <Widget> { new GestureDetector( onTap: () => { ActionSheetUtils.hiddenModalPopup(); if (item.onTap != null) { item.onTap(); } }, child: new Container( alignment: Alignment.center, height: 49.0f, color: CColors.White, child: new Text( item.title, style: CTextStyle.PLargeBody.copyWith(titleColor) ) ) ), new CustomDivider( height: 1, color: CColors.Separator2 ) } ); if (type == ActionType.destructive) { destructiveWidgets.Add(widget); } else if (type == ActionType.cancel) { cancelWidgets.Add(new CustomDivider(height: 4, color: CColors.Separator2)); cancelWidgets.Add(widget); } else { normalWidgets.Add(widget); } }); widgets.AddRange(normalWidgets); widgets.AddRange(destructiveWidgets); widgets.AddRange(cancelWidgets); return(new Column( children: widgets )); }
static Widget _buildButtons(List <ActionSheetItem> items) { if (items.isNullOrEmpty()) { return(new Container()); } List <Widget> widgets = new List <Widget>(); List <Widget> normalWidgets = new List <Widget>(); List <Widget> destructiveWidgets = new List <Widget>(); List <Widget> cancelWidgets = new List <Widget>(); items.ForEach(item => { Color titleColor; switch (item.type) { case ActionType.normal: titleColor = CColors.TextBody; break; case ActionType.cancel: titleColor = CColors.Cancel; break; case ActionType.destructive: titleColor = CColors.Error; break; default: titleColor = CColors.TextBody; break; } Widget widget = new GestureDetector( onTap: () => { ActionSheetUtils.hiddenModalPopup(); item.onTap?.Invoke(); }, child: new Container( alignment: Alignment.center, height: 49, padding: EdgeInsets.symmetric(horizontal: 16), color: CColors.White, child: new Text( data: item.title, style: CTextStyle.PLargeBody.copyWith(color: titleColor), maxLines: 1, overflow: TextOverflow.ellipsis ) ) ); var divider = new CustomDivider( height: 1, color: CColors.Separator2 ); if (item.type == ActionType.destructive) { destructiveWidgets.Add(item: widget); destructiveWidgets.Add(item: divider); } else if (item.type == ActionType.cancel) { cancelWidgets.Add(new CustomDivider(height: 4, color: CColors.Separator2)); cancelWidgets.Add(item: widget); } else { normalWidgets.Add(item: widget); normalWidgets.Add(item: divider); } }); widgets.AddRange(collection: normalWidgets); widgets.AddRange(collection: destructiveWidgets); widgets.AddRange(collection: cancelWidgets); if (widgets.isNotEmpty() && widgets.last() is CustomDivider) { widgets.removeLast(); } return(new Column( children: widgets )); }