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) ) ) } ) ) } ) )); }
public override Widget build(BuildContext context) { Widget title = new Text( this.channel.name ?? "", style: CTextStyle.PLargeMedium, maxLines: 1, overflow: TextOverflow.ellipsis ); Widget body = new Container( padding: EdgeInsets.symmetric(0, 16), child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { this.channel.live ? new Row( children: new List <Widget> { new Icon(icon: Icons.whatshot, color: CColors.Error, size: 18), new Container(width: 7), new Expanded(child: title) } ) : title, new Text( $"{this.channel.memberCount}成员", style: CTextStyle.PRegularBody4 ) } ) ); return(new GestureDetector( onTap: this.onTap, child: new Container( color: CColors.White, height: 72, padding: EdgeInsets.symmetric(12, 16), child: new Row( children: new List <Widget> { new PlaceholderImage( this.channel?.thumbnail ?? "", 48, 48, 4, fit: BoxFit.cover, true, CColorUtils.GetSpecificDarkColorFromId(id: this.channel?.id) ), new Expanded(child: body), this._buildJoinButton() } ) ) )); }
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 ) )); }
public override Widget build(BuildContext context) { return(this.size == null || (this.widget.url == null && this.widget.data == null) ? new Container( width: this.widget.size, height: this.widget.size, decoration: new BoxDecoration( CColorUtils.GetSpecificDarkColorFromId(id: this.widget.id), borderRadius: BorderRadius.all(this.widget.radius) )) : (Widget) new ClipRRect( borderRadius: BorderRadius.all(this.widget.radius), child: new Container( width: this.size.width, height: this.size.height, color: CColorUtils.GetSpecificDarkColorFromId(id: this.widget.id), child: this._getImage()) )); }
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 = CImageUtils.SuitableSizeImageUrl(imageWidth: imageWidth, imageUrl: thumbnailUrl); // 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, CColorUtils.GetSpecificDarkColorFromId(id: this.article.id) ) ) } ) ), 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 _buildBlogger(User user, string resetTitle) { UserType userType = UserType.unFollow; if (!this.isLoggedIn) { userType = UserType.unFollow; } else { if (UserInfoManager.getUserInfo().userId == user.id) { userType = UserType.me; } else if (user.followUserLoading ?? false) { userType = UserType.loading; } else if (this.followMap.ContainsKey(key: user.id)) { userType = UserType.follow; } } return(new GestureDetector( onTap: () => this.onPressItem?.Invoke(text: user.id), child: new Container( width: 160, margin: EdgeInsets.only(right: 16), decoration: new BoxDecoration( color: CColors.White, borderRadius: BorderRadius.all(6) ), child: new ClipRRect( borderRadius: BorderRadius.all(6), child: new Column( children: new List <Widget> { new Container( height: 88, color: CColorUtils.GetSpecificDarkColorFromId(id: user.id), child: new Stack( fit: StackFit.expand, children: new List <Widget> { Image.asset( "image/blogger-avatar-pattern", fit: BoxFit.fill ), Positioned.fill( new Center( child: Avatar.User(user: user, 64, true) ) ) } ) ), new Padding( padding: EdgeInsets.only(16, 16, 16, 4), child: new Text(data: user.fullName, style: CTextStyle.PXLargeMedium, maxLines: 1) ), new Text( $"粉丝{user.followCount ?? 0} • 文章{user.articleCount ?? 0}", style: CTextStyle.PSmallBody4 ), new Text(resetTitle ?? "", style: CTextStyle.PSmallBody4), new Padding( padding: EdgeInsets.only(top: 12), child: new FollowButton( userType: userType, () => this._onFollow(userType: userType, userId: user.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 ) } ) )); }
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 time = Convert.ToDateTime(value: 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, padding: EdgeInsets.all(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.Error ) ), 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, color: CColorUtils.GetSpecificDarkColorFromId(id: this.model.id) ), new Positioned( bottom: 0, right: 0, child: new ClipRRect( borderRadius: BorderRadius.only(4, bottomRight: 4), child: new Container( width: 41, height: 24, decoration: new BoxDecoration( gradient: new LinearGradient( begin: Alignment.centerLeft, end: Alignment.centerRight, this.model.mode == "online" ? new List <Color> { Color.fromARGB(255, 250, 120, 102), CColors.SecondaryPink } : new List <Color> { Color.fromARGB(255, 69, 199, 250), 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 )); }
public override Widget build(BuildContext context) { if (this.game == null) { return(new Container()); } var imageUrl = this.game.attachmentURLs.FirstOrDefault(); return(new GestureDetector( onTap: () => this.onTap?.Invoke(), child: new Container( padding: EdgeInsets.only(16, 16, 16, 0), child: new AspectRatio( aspectRatio: 4f / 3, child: new Container( decoration: new BoxDecoration( CColorUtils.GetSpecificDarkColorFromId(id: this.game.id), new DecorationImage( new CachedNetworkImageProvider(url: imageUrl), fit: BoxFit.cover ), borderRadius: BorderRadius.circular(8) ), child: new Container( margin: EdgeInsets.only(top: 87), decoration: new BoxDecoration( gradient: new LinearGradient( colors: new List <Color> { Color.fromRGBO(0, 0, 0, 0), Color.fromRGBO(0, 0, 0, 0.6f) }, begin: Alignment.topCenter, end: Alignment.bottomCenter ), borderRadius: BorderRadius.circular(8) ), child: new Container( padding: EdgeInsets.only(16, 0, 16, 16), child: new Column( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Text( data: this.game.resetTitle, maxLines: 1, style: CTextStyle.H2White.defaultHeight() ), new SizedBox(height: 8), new Text( data: this.game.resetSubLabel, maxLines: 1, style: CTextStyle.PLargeWhite.defaultHeight() ) } ) ) ) ) ) ) )); }
public override Widget build(BuildContext context) { string text; if (this.channel.lastMessage != null) { if (this.channel.lastMessage.deleted) { text = "[此消息已被删除]"; } else if (this.channel.lastMessage.type == ChannelMessageType.image) { text = "[图片]"; } else if (this.channel.lastMessage.type == ChannelMessageType.file) { text = "[文件]"; } else { text = this.channel.lastMessage.content ?? ""; } } else { text = ""; } var contentTextSpans = new List <TextSpan>(); if (this.channel.lastMessage.author?.fullName.isNotEmpty() ?? text.isNotEmpty() && this.channel.lastMessage.author.id != this.myUserId) { contentTextSpans.Add(new TextSpan( $"{this.channel.lastMessage.author?.fullName}: ", style: CTextStyle.PRegularBody4 )); } contentTextSpans.AddRange(MessageUtils.messageWithMarkdownToTextSpans( content: text, mentions: this.channel.lastMessage?.mentions, this.channel.lastMessage?.mentionEveryone ?? false, null, bodyStyle: CTextStyle.PRegularBody4, linkStyle: CTextStyle.PRegularBody4 )); Widget message = new RichText( text: new TextSpan( (this.channel.atMe || this.channel.atAll) && this.channel.unread > 0 ? "[有人@我] " : "", style: CTextStyle.PRegularError, children: contentTextSpans ), overflow: TextOverflow.ellipsis, maxLines: 1 ); // Don't show the time if nonce is 0, i.e. the time is not loaded yet. // Otherwise, the time would be like 0001/01/01 8:00 string timeString = this.channel.lastMessage?.nonce != 0 ? this.channel.lastMessage?.time.DateTimeString() ?? "" : ""; Widget titleLine = new Container( padding: EdgeInsets.only(16), child: new Row( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Expanded( child: new Text( data: this.channel.name, style: CTextStyle.PLargeMedium, maxLines: 1, overflow: TextOverflow.ellipsis ) ), new Container(width: 16), new Text( data: timeString, style: CTextStyle.PSmallBody4 ) } ) ); return(new GestureDetector( onTap: this.onTap, child: new Container( color: this.channel.isTop ? CColors.PrimaryBlue.withOpacity(0.04f) : CColors.White, height: 72, padding: EdgeInsets.symmetric(12, 16), child: new Row( children: new List <Widget> { new PlaceholderImage( this.channel?.thumbnail ?? "", 48, 48, 4, fit: BoxFit.cover, true, CColorUtils.GetSpecificDarkColorFromId(id: this.channel?.id) ), new Expanded( child: new Column( children: new List <Widget> { titleLine, new Row( children: new List <Widget> { new Container(width: 16), new Expanded( child: message ), new NotificationDot( this.channel.unread > 0 ? this.channel.mentioned > 0 ? $"{this.channel.mentioned}" : "" : null, margin: EdgeInsets.only(16) ) } ) } ) ) } ) ) )); }
Widget _buildSwiper() { var homeSliderIds = this.widget.viewModel.homeSliderIds; if (homeSliderIds.isNullOrEmpty()) { return(new Container()); } Widget swiperContent; if (homeSliderIds.Count == 1) { var homeSliderId = homeSliderIds[0]; var imageUrl = this.widget.viewModel.rankDict.ContainsKey(key: homeSliderId) ? this.widget.viewModel.rankDict[key : homeSliderId].image : ""; swiperContent = new GestureDetector( onTap: () => { var redirectURL = this.widget.viewModel.rankDict.ContainsKey(key: homeSliderId) ? this.widget.viewModel.rankDict[key: homeSliderId].redirectURL : ""; if (redirectURL.isNotEmpty()) { this.widget.actionModel.openUrl(obj: redirectURL); } }, child: new PlaceholderImage( imageUrl: imageUrl, fit: BoxFit.fill, useCachedNetworkImage: true, color: CColorUtils.GetSpecificDarkColorFromId(id: homeSliderId) ) ); } else { swiperContent = new Swiper( (cxt, index) => { var homeSliderId = homeSliderIds[index: index]; var imageUrl = this.widget.viewModel.rankDict.ContainsKey(key: homeSliderId) ? this.widget.viewModel.rankDict[key: homeSliderId].image : ""; return(new PlaceholderImage( CImageUtils.SizeToScreenImageUrl(imageUrl: imageUrl), fit: BoxFit.fill, useCachedNetworkImage: true, color: CColorUtils.GetSpecificDarkColorFromId(id: homeSliderId) )); }, itemCount: homeSliderIds.Count, autoplay: true, onTap: index => { var homeSliderId = homeSliderIds[index: index]; var redirectURL = this.widget.viewModel.rankDict.ContainsKey(key: homeSliderId) ? this.widget.viewModel.rankDict[key: homeSliderId].redirectURL : ""; if (redirectURL.isNotEmpty()) { this.widget.actionModel.openUrl(obj: redirectURL); } }, pagination: new SwiperPagination(margin: EdgeInsets.only(bottom: 5)) ); } return(new Container( padding: EdgeInsets.only(top: 8, left: 16, right: 16), decoration: new BoxDecoration( borderRadius: BorderRadius.all(8), color: CColors.White ), child: new AspectRatio( aspectRatio: 3, child: new ClipRRect( borderRadius: BorderRadius.all(8), child: swiperContent ) ) )); }