void _pickImage() { var imageUrl = this.widget.urls[this.currentIndex]; var imagePath = SQLiteDBManager.instance.GetCachedFilePath(imageUrl); if (imagePath.isEmpty()) { return; } var items = new List <ActionSheetItem> { new ActionSheetItem( "保存图片", onTap: () => { if (imagePath.isNotEmpty()) { var imageStr = CImageUtils.readImage(imagePath); PickImagePlugin.SaveImage(imagePath, imageStr); } } ), new ActionSheetItem("取消", type: ActionType.cancel) }; ActionSheetUtils.showModalActionSheet(new ActionSheet( title: "", items: items )); }
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()); } } ) ); }
void _onShare(Article article) { var linkUrl = CStringUtils.JointProjectShareLink(projectId: article.id); ShareManager.showArticleShareView( true, 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(arg1: article.id, arg2: ReportType.article), type => { CustomDialogUtils.showCustomDialog( child: new CustomLoadingDialog() ); string imageUrl = CImageUtils.SizeTo200ImageUrl(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()); } ); }
static void _handleMethodCall(string method, List <JSONNode> args) { if (GlobalContext.context != null) { using (WindowProvider.of(context: GlobalContext.context).getScope()) { switch (method) { case "pickImageSuccess": { var node = args[0]; var dict = JSON.Parse(aJSON: node); if (dict["image"] != null) { var image = (string)dict["image"]; var imageData = Convert.FromBase64String(s: image); _imageCallBack?.Invoke(obj: imageData); } else if (dict["imagePath"] != null) { var imagePath = (string)dict["imagePath"]; CImageUtils.asyncLoadFile(imagePath).Then(bytes => { _imageCallBack?.Invoke(obj: bytes); }); } removeListener(); StatusBarManager.hideStatusBar(false); break; } case "pickVideoSuccess": { var node = args[0]; var dict = JSON.Parse(aJSON: node); if (dict["videoData"] != null) { var videoData = (string)dict["videoData"]; var data = Convert.FromBase64String(s: videoData); _videoCallBack?.Invoke(obj: data); } else if (dict["videoPath"] != null) { var videoPath = (string)dict["videoPath"]; CImageUtils.asyncLoadFile(videoPath).Then(bytes => { _videoCallBack?.Invoke(obj: bytes); }); } removeListener(); StatusBarManager.hideStatusBar(false); break; } case "cancel": { removeListener(); StatusBarManager.hideStatusBar(false); break; } } } } }
Widget _buildHeadImage(BuildContext context) { if (!this.isShowImage) { return(new Container()); } var imageUrl = this.eventObj.avatar ?? ""; var aspectRatio = 16.0f / 9; if (Application.platform != RuntimePlatform.Android) { aspectRatio = 3f / 2; } return(new Container( child: new AspectRatio( aspectRatio: aspectRatio, child: new PlaceholderImage( imageUrl.EndsWith(".gif") ? imageUrl : CImageUtils.SuitableSizeImageUrl(MediaQuery.of(context).size.width, imageUrl), fit: BoxFit.cover ) ) )); }
Widget _buildUserCard(BuildContext context, int index) { var articleId = this.widget.viewModel.likeArticleIds[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(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, new ObjectKey(value: article.id) )); }
Widget _buildArticleCard(BuildContext context, int index) { var article = this.viewModel.articleHistory[index : index]; var linkUrl = CStringUtils.JointProjectShareLink(projectId: article.id); return(CustomDismissible.builder( Key.key(value: article.id), new ArticleCard( article: article, () => this.actionModel.pushToArticleDetail(obj: article.id), () => ShareManager.showArticleShareView( true, isLoggedIn: this.viewModel.isLoggedIn, () => { Clipboard.setData(new ClipboardData(text: linkUrl)); CustomDialogUtils.showToast("复制链接成功", Icons.check_circle_outline); }, () => this.actionModel.pushToLogin(), () => this.actionModel.pushToBlock(article.id), () => this.actionModel.pushToReport(article.id, ReportType.article), type => { CustomDialogUtils.showCustomDialog( child: new CustomLoadingDialog() ); string imageUrl = CImageUtils.SizeTo200ImageUrl(article.thumbnail.url); this.actionModel.shareToWechat(arg1: type, arg2: article.title, arg3: article.subTitle, arg4: linkUrl, arg5: imageUrl) .Then(onResolved: CustomDialogUtils.hiddenCustomDialog) .Catch(_ => CustomDialogUtils.hiddenCustomDialog()); } ), fullName: article.fullName, index == 0, new ObjectKey(value: article.id) ), new CustomDismissibleDrawerDelegate(), secondaryActions: new List <Widget> { new GestureDetector( onTap: () => this.actionModel.deleteArticleHistory(obj: article.id), child: new Container( color: CColors.Separator2, width: 80, alignment: Alignment.center, child: new Container( width: 44, height: 44, alignment: Alignment.center, decoration: new BoxDecoration( CColors.White, borderRadius: BorderRadius.circular(22) ), child: new Icon(Icons.delete_outline, size: 28, color: CColors.Error) ) ) ) }, controller: this._controller )); }
Widget _buildArticleInfo() { const float imageWidth = 100; const float imageHeight = 66; const float borderRadius = 4; var imageUrl = this.article.thumbnail.url.EndsWith(".gif") ? this.article.thumbnail.url : CImageUtils.SuitableSizeImageUrl(imageWidth: imageWidth, imageUrl: this.article.thumbnail.url); return(new Container( padding: EdgeInsets.only(16, 10, 16), child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Text( data: this.article.title, style: CTextStyle.H5, maxLines: 2, overflow: TextOverflow.ellipsis ), new Container( margin: EdgeInsets.only(top: 10), child: new Row( children: new List <Widget> { new Expanded( child: new Container( height: imageHeight, child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Text( data: this.article.subTitle, style: CTextStyle.PRegularBody3, maxLines: 3, overflow: TextOverflow.ellipsis ) } ) ) ), new Container( margin: EdgeInsets.only(8), child: new PlaceholderImage( imageUrl: imageUrl, width: imageWidth, height: imageHeight, borderRadius: borderRadius, fit: BoxFit.cover, color: CColorUtils.GetSpecificDarkColorFromId(id: this.article.id) ) ) } ) ) } ) )); }
Image _getImage() { return(this.widget.data == null ? CachedNetworkImageProvider.cachedNetworkImage( this.widget.isOriginalImage?this.widget.url : CImageUtils.SizeToScreenImageUrl(this.widget.url), fit : BoxFit.cover, headers : this.widget.headers) : Image.memory(bytes: this.widget.data)); }
public override Widget build(BuildContext context) { var attachmentUrLs = this.game.attachmentURLs; if (attachmentUrLs.isNullOrEmpty()) { return(new Container()); } Widget swiperContent; if (attachmentUrLs.Count == 1) { var imageUrl = attachmentUrLs.FirstOrDefault(); swiperContent = new GestureDetector( onTap: () => { }, child: new PlaceholderImage( imageUrl: imageUrl, fit: BoxFit.fill, useCachedNetworkImage: true, color: CColorUtils.GetSpecificDarkColorFromId(id: imageUrl) ) ); } else { swiperContent = new Swiper.Swiper( (cxt, index) => { var imageUrl = attachmentUrLs[index: index]; return(new PlaceholderImage( CImageUtils.SizeToScreenImageUrl(imageUrl: imageUrl), fit: BoxFit.fill, useCachedNetworkImage: true, color: CColorUtils.GetSpecificDarkColorFromId(id: imageUrl) )); }, itemCount: attachmentUrLs.Count, autoplay: true, onTap: index => { }, pagination: new SwiperPagination(margin: EdgeInsets.only(bottom: 5)) ); } return(new Container( child: new AspectRatio( aspectRatio: 16 / 9f, child: swiperContent ) )); }
Widget _buildLeaderBoardItem(BuildContext context, int index) { var collectionId = this.data[index : index]; var rankData = this.rankDict.ContainsKey(key: collectionId) ? this.rankDict[key : collectionId] : new RankData(); var favoriteTag = this.favoriteTagDict.ContainsKey(key: rankData.itemId) ? this.favoriteTagDict[key : rankData.itemId] : new FavoriteTag(); return(new GestureDetector( onTap: () => this.onPressItem?.Invoke(text: rankData.id), child: new Container( width: 160, height: 80, margin: EdgeInsets.only(index == 0 ? 16 : 0, right: 16), decoration: new BoxDecoration( borderRadius: BorderRadius.all(4) ), child: new ClipRRect( borderRadius: BorderRadius.all(4), child: new Stack( children: new List <Widget> { Positioned.fill( new Container(color: CColorUtils.GetCardColorFromId(id: collectionId)) ), Image.asset( CImageUtils.GetSpecificPatternImageNameFromId(id: collectionId), width: 160, height: 80, fit: BoxFit.fill ), Positioned.fill( new Padding( padding: EdgeInsets.all(16), child: new Text( rankData.resetTitle.isNotEmpty() ? rankData.resetTitle : favoriteTag.name, maxLines: 2, overflow: TextOverflow.ellipsis, style: CTextStyle.PLargeMediumWhite ) ) ) } ) ) ) )); }
Widget _buildArticleCard(BuildContext context, int index) { var article = this.viewModel.articleHistory[index : index]; var linkUrl = CStringUtils.JointProjectShareLink(projectId: article.id); return(CustomDismissible.builder( Key.key(value: article.id), new ArticleCard( article: article, () => this.actionModel.pushToArticleDetail(obj: article.id), () => ShareManager.showArticleShareView( true, isLoggedIn: this.viewModel.isLoggedIn, () => { Clipboard.setData(new ClipboardData(text: linkUrl)); CustomDialogUtils.showToast("复制链接成功", iconData: Icons.check_circle_outline); }, () => this.actionModel.pushToLogin(), () => this.actionModel.pushToBlock(obj: article.id), () => this.actionModel.pushToReport(arg1: article.id, arg2: ReportType.article), type => { CustomDialogUtils.showCustomDialog( child: new CustomLoadingDialog() ); string imageUrl = CImageUtils.SizeTo200ImageUrl(imageUrl: article.thumbnail.url); this.actionModel.shareToWechat(arg1: type, arg2: article.title, arg3: article.subTitle, arg4: linkUrl, arg5: imageUrl) .Then(onResolved: CustomDialogUtils.hiddenCustomDialog) .Catch(_ => CustomDialogUtils.hiddenCustomDialog()); } ), fullName: article.fullName, new ObjectKey(value: article.id) ), new CustomDismissibleDrawerDelegate(), secondaryActions: new List <Widget> { new DeleteActionButton( 80, onTap: () => this.actionModel.deleteArticleHistory(obj: article.id) ) }, controller: this._controller )); }
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 ) ) )); }
Widget _buildCommentAvatarName(bool isMe) { var textStyle = CTextStyle.PMediumBody3.apply(heightFactor: 0, heightDelta: 1); return(new Container( height: 24, child: new Row( children: new List <Widget> { new Expanded( child: new GestureDetector( onTap: () => this.pushToUserDetail(obj: this.message.author.id), child: new Row( children: new List <Widget> { new Flexible( child: new Text( this.message.author.fullName, style: textStyle, maxLines: 1, overflow: TextOverflow.ellipsis ) ), CImageUtils.GenBadgeImage( badges: this.message.author.badges, license: this.userLicense, EdgeInsets.only(4) ) } ) ) ), !isMe ? new CustomButton( padding: EdgeInsets.only(16, 0, 0, 8), onPressed: this.moreCallBack, child: new Icon( icon: Icons.ellipsis, size: 20, color: CColors.BrownGrey ) ) : (Widget) new Container() } ) )); }
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 share() { var userId = ""; if (this._article.ownerType == OwnerType.user.ToString()) { userId = this._article.userId; } if (this._article.ownerType == OwnerType.team.ToString()) { userId = this._article.teamId; } var linkUrl = CStringUtils.JointProjectShareLink(projectId: this._article.id); ShareManager.showArticleShareView( this.widget.viewModel.loginUserId != userId, isLoggedIn: this.widget.viewModel.isLoggedIn, () => { Clipboard.setData(new ClipboardData(text: linkUrl)); CustomDialogUtils.showToast("复制链接成功", Icons.check_circle_outline); }, () => this.widget.actionModel.pushToLogin(), () => this.widget.actionModel.pushToBlock(this._article.id), () => this.widget.actionModel.pushToReport(this._article.id, ReportType.article), type => { CustomDialogUtils.showCustomDialog( child: new CustomLoadingDialog() ); string imageUrl = CImageUtils.SizeTo200ImageUrl(this._article.thumbnail.url); this.widget.actionModel.shareToWechat(arg1: type, arg2: this._article.title, arg3: this._article.subTitle, arg4: linkUrl, arg5: imageUrl) .Then(onResolved: CustomDialogUtils.hiddenCustomDialog) .Catch(_ => CustomDialogUtils.hiddenCustomDialog()); }, () => this.widget.actionModel.mainRouterPop() ); }
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 )); }
Widget _buildLecture(User host) { if (host == null) { return(new Container()); } return(new Container( padding: EdgeInsets.symmetric(horizontal: 16), margin: EdgeInsets.only(bottom: 24), color: CColors.White, child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new GestureDetector( onTap: () => this.pushToUserDetail(obj: host.id), child: new Row( children: new List <Widget> { new Container( margin: EdgeInsets.only(right: 8), child: Avatar.User(user: host, 48) ), new Flexible( child: new Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Row( children: new List <Widget> { new Flexible( child: new Text( host.fullName ?? host.name ?? "", maxLines: 1, style: new TextStyle( color: CColors.TextBody, height: 1, fontFamily: "Roboto-Medium", fontSize: 16 ), overflow: TextOverflow.ellipsis ) ), CImageUtils.GenBadgeImage( badges: host.badges, CCommonUtils.GetUserLicense( userId: host.id, userLicenseMap: this.userLicenseDict ), EdgeInsets.only(4) ) } ), host.title.isNotEmpty() ? new Container( child: new Text( data: host.title, maxLines: 1, overflow: TextOverflow.ellipsis, style: CTextStyle.PRegularBody3 ) ) : new Container() } ) ) } ) ), new Container( margin: EdgeInsets.only(top: 8), child: new Text( data: host.description, style: new TextStyle( color: CColors.TextBody3, fontFamily: "Roboto-Regular", fontSize: 16 ) ) ) } ) )); }
Widget _buildContentHead() { var user = this.eventObj.user ?? new User(); return(new Container( padding: EdgeInsets.symmetric(horizontal: 16), margin: EdgeInsets.only(top: 16, bottom: 20), child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Text( this.eventObj.title ?? "", this.titleKey, style: CTextStyle.H4 ), new Container( margin: EdgeInsets.only(top: 20), child: new Row( children: new List <Widget> { new Container( margin: EdgeInsets.only(right: 8), child: new GestureDetector( onTap: () => this.pushToUserDetail(user.id), child: Avatar.User(user, 32) ) ), new Expanded( child: new Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new GestureDetector( onTap: () => this.pushToUserDetail(user.id), child: new Row( children: new List <Widget> { new Flexible( child: new Text( user.fullName ?? user.name ?? "", style: CTextStyle.PMediumBody.merge( new TextStyle(height: 1)), maxLines: 1, overflow: TextOverflow.ellipsis ) ), CImageUtils.GenBadgeImage( badges: user.badges, CCommonUtils.GetUserLicense( userId: user.id, userLicenseMap: this.userLicenseDict ), EdgeInsets.only(4) ) } ) ), new Text( $"{DateConvert.DateStringFromNow(this.eventObj.createdTime ?? DateTime.Now)}发布", style: CTextStyle.PSmallBody3 ) } ) ) } ) ) } ) )); }
public override Widget build(BuildContext context) { if (this.model == null) { return(new Container()); } const float imageWidth = 114; const float imageHeight = 76; const float borderRadius = 4; var gap = this.topPadding ? 16 : 0; var time = Convert.ToDateTime(this.model.begin.startTime); var hour = $"{time.Hour.ToString().PadLeft(2, '0')}"; var minute = $"{time.Minute.ToString().PadLeft(2, '0')}"; var hourMinute = $"{hour}:{minute}"; var address = this.place ?? ""; var imageUrl = this.model.avatar ?? this.model.background; var card = new Container( height: 108 + gap, padding: EdgeInsets.only(16, 16 + gap, 16, 16), color: CColors.White, child: new Row( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Container( width: 32, margin: EdgeInsets.only(right: 10), child: new Column( crossAxisAlignment: CrossAxisAlignment.center, children: new List <Widget> { new Text( time.Day.ToString(), style: new TextStyle( height: 1.33f, fontSize: 24, fontFamily: "Roboto-Bold", color: CColors.SecondaryPink ) ), new Text( $"{time.Month.ToString()}月", style: CTextStyle.CaptionBody ) } ) ), new Expanded( child: new Container( margin: EdgeInsets.only(right: 8), child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Container( margin: EdgeInsets.only(bottom: 8), child: new Text(this.model.title, style: CTextStyle.PLargeMedium, maxLines: 2, overflow: TextOverflow.ellipsis ) ), new Text(this.model.mode == "online" ? $"{hourMinute} · {this.model.participantsCount}人已预订" : $"{hourMinute} · {address}", style: CTextStyle.PSmallBody3 ) } ) ) ), new Container( child: new Stack( children: new List <Widget> { new PlaceholderImage( imageUrl.EndsWith(".gif") ? imageUrl : CImageUtils.SuitableSizeImageUrl(imageWidth, imageUrl), imageWidth, imageHeight, borderRadius, BoxFit.cover ), new Positioned( bottom: 0, right: 0, child: new ClipRRect( borderRadius: BorderRadius.only(bottomRight: 4), child: new Container( width: 41, height: 24, color: this.model.mode == "online" ? CColors.SecondaryPink : CColors.PrimaryBlue, alignment: Alignment.center, child: new Text(this.model.mode == "online" ? "线上" : "线下", style: CTextStyle.CaptionWhite, textAlign: TextAlign.center ) ) ) ) } ) ) } ) ); return(new GestureDetector( child: card, onTap: this.onTap )); }
Widget _buildArticleList(BuildContext context) { Widget content; var recommendArticleIds = this.widget.viewModel.recommendArticleIds; if (!this._hasBeenLoadedData || this.widget.viewModel.articlesLoading && recommendArticleIds.isEmpty()) { content = ListView.builder( physics: new NeverScrollableScrollPhysics(), itemCount: 6, itemBuilder: (cxt, index) => new ArticleLoading() ); } else if (0 == recommendArticleIds.Count) { content = new Container( padding: EdgeInsets.only(bottom: CConstant.TabBarHeight + CCommonUtils.getSafeAreaBottomPadding(context: context)), child: new BlankView( "哎呀,暂无推荐文章", "image/default-article", true, () => { this.widget.actionModel.startFetchArticles(); this.widget.actionModel.fetchArticles(arg: initOffset); } ) ); } else { content = new SmartRefresher( controller: this._refreshController, enablePullDown: true, enablePullUp: this.widget.viewModel.hottestHasMore, onRefresh: this._onRefresh, hasBottomMargin: true, child: ListView.builder( physics: new AlwaysScrollableScrollPhysics(), itemCount: recommendArticleIds.Count, itemBuilder: (cxt, index) => { var articleId = recommendArticleIds[index: index]; if (this.widget.viewModel.blockArticleList.Contains(item: articleId)) { return(new Container()); } if (!this.widget.viewModel.articleDict.ContainsKey(key: articleId)) { return(new Container()); } if (!this.widget.viewModel.hottestHasMore && recommendArticleIds.Count > 0 && index + 1 == recommendArticleIds.Count) { return(new EndView(hasBottomMargin: true)); } var article = this.widget.viewModel.articleDict[key: articleId]; var fullName = ""; var userId = ""; if (article.ownerType == OwnerType.user.ToString()) { userId = article.userId; 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()) { userId = article.teamId; if (this.widget.viewModel.teamDict.ContainsKey(key: article.teamId)) { fullName = this.widget.viewModel.teamDict[key: article.teamId].name; } } var linkUrl = CStringUtils.JointProjectShareLink(projectId: article.id); return(new ArticleCard( article: article, () => { this.widget.actionModel.pushToArticleDetail(obj: articleId); AnalyticsManager.ClickEnterArticleDetail("Home_Article", articleId: article.id, articleTitle: article.title); }, () => ShareManager.showArticleShareView( this.widget.viewModel.currentUserId != userId, 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(arg1: article.id, arg2: ReportType.article), type => { CustomDialogUtils.showCustomDialog( child: new CustomLoadingDialog() ); string imageUrl = CImageUtils.SizeTo200ImageUrl(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) )); } ) ); } if (this.widget.viewModel.isLoggedIn) { return(new Container( color: CColors.Background, child: new CustomScrollbar(child: content) )); } return(new NotificationListener <ScrollNotification>( onNotification: this._onNotification, child: new Container( color: CColors.Background, child: new CustomScrollbar(child: content) ) )); }
Widget _buildUserInfo(BuildContext context) { var user = this.widget.viewModel.user ?? new User(); Widget titleWidget; if (user.title != null && user.title.isNotEmpty()) { titleWidget = new Text( data: user.title, style: new TextStyle( fontSize: 14, fontFamily: "Roboto-Regular", color: CColors.BgGrey ), maxLines: 1, overflow: TextOverflow.ellipsis ); } else { titleWidget = new Container(); } return(new CoverImage( coverImage: user.coverImage, imageBaseHeight + CCommonUtils.getSafeAreaTopPadding(context: context), new Container( padding: EdgeInsets.only(16, 0, 16, 24), child: new Column( mainAxisAlignment: MainAxisAlignment.end, children: new List <Widget> { new Row( children: new List <Widget> { new Container( margin: EdgeInsets.only(right: 16), child: Avatar.User( user: user, 80, true ) ), new Expanded( child: new Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Row( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Flexible( child: new Text( user.fullName ?? user.name, style: CTextStyle.H4White.merge( new TextStyle(height: 1)), maxLines: 1, overflow: TextOverflow.ellipsis ) ), CImageUtils.GenBadgeImage( badges: user.badges, CCommonUtils.GetUserLicense( userId: user.id, userLicenseMap: this.widget.viewModel.userLicenseDict ), EdgeInsets.only(4, 6) ) } ), titleWidget } ) ) } ), new Container( margin: EdgeInsets.only(top: 16), child: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: new List <Widget> { new Row( children: new List <Widget> { _buildFollowCount( "关注", $"{(user.followingUsersCount ?? 0) + (user.followingTeamsCount ?? 0)}", () => this.widget.actionModel.pushToUserFollowing( arg1: this.widget.viewModel.user.id, 0) ), new SizedBox(width: 16), _buildFollowCount( "粉丝", $"{user.followCount ?? 0}", () => this.widget.actionModel.pushToUserFollower( obj: this.widget.viewModel.user.id) ) } ), this._buildFollowButton() } ) ) } ) ) )); }
Widget _buildTeamInfo(BuildContext context) { var team = this.widget.viewModel.team; return(new CoverImage( coverImage: team.coverImage, height: imageBaseHeight + CCommonUtils.getSafeAreaTopPadding(context: context), new Container( padding: EdgeInsets.only(16, 0, 16, 24), child: new Column( mainAxisAlignment: MainAxisAlignment.end, children: new List <Widget> { new Row( children: new List <Widget> { new Container( margin: EdgeInsets.only(right: 16), child: Avatar.Team( team: team, 80, true ) ), new Expanded( child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Row( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Flexible( child: new Text( data: team.name, style: CTextStyle.H4White.merge( new TextStyle(height: 1)), maxLines: 1, overflow: TextOverflow.ellipsis ) ), CImageUtils.GenBadgeImage( badges: team.badges, CCommonUtils.GetUserLicense( userId: team.id ), EdgeInsets.only(4, 6) ) } ) } ) ) } ), new Container( margin: EdgeInsets.only(top: 16), child: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: new List <Widget> { new Row( children: new List <Widget> { _buildFollowCount( "粉丝", $"{team.stats?.followCount ?? 0}", () => { if (this.widget.viewModel.isLoggedIn) { this.widget.actionModel.pushToTeamFollower( obj: this.widget.viewModel.team.id); } else { this.widget.actionModel.pushToLogin(); } } ), new SizedBox(width: 16), _buildFollowCount( "成员", $"{team.stats?.membersCount ?? 0}", () => this.widget.actionModel.pushToTeamMember( obj: this.widget.viewModel.team.id) ) } ), this._buildFollowButton() } ) ) } ) ) )); }
public override Widget build(BuildContext context) { if (this.article == null) { return(new Container()); } const float imageWidth = 100; const float imageHeight = 66; const float borderRadius = 4; var time = this.article.publishedTime; var thumbnailUrl = this.article.thumbnail?.url ?? ""; var imageUrl = thumbnailUrl.EndsWith(".gif") ? thumbnailUrl : CImageUtils.SuitableSizeImageUrl(imageWidth: imageWidth, imageUrl: thumbnailUrl); var card = new Container( color: CColors.White, padding: EdgeInsets.only(top: 16), child: new Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Container( padding: EdgeInsets.symmetric(horizontal: 16), child: new Text( data: this.article.title, style: CTextStyle.H5, maxLines: 2, textAlign: TextAlign.left, overflow: TextOverflow.ellipsis ) ), new Container( margin: EdgeInsets.only(top: 8, bottom: 8), padding: EdgeInsets.symmetric(horizontal: 16), child: new Row( children: new List <Widget> { new Expanded( child: new Container( height: imageHeight, child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Text( data: this.article.subTitle, style: CTextStyle.PRegularBody2, maxLines: 3, overflow: TextOverflow.ellipsis ) } ) ) ), new Container( margin: EdgeInsets.only(8.0f), child: new PlaceholderImage( imageUrl: imageUrl, width: imageWidth, height: imageHeight, borderRadius: borderRadius, fit: BoxFit.cover, true ) ) } ) ), new Container( height: 36, child: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Expanded( child: new Container( height: 20, padding: EdgeInsets.only(16), alignment: Alignment.topLeft, child: new ArticleCardInfo( fullName: this.fullName, time: time, viewCount: this.article.viewCount ) ) ), new CustomButton( padding: EdgeInsets.only(16, right: 16, bottom: 16), child: new Icon( icon: Icons.ellipsis, size: 20, color: CColors.BrownGrey ), onPressed: this.moreCallBack ) } ) ) } ) ); return(new GestureDetector( child: card, onTap: this.onTap )); }
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 _buildUserContent(BuildContext context) { var articleIds = this.widget.viewModel.user.articleIds; var favoriteIds = this.widget.viewModel.favoriteTagIdDict.ContainsKey(key: this.widget.viewModel.user.id) ? this.widget.viewModel.favoriteTagIdDict[key : this.widget.viewModel.user.id] : null; var articlesHasMore = this.widget.viewModel.user.articlesHasMore ?? false; var userFavoriteHasMore = this.widget.viewModel.userFavoriteHasMore; var userArticleLoading = this.widget.viewModel.userArticleLoading && articleIds == null; var userFavoriteLoading = this.widget.viewModel.userFavoriteLoading && favoriteIds == null; int itemCount; if (userArticleLoading && this._selectedIndex == 0) { itemCount = 3; } else if (userFavoriteLoading && this._selectedIndex == 1) { itemCount = 3; } else { if (articleIds == null && this._selectedIndex == 0) { itemCount = 3; } else if (favoriteIds == null && this._selectedIndex == 1) { itemCount = 3; } else { if (this._selectedIndex == 0) { var articleCount = articlesHasMore ? articleIds.Count : articleIds.Count + 1; itemCount = 2 + (articleIds.Count == 0 ? 1 : articleCount); } else { var favoriteCount = userFavoriteHasMore ? favoriteIds.Count : favoriteIds.Count + 1; itemCount = 2 + (favoriteIds.Count == 0 ? 1 : favoriteCount); } } } var headerHeight = imageBaseHeight + 44 + CCommonUtils.getSafeAreaTopPadding(context: context); return(new Container( color: CColors.Background, child: new CustomScrollbar( new SmartRefresher( controller: this._refreshController, enablePullDown: false, enablePullUp: this._selectedIndex == 0 ? articlesHasMore : userFavoriteHasMore, onRefresh: this._onRefresh, onNotification: this._onNotification, child: ListView.builder( physics: new AlwaysScrollableScrollPhysics(), itemCount: itemCount, itemBuilder: (cxt, index) => { if (index == 0) { return Transform.scale( scale: this._factor, child: this._buildUserInfo(context) ); } if (index == 1) { return this._buildUserArticleTitle(); } if (userArticleLoading && index == 2 && this._selectedIndex == 0) { var height = MediaQuery.of(context: context).size.height - headerHeight; return new Container( height: height, child: new GlobalLoading() ); } if (userFavoriteLoading && index == 2 && this._selectedIndex == 1) { var height = MediaQuery.of(context: context).size.height - headerHeight; return new Container( height: height, child: new GlobalLoading() ); } if ((articleIds == null || articleIds.Count == 0) && index == 2 && this._selectedIndex == 0) { var height = MediaQuery.of(context: context).size.height - headerHeight; return new Container( height: height, child: new BlankView( "哎呀,暂无已发布的文章", "image/default-article" ) ); } if ((favoriteIds == null || favoriteIds.Count == 0) && index == 2 && this._selectedIndex == 1) { var height = MediaQuery.of(context: context).size.height - headerHeight; return new Container( height: height, child: new BlankView( "哎呀,暂无已收藏的文章", "image/default-article" ) ); } if (index == itemCount - 1 && !articlesHasMore && this._selectedIndex == 0) { return new EndView(); } if (index == itemCount - 1 && !userFavoriteHasMore && this._selectedIndex == 1) { return new EndView(); } if (this._selectedIndex == 1) { var favoriteId = favoriteIds[index - 2]; return this._buildFavoriteCard(favoriteId: favoriteId); } var articleId = articleIds[index - 2]; if (!this.widget.viewModel.articleDict.ContainsKey(key: articleId)) { return new Container(); } var article = this.widget.viewModel.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 new ArticleCard( article: article, () => this.widget.actionModel.pushToArticleDetail(obj: article.id), () => ShareManager.showArticleShareView( this.widget.viewModel.currentUserId != article.userId, isLoggedIn: this.widget.viewModel.isLoggedIn, () => { Clipboard.setData(new ClipboardData(text: linkUrl)); CustomDialogUtils.showToast("复制链接成功", Icons.check_circle_outline); }, () => this.widget.actionModel.pushToLogin(), () => this.widget.actionModel.pushToBlock(article.id), () => this.widget.actionModel.pushToReport(article.id, ReportType.article), type => { CustomDialogUtils.showCustomDialog( child: new CustomLoadingDialog() ); string imageUrl = CImageUtils.SizeTo200ImageUrl(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()); }, () => this.widget.actionModel.mainRouterPop() ), fullName, key: new ObjectKey(value: article.id) ); } ) ) ) )); }
public override Widget build(BuildContext context) { if (this.images.isNullOrEmpty()) { return(new Container()); } Widget firstImage; if (this.images.Count > 0) { firstImage = new PlaceholderImage( CImageUtils.SuitableSizeImageUrl( imageWidth: MediaQuery.of(context: context).size.width, this.images[0] ), this.size + this.ratioGap * 2, this.size + this.ratioGap * 2, 6, fit: BoxFit.cover, true, CColorUtils.GetSpecificDarkColorFromId(this.images[0]) ); } else { firstImage = new Container(); } Widget secondImage; if (this.images.Count > 1) { secondImage = this.onlyShowFirst ? (Widget) new Container( width: this.size + this.ratioGap * 2, height: this.size + this.ratioGap * 2, decoration: new BoxDecoration(borderRadius: BorderRadius.all(6), color: Color.fromRGBO(207, 213, 219, 1)) ) : new PlaceholderImage( CImageUtils.SuitableSizeImageUrl( imageWidth: MediaQuery.of(context: context).size.width, this.images[1] ), this.size + this.ratioGap, this.size + this.ratioGap, 6, fit: BoxFit.cover, true, CColorUtils.GetSpecificDarkColorFromId(this.images[1]) ); } else { secondImage = new Container(); } Widget thirdImage; if (this.images.Count > 2) { thirdImage = this.onlyShowFirst ? (Widget) new Container( width: this.size + this.ratioGap * 2, height: this.size + this.ratioGap * 2, decoration: new BoxDecoration(borderRadius: BorderRadius.all(6), color: Color.fromRGBO(137, 150, 165, 1)) ) : new PlaceholderImage( CImageUtils.SuitableSizeImageUrl( imageWidth: MediaQuery.of(context: context).size.width, this.images[2] ), width: this.size, height: this.size, 6, fit: BoxFit.cover, true, CColorUtils.GetSpecificDarkColorFromId(this.images[2]) ); } else { thirdImage = new Container(); } return(new Container( width: this.size + this.ratioGap * 2 + this.horizontalGap * (this.images.Count - 1), height: this.size + this.ratioGap * 2 + this.verticalGap * (this.images.Count - 1), child: new Stack( children: new List <Widget> { new Positioned( right: 0, bottom: 0, child: thirdImage ), new Positioned( right: this.horizontalGap, bottom: this.verticalGap, child: secondImage ), new Positioned( left: 0, top: 0, child: firstImage ) } ) )); }
static Widget _Atomic(BuildContext context, string type, string contentType, string title, _OriginalImage originalImage, string url, string downloadUrl, Action <string> openUrl, Action <string> playVideo, Action browserImage = null) { if (type == "ATTACHMENT" && contentType != "video/mp4") { return(new Container()); } var playButton = Positioned.fill( new Container() ); if (type == "VIDEO" || type == "ATTACHMENT") { playButton = Positioned.fill( new Center( child: new CustomButton( onPressed: () => { if (type == "ATTACHMENT") { playVideo($"{downloadUrl}?noLoginRequired=true"); } else { if (url == null || url.Length <= 0) { return; } openUrl(url); } }, child: new Container( width: 60, height: 60, decoration: new BoxDecoration( CColors.H5White, borderRadius: BorderRadius.all(30) ), child: new Icon( Icons.play_arrow, size: 45, color: CColors.Icon ) ) ) ) ); } var attachWidth = MediaQuery.of(context).size.width - 32; var attachHeight = attachWidth * 9 / 16; if (type == "ATTACHMENT") { return(new Container( color: CColors.White, padding: EdgeInsets.only(bottom: 32), alignment: Alignment.center, child: new Container( padding: EdgeInsets.only(16, right: 16), child: new Column( children: new List <Widget> { new Stack( children: new List <Widget> { new Container( width: attachWidth, height: attachHeight, color: CColors.Black ), playButton } ) } ) ) )); } var width = originalImage.width < MediaQuery.of(context).size.width - 32 ? originalImage.width : MediaQuery.of(context).size.width - 32; var height = width * originalImage.height / originalImage.width; var imageUrl = originalImage.url; if (imageUrl.isNotEmpty()) { imageUrl = imageUrl.EndsWith(".gif") || imageUrl.EndsWith(".png") ? imageUrl : CImageUtils.SuitableSizeImageUrl(MediaQuery.of(context).size.width, imageUrl); } var nodes = new List <Widget> { new Stack( children: new List <Widget> { new GestureDetector( child: new PlaceholderImage( imageUrl, width, height, fit: BoxFit.cover ), onTap: () => { if (browserImage != null) { browserImage(); } }), playButton } ) }; if (title != null) { var imageTitle = new Container( decoration: new BoxDecoration( border: new Border( bottom: new BorderSide( CColors.Separator, 2 ) ) ), child: new Container( margin: EdgeInsets.only(4, 8, 4, 4), child: new Text( title, style: CTextStyle.PRegularBody4 ) ) ); nodes.Add(imageTitle); } return(new Container( color: CColors.White, padding: EdgeInsets.only(bottom: 32), alignment: Alignment.center, child: new Container( padding: EdgeInsets.only(16, right: 16), child: new Column( children: nodes ) ) )); }
static Widget _Atomic(BuildContext context, string type, string contentType, string title, string dataUrl, _OriginalImage originalImage, string videoStatus, string videoPoster, string url, string downloadUrl, string attachmentId, Action <string> openUrl, Action <string, bool, int> playVideo, Action loginAction, bool needUpdate, int limitSeconds, Action <string> browserImage = null) { if (type == "ATTACHMENT" && contentType != "video/mp4") { return(new Container()); } var playButton = Positioned.fill( new Container() ); if (type == "VIDEO" || type == "ATTACHMENT") { playButton = Positioned.fill( new Center( child: videoStatus == "completed" ? UserInfoManager.isLogin() ? new CustomButton( onPressed: () => { if (type == "ATTACHMENT") { if (url.isEmpty()) { playVideo(downloadUrl, false, 0); } else { playVideo($"{Config.apiAddress}/playlist/{attachmentId}", needUpdate, limitSeconds); } } else { if (url == null || url.Length <= 0) { return; } openUrl(url); } }, child: new Container( width: 60, height: 60, decoration: new BoxDecoration( CColors.H5White, borderRadius: BorderRadius.all(30) ), child: new Icon( Icons.play_arrow, size: 45, color: CColors.Icon ) ) ) : (Widget) new GestureDetector( onTap: () => { loginAction(); }, child: new Container( color: CColors.Black.withOpacity(0.5f), alignment: Alignment.center, child: new Text("Login to view this video", style: CTextStyle.PXLargeWhite.merge( new TextStyle(decoration: TextDecoration.underline))) )) : new Container( color: CColors.Black.withOpacity(0.5f), alignment: Alignment.center, child: new Text("Video is processing, try it later", style: CTextStyle.PXLargeWhite) ) ) ); } var attachWidth = MediaQuery.of(context).size.width - 32; var attachHeight = attachWidth * 9 / 16; if (type == "ATTACHMENT") { return(new Container( color: CColors.White, padding: EdgeInsets.only(bottom: 32), alignment: Alignment.center, child: new Container( padding: EdgeInsets.only(16, right: 16), child: new Column( children: new List <Widget> { new Stack( children: new List <Widget> { new Container( width: attachWidth, height: attachHeight, color: CColors.Black, child: Image.network( videoPoster, fit: BoxFit.cover ) ), playButton } ) } ) ) )); } var width = originalImage.width < MediaQuery.of(context).size.width - 32 ? originalImage.width : MediaQuery.of(context).size.width - 32; var height = width * originalImage.height / originalImage.width; var imageUrl = originalImage.url; if (imageUrl.isNotEmpty()) { imageUrl = imageUrl.EndsWith(".gif") || imageUrl.EndsWith(".png") ? imageUrl : CImageUtils.SuitableSizeImageUrl(MediaQuery.of(context).size.width, imageUrl); imageUrls.Add(imageUrl); } var nodes = new List <Widget> { new Stack( children: new List <Widget> { new GestureDetector( child: new Hero( tag: imageUrl, child: new PlaceholderImage( imageUrl: imageUrl, width: width, height: height, fit: BoxFit.cover, useCachedNetworkImage: true ) ), onTap: () => { if (dataUrl.isNotEmpty()) { openUrl(obj: dataUrl); } else { browserImage?.Invoke(imageUrl); } } ), playButton } ) }; if (title != null) { var imageTitle = new Container( decoration: new BoxDecoration( border: new Border( bottom: new BorderSide( CColors.Separator, 2 ) ) ), child: new Container( margin: EdgeInsets.only(4, 8, 4, 4), child: new Text( title, style: CTextStyle.PRegularBody4 ) ) ); nodes.Add(imageTitle); } return(new Container( color: CColors.White, padding: EdgeInsets.only(bottom: 32), alignment: Alignment.center, child: new Container( padding: EdgeInsets.only(16, right: 16), child: new Column( children: nodes ) ) )); }
public override Widget build(BuildContext context) { if (this.team == null) { return(new Container()); } return(new GestureDetector( onTap: this.onTap, child: new Container( padding: EdgeInsets.symmetric(horizontal: 16), color: CColors.White, height: 72, child: new Row( children: new List <Widget> { new Expanded( child: new Row( children: new List <Widget> { Avatar.Team(team: this.team, 48), new Expanded( child: new Container( margin: EdgeInsets.only(12, right: 16), child: new Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Row( children: new List <Widget> { new Flexible( child: new Text( data: this.team.name, style: new TextStyle( height: 1, fontSize: this.isSearchCard ? 16 : 14, fontFamily: "Roboto-Medium", color: CColors.TextBody ), maxLines: 1, overflow: TextOverflow.ellipsis ) ), CImageUtils.GenBadgeImage( badges: this.team.badges, null, EdgeInsets.only(4) ) } ) } ) ) ) } ) ), new FollowButton( userType: this.userType, onFollow: this.onFollow ) } ) ) )); }