Skip to content

Commit 9f82781

Browse files
committed
Added more UWPC project props
1 parent 4137e02 commit 9f82781

File tree

4 files changed

+62
-9
lines changed

4 files changed

+62
-9
lines changed

FluentStore.SDK/Handlers/UwpCommunityHandler.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ public async Task<PackageBase> GetPackage(string projectIdStr)
8787
.SetQueryParam("projectId", projectIdStr).GetJsonAsync<List<dynamic>>();
8888
package.UpdateWithCollaborators(collaborators);
8989

90+
var features = await BASE_URL.AppendPathSegments("projects", "features")
91+
.SetQueryParam("projectId", projectIdStr).GetJsonAsync<List<string>>();
92+
package.UpdateWithFeatures(features);
93+
9094
package.Status = PackageStatus.DownloadReady;
9195
return package;
9296
}
@@ -197,6 +201,8 @@ public override async Task<PackageBase> GetPackageFromUrl(Url url)
197201

198202
public override Url GetUrlFromPackage(PackageBase package)
199203
{
204+
if (package is UwpCommunityPackage uwpcPackage && uwpcPackage.HasWebsite)
205+
return uwpcPackage.Website;
200206
return "fluentstore://package/" + package.Urn.ToString();
201207
}
202208
}

FluentStore.SDK/Models/Link.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,8 @@ public static Link Create(string url, string textContent = null)
7575
return null;
7676
}
7777
}
78+
79+
public static implicit operator Flurl.Url(Link link) => link.Uri;
80+
public static implicit operator Uri(Link link) => link.Uri;
7881
}
7982
}

FluentStore.SDK/PackageTypes/UwpCommunityPackage.cs

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
11
using FluentStore.SDK.Images;
22
using FluentStore.Services;
3-
using Flurl;
43
using Garfoot.Utilities.FluentUrn;
54
using CommunityToolkit.Diagnostics;
6-
using CommunityToolkit.Mvvm.ComponentModel;
75
using CommunityToolkit.Mvvm.DependencyInjection;
86
using System;
97
using System.Collections.Generic;
108
using System.Linq;
119
using System.Threading.Tasks;
12-
using Windows.Storage;
1310
using System.IO;
1411
using CommunityToolkit.Mvvm.Messaging;
1512
using FluentStore.SDK.Messages;
13+
using FluentStore.SDK.Models;
14+
using FluentStore.SDK.Attributes;
1615

1716
namespace FluentStore.SDK.Packages
1817
{
1918
public class UwpCommunityPackage : PackageBase<dynamic>
2019
{
21-
INavigationService NavigationService = Ioc.Default.GetRequiredService<INavigationService>();
22-
PackageService PackageService = Ioc.Default.GetRequiredService<PackageService>();
20+
readonly INavigationService NavigationService = Ioc.Default.GetRequiredService<INavigationService>();
21+
readonly PackageService PackageService = Ioc.Default.GetRequiredService<PackageService>();
2322

24-
public UwpCommunityPackage(dynamic project = null, IEnumerable<string> images = null, IEnumerable<dynamic> collaborators = null)
23+
public UwpCommunityPackage(dynamic project = null, IEnumerable<string> images = null, IEnumerable<dynamic> collaborators = null, IEnumerable<string> features = null)
2524
{
2625
if (project != null)
2726
UpdateWithProject(project);
2827
if (images != null)
2928
UpdateWithImages(images);
3029
if (collaborators != null)
3130
UpdateWithCollaborators(collaborators);
31+
if (features != null)
32+
UpdateWithFeatures(features);
3233
}
3334

3435
public void UpdateWithProject(dynamic project)
@@ -40,6 +41,8 @@ public void UpdateWithProject(dynamic project)
4041
Title = project.appName;
4142
Description = project.description;
4243
ReleaseDate = project.createdAt;
44+
if (project.externalLink != null)
45+
Website = Link.Create(project.externalLink, ShortTitle + " website");
4346

4447
if (project.heroImage != null)
4548
Images.Add(new FileImage
@@ -55,13 +58,16 @@ public void UpdateWithProject(dynamic project)
5558
ImageType = ImageType.Logo,
5659
BackgroundColor = project.accentColor,
5760
});
58-
else
59-
Images.Add(TextImage.CreateFromName(Title));
6061

6162
// Set UWPC properties
6263
ProjectId = (int)project.id;
6364
if (project.downloadLink != null)
6465
PackageUri = new(project.downloadLink);
66+
if (project.githubLink != null)
67+
GithubLink = Link.Create(project.githubLink, ShortTitle + " on GitHub");
68+
if (project.tags != null)
69+
foreach (dynamic tag in project.tags)
70+
Tags.Add(tag.name);
6571
}
6672

6773
public void UpdateWithImages(IEnumerable<string> images)
@@ -87,6 +93,13 @@ public void UpdateWithCollaborators(IEnumerable<dynamic> collaborators)
8793
DeveloperName = owner.name;
8894
}
8995

96+
public void UpdateWithFeatures(IEnumerable<string> features)
97+
{
98+
Guard.IsNotNull(features, nameof(features));
99+
100+
Features.AddRange(features);
101+
}
102+
90103
private Urn _Urn;
91104
public override Urn Urn
92105
{
@@ -187,5 +200,29 @@ public PackageBase LinkedPackage
187200
get => _LinkedPackage;
188201
set => SetProperty(ref _LinkedPackage, value);
189202
}
203+
204+
private Link _GithubLink;
205+
[DisplayAdditionalInformation("Source code", "\uE943")]
206+
public Link GithubLink
207+
{
208+
get => _GithubLink;
209+
set => SetProperty(ref _GithubLink, value);
210+
}
211+
212+
private List<string> _Tags = new();
213+
[DisplayAdditionalInformation(Icon = "\uE1CB")]
214+
public List<string> Tags
215+
{
216+
get => _Tags;
217+
set => SetProperty(ref _Tags, value);
218+
}
219+
220+
private List<string> _Features = new();
221+
[Display(Rank = 2)]
222+
public List<string> Features
223+
{
224+
get => _Features;
225+
set => SetProperty(ref _Features, value);
226+
}
190227
}
191228
}

Installer/Installer.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk"
2+
InitialTargets="CopyInstallerPackage">
23

34
<PropertyGroup>
45
<OutputType>WinExe</OutputType>
@@ -21,6 +22,12 @@
2122
<None Remove="Resources\Background.png" />
2223
<None Remove="Resources\Square71x71Logo.png" />
2324
</ItemGroup>
25+
26+
<Target Name="CopyInstallerPackage" BeforeTargets="Resources">
27+
<Message Text="Copied installer package" />
28+
<Copy SourceFiles="Resources\Packages\FluentStore_Beta_$(Platform).zip"
29+
DestinationFiles="Resources\FluentStore_Beta.zip" />
30+
</Target>
2431

2532
<ItemGroup>
2633
<PackageReference Include="PostSharp.Community.Packer" Version="1.2.0" />

0 commit comments

Comments
 (0)