public override Widget build(BuildContext context) { var fontSize = (int)Math.Ceiling(this.size * 0.5f); var name = CStringUtils.genAvatarName(name: this.title); if (name.IsLetterOrNumber()) { fontSize = (int)Math.Ceiling(this.size * 0.4f); } return(new Container( width: this.size, height: this.size, alignment: Alignment.center, color: CColorUtils.GetSpecificColorFromId(id: this.id), child: new Container( alignment: Alignment.center, child: new Text( CStringUtils.genAvatarName(name: this.title), textAlign: TextAlign.center, style: new TextStyle( color: CColors.White, height: 1.15f, fontFamily: "Roboto-Medium", fontSize: fontSize ) ) ) )); }
bool Execute(int index, string rgb) { uint value; try { value = Convert.ToUInt32(rgb, 16); } catch (Exception) { PrintError("Wrong color value"); return(false); } CColorCode[] values = (CColorCode[])Enum.GetValues(typeof(CColorCode)); if (index >= 0 && index < values.Length) { Color color = CColorUtils.FromRGB(value); CEditorSkin.SetColor(values[index], color); Print("{0}: {1}", index, CStringUtils.C(values[index].ToString(), values[index])); } else { PrintError("Wrong index"); Execute(); } return(true); }
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() } ) ) )); }
void Execute() { CTag tag = CTag.Find(name); if (tag == null) { tag = new CTag(name); // the tag would be registered } tag.Enabled = enabled; tag.Color = CColorUtils.FromRGBA((uint)color); tag.BackColor = CColorUtils.FromRGBA((uint)color); }
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 ) ) ) } ) ) ) )); }
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 void TestCvarColor() { Color color = CColorUtils.FromRGBA(0x12345678); string colorDefault = string.Format("{0} {1} {2} {3}", color.r, color.g, color.b, color.a); CVar cvar = new CVar("var", color); Assert.IsTrue(cvar.IsColor); Assert.IsTrue(cvar.IsDefault); Assert.AreEqual(colorDefault, cvar.DefaultValue); Assert.AreEqual(color, cvar.ColorValue); Assert.AreEqual(0x12345678, cvar.IntValue); Assert.AreEqual(colorDefault, cvar.Value); Color otherColor = new Color(0.1f, 0.2f, 0.3f, 0.4f); uint otherColorValue = CColorUtils.ToRGBA(ref otherColor); Execute("var 0.1 0.2 0.3 0.4"); Assert.IsFalse(cvar.IsDefault); Assert.AreEqual(otherColor, cvar.ColorValue); Assert.AreEqual(otherColorValue, (uint)cvar.IntValue); Assert.AreEqual("0.1 0.2 0.3 0.4", cvar.Value); otherColorValue = 0x87654321; otherColor = CColorUtils.FromRGBA(0x87654321); Execute("var 0x{0}", otherColorValue.ToString("X")); Assert.IsFalse(cvar.IsDefault); Assert.AreEqual(otherColor, cvar.ColorValue); Assert.AreEqual(otherColorValue, (uint)cvar.IntValue); Assert.AreEqual("0.5294118 0.3960785 0.2627451 0.1294118", cvar.Value); Execute("reset var"); Assert.IsTrue(cvar.IsDefault); Assert.AreEqual(colorDefault, cvar.Value); Assert.AreEqual(color, cvar.ColorValue); Assert.AreEqual(0x12345678, cvar.IntValue); }
protected override Color CreateLevelCritical() { return(CColorUtils.FromRGB(0xbe2323)); }
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() ) } ) ) ) ) ) ) )); }
protected override Color CreateLink() { return(CColorUtils.FromRGB(0x6ba1ff)); }
protected override Color CreateError() { return(CColorUtils.FromRGB(0xbe2323)); }
protected override Color CreatePlain() { return(CColorUtils.FromRGB(0xb8c4d0)); }
protected override Color CreateLink() { return(CColorUtils.FromRGB(0x193562)); }
protected override Color CreateErrorUnknownCommand() { return(CColorUtils.FromRGB(0xe1614e)); }
protected override Color CreateLevelError() { return(CColorUtils.FromRGB(0xff6f5d)); }
protected override Color CreateTableVar() { return(CColorUtils.FromRGB(0xb4c974)); }
protected override Color CreateTableCommandDisabled() { return(CColorUtils.FromRGB(0xb8c4d0)); }
protected override Color CreateTableCommand() { return(CColorUtils.FromRGB(0xffcf85)); }
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.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 )); }
protected override Color CreateLevelWarning() { return(CColorUtils.FromRGB(0xffcf85)); }
protected override Color CreateClear() { return(CColorUtils.FromRGB(0x383838)); }
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 ) } ) )); }
protected override Color CreateLevelInfo() { return(CColorUtils.FromRGB(0xb4c974)); }
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) ) ) } ) ) ) )); }
protected override Color CreateLevelVerbose() { return(CColorUtils.FromRGB(0xb8c4d0)); }
protected override Color CreateLevelDebug() { return(CColorUtils.FromRGB(0xdee4ed)); }
protected override Color CreatePlain() { return(CColorUtils.FromRGB(0x243e57)); }