-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
now categories cant be clicked and look like categories
- Loading branch information
Showing
6 changed files
with
157 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Avalonia.Data.Converters; | ||
using System.Globalization; | ||
|
||
namespace Turbulence.Desktop.Converters; | ||
|
||
public class ObjectEqualsMultiConverter : IMultiValueConverter | ||
{ | ||
public object? Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
if (values.Count == 0) | ||
return true; | ||
|
||
var val = values[0]; | ||
foreach (var item in values.Skip(1)) | ||
{ | ||
if (val != item) | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
Turbulence.Desktop/DataTemplates/ChannelTypeTemplateSelector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Avalonia.Controls.Templates; | ||
using Avalonia.Controls; | ||
using Avalonia.Metadata; | ||
using Turbulence.Discord.Models.DiscordChannel; | ||
|
||
namespace Turbulence.Desktop.DataTemplates; | ||
|
||
public class ChannelTypeTemplateSelector : IDataTemplate | ||
{ | ||
[Content] | ||
public Dictionary<string, IDataTemplate> Templates { get; } = new Dictionary<string, IDataTemplate>(); | ||
|
||
public bool Match(object? data) => data is Channel; | ||
|
||
Control? ITemplate<object?, Control?>.Build(object? param) | ||
{ | ||
var channel = (Channel)param!; | ||
if (!Templates.TryGetValue(channel.Type.ToString(), out var template)) | ||
return Templates["unknown"].Build(param); | ||
return template.Build(param); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters