完善主页UI

This commit is contained in:
muqing 2024-07-19 15:36:44 +08:00
parent 6f60948872
commit 1fccc85b77
7 changed files with 130 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

View File

@ -18,6 +18,18 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
<DefaultLanguage>zh-cn</DefaultLanguage>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Assets\新文件夹1\**" />
<Compile Remove="Assets\新文件夹\**" />
<Content Remove="Assets\新文件夹1\**" />
<Content Remove="Assets\新文件夹\**" />
<EmbeddedResource Remove="Assets\新文件夹1\**" />
<EmbeddedResource Remove="Assets\新文件夹\**" />
<None Remove="Assets\新文件夹1\**" />
<None Remove="Assets\新文件夹\**" />
<Page Remove="Assets\新文件夹1\**" />
<Page Remove="Assets\新文件夹\**" />
</ItemGroup>
<ItemGroup>
<None Remove="Views\Concern.xaml" />
<None Remove="Views\HomePage.xaml" />
@ -77,4 +89,12 @@
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
</PropertyGroup>
<ItemGroup>
<PRIResource Remove="Assets\新文件夹1\**" />
</ItemGroup>
<ItemGroup>
<PRIResource Remove="Assets\新文件夹\**" />
</ItemGroup>
</Project>

View File

@ -24,7 +24,7 @@ namespace RustTools.Views;
public sealed partial class Concern : Page
{
public ConcernViewModel ConcernViewModel { get; set; }
public Concern()
public Concern(string v)
{
ConcernViewModel = App.GetService<ConcernViewModel>();
InitializeComponent();

View File

@ -1,15 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<Page
x:Class="RustTools.Views.HomePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:RustTools.Views"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:RustTools.Views"
xmlns:local1="using:Windows.ApplicationModel.Contacts"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
mc:Ignorable="d">
<ScrollView HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<Grid>
<StackPanel Orientation="Vertical">
<FlipView
x:Name="Gallery"
Height="270"
ItemsSource="{x:Bind Pictures}">
<FlipView.ItemTemplate>
<DataTemplate x:DataType="x:String">
<Image Source="{x:Bind Mode=OneTime}" />
</DataTemplate>
</FlipView.ItemTemplate>
</FlipView>
<PipsPager
x:Name="FlipViewPipsPager"
Margin="0,12,0,0"
HorizontalAlignment="Center"
NumberOfPages="{x:Bind Pictures.Count}"
SelectedPageIndex="{x:Bind Path=Gallery.SelectedIndex, Mode=TwoWay}" />
</Grid>
<RelativePanel>
<TextBlock Style="{StaticResource TitleTextBlockStyle}" Text="随机推荐" />
<AppBarButton
Icon="Refresh"
Label="刷新"
RelativePanel.AlignRightWithPanel="True" />
</RelativePanel>
<ListView
IsItemClickEnabled="True"
ItemsSource="{x:Bind conns}"
SelectionMode="None">
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
FontSize="20"
Text="{Binding FirstName}" />
<TextBlock Grid.Column="1" Text="{Binding LastName}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<RelativePanel>
<TextBlock Style="{StaticResource TitleTextBlockStyle}" Text="最新发布" />
<AppBarButton
Icon="Refresh"
Label="刷新"
RelativePanel.AlignRightWithPanel="True" />
</RelativePanel>
<ListView
Grid.Row="2"
IsItemClickEnabled="True"
SelectionMode="None" />
</StackPanel>
</ScrollView>
</Page>

View File

@ -1,21 +1,66 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using RustTools.ViewModels;
namespace RustTools.Views;
namespace RustTools.Views;
public sealed partial class HomePage : Page
{
public HomePageViewModel ViewModel {
get;
}
public ObservableCollection<Contact> conns = new();
public ObservableCollection<string> Pictures { get; } = new ObservableCollection<string>();
public HomePage()
{
ViewModel= App.GetService<HomePageViewModel>();
Pictures.Add("/Assets/image/a.jpeg");
Pictures.Add("/Assets/image/b.jpeg");
StartAsync();
InitializeComponent();
}
private void StartAsync()
{
var concern = new Contact("DeBug", "Debug", "DeBug");
conns.Add(concern);
conns.Add(concern);
conns.Add(concern);
conns.Add(concern);
conns.Add(concern);
conns.Add(concern);
conns.Add(concern);
conns.Add(concern);
}
public class Contact
{
public string FirstName
{
get; private set;
}
public string LastName
{
get; private set;
}
public string Company
{
get; private set;
}
public string Name => FirstName + " " + LastName;
public Contact(string firstName, string lastName, string company)
{
FirstName = firstName;
LastName = lastName;
Company = company;
}
}
}