public static void cancelBlockUser( bool isLoggedIn, VoidCallback pushToLogin, VoidCallback cancelBlockUserAction, VoidCallback mainRouterPop = null ) { if (!isLoggedIn) { pushToLogin(); return; } ActionSheetUtils.showModalActionSheet(new ActionSheet( title: "确定取消屏蔽该用户吗?", items: new List <ActionSheetItem> { new ActionSheetItem( "确定", type: ActionType.destructive, () => { cancelBlockUserAction(); mainRouterPop?.Invoke(); } ), new ActionSheetItem("取消", type: ActionType.cancel) } )); }
public static void block( bool isLoggedIn, string reportId, Action pushToLogin, Action <string> pushToBlock, Action mainRouterPop = null ) { if (!isLoggedIn) { pushToLogin(); return; } ActionSheetUtils.showModalActionSheet(new ActionSheet( title: "确定屏蔽当前内容吗?", items: new List <ActionSheetItem> { new ActionSheetItem( "确定", ActionType.destructive, () => { pushToBlock(reportId); if (mainRouterPop != null) { mainRouterPop(); } } ), new ActionSheetItem("取消", ActionType.cancel) } )); }
void _onFollow(UserType userType, string userId) { if (this.widget.viewModel.isLoggedIn) { if (userType == UserType.follow) { ActionSheetUtils.showModalActionSheet( new ActionSheet( title: "确定不再关注?", items: new List <ActionSheetItem> { new ActionSheetItem("确定", type: ActionType.normal, () => { this.widget.actionModel.startUnFollowUser(obj: userId); this.widget.actionModel.unFollowUser(arg: userId); }), new ActionSheetItem("取消", type: ActionType.cancel) } ) ); } if (userType == UserType.unFollow) { this.widget.actionModel.startFollowUser(obj: userId); this.widget.actionModel.followUser(arg: userId); } } else { this.widget.actionModel.pushToLogin(); } }
void _pickImage() { var items = new List <ActionSheetItem> { new ActionSheetItem( "拍照", onTap: () => PickImagePlugin.PickImage( source: ImageSource.camera, pickImage => { this._pickedImage = pickImage; this.setState(() => { }); } ) ), new ActionSheetItem( "从相册选择", onTap: () => PickImagePlugin.PickImage( source: ImageSource.gallery, pickImage => { this._pickedImage = pickImage; this.setState(() => { }); } ) ), new ActionSheetItem("取消", type: ActionType.cancel) }; ActionSheetUtils.showModalActionSheet(new ActionSheet( title: "修改头像", items: items )); }
public static void block( bool isLoggedIn, VoidCallback pushToLogin, VoidCallback pushToBlock, VoidCallback mainRouterPop = null ) { if (!isLoggedIn) { pushToLogin(); return; } ActionSheetUtils.showModalActionSheet(new ActionSheet( title: "确定屏蔽当前内容吗?", items: new List <ActionSheetItem> { new ActionSheetItem( "确定", type: ActionType.destructive, () => { pushToBlock(); if (mainRouterPop != null) { mainRouterPop(); } } ), new ActionSheetItem("取消", type: ActionType.cancel) } )); }
Widget _buildArticleTabBar() { return(new ArticleTabBar( this._article.like && this.widget.viewModel.isLoggedIn, this.widget.viewModel.isLoggedIn && this._article.favorites.isNotNullAndEmpty(), () => this._sendComment("Article"), () => this._sendComment("Article"), () => { if (!this.widget.viewModel.isLoggedIn) { this.widget.actionModel.pushToLogin(); } else { if (!this._article.like) { this.widget.actionModel.likeArticle(arg: this._article.id); } } }, () => { if (!this.widget.viewModel.isLoggedIn) { this.widget.actionModel.pushToLogin(); } else { ActionSheetUtils.showModalActionSheet(new FavoriteSheetConnector(articleId: this._article.id)); } }, shareCallback: this.share )); }
void _onPressed() { if (!UserInfoManager.isLogin()) { this.widget.actionModel.pushToLogin(); return; } if (this.widget.viewModel.type == LeaderBoardType.collection) { if (this.widget.viewModel.isCollected) { ActionSheetUtils.showModalActionSheet( new ActionSheet( title: "确定取消收藏?", items: new List <ActionSheetItem> { new ActionSheetItem("确定", type: ActionType.normal, () => { this.widget.actionModel.cancelCollectFavoriteTag(this.widget.viewModel.rankData .myFavoriteTagId, this.widget.viewModel.rankData .itemId); }), new ActionSheetItem("取消", type: ActionType.cancel) } ) ); } else { this.widget.actionModel.collectFavoriteTag(this.widget.viewModel.rankData.itemId, this.widget.viewModel.rankData.id); } } }
public static void showReportView( bool isLoggedIn, string reportId, ReportType reportType, Action pushToLogin, Action <string, ReportType> pushToReport, Action <string> pushToBlock = null ) { var items = new List <ActionSheetItem> { new ActionSheetItem( "举报", ActionType.normal, () => report(isLoggedIn, reportId, reportType, pushToLogin, pushToReport) ), new ActionSheetItem("取消", ActionType.cancel) }; if (reportType == ReportType.article) { items.Insert(0, new ActionSheetItem( "屏蔽", ActionType.normal, () => block(isLoggedIn, reportId, pushToLogin, pushToBlock) )); } ActionSheetUtils.showModalActionSheet(new ActionSheet( items: items )); }
Widget _buildLogoutBtn() { return(new CustomButton( padding: EdgeInsets.zero, onPressed: () => { ActionSheetUtils.showModalActionSheet(new ActionSheet( title: "确定退出当前账号吗?", items: new List <ActionSheetItem> { new ActionSheetItem("退出", type: ActionType.destructive, () => { AnalyticsManager.ClickLogout(); this.widget.actionModel.logout(); }), new ActionSheetItem("取消", type: ActionType.cancel) } )); }, child: new Container( height: 60, color: CColors.White, child: new Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: new List <Widget> { new Text( "退出登录", style: CTextStyle.PLargeError ) } ) ) )); }
void _showShareView(IEvent eventObj) { ActionSheetUtils.showModalActionSheet( new ShareView( projectType: ProjectType.iEvent, onPressed: type => { AnalyticsManager.ClickShare(shareType: type, "Event", "Event_" + eventObj.id, title: eventObj.title); var linkUrl = $"{Config.unity_cn_url}/events/{eventObj.id}"; var path = CStringUtils.CreateMiniPath(id: eventObj.id, title: eventObj.title); if (type == ShareType.clipBoard) { this.widget.actionModel.copyText(obj: linkUrl); CustomDialogUtils.showToast("复制链接成功", iconData: Icons.check_circle_outline); } else { var imageUrl = CImageUtils.SizeTo200ImageUrl(imageUrl: eventObj.avatar); CustomDialogUtils.showCustomDialog( child: new CustomLoadingDialog() ); this.widget.actionModel.shareToWechat( arg1: type, arg2: eventObj.title, arg3: eventObj.shortDescription, arg4: linkUrl, arg5: imageUrl, arg6: path) .Then(onResolved: CustomDialogUtils.hiddenCustomDialog) .Catch(_ => CustomDialogUtils.hiddenCustomDialog()); } } ) ); }
List <Widget> _buildSecondaryActions(FavoriteTag favoriteTag) { if (favoriteTag.type == "default") { return(new List <Widget>()); } return(new List <Widget> { new DeleteActionButton( 80, EdgeInsets.only(24, right: 12), () => { ActionSheetUtils.showModalActionSheet( new ActionSheet( title: "确定删除收藏夹及收藏夹中的内容?", items: new List <ActionSheetItem> { new ActionSheetItem( "确定", type: ActionType.normal, () => this.widget.actionModel.deleteFavoriteTag(arg: favoriteTag.id) ), new ActionSheetItem("取消", type: ActionType.cancel) } ) ); } ), new EditActionButton( 80, EdgeInsets.only(12, right: 24), () => this.widget.actionModel.pushToCreateFavorite(obj: favoriteTag.id) ) }); }
void _pickImage() { var items = new List <ActionSheetItem> { new ActionSheetItem( "拍照", onTap: () => PickImagePlugin.PickImage( source: ImageSource.camera, pickImage => { this._pickedImage = Convert.ToBase64String(inArray: pickImage); this.setState(() => { }); }, maxSize: 100 * 1024 ) ), new ActionSheetItem( "从相册选择", onTap: () => PickImagePlugin.PickImage( source: ImageSource.gallery, pickImage => { this._pickedImage = Convert.ToBase64String(inArray: pickImage); this.setState(() => { }); }, maxSize: 100 * 1024 ) ), new ActionSheetItem("取消", type: ActionType.cancel) }; ActionSheetUtils.showModalActionSheet(new ActionSheet( title: "修改头像", items: items )); }
Widget _buildLogoutBtn(BuildContext context) { return(new CustomButton( padding: EdgeInsets.zero, onPressed: () => { ActionSheetUtils.showModalActionSheet(new ActionSheet( title: "确定退出当前账号吗?", items: new List <ActionSheetItem> { new ActionSheetItem("退出", ActionType.destructive, () => { this.widget.actionModel.logout(); JPushPlugin.deleteJPushAlias(); }), new ActionSheetItem("取消", ActionType.cancel) } )); }, child: new Container( height: 60, decoration: new BoxDecoration( CColors.White ), child: new Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: new List <Widget> { new Text( "退出登录", style: CTextStyle.PLargeError ) } ) ) )); }
void _sendComment(string type, string parentMessageId = "", string upperMessageId = "", string replyUserName = null) { if (!this.widget.viewModel.isLoggedIn) { this.widget.actionModel.pushToLogin(); } else { AnalyticsManager.ClickComment( type: type, channelId: this._article.channelId, title: this._article.title, commentId: parentMessageId ); ActionSheetUtils.showModalActionSheet(new CustomInput( replyUserName: replyUserName, text => { ActionSheetUtils.hiddenModalPopup(); this.widget.actionModel.sendComment( arg1: this._article.channelId, arg2: text, Snowflake.CreateNonce(), arg4: parentMessageId, arg5: upperMessageId ); }) ); } }
Widget _buildArticleTabBar() { return(new ArticleTabBar( this._article.like && this.widget.viewModel.isLoggedIn, this._article.favorite != null && this.widget.viewModel.isLoggedIn, () => this._sendComment("Article"), () => this._sendComment("Article"), () => { if (!this.widget.viewModel.isLoggedIn) { this.widget.actionModel.pushToLogin(); } else { if (!this._article.like) { this.widget.actionModel.likeArticle(arg: this._article.id); } } }, () => { if (!this.widget.viewModel.isLoggedIn) { this.widget.actionModel.pushToLogin(); } else { if (this._article.favorite == null) { ActionSheetUtils.showModalActionSheet(new FavoriteSheetConnector(articleId: this._article.id)); } else { ActionSheetUtils.showModalActionSheet( new ActionSheet( title: "确定不再收藏?", items: new List <ActionSheetItem> { new ActionSheetItem( "确定", type: ActionType.normal, () => { this.widget.actionModel.unFavoriteArticle(arg: this._article.favorite.id); } ), new ActionSheetItem("取消", type: ActionType.cancel) } ) ); } } }, shareCallback: this.share )); }
public static void showReportView( bool isLoggedIn, string userName, ReportType reportType, VoidCallback pushToLogin, VoidCallback pushToReport, VoidCallback pushToBlock = null, VoidCallback blockUserCallback = null ) { var items = new List <ActionSheetItem> { new ActionSheetItem( $"屏蔽该用户 {userName}", type: ActionType.destructive, () => blockUser( isLoggedIn: isLoggedIn, userName: userName, pushToLogin: pushToLogin, blockUserAction: blockUserCallback ) ), new ActionSheetItem( "举报", type: ActionType.normal, () => report( isLoggedIn: isLoggedIn, pushToLogin: pushToLogin, pushToReport: pushToReport ) ), new ActionSheetItem("取消", type: ActionType.cancel) }; if (reportType == ReportType.article) { items.Insert(0, new ActionSheetItem( "屏蔽", type: ActionType.normal, () => blockProject( isLoggedIn: isLoggedIn, pushToLogin: pushToLogin, pushToBlock: pushToBlock ) ) ); } ActionSheetUtils.showModalActionSheet(new ActionSheet( items: items )); }
void _onFollow(Article article, UserType userType) { if (this.widget.viewModel.isLoggedIn) { if (userType == UserType.follow) { ActionSheetUtils.showModalActionSheet( new ActionSheet( title: "确定不再关注?", items: new List <ActionSheetItem> { new ActionSheetItem("确定", type: ActionType.normal, () => { if (article.ownerType == OwnerType.user.ToString()) { this.widget.actionModel.startUnFollowUser(obj: article.userId); this.widget.actionModel.unFollowUser(arg: article.userId); } if (article.ownerType == OwnerType.team.ToString()) { this.widget.actionModel.startUnFollowTeam(obj: article.teamId); this.widget.actionModel.unFollowTeam(arg: article.teamId); } }), new ActionSheetItem("取消", type: ActionType.cancel) } ) ); } if (userType == UserType.unFollow) { if (article.ownerType == OwnerType.user.ToString()) { this.widget.actionModel.startFollowUser(obj: article.userId); this.widget.actionModel.followUser(arg: article.userId); } if (article.ownerType == OwnerType.team.ToString()) { this.widget.actionModel.startFollowTeam(obj: article.teamId); this.widget.actionModel.followTeam(arg: article.teamId); } } } else { this.widget.actionModel.pushToLogin(); } }
Widget _buildShareWidget(RankData game) { return(new CustomButton( onPressed: () => ActionSheetUtils.showModalActionSheet( new ShareView( projectType: ProjectType.iEvent, onPressed: type => { // AnalyticsManager.ClickShare(type, "Event", "Event_" + eventObj.id, eventObj.title); var linkUrl = CStringUtils.JointTinyGameShareLink(gameId: game.id);; if (type == ShareType.clipBoard) { this.widget.actionModel.copyText(obj: linkUrl); CustomDialogUtils.showToast("复制链接成功", iconData: Icons.check_circle_outline); } else { var imageUrl = CImageUtils.SizeTo200ImageUrl(imageUrl: game.image); CustomDialogUtils.showCustomDialog( child: new CustomLoadingDialog() ); this.widget.actionModel.shareToWechat( arg1: type, arg2: game.resetTitle, arg3: game.resetSubLabel, arg4: linkUrl, arg5: imageUrl , null) .Then(onResolved: CustomDialogUtils.hiddenCustomDialog) .Catch(_ => CustomDialogUtils.hiddenCustomDialog()); } } ) ), child: new Container( color: CColors.Transparent, child: new Icon( icon: Icons.outline_share, size: 24, color: CColors.Icon ) ) )); }
public static void showArticleShareView( bool showReportAndBlock, bool isLoggedIn, VoidCallback pushToCopy, VoidCallback pushToLogin, VoidCallback pushToBlock, VoidCallback pushToReport, OnShareType shareToWechat, VoidCallback mainRouterPop = null ) { ActionSheetUtils.showModalActionSheet(new ShareView( projectType: ProjectType.article, showReportAndBlock: showReportAndBlock, onPressed: type => { if (type == ShareType.clipBoard) { pushToCopy?.Invoke(); } else if (type == ShareType.block) { ReportManager.blockProject( isLoggedIn: isLoggedIn, pushToLogin: pushToLogin, pushToBlock: pushToBlock, mainRouterPop: mainRouterPop ); } else if (type == ShareType.report) { ReportManager.report( isLoggedIn: isLoggedIn, pushToLogin: pushToLogin, pushToReport: pushToReport ); } else { shareToWechat?.Invoke(type: type); } } )); }
void _share(Article article) { ActionSheetUtils.showModalActionSheet(new ShareView( projectType: ProjectType.article, onPressed: type => { var linkUrl = CStringUtils.JointProjectShareLink(projectId: article.id); if (type == ShareType.clipBoard) { Clipboard.setData(new ClipboardData(text: linkUrl)); CustomDialogUtils.showToast("复制链接成功", iconData: Icons.check_circle_outline); } else if (type == ShareType.block) { ReportManager.block( isLoggedIn: this.widget.viewModel.isLoggedIn, () => this.widget.actionModel.pushToLogin(), () => this.widget.actionModel.pushToBlock(article.id), () => this.widget.actionModel.mainRouterPop() ); } else if (type == ShareType.report) { ReportManager.report( isLoggedIn: this.widget.viewModel.isLoggedIn, () => this.widget.actionModel.pushToLogin(), () => this.widget.actionModel.pushToReport(arg1: article.id, arg2: ReportType.article) ); } else { CustomDialogUtils.showCustomDialog( child: new CustomLoadingDialog() ); string imageUrl = CImageUtils.SizeTo200ImageUrl(article.thumbnail.url); this.widget.actionModel.shareToWechat(type, article.title, article.subTitle, linkUrl, imageUrl).Then(CustomDialogUtils.hiddenCustomDialog) .Catch(_ => CustomDialogUtils.hiddenCustomDialog()); } } )); }
void _onPressed() { if (!UserInfoManager.isLogin()) { this.widget.actionModel.pushToLogin(); return; } if (this.widget.viewModel.isCollect) { ActionSheetUtils.showModalActionSheet( new ActionSheet( title: "确定取消收藏?", items: new List <ActionSheetItem> { new ActionSheetItem("确定", type: ActionType.normal, () => { var tagId = this.widget.viewModel.favoriteTag.id; if (this.widget.viewModel.collectChangeMap.isNotEmpty() && this.widget.viewModel.collectChangeMap.ContainsKey(tagId)) { tagId = this.widget.viewModel.collectChangeMap[tagId]; } this.widget.actionModel.cancelCollectFavoriteTag( tagId, this.widget.viewModel.favoriteTag.quoteTagId ?? ""); }), new ActionSheetItem("取消", type: ActionType.cancel) } ) ); } else { this.widget.actionModel.collectFavoriteTag( this.widget.viewModel.favoriteTag.quoteTagId.isEmpty() ? this.widget.viewModel.favoriteTag.id : this.widget.viewModel.favoriteTag.quoteTagId, this.widget.viewModel.favoriteTag.id); } }
void _deleteAllHistory() { ActionSheetUtils.showModalActionSheet(new ActionSheet( title: "确定删除浏览历史?", items: new List <ActionSheetItem> { new ActionSheetItem( "删除", ActionType.destructive, () => { if (this._selectedIndex == 0) { this.widget.actionModel.deleteAllArticleHistory(); } else { this.widget.actionModel.deleteAllEventHistory(); } }), new ActionSheetItem("取消", ActionType.cancel) } )); }
void _onComment(Article article) { if (!this.widget.viewModel.isLoggedIn) { this.widget.actionModel.pushToLogin(); } else { ActionSheetUtils.showModalActionSheet(new CustomInput( doneCallBack: text => { ActionSheetUtils.hiddenModalPopup(); this.widget.actionModel.sendComment( arg1: article.id, arg2: article.channelId, arg3: text, Snowflake.CreateNonce(), "" ); }) ); } }
List <Widget> _buildSecondaryActions(Article article) { if (!this.widget.viewModel.isLoggedIn) { return(new List <Widget>()); } if (!this.widget.viewModel.userId.Equals(value: this.widget.viewModel.currentUserId)) { return(new List <Widget>()); } return(new List <Widget> { new DeleteActionButton( 80, onTap: () => { ActionSheetUtils.showModalActionSheet( new ActionSheet( title: "确定不再收藏?", items: new List <ActionSheetItem> { new ActionSheetItem( "确定", type: ActionType.normal, () => { var currentFavorite = article.favorites.Find( favorite => favorite.tagId == this.widget.viewModel.tagId); this.widget.actionModel.unFavoriteArticle(arg1: article.id, arg2: currentFavorite.id); } ), new ActionSheetItem("取消", type: ActionType.cancel) } ) ); } ) }); }
public static void showBlockUserView( bool isLoggedIn, bool hasBeenBlocked, VoidCallback pushToLogin, VoidCallback blockUserCallback = null, VoidCallback cancelBlockUserCallback = null ) { var items = new List <ActionSheetItem> { new ActionSheetItem( hasBeenBlocked ? "取消屏蔽该用户" : "屏蔽该用户", type: ActionType.destructive, () => { if (hasBeenBlocked) { cancelBlockUser( isLoggedIn: isLoggedIn, pushToLogin: pushToLogin, cancelBlockUserAction: cancelBlockUserCallback ); } else { blockUser( isLoggedIn: isLoggedIn, pushToLogin: pushToLogin, blockUserAction: blockUserCallback ); } } ), new ActionSheetItem("取消", type: ActionType.cancel) }; ActionSheetUtils.showModalActionSheet(new ActionSheet( items: items )); }
public static void showReportView( bool isLoggedIn, ReportType reportType, VoidCallback pushToLogin, VoidCallback pushToReport, VoidCallback pushToBlock = null ) { var items = new List <ActionSheetItem> { new ActionSheetItem( "举报", type: ActionType.normal, () => report( isLoggedIn: isLoggedIn, pushToLogin: pushToLogin, pushToReport: pushToReport ) ), new ActionSheetItem("取消", type: ActionType.cancel) }; if (reportType == ReportType.article) { items.Insert(0, new ActionSheetItem( "屏蔽", type: ActionType.normal, () => block( isLoggedIn: isLoggedIn, pushToLogin: pushToLogin, pushToBlock: pushToBlock ) )); } ActionSheetUtils.showModalActionSheet(new ActionSheet( items: items )); }
public override Widget build(BuildContext context) { this.widget.viewModel.articleDict.TryGetValue(this.widget.viewModel.articleId, out this._article); if (this.widget.viewModel.articleDetailLoading && (this._article == null || !this._article.isNotFirst)) { return(new Container( color: CColors.White, child: new CustomSafeArea( child: new Column( children: new List <Widget> { this._buildNavigationBar(false), new ArticleDetailLoading() } ) ) )); } if (this._article == null || this._article.channelId == null) { return(new Container()); } if (this._article.ownerType == "user") { if (this._article.userId != null && this.widget.viewModel.userDict.TryGetValue(this._article.userId, out this._user)) { this._user = this.widget.viewModel.userDict[this._article.userId]; } } if (this._article.ownerType == "team") { if (this._article.teamId != null && this.widget.viewModel.teamDict.TryGetValue(this._article.teamId, out this._team)) { this._team = this.widget.viewModel.teamDict[this._article.teamId]; } } if (this._titleHeight == 0f && this._article.title.isNotEmpty()) { this._titleHeight = CTextUtils.CalculateTextHeight( text: this._article.title, textStyle: CTextStyle.H3, MediaQuery.of(context).size.width - 16 * 2, // 16 is horizontal padding null ) + 16; // 16 is top padding this.setState(() => { }); } var commentIndex = 0; var originItems = this._article == null ? new List <Widget>() : this._buildItems(context, out commentIndex); commentIndex = this._jumpState == _ArticleJumpToCommentState.active ? commentIndex : 0; this._jumpState = _ArticleJumpToCommentState.Inactive; var child = new Container( color: CColors.Background, child: new Column( children: new List <Widget> { this._buildNavigationBar(), new Expanded( child: new CustomScrollbar( new CenteredRefresher( controller: this._refreshController, enablePullDown: false, enablePullUp: this._article.hasMore, onRefresh: this._onRefresh, onNotification: this._onNotification, children: originItems, centerIndex: commentIndex ) ) ), new ArticleTabBar(this._article.like, () => { if (!this.widget.viewModel.isLoggedIn) { this.widget.actionModel.pushToLogin(); } else { AnalyticsManager.ClickComment("Article", this._article.channelId, this._article.title); ActionSheetUtils.showModalActionSheet(new CustomInput( doneCallBack: text => { ActionSheetUtils.hiddenModalPopup(); this.widget.actionModel.sendComment(this._article.channelId, text, Snowflake.CreateNonce(), null ); }) ); } }, () => { if (!this.widget.viewModel.isLoggedIn) { this.widget.actionModel.pushToLogin(); } else { AnalyticsManager.ClickComment("Article", this._article.channelId, this._article.title); ActionSheetUtils.showModalActionSheet(new CustomInput( doneCallBack: text => { ActionSheetUtils.hiddenModalPopup(); this.widget.actionModel.sendComment(this._article.channelId, text, Snowflake.CreateNonce(), null ); }) ); } }, () => { if (!this.widget.viewModel.isLoggedIn) { this.widget.actionModel.pushToLogin(); } else { if (!this._article.like) { this.widget.actionModel.likeArticle(this._article.id); } } }, shareCallback: this.share ) } ) ); return(new Container( color: CColors.White, child: new CustomSafeArea( child: child ) )); }
Widget _buildHeadTop(IEvent eventObj, BuildContext context) { Widget shareWidget = new CustomButton( onPressed: () => ActionSheetUtils.showModalActionSheet(new ShareView( projectType: ProjectType.iEvent, onPressed: type => { AnalyticsManager.ClickShare(type, "Event", "Event_" + eventObj.id, eventObj.title); var linkUrl = CStringUtils.JointEventShareLink(eventId: eventObj.id); if (type == ShareType.clipBoard) { this.widget.actionModel.copyText(linkUrl); CustomDialogUtils.showToast("复制链接成功", Icons.check_circle_outline); } else { var imageUrl = CImageUtils.SizeTo200ImageUrl(eventObj.avatar); CustomDialogUtils.showCustomDialog( child: new CustomLoadingDialog() ); this.widget.actionModel.shareToWechat(type, eventObj.title, eventObj.shortDescription, linkUrl, imageUrl, null).Then(CustomDialogUtils.hiddenCustomDialog) .Catch(_ => CustomDialogUtils.hiddenCustomDialog()); } })), child: new Container( color: CColors.Transparent, child: new Icon(Icons.share, size: 24, color: this._showNavBarShadow ? CColors.White : CColors.Icon)) ); Widget titleWidget = new Container(); if (this._isHaveTitle) { titleWidget = new Text( eventObj.title, style: CTextStyle.PXLargeMedium, maxLines: 1, overflow: TextOverflow.ellipsis, textAlign: TextAlign.center ); } return(new AnimatedContainer( height: 44 + CCommonUtils.getSafeAreaTopPadding(context: context), duration: TimeSpan.Zero, padding: EdgeInsets.only(8, right: 8, top: CCommonUtils.getSafeAreaTopPadding(context: context)), decoration: new BoxDecoration( CColors.White, border: new Border( bottom: new BorderSide(this._isHaveTitle ? CColors.Separator2 : CColors.Transparent)), gradient: this._showNavBarShadow ? new LinearGradient( colors: new List <Color> { new Color(0x80000000), new Color(0x0) }, begin: Alignment.topCenter, end: Alignment.bottomCenter ) : null ), child: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: new List <Widget> { new CustomButton( onPressed: () => this.widget.actionModel.mainRouterPop(), child: new Icon( Icons.arrow_back, size: 24, color: this._showNavBarShadow ? CColors.White : CColors.Icon ) ), new Expanded( child: new Stack( fit: StackFit.expand, children: new List <Widget> { new PositionedTransition( rect: this._animation, child: titleWidget ) } ) ), shareWidget } ) )); }
Widget _buildArticleCard(int index) { var articleId = this.widget.viewModel.favoriteDetailArticleIds[index : index]; var articleDict = this.widget.viewModel.articleDict; if (!articleDict.ContainsKey(key: articleId)) { return(new Container()); } var article = articleDict[key : articleId]; var linkUrl = CStringUtils.JointProjectShareLink(projectId: article.id); var fullName = ""; if (article.ownerType == OwnerType.user.ToString()) { if (this.widget.viewModel.userDict.ContainsKey(key: article.userId)) { fullName = this.widget.viewModel.userDict[key : article.userId].fullName ?? this.widget.viewModel.userDict[key : article.userId].name; } } if (article.ownerType == OwnerType.team.ToString()) { if (this.widget.viewModel.teamDict.ContainsKey(key: article.teamId)) { fullName = this.widget.viewModel.teamDict[key : article.teamId].name; } } return(CustomDismissible.builder( Key.key(value: article.id), new ArticleCard( article: article, () => this.widget.actionModel.pushToArticleDetail(obj: article.id), () => ShareManager.showArticleShareView( false, isLoggedIn: this.widget.viewModel.isLoggedIn, () => { Clipboard.setData(new ClipboardData(text: linkUrl)); CustomDialogUtils.showToast("复制链接成功", iconData: Icons.check_circle_outline); }, () => this.widget.actionModel.pushToLogin(), () => this.widget.actionModel.pushToBlock(obj: article.id), () => this.widget.actionModel.pushToReport(obj: article.id), type => { CustomDialogUtils.showCustomDialog( child: new CustomLoadingDialog() ); string imageUrl = CImageUtils.SizeTo200ImageUrl(imageUrl: article.thumbnail.url); this.widget.actionModel.shareToWechat(arg1: type, arg2: article.title, arg3: article.subTitle, arg4: linkUrl, arg5: imageUrl) .Then(onResolved: CustomDialogUtils.hiddenCustomDialog) .Catch(_ => CustomDialogUtils.hiddenCustomDialog()); } ), fullName: fullName, key: new ObjectKey(value: article.id) ), new CustomDismissibleDrawerDelegate(), secondaryActions: new List <Widget> { new DeleteActionButton( 80, onTap: () => { ActionSheetUtils.showModalActionSheet( new ActionSheet( title: "确定不再收藏?", items: new List <ActionSheetItem> { new ActionSheetItem( "确定", type: ActionType.normal, () => { this.widget.actionModel.unFavoriteArticle(arg1: article.id, arg2: article.favorite.id); } ), new ActionSheetItem("取消", type: ActionType.cancel) } ) ); } ) }, controller: this._dismissibleController )); }
IEnumerable <Widget> _buildComments(BuildContext context) { List <string> channelComments = new List <string>(); if (this.widget.viewModel.channelMessageList.ContainsKey(this._article.channelId)) { channelComments = this.widget.viewModel.channelMessageList[this._article.channelId]; } var mediaQuery = MediaQuery.of(context); var comments = new List <Widget> { new Container( color: CColors.White, width: mediaQuery.size.width, padding: EdgeInsets.only(16, 16, 16), child: new Text( "评论", style: CTextStyle.H5, textAlign: TextAlign.left ) ) }; var titleHeight = CTextUtils.CalculateTextHeight( "评论", CTextStyle.H5, mediaQuery.size.width - 16 * 2, // 16 is horizontal padding null ) + 16; // 16 is top padding var height = mediaQuery.size.height - navBarHeight - 44 - mediaQuery.padding.vertical; if (channelComments.Count == 0) { var blankView = new Container( height: height - titleHeight, child: new BlankView( "快来写下第一条评论吧", "image/default-comment" ) ); comments.Add(item: blankView); return(comments); } var messageDict = this.widget.viewModel.channelMessageDict[this._article.channelId]; float contentHeights = 0; foreach (var commentId in channelComments) { if (!messageDict.ContainsKey(commentId)) { break; } var message = messageDict[commentId]; bool isPraised = _isPraised(message, this.widget.viewModel.loginUserId); var parentName = ""; if (message.parentMessageId.isNotEmpty()) { if (messageDict.ContainsKey(message.parentMessageId)) { var parentMessage = messageDict[message.parentMessageId]; parentName = parentMessage.author.fullName; } } var content = MessageUtils.AnalyzeMessage(message.content, message.mentions, message.mentionEveryone) + (parentName.isEmpty() ? "" : $"回复@{parentName}"); var contentHeight = CTextUtils.CalculateTextHeight( content, CTextStyle.PLargeBody, // 16 is horizontal padding, 24 is avatar size, 8 is content left margin to avatar mediaQuery.size.width - 16 * 2 - 24 - 8, null ) + 16 + 24 + 3 + 5 + 22 + 12; // 16 is top padding, 24 is avatar size, 3 is content top margin to avatar, 5 is content bottom margin to commentTime // 22 is commentTime height, 12 is commentTime bottom margin contentHeights += contentHeight; var card = new CommentCard( message, isPraised, parentName, () => ReportManager.showReportView(this.widget.viewModel.isLoggedIn, commentId, ReportType.comment, this.widget.actionModel.pushToLogin, this.widget.actionModel.pushToReport ), replyCallBack: () => { if (!this.widget.viewModel.isLoggedIn) { this.widget.actionModel.pushToLogin(); } else { AnalyticsManager.ClickComment("Article_Comment", this._article.channelId, this._article.title, commentId); ActionSheetUtils.showModalActionSheet(new CustomInput( message.author.fullName.isEmpty() ? "" : message.author.fullName, text => { ActionSheetUtils.hiddenModalPopup(); this.widget.actionModel.sendComment(this._article.channelId, text, Snowflake.CreateNonce(), commentId ); }) ); } }, praiseCallBack: () => { if (!this.widget.viewModel.isLoggedIn) { this.widget.actionModel.pushToLogin(); } else { if (isPraised) { this.widget.actionModel.removeLikeComment(message); } else { this.widget.actionModel.likeComment(message); } } }); comments.Add(card); } float endHeight = 0; if (!this._article.hasMore) { comments.Add(new Container( height: 52, alignment: Alignment.center, child: new Text( "一 已经全部加载完毕 一", style: CTextStyle.PRegularBody4, textAlign: TextAlign.center ) )); endHeight = 52; } if (titleHeight + contentHeights + endHeight < height) { return(new List <Widget> { new Container( height: height, child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: comments ) ) }); } return(comments); }