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
TeamMatesViewModel.cs | |
public readonly SQLiteConnection conn; | |
... | |
public TeamMatesViewModel() | |
{ | |
... | |
conn = new SQLiteConnection($@"{FileSystem.AppDataDirectory}/teammates.db3"); | |
TeamMateSquad = new ObservableCollection<TeamMateItem>(conn.Table<TeamMateItem>().ToList()); | |
} |
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
<CollectionView ItemsSource="{Binding TeamMateSquad}"> | |
<CollectionView.ItemTemplate> | |
<DataTemplate> | |
<in2teamssplitter:NameAndRating Name="{Binding Name, Mode=TwoWay}" Level="{Binding Level}"/> | |
</DataTemplate> | |
</CollectionView.ItemTemplate> | |
</CollectionView> |
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
TeamMateSquad = new ObservableCollection<TeamMateItem>(new List<TeamMateItem>() | |
{ | |
new TeamMateItem() | |
{ | |
Name = "First TeamMate", | |
Level = 0 | |
}, | |
new TeamMateItem() | |
{ | |
Name = "Second TeamMate", |
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
class TeamMateItem : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler PropertyChanged; | |
protected bool SetPropertyValue<T>(ref T field, T value, [CallerMemberName] string propertyName = null) | |
{ | |
if (Equals(field, value)) return false; | |
field = value; | |
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
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
<Grid.ColumnDefinitions> | |
<ColumnDefinition /> | |
<ColumnDefinition Width="50" /> | |
<ColumnDefinition Width="50" /> | |
<ColumnDefinition Width="50" /> | |
</Grid.ColumnDefinitions> | |
<Entry Grid.Column="0" Text="{Binding Name, Source={x:Reference _nameAndRate}}" HorizontalOptions="FillAndExpand" /> | |
<ffsvg:SvgCachedImage Grid.Column="1" Source="{Binding Level, Source={x:Reference _nameAndRate}, Converter={StaticResource SVGStatusConverter}, ConverterParameter = 1}" /> | |
<ffsvg:SvgCachedImage Grid.Column="2" Source="{Binding Level, Source={x:Reference _nameAndRate}, Converter={StaticResource SVGStatusConverter}, ConverterParameter = 2}" /> | |
<ffsvg:SvgCachedImage Grid.Column="3" Source="{Binding Level, Source={x:Reference _nameAndRate}, Converter={StaticResource SVGStatusConverter}, ConverterParameter = 3}" /> |
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
public static readonly BindableProperty LevelProperty = BindableProperty.Create(nameof(Level), typeof(int), typeof(NameAndRating), defaultBindingMode: BindingMode.TwoWay); | |
public int Level | |
{ | |
get => (int)GetValue(LevelProperty); | |
set => SetValue(LevelProperty, value); | |
} |
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
public class SVGPathConverter : IValueConverter | |
{ | |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => GetSVGName((int)(value ?? 0), int.Parse(parameter as string ?? "0")); | |
string GetSVGName(int status, int parameter) | |
{ | |
if (status >= parameter) | |
return "resource://In2TeamsSplitter.Resources.starFilled.svg"; | |
else | |
return "resource://In2TeamsSplitter.Resources.starEmpty.svg"; |
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
Forms.SetFlags("CollectionView_Experimental"); |
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
<?xml version="1.0" encoding="utf-8" ?> | |
<Grid xmlns="http://xamarin.com/schemas/2014/forms" | |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | |
xmlns:d="http://xamarin.com/schemas/2014/forms/design" | |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
mc:Ignorable="d" | |
x:Name="_nameAndRate" | |
x:Class="In2TeamsSplitter.NameAndRating"> | |
<Entry Text="{Binding Name, Source={x:Reference _nameAndRate}}" HorizontalOptions="FillAndExpand" /> | |
</Grid> |
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
[XamlCompilation(XamlCompilationOptions.Compile)] | |
public partial class NameAndRating : Grid | |
{ | |
public NameAndRating() | |
{ | |
InitializeComponent(); | |
} | |
public static readonly BindableProperty NameProperty = BindableProperty.Create(nameof(Name), typeof(string), typeof(NameAndRating), defaultBindingMode: BindingMode.TwoWay); |