Skip to content

Commit 279fae6

Browse files
authored
添加粉丝及关注页面 (Richasy#12)
* 调整账户菜单的样式 * 添加粉丝显示页面 * 添加关注页面
1 parent 3cc99f0 commit 279fae6

37 files changed

Lines changed: 1314 additions & 166 deletions

src/App/App.csproj

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<Compile Include="$(SolutionDir)\src\Shared\SharedAssemblyInfo.cs">
2020
<Link>Properties\SharedAssemblyInfo.cs</Link>
2121
</Compile>
22+
<Compile Include="Controls\App\TwoLineButton\TwoLineButton.cs" />
2223
<Compile Include="Controls\User\AccountPanel.xaml.cs">
2324
<DependentUpon>AccountPanel.xaml</DependentUpon>
2425
</Compile>
@@ -143,6 +144,9 @@
143144
<Compile Include="Controls\Settings\ThemeSettingSection.xaml.cs">
144145
<DependentUpon>ThemeSettingSection.xaml</DependentUpon>
145146
</Compile>
147+
<Compile Include="Controls\User\UserSlimCard.xaml.cs">
148+
<DependentUpon>UserSlimCard.xaml</DependentUpon>
149+
</Compile>
146150
<Compile Include="Controls\User\UserView.xaml.cs">
147151
<DependentUpon>UserView.xaml</DependentUpon>
148152
</Compile>
@@ -183,6 +187,12 @@
183187
<DependentUpon>UserAvatar.xaml</DependentUpon>
184188
</Compile>
185189
<Compile Include="Controls\VisualExtensions.cs" />
190+
<Compile Include="Pages\Overlay\FansPage.xaml.cs">
191+
<DependentUpon>FansPage.xaml</DependentUpon>
192+
</Compile>
193+
<Compile Include="Pages\Overlay\FollowsPage.xaml.cs">
194+
<DependentUpon>FollowsPage.xaml</DependentUpon>
195+
</Compile>
186196
<Compile Include="Pages\Overlay\HistoryPage.xaml.cs">
187197
<DependentUpon>HistoryPage.xaml</DependentUpon>
188198
</Compile>
@@ -380,6 +390,10 @@
380390
<Generator>MSBuild:Compile</Generator>
381391
<SubType>Designer</SubType>
382392
</ApplicationDefinition>
393+
<Page Include="Controls\App\TwoLineButton\TwoLineButton.xaml">
394+
<SubType>Designer</SubType>
395+
<Generator>MSBuild:Compile</Generator>
396+
</Page>
383397
<Page Include="Controls\User\AccountPanel.xaml">
384398
<SubType>Designer</SubType>
385399
<Generator>MSBuild:Compile</Generator>
@@ -544,6 +558,10 @@
544558
<SubType>Designer</SubType>
545559
<Generator>MSBuild:Compile</Generator>
546560
</Page>
561+
<Page Include="Controls\User\UserSlimCard.xaml">
562+
<SubType>Designer</SubType>
563+
<Generator>MSBuild:Compile</Generator>
564+
</Page>
547565
<Page Include="Controls\User\UserView.xaml">
548566
<SubType>Designer</SubType>
549567
<Generator>MSBuild:Compile</Generator>
@@ -592,6 +610,14 @@
592610
<SubType>Designer</SubType>
593611
<Generator>MSBuild:Compile</Generator>
594612
</Page>
613+
<Page Include="Pages\Overlay\FansPage.xaml">
614+
<SubType>Designer</SubType>
615+
<Generator>MSBuild:Compile</Generator>
616+
</Page>
617+
<Page Include="Pages\Overlay\FollowsPage.xaml">
618+
<SubType>Designer</SubType>
619+
<Generator>MSBuild:Compile</Generator>
620+
</Page>
595621
<Page Include="Pages\Overlay\HistoryPage.xaml">
596622
<SubType>Designer</SubType>
597623
<Generator>MSBuild:Compile</Generator>

src/App/Controls/App/RootNavigationView.xaml.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,12 @@ private void CheckOverlayContentNavigation(object param)
202202
case PageIds.DynamicFeed:
203203
pageType = typeof(DynamicFeedPage);
204204
break;
205+
case PageIds.Fans:
206+
pageType = typeof(FansPage);
207+
break;
208+
case PageIds.Follows:
209+
pageType = typeof(FollowsPage);
210+
break;
205211
default:
206212
break;
207213
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright (c) Richasy. All rights reserved.
2+
3+
using Windows.UI.Xaml;
4+
using Windows.UI.Xaml.Controls;
5+
6+
namespace Richasy.Bili.App.Controls
7+
{
8+
/// <summary>
9+
/// 包含双行文本的按钮.
10+
/// </summary>
11+
public sealed class TwoLineButton : Button
12+
{
13+
/// <summary>
14+
/// <see cref="FirstLineText"/>的依赖属性.
15+
/// </summary>
16+
public static readonly DependencyProperty FirstLineTextProperty =
17+
DependencyProperty.Register(nameof(FirstLineText), typeof(string), typeof(TwoLineButton), new PropertyMetadata(string.Empty));
18+
19+
/// <summary>
20+
/// <see cref="SecondLineText"/>的依赖属性.
21+
/// </summary>
22+
public static readonly DependencyProperty SecondLineTextProperty =
23+
DependencyProperty.Register(nameof(SecondLineText), typeof(string), typeof(TwoLineButton), new PropertyMetadata(string.Empty));
24+
25+
/// <summary>
26+
/// Initializes a new instance of the <see cref="TwoLineButton"/> class.
27+
/// </summary>
28+
public TwoLineButton()
29+
{
30+
this.DefaultStyleKey = typeof(TwoLineButton);
31+
}
32+
33+
/// <summary>
34+
/// 首行文本.
35+
/// </summary>
36+
public string FirstLineText
37+
{
38+
get { return (string)GetValue(FirstLineTextProperty); }
39+
set { SetValue(FirstLineTextProperty, value); }
40+
}
41+
42+
/// <summary>
43+
/// 次行文本.
44+
/// </summary>
45+
public string SecondLineText
46+
{
47+
get { return (string)GetValue(SecondLineTextProperty); }
48+
set { SetValue(SecondLineTextProperty, value); }
49+
}
50+
}
51+
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<ResourceDictionary
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="using:Richasy.Bili.App.Controls"
5+
xmlns:muxc="using:Microsoft.UI.Xaml.Controls">
6+
7+
<Style BasedOn="{StaticResource DefaultTwoLineButtonStyle}" TargetType="local:TwoLineButton" />
8+
9+
<Style x:Key="DefaultTwoLineButtonStyle" TargetType="local:TwoLineButton">
10+
<Setter Property="Background" Value="Transparent" />
11+
<Setter Property="BackgroundSizing" Value="InnerBorderEdge" />
12+
<Setter Property="Foreground" Value="{ThemeResource ButtonForeground}" />
13+
<Setter Property="BorderBrush" Value="{ThemeResource ButtonBorderBrush}" />
14+
<Setter Property="BorderThickness" Value="0" />
15+
<Setter Property="Padding" Value="{StaticResource ButtonPadding}" />
16+
<Setter Property="HorizontalAlignment" Value="Stretch" />
17+
<Setter Property="VerticalAlignment" Value="Center" />
18+
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
19+
<Setter Property="FontWeight" Value="Normal" />
20+
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
21+
<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}" />
22+
<Setter Property="FocusVisualMargin" Value="-3" />
23+
<Setter Property="CornerRadius" Value="{ThemeResource ControlCornerRadius}" />
24+
<Setter Property="Template">
25+
<Setter.Value>
26+
<ControlTemplate TargetType="local:TwoLineButton">
27+
<Grid
28+
x:Name="ContentPresenter"
29+
Padding="{TemplateBinding Padding}"
30+
muxc:AnimatedIcon.State="Normal"
31+
AutomationProperties.AccessibilityView="Raw"
32+
Background="{TemplateBinding Background}"
33+
BackgroundSizing="{TemplateBinding BackgroundSizing}"
34+
BorderBrush="{TemplateBinding BorderBrush}"
35+
BorderThickness="{TemplateBinding BorderThickness}"
36+
CornerRadius="{TemplateBinding CornerRadius}">
37+
38+
<Grid.BackgroundTransition>
39+
<BrushTransition Duration="0:0:0.083" />
40+
</Grid.BackgroundTransition>
41+
42+
<VisualStateManager.VisualStateGroups>
43+
<VisualStateGroup x:Name="CommonStates">
44+
<VisualState x:Name="Normal" />
45+
46+
<VisualState x:Name="PointerOver">
47+
<Storyboard>
48+
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
49+
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBackgroundPointerOver}" />
50+
</ObjectAnimationUsingKeyFrames>
51+
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
52+
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBorderBrushPointerOver}" />
53+
</ObjectAnimationUsingKeyFrames>
54+
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="FirstLineBlock" Storyboard.TargetProperty="Foreground">
55+
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonForegroundPointerOver}" />
56+
</ObjectAnimationUsingKeyFrames>
57+
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="SecondLineBlock" Storyboard.TargetProperty="Foreground">
58+
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonForegroundPointerOver}" />
59+
</ObjectAnimationUsingKeyFrames>
60+
</Storyboard>
61+
<VisualState.Setters>
62+
<Setter Target="ContentPresenter.(muxc:AnimatedIcon.State)" Value="PointerOver" />
63+
</VisualState.Setters>
64+
</VisualState>
65+
66+
<VisualState x:Name="Pressed">
67+
<Storyboard>
68+
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
69+
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBackgroundPressed}" />
70+
</ObjectAnimationUsingKeyFrames>
71+
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
72+
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBorderBrushPressed}" />
73+
</ObjectAnimationUsingKeyFrames>
74+
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="FirstLineBlock" Storyboard.TargetProperty="Foreground">
75+
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonForegroundPressed}" />
76+
</ObjectAnimationUsingKeyFrames>
77+
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="SecondLineBlock" Storyboard.TargetProperty="Foreground">
78+
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonForegroundPressed}" />
79+
</ObjectAnimationUsingKeyFrames>
80+
</Storyboard>
81+
<VisualState.Setters>
82+
<Setter Target="ContentPresenter.(muxc:AnimatedIcon.State)" Value="Pressed" />
83+
</VisualState.Setters>
84+
</VisualState>
85+
86+
<VisualState x:Name="Disabled">
87+
<Storyboard>
88+
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
89+
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBackgroundDisabled}" />
90+
</ObjectAnimationUsingKeyFrames>
91+
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
92+
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBorderBrushDisabled}" />
93+
</ObjectAnimationUsingKeyFrames>
94+
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="FirstLineBlock" Storyboard.TargetProperty="Foreground">
95+
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonForegroundDisabled}" />
96+
</ObjectAnimationUsingKeyFrames>
97+
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="SecondLineBlock" Storyboard.TargetProperty="Foreground">
98+
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonForegroundDisabled}" />
99+
</ObjectAnimationUsingKeyFrames>
100+
</Storyboard>
101+
<VisualState.Setters>
102+
<!-- DisabledVisual Should be handled by the control, not the animated icon. -->
103+
<Setter Target="ContentPresenter.(muxc:AnimatedIcon.State)" Value="Normal" />
104+
</VisualState.Setters>
105+
</VisualState>
106+
</VisualStateGroup>
107+
</VisualStateManager.VisualStateGroups>
108+
109+
<StackPanel Spacing="2">
110+
<TextBlock
111+
x:Name="FirstLineBlock"
112+
Style="{StaticResource BodyTextBlockStyle}"
113+
HorizontalAlignment="Center"
114+
Text="{TemplateBinding FirstLineText}" />
115+
<TextBlock
116+
x:Name="SecondLineBlock"
117+
Style="{StaticResource CaptionTextBlockStyle}"
118+
HorizontalAlignment="Center"
119+
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
120+
Text="{TemplateBinding SecondLineText}" />
121+
</StackPanel>
122+
</Grid>
123+
</ControlTemplate>
124+
</Setter.Value>
125+
</Setter>
126+
</Style>
127+
</ResourceDictionary>

src/App/Controls/Search/SearchUserView.xaml

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -20,73 +20,7 @@
2020
RequestLoadMore="OnViewRequestLoadMoreAsync">
2121
<local:VerticalRepeaterView.ItemTemplate>
2222
<DataTemplate x:DataType="uwp:UserViewModel">
23-
<local:CardPanel
24-
AutomationProperties.Name="{x:Bind Name, Mode=OneWay}"
25-
Click="OnUserItemClickAsync"
26-
DataContext="{x:Bind}">
27-
<Grid Padding="20,20,20,16" RowSpacing="8">
28-
<Grid.RowDefinitions>
29-
<RowDefinition Height="Auto" />
30-
<RowDefinition Height="Auto" />
31-
<RowDefinition Height="*" />
32-
<RowDefinition Height="Auto" />
33-
</Grid.RowDefinitions>
34-
<local:UserAvatar
35-
Width="40"
36-
Height="40"
37-
Avatar="{x:Bind Avatar, Mode=OneWay}"
38-
DecodeSize="40"
39-
UserName="{x:Bind Name, Mode=OneWay}" />
40-
<StackPanel Grid.Row="1" Spacing="8">
41-
<TextBlock
42-
Style="{StaticResource BodyTextBlockStyle}"
43-
HorizontalAlignment="Center"
44-
FontWeight="Bold"
45-
MaxLines="1"
46-
Text="{x:Bind Name, Mode=OneWay}"
47-
TextAlignment="Center"
48-
TextTrimming="CharacterEllipsis" />
49-
<Image
50-
Height="10"
51-
HorizontalAlignment="Center"
52-
Source="{x:Bind Level, Mode=OneWay, Converter={StaticResource UserLevelConverter}}" />
53-
</StackPanel>
54-
<TextBlock
55-
x:Name="SignBlock"
56-
Style="{StaticResource CaptionTextBlockStyle}"
57-
Grid.Row="2"
58-
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
59-
Text="{x:Bind Sign, Mode=OneWay}"
60-
TextAlignment="Center"
61-
TextTrimming="CharacterEllipsis">
62-
<ToolTipService.ToolTip>
63-
<ToolTip Content="{x:Bind Sign, Mode=OneWay}" IsEnabled="{Binding ElementName=SignBlock, Path=IsTextTrimmed}" />
64-
</ToolTipService.ToolTip>
65-
</TextBlock>
66-
<Grid
67-
Grid.Row="3"
68-
HorizontalAlignment="Stretch"
69-
Visibility="{x:Bind IsShowFollowButton, Mode=OneWay}">
70-
<Button
71-
x:Name="FollowButton"
72-
Style="{StaticResource AccentButtonStyle}"
73-
HorizontalAlignment="Stretch"
74-
Click="OnFollowButtonClickAsync"
75-
Content="{loc:LocaleLocator Name=Follow}"
76-
DataContext="{x:Bind}"
77-
FontSize="12"
78-
Visibility="{x:Bind IsFollow, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}" />
79-
<Button
80-
x:Name="UnFollowButton"
81-
HorizontalAlignment="Stretch"
82-
Click="OnFollowButtonClickAsync"
83-
Content="{loc:LocaleLocator Name=Followed}"
84-
DataContext="{x:Bind}"
85-
FontSize="12"
86-
Visibility="{x:Bind IsFollow, Mode=OneWay}" />
87-
</Grid>
88-
</Grid>
89-
</local:CardPanel>
23+
<local:UserSlimCard Click="OnUserCardClickAsync" ViewModel="{x:Bind}" />
9024
</DataTemplate>
9125
</local:VerticalRepeaterView.ItemTemplate>
9226
</local:VerticalRepeaterView>

src/App/Controls/Search/SearchUserView.xaml.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright (c) Richasy. All rights reserved.
22

3-
using Richasy.Bili.ViewModels.Uwp;
43
using Windows.UI.Xaml;
54

65
namespace Richasy.Bili.App.Controls
@@ -23,15 +22,9 @@ private async void OnUserRefreshButtonClickAsync(object sender, RoutedEventArgs
2322
await ViewModel.UserModule.InitializeRequestAsync();
2423
}
2524

26-
private async void OnUserItemClickAsync(object sender, RoutedEventArgs e)
25+
private async void OnUserCardClickAsync(object sender, System.EventArgs e)
2726
{
28-
await new UserView().ShowAsync((sender as FrameworkElement).DataContext as UserViewModel);
29-
}
30-
31-
private async void OnFollowButtonClickAsync(object sender, RoutedEventArgs e)
32-
{
33-
var data = (sender as FrameworkElement).DataContext as UserViewModel;
34-
await data.ToggleFollowStateAsync();
27+
await new UserView().ShowAsync((sender as UserSlimCard).ViewModel);
3528
}
3629
}
3730
}

0 commit comments

Comments
 (0)