Skip to content

Commit

Permalink
Merge pull request #17 from nor0x/force-refresh
Browse files Browse the repository at this point in the history
improvements & fixes
  • Loading branch information
nor0x authored Apr 25, 2023
2 parents 24eb572 + 089f809 commit 69e7877
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 16 deletions.
Binary file added Assets/dotsanimation1.webm
Binary file not shown.
Binary file added Assets/logo_empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace Dots;
public class Constants
{
public const string AppName = "Dots";
public const string InstalledSdkSKey = "Installed-Sdks-Key";
public const string InstalledSdkSKey = "installed-sdks-key";
public const string LastCheckedKey = "last-checked";
#if MACCATALYST
public const string UninstallerPath = "Package Cache";
public const string InstallerScript = "https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh";
Expand Down
18 changes: 9 additions & 9 deletions src/Data/ReleaseIndex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public class ReleaseIndex
public Uri ReleasesJson { get; set; }
}

public enum Product { Net, NetCore };
public enum Product { Net, NetCore, Undefined };

public enum ReleaseType { Lts, Sts };
public enum ReleaseType { Lts, Sts, Undefined };

public enum SupportPhase { Active, Eol, Preview };
public enum SupportPhase { Active, Eol, Preview, Undefined };


public class ProductEnumConverter : JsonConverter<Product>
Expand All @@ -61,7 +61,7 @@ public override Product Read(ref Utf8JsonReader reader, Type typeToConvert, Json
{
".NET" => Product.Net,
".NET Core" => Product.NetCore,
_ => throw new JsonException()
_ => Product.Undefined
};
}

Expand All @@ -71,7 +71,7 @@ public override void Write(Utf8JsonWriter writer, Product value, JsonSerializerO
{
Product.Net => ".NET",
Product.NetCore => ".NET Core",
_ => throw new JsonException()
_ => ""
});
}
}
Expand All @@ -84,7 +84,7 @@ public override ReleaseType Read(ref Utf8JsonReader reader, Type typeToConvert,
{
"lts" => ReleaseType.Lts,
"sts" => ReleaseType.Sts,
_ => throw new JsonException()
_ => ReleaseType.Undefined
};
}

Expand All @@ -94,7 +94,7 @@ public override void Write(Utf8JsonWriter writer, ReleaseType value, JsonSeriali
{
ReleaseType.Lts => "lts",
ReleaseType.Sts => "sts",
_ => throw new JsonException()
_ => ""
});
}
}
Expand All @@ -108,7 +108,7 @@ public override SupportPhase Read(ref Utf8JsonReader reader, Type typeToConvert,
"preview" => SupportPhase.Preview,
"active" => SupportPhase.Active,
"eol" => SupportPhase.Eol,
_ => throw new JsonException()
_ => SupportPhase.Undefined
};
}

Expand All @@ -119,7 +119,7 @@ public override void Write(Utf8JsonWriter writer, SupportPhase value, JsonSerial
SupportPhase.Preview => "preview",
SupportPhase.Active => "active",
SupportPhase.Eol => "eol",
_ => throw new JsonException()
_ => ""
});
}
}
Expand Down
18 changes: 16 additions & 2 deletions src/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -629,15 +629,28 @@
</Border>
</Grid>
</Grid>
<Border
IsVisible="{Binding IsBusy}"
Padding="0"
StrokeThickness="0"
Grid.RowSpan="2">
<Border.Background>
<RadialGradientBrush>
<GradientStopCollection>
<GradientStop Color="{StaticResource BackgroundSubtle}" Offset="0" />
<GradientStop Color="#aa605d64" Offset="1" />
</GradientStopCollection>
</RadialGradientBrush>
</Border.Background>
<VerticalStackLayout
IsVisible="{Binding IsBusy}"
x:Name="LoadingPanel"
Grid.Row="1"
BackgroundColor="{StaticResource BackgroundSubtle}"
HorizontalOptions="Center"
VerticalOptions="Center">
<WebView
x:Name="AnimationView"
WidthRequest="180"
BackgroundColor="{StaticResource BackgroundSubtle}"
HeightRequest="200"
InputTransparent="true" />
<Label
Expand All @@ -647,5 +660,6 @@
FontSize="16"
HorizontalTextAlignment="Center" />
</VerticalStackLayout>
</Border>
</Grid>
</ContentPage>
25 changes: 23 additions & 2 deletions src/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System;
using System.Diagnostics;
using static System.Runtime.InteropServices.JavaScript.JSType;
using Microsoft.Maui.Platform;

namespace Dots;

Expand All @@ -22,14 +23,34 @@ public MainPage(MainViewModel vm)
InitializeComponent();
AnimationView.Source = new HtmlWebViewSource()
{
Html = $$"""<body style=background:#605d64;overflow:hidden><video autoplay loop muted style=width:180px;height:180px><source src="https://github.com/nor0x/Dots/raw/main/Assets/dotsanimation1.mp4" "type=" video/mp4">"""
Html = $$"""<body style="background:#605d64 !important;overflow:hidden"><video autoplay loop muted style="width:180px;height:180px;background:#605d64 !important;border:0px!important"><source src="https://github.com/nor0x/Dots/raw/main/Assets/dotsanimation1.mp4" "type=" video/mp4">"""
};
}

protected override void OnHandlerChanged()
{
base.OnHandlerChanged();
#if WINDOWS
if(MainSearchBar.Handler.PlatformView is Microsoft.UI.Xaml.Controls.AutoSuggestBox asb)
{

}
#endif
}

protected async override void OnAppearing()
{
base.OnAppearing();
await _vm.CheckSdks();
var lastChecked = Preferences.Get(Constants.LastCheckedKey, DateTime.MinValue);

bool force = false;
if (DateTime.Now.Subtract(lastChecked).TotalDays > 15)
{
force = true;
Preferences.Set(Constants.LastCheckedKey, DateTime.Now);
}
await _vm.CheckSdks(force);

}

private async void CollapseDetails_Tapped(object sender, Microsoft.Maui.Controls.TappedEventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions src/Services/DotnetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public class DotnetService
public async Task<List<Sdk>> GetSdks(bool force = false)
{
var result = new List<Sdk>();
var index = await GetReleaseIndex();
var index = await GetReleaseIndex(force);
var releaseInfos = new List<Release>();
var installed = GetInstalledSdks(force);
foreach(var item in index)
{
var infos = await GetReleaseInfos(item.ChannelVersion);
var infos = await GetReleaseInfos(item.ChannelVersion, force);
releaseInfos.AddRange(infos);
}
int i = 0;
Expand Down

0 comments on commit 69e7877

Please sign in to comment.