Skip to content

Commit

Permalink
Update todolist
Browse files Browse the repository at this point in the history
  • Loading branch information
dogzz9445 committed Jul 12, 2024
1 parent 3328a21 commit c8950a7
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="8.0.6" />
<PackageReference Include="NuGet.Protocol" Version="6.10.0" />
<PackageReference Include="Usa.Smart.Navigation.Windows" Version="2.6.0" />
<PackageReference Include="WPF-UI" Version="3.0.4" />
<PackageReference Include="WPF-UI.Tray" Version="3.0.4" />
Expand Down
5 changes: 3 additions & 2 deletions src/Apps/Corathing.Organizer/Corathing.Organizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NuGet.Packaging" Version="6.10.0" />
<PackageReference Include="NuGet.Protocol" Version="6.10.0" />
<PackageReference Include="NuGet.Packaging" Version="6.10.1" />
<PackageReference Include="NuGet.Protocol" Version="6.10.1" />
<PackageReference Include="Supabase" Version="1.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
34 changes: 34 additions & 0 deletions src/Apps/Corathing.Organizer/Supabases/SupabaseAuthManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Supabase;
using Supabase.Interfaces;

namespace Corathing.Organizer.Supabases;

public class SupabaseAuthManager
{
public Supabase.Client Client { get; private set; }

public SupabaseAuthManager(IServiceProvider services)
{

}

public async Task InitializeAsync()
{
var url = Environment.GetEnvironmentVariable("SUPABASE_URL");
var key = Environment.GetEnvironmentVariable("SUPABASE_KEY");

var options = new Supabase.SupabaseOptions
{
AutoConnectRealtime = true
};

var supabase = new Supabase.Client(url, key, options);
await supabase.InitializeAsync();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,21 @@ namespace Corathing.Widgets.Basics.Widgets.ToDoLists.Models;

public partial class Job : ObservableObject
{
[ObservableProperty]
private JobType _jobType;
}

public partial class AddingJob : Job
{
}

public enum JobType
{
Normal,
IsCompleted,
Placeholder
}

public partial class ToDoJob : Job
{
[DefaultValue(false)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,19 @@
BorderBrush="{DynamicResource TextControlForegroundDisabled}" />
</Grid>
</DataTemplate>

</UserControl.Resources>
<Grid>
<ListBox x:Name="ToDoListBox"
<ListView BorderThickness="0"
Background="Transparent"
ItemsSource="{Binding GroupedJobs}"
ItemTemplateSelector="{StaticResource JobTemplateSelector}">

</ListView>
<!--<ListBox x:Name="ToDoListBox"
BorderThickness="0"
Background="Transparent"
ItemsSource="{Binding Jobs}"
ItemTemplateSelector="{StaticResource JobTemplateSelector}" />

ItemsSource="{Binding GroupedJobs}"
ItemTemplateSelector="{StaticResource JobTemplateSelector}" />-->
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using Corathing.Contracts.Services;
using Corathing.Widgets.Basics.Widgets.Timers;
using Corathing.Widgets.Basics.Widgets.ToDoLists.Models;
using CommunityToolkit.Mvvm.Collections;

namespace Corathing.Widgets.Basics.Widgets.ToDoLists;

Expand All @@ -38,20 +39,19 @@ namespace Corathing.Widgets.Basics.Widgets.ToDoLists;
)]
public partial class ToDoListViewModel : WidgetContext
{
private ObservableCollection<Job> _jobs;
public ObservableCollection<Job> Jobs
private ObservableGroupedCollection<JobType, Job>? _groupedJobs;
public ObservableGroupedCollection<JobType, Job>? GroupedJobs
{
get => _jobs;
get => _groupedJobs;
set
{

if (EqualityComparer<ObservableCollection<Job>?>.Default.Equals(_jobs, value))
if (EqualityComparer<ObservableGroupedCollection<JobType, Job>?>.Default.Equals(_groupedJobs, value))
return;
OnPropertyChanging(nameof(Jobs));
_jobs = value;
var itemsView = (IEditableCollectionView)CollectionViewSource.GetDefaultView(_jobs);
OnPropertyChanging(nameof(GroupedJobs));
_groupedJobs = value;
var itemsView = (IEditableCollectionView)CollectionViewSource.GetDefaultView(_groupedJobs);
itemsView.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtEnd;
OnPropertyChanged(nameof(Jobs));
OnPropertyChanged(nameof(GroupedJobs));
}
}

Expand All @@ -60,19 +60,31 @@ public override void OnCreate(IServiceProvider services, WidgetState state)
ILocalizationService localizationService = _services.GetService<ILocalizationService>();
localizationService.Provide("Corathing.Widgets.Basics.ToDoListName", value => WidgetTitle = value);

Jobs = new ObservableCollection<Job>();
GroupedJobs = new ObservableGroupedCollection<JobType, Job>();
}

[RelayCommand]
public void AddNewJob()
{
Jobs.Add(new ToDoJob());
GroupedJobs?.AddItem(JobType.Normal, new ToDoJob());
}

[RelayCommand]
public void RemoveJob(ToDoJob job)
{
Jobs.Remove(job);
GroupedJobs?.RemoveItem(job.JobType, job);
}

[RelayCommand]
public void MarkJob(ToDoJob job)
{

}

[RelayCommand]
public void UnmarkJob(ToDoJob job)
{

}
}

Expand Down

0 comments on commit c8950a7

Please sign in to comment.