Skip to content

Commit

Permalink
绑定下载列表
Browse files Browse the repository at this point in the history
  • Loading branch information
lindexi committed Dec 20, 2023
1 parent 4df2808 commit 1bf1065
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
using System.Collections.ObjectModel;
using System.Xml.Linq;

using Uno.Extensions;

using UnoFileDownloader.Business;
using UnoFileDownloader.Utils;

namespace UnoFileDownloader.Presentation
{
public partial record MainModel
{
private INavigator _navigator;
private readonly DownloadFileListManager _downloadFileListManager;

public MainModel(
IStringLocalizer localizer,
IOptions<AppConfig> appInfo,
INavigator navigator)
INavigator navigator, DownloadFileListManager downloadFileListManager)
{
_navigator = navigator;
_downloadFileListManager = downloadFileListManager;
Title = localizer["Main"];
Title += $" - {localizer["ApplicationName"]}";
Title += $" - {appInfo?.Value?.Environment}";

UpdateDownloadFileInfoViewList();
}

public string? Title { get; }

public ObservableCollection<DownloadFileInfo> DownloadFileInfoViewList { get; } =
new ObservableCollection<DownloadFileInfo>();

public IState<string> Name => State<string>.Value(this, () => string.Empty);

public async Task GoToSecond()
Expand All @@ -33,6 +48,12 @@ public async Task GotToNewTask()
public async Task GoToAbout()
{
await _navigator.NavigateViewModelAsync<AboutModel>(this);
}
}

private void UpdateDownloadFileInfoViewList()
{
DownloadFileInfoViewList.Clear();
DownloadFileInfoViewList.AddRange(_downloadFileListManager.DownloadFileInfoList);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
<ListView
x:Name="TaskList"
Grid.Row="1"
ItemsSource="{Binding DownloadFileInfoViewList}"
>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
Expand Down Expand Up @@ -254,6 +255,9 @@
Padding="4"
VerticalAlignment="Bottom"
FontSize="15"
Visibility="Collapsed"
Text="&#x2193; 0 Byte/s &#x2191; 0 Byte/s" />
<TextBlock Grid.Row="2" Margin="5 0 0 0" FontSize="10"
Text="Powered By UNO Platform with C# dotnet"></TextBlock>
</Grid>
</Page>

0 comments on commit 1bf1065

Please sign in to comment.