Skip to content

Commit

Permalink
💄 主页 UI 改进
Browse files Browse the repository at this point in the history
  • Loading branch information
rmbadmin committed Nov 17, 2023
1 parent 09dc6a5 commit eaeb90d
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</UserControl.Styles>
<Border
BorderBrush="{DynamicResource CardStrokeColorDefaultBrush}"
BorderThickness="1"
BorderThickness="0"
ClipToBounds="True"
CornerRadius="8">
<Panel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public partial class CarouselBanner : UserControl
public static readonly StyledProperty<IDataTemplate?> ItemTemplateProperty =
Carousel.ItemTemplateProperty.AddOwner<CarouselBanner>();

///// <summary>
///// Defines the <see cref="GroupView"/> property.
///// </summary>
//public static readonly StyledProperty<bool> GroupViewProperty =
// AvaloniaProperty.Register<CarouselBanner, bool>(nameof(GroupView), true);

/// <summary>
/// Gets or sets the items to display.
/// </summary>
Expand Down Expand Up @@ -65,6 +71,15 @@ public int AutoScrollInterval
set => SetValue(AutoScrollIntervalProperty, value);
}

///// <summary>
///// GroupView
///// </summary>
//public bool GroupView
//{
// get => GetValue(GroupViewProperty);
// set => SetValue(GroupViewProperty, value);
//}

private Timer? _timer;

public CarouselBanner()
Expand Down
105 changes: 103 additions & 2 deletions src/BD.WTTS.Client.Avalonia/UI/Views/Pages/HomePage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
x:Class="BD.WTTS.UI.Views.Pages.HomePage"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:col="using:System.Collections.Generic"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:s="https://steampp.net/services"
Expand Down Expand Up @@ -125,6 +126,7 @@

<Grid Margin="0,-10,0,0" RowDefinitions="Auto,*">
<spp:CarouselBanner
MinHeight="350"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
ItemsSource="{Binding NavigationBanners}">
Expand Down Expand Up @@ -268,7 +270,106 @@
Theme="{StaticResource HyperlinkButton}" />
</DockPanel>

<ScrollViewer
<spp:CarouselBanner
MinHeight="250"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
ItemsSource="{Binding Shops}">
<spp:CarouselBanner.Resources>
<DataTemplate x:Key="ShopItem" DataType="spp:ShopRecommendGoodItem">
<Border spp:Animations.EnableAnimations="True">
<spp:AppItem
Title="{Binding Name}"
MaxWidth="260"
Classes="Vertical Scale"
ClickCommand="{Binding OpenBrowserCommand, Source={x:Static spp:App.Instance}}"
Cursor="Hand"
Tags="{Binding GoodsAllCategorysText}"
ToolTip.Tip="{Binding Brief}">
<spp:AppItem.ClickCommandParameter>
<MultiBinding Converter="{StaticResource StringFormatConverter}">
<CompiledBinding Path="." Source="{x:Static spp:HomePageViewModel.WattGame_Goods_Detail_}" />
<CompiledBinding Path="Id" />
</MultiBinding>
</spp:AppItem.ClickCommandParameter>
<spp:AppItem.Image>
<spp:Image2 RenderOptions.BitmapInterpolationMode="HighQuality" Source="{Binding Image}" />
</spp:AppItem.Image>
<spp:AppItem.Status>
<Border Classes="Status">
<StackPanel Orientation="Horizontal">
<TextBlock
VerticalAlignment="Center"
FontSize="12"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
IsVisible="{Binding !!DiscountValue}"
Text="{Binding Mktprice, Converter={StaticResource StringFormatConverter}, ConverterParameter={x:Static spp:CurrencyCode.CNY}}"
TextDecorations="Strikethrough" />
<TextBlock
VerticalAlignment="Center"
FontSize="14"
Text="{Binding Price, Converter={StaticResource StringFormatConverter}, ConverterParameter={x:Static spp:CurrencyCode.CNY}}" />
</StackPanel>
</Border>
</spp:AppItem.Status>
<spp:AppItem.ActionButton>
<Border
Height="24"
Padding="8,0"
Background="#4c6b22"
ClipToBounds="True"
CornerRadius="4"
IsVisible="{Binding !!DiscountValue}">
<TextBlock
VerticalAlignment="Center"
Foreground="#beee11"
Text="{Binding DiscountValue, StringFormat={}-{0}%}" />
</Border>
</spp:AppItem.ActionButton>
</spp:AppItem>
</Border>
</DataTemplate>
</spp:CarouselBanner.Resources>
<spp:CarouselBanner.ItemTemplate>
<DataTemplate>
<DataTemplate.DataType>
<x:Type x:TypeArguments="spp:ShopRecommendGoodItem" TypeName="col:List" />
</DataTemplate.DataType>
<Grid ColumnDefinitions="*,10,*,10,*,10,*">
<ContentPresenter
Grid.Column="0"
Content="{Binding [0]}"
ContentTemplate="{StaticResource ShopItem}" />
<ContentPresenter
Grid.Column="2"
Content="{Binding [1]}"
ContentTemplate="{StaticResource ShopItem}" />
<ContentPresenter
Grid.Column="4"
Content="{Binding [2]}"
ContentTemplate="{StaticResource ShopItem}" />
<ContentPresenter
Grid.Column="6"
Content="{Binding [3]}"
ContentTemplate="{StaticResource ShopItem}" />
</Grid>
</DataTemplate>
<!--<DataTemplate>
<DataTemplate.DataType>
<x:Type x:TypeArguments="spp:ShopRecommendGoodItem" TypeName="col:IEnumerable" />
</DataTemplate.DataType>
<ItemsControl ItemTemplate="{StaticResource ShopItem}" ItemsSource="{Binding}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Grid ColumnDefinitions="*,*,*,*" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</DataTemplate>-->
</spp:CarouselBanner.ItemTemplate>
</spp:CarouselBanner>

<!--<ScrollViewer
Name="ShopsScrollViewer"
Margin="0,0,0,20"
Padding="0,0,0,15"
Expand Down Expand Up @@ -336,7 +437,7 @@
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</ScrollViewer>-->

<TextBlock
Margin="-3,0,0,0"
Expand Down
10 changes: 7 additions & 3 deletions src/BD.WTTS.Client/UI/ViewModels/Pages/HomePageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public sealed class HomePageViewModel : TabItemViewModel
public ObservableCollection<AdvertisementDTO> NavigationBanners { get; set; }

[Reactive]
public ObservableCollection<ShopRecommendGoodItem> Shops { get; set; }
public ObservableCollection<List<ShopRecommendGoodItem>> Shops { get; set; }

public ICommand NavgationToMenuPageCommand { get; }

Expand All @@ -31,7 +31,7 @@ public HomePageViewModel()
Articles = new ObservableCollection<ArticleItemDTO>() { null, null, null };
#pragma warning restore CS8625 // 无法将 null 字面量转换为非 null 的引用类型。
NavigationBanners = new ObservableCollection<AdvertisementDTO>();
Shops = new ObservableCollection<ShopRecommendGoodItem>();
Shops = new ObservableCollection<List<ShopRecommendGoodItem>>();

NavgationToMenuPageCommand = ReactiveCommand.Create<TabItemViewModel>(NavgationToMenuPage);

Expand All @@ -56,7 +56,11 @@ public async void GetServerContent()
if (result2.IsSuccess && result2.Content != null)
{
Shops.Clear();
Shops.Add(result2.Content);
var data = result2.Content
.Select((v, i) => new { v, i })
.GroupBy(x => x.i / 4)
.Select(g => g.Select(x => x.v).ToList());
Shops.Add(data);
}

var result3 = await Instance.Advertisement.All(AdvertisementType.DeskTopHomeBanner);
Expand Down

0 comments on commit eaeb90d

Please sign in to comment.