This commit is contained in:
@@ -21,6 +21,9 @@ namespace AyaNova.Api.Controllers
|
||||
[Authorize]
|
||||
public class ScheduleController : ControllerBase
|
||||
{
|
||||
private const string WHITE_HEXA = "#FFFFFFFF";
|
||||
private const string BLACK_HEXA = "#000000FF";
|
||||
private const string GRAY_NEUTRAL_HEXA = "#CACACAFF";
|
||||
private readonly AyContext ct;
|
||||
private readonly ILogger<ScheduleController> log;
|
||||
private readonly ApiServerState serverState;
|
||||
@@ -183,8 +186,8 @@ namespace AyaNova.Api.Controllers
|
||||
{
|
||||
var s = new PersonalScheduleListItem();
|
||||
s.Id = v.Id;
|
||||
s.Color = p.Dark ? "white" : "black";
|
||||
s.TextColor = TextColor(s.Color);
|
||||
s.Color = p.Dark ? WHITE_HEXA : BLACK_HEXA;
|
||||
s.TextColor = p.Dark ? BLACK_HEXA : WHITE_HEXA;
|
||||
s.Start = (DateTime)v.ReviewDate;
|
||||
s.End = (DateTime)v.ReviewDate.AddMinutes(30);//just something to show in schedule as not supporting all day or unscheduled type stuff
|
||||
s.Type = AyaType.Review;
|
||||
@@ -211,13 +214,16 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
private static string TextColor(string hexcolor)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(hexcolor)) return "black";
|
||||
//Note: we use HEXA format which is 8 hex digits
|
||||
//this here works even though it's considering as 6 digits because in hexA the last two
|
||||
//digits are the opacity which this can ignore
|
||||
if (string.IsNullOrWhiteSpace(hexcolor) || hexcolor.Length < 6) return GRAY_NEUTRAL_HEXA;//gray neutral
|
||||
hexcolor = hexcolor.Replace("#", "");
|
||||
var r = StringUtil.HexToInt(hexcolor.Substring(0, 2));
|
||||
var g = StringUtil.HexToInt(hexcolor.Substring(2, 2));
|
||||
var b = StringUtil.HexToInt(hexcolor.Substring(4, 2));
|
||||
var yiq = (r * 299 + g * 587 + b * 114) / 1000;
|
||||
return yiq >= 128 ? "black" : "white";
|
||||
return yiq >= 128 ? WHITE_HEXA : BLACK_HEXA;
|
||||
}
|
||||
|
||||
private static string NameFromWOItem(ViewSchedulePersonalWorkOrder v, PersonalScheduleParams p)
|
||||
|
||||
Reference in New Issue
Block a user