Move Joined to Channel

This commit is contained in:
DrabWeb 2017-05-20 19:37:11 -03:00
parent 3cc51006cc
commit 7eba619f80
3 changed files with 17 additions and 16 deletions

View File

@ -23,9 +23,9 @@ public class Channel
[JsonProperty(@"channel_id")]
public int Id;
public readonly SortedList<Message> Messages = new SortedList<Message>((m1, m2) => m1.Id.CompareTo(m2.Id));
public bool Joined;
//internal bool Joined;
public readonly SortedList<Message> Messages = new SortedList<Message>((m1, m2) => m1.Id.CompareTo(m2.Id));
public bool ReadOnly => Name != "#lazer";

View File

@ -21,25 +21,28 @@ public class ChannelListItem : ClickableContainer
private const float transition_duration = 100;
private readonly OsuSpriteText topic;
private readonly OsuSpriteText name;
private readonly TextAwesome joinedCheckmark;
private Color4? joinedColour;
private Color4? topicColour;
private bool joined;
public bool Joined
private Channel channel;
public Channel Channel
{
get { return joined; }
get { return channel; }
set
{
if (value == joined) return;
joined = value;
if (value == channel) return;
channel = value;
name.Text = Channel.ToString();
topic.Text = Channel.Topic;
updateColour();
}
}
public ChannelListItem(Channel channel)
public ChannelListItem()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
@ -74,9 +77,8 @@ public ChannelListItem(Channel channel)
AutoSizeAxes = Axes.Y,
Children = new[]
{
new OsuSpriteText
name = new OsuSpriteText
{
Text = channel.ToString(),
TextSize = text_size,
Font = @"Exo2.0-Bold",
},
@ -91,7 +93,6 @@ public ChannelListItem(Channel channel)
{
topic = new OsuSpriteText
{
Text = channel.Topic,
TextSize = text_size,
Font = @"Exo2.0-SemiBold",
Alpha = 0.8f,
@ -136,10 +137,10 @@ private void load(OsuColour colours)
private void updateColour()
{
joinedCheckmark.FadeTo(joined ? 1f : 0f, transition_duration);
topic.FadeTo(joined ? 0.8f : 1f, transition_duration);
topic.FadeColour(joined ? Color4.White : topicColour ?? Color4.White, transition_duration);
FadeColour(joined ? joinedColour ?? Color4.White : Color4.White, transition_duration);
joinedCheckmark.FadeTo(Channel.Joined ? 1f : 0f, transition_duration);
topic.FadeTo(Channel.Joined ? 0.8f : 1f, transition_duration);
topic.FadeColour(Channel.Joined ? Color4.White : topicColour ?? Color4.White, transition_duration);
FadeColour(Channel.Joined ? joinedColour ?? Color4.White : Color4.White, transition_duration);
}
}
}

View File

@ -28,7 +28,7 @@ public IEnumerable<Channel> Channels
{
set
{
items.Children = value.Select(c => new ChannelListItem(c));
items.Children = value.Select(c => new ChannelListItem { Channel = c });
}
}