Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

Commit 4d1d9c5

Browse files
authored
Feature/misc UI tweaks and refactorings (#3)
* feat: add AppSettings model and database migration for application settings * feat: implement file deletion functionality with UI for pending deletions
1 parent 9c2f5d3 commit 4d1d9c5

14 files changed

Lines changed: 764 additions & 33 deletions

src/AStar.Dev.File.App/App.axaml.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ public partial class App : Application
1616
{
1717
private IServiceProvider? _services;
1818

19+
public IServiceProvider? Services => _services;
20+
21+
public T? GetService<T>() where T : class => _services?.GetService(typeof(T)) as T;
22+
1923
public override void Initialize()
2024
{
2125
AvaloniaXamlLoader.Load(this);
@@ -56,8 +60,10 @@ private static IServiceProvider BuildServices()
5660

5761
services.AddSingleton<IFileTypeClassifier, FileTypeClassifier>();
5862
services.AddSingleton<IFolderPickerService, FolderPickerService>();
63+
services.AddSingleton<IFileDeleteService, FileDeleteService>();
5964
services.AddTransient<IFileScannerService, FileScannerService>();
6065
services.AddTransient<MainWindowViewModel>();
66+
services.AddTransient<DeletePendingViewModel>();
6167

6268
return services.BuildServiceProvider();
6369
}

src/AStar.Dev.File.App/Data/FileAppDbContext.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace AStar.Dev.File.App.Data;
66
public class FileAppDbContext(DbContextOptions<FileAppDbContext> options) : DbContext(options)
77
{
88
public DbSet<ScannedFile> ScannedFiles => Set<ScannedFile>();
9+
public DbSet<AppSetting> AppSettings => Set<AppSetting>();
910

1011
protected override void OnModelCreating(ModelBuilder modelBuilder)
1112
{
@@ -19,5 +20,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
1920
entity.Property(e => e.FileType)
2021
.HasConversion<string>();
2122
});
23+
24+
modelBuilder.Entity<AppSetting>(entity =>
25+
{
26+
entity.HasKey(e => e.Id);
27+
entity.HasIndex(e => e.Key).IsUnique();
28+
});
2229
}
2330
}

src/AStar.Dev.File.App/Migrations/20260401200334_AddAppSettings.Designer.cs

Lines changed: 98 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using Microsoft.EntityFrameworkCore.Migrations;
2+
3+
#nullable disable
4+
5+
namespace AStar.Dev.File.App.Migrations
6+
{
7+
/// <inheritdoc />
8+
public partial class AddAppSettings : Migration
9+
{
10+
/// <inheritdoc />
11+
protected override void Up(MigrationBuilder migrationBuilder)
12+
{
13+
migrationBuilder.CreateTable(
14+
name: "AppSettings",
15+
columns: table => new
16+
{
17+
Id = table.Column<int>(type: "INTEGER", nullable: false)
18+
.Annotation("Sqlite:Autoincrement", true),
19+
Key = table.Column<string>(type: "TEXT", nullable: false),
20+
Value = table.Column<string>(type: "TEXT", nullable: false)
21+
},
22+
constraints: table =>
23+
{
24+
table.PrimaryKey("PK_AppSettings", x => x.Id);
25+
});
26+
27+
migrationBuilder.CreateIndex(
28+
name: "IX_AppSettings_Key",
29+
table: "AppSettings",
30+
column: "Key",
31+
unique: true);
32+
}
33+
34+
/// <inheritdoc />
35+
protected override void Down(MigrationBuilder migrationBuilder)
36+
{
37+
migrationBuilder.DropTable(
38+
name: "AppSettings");
39+
}
40+
}
41+
}

src/AStar.Dev.File.App/Migrations/FileAppDbContextModelSnapshot.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,28 @@ protected override void BuildModel(ModelBuilder modelBuilder)
1717
#pragma warning disable 612, 618
1818
modelBuilder.HasAnnotation("ProductVersion", "10.0.4");
1919

20+
modelBuilder.Entity("AStar.Dev.File.App.Models.AppSetting", b =>
21+
{
22+
b.Property<int>("Id")
23+
.ValueGeneratedOnAdd()
24+
.HasColumnType("INTEGER");
25+
26+
b.Property<string>("Key")
27+
.IsRequired()
28+
.HasColumnType("TEXT");
29+
30+
b.Property<string>("Value")
31+
.IsRequired()
32+
.HasColumnType("TEXT");
33+
34+
b.HasKey("Id");
35+
36+
b.HasIndex("Key")
37+
.IsUnique();
38+
39+
b.ToTable("AppSettings");
40+
});
41+
2042
modelBuilder.Entity("AStar.Dev.File.App.Models.ScannedFile", b =>
2143
{
2244
b.Property<int>("Id")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace AStar.Dev.File.App.Models;
2+
3+
public class AppSetting
4+
{
5+
public int Id { get; set; }
6+
7+
public required string Key { get; set; }
8+
9+
public required string Value { get; set; }
10+
}

0 commit comments

Comments
 (0)