Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Commit

Permalink
用户详情页可以关注用户了
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiichiamane committed May 20, 2019
1 parent dd6d519 commit 7a329cb
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
4 changes: 2 additions & 2 deletions PixivFSUWP/UserDetailPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
</Grid>
</Grid>
<StackPanel Margin="15" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button Style="{StaticResource ButtonRevealStyle}"
<Button Style="{StaticResource ButtonRevealStyle}"
Background="#99F3F3F3" BorderThickness="1.5" Height="70"
Width="70">
<StackPanel Margin="5">
Expand All @@ -242,7 +242,7 @@
</Button>
<ToggleButton x:Name="btnFollow" Style="{StaticResource ToggleButtonRevealStyle}"
Margin="5,0,0,0" Background="#99F3F3F3" BorderThickness="1.5" Height="70"
Width="70">
Width="70" Click="BtnFollow_Click">
<StackPanel Margin="5">
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}"
FontSize="20" Glyph="&#xE8FA;"/>
Expand Down
54 changes: 54 additions & 0 deletions PixivFSUWP/UserDetailPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ async Task loadContents()
txtMusic.Text = _getHW(detail.Music);
txtDesk.Text = _getHW(detail.Desk);
txtChair.Text = _getHW(detail.Chair);
txtBtnFollow.Text = detail.IsFollowed ? "已关注" : "未关注";
btnFollow.IsChecked = detail.IsFollowed;
imgAvatar.ImageSource = await Data.OverAll.LoadImageAsync(detail.AvatarUrl);
imgAuthor.ImageSource = imgAvatar.ImageSource;
_ = loadPage();
Expand Down Expand Up @@ -138,5 +140,57 @@ private async void Button_Click(object sender, RoutedEventArgs e)
await Task.Delay(TimeSpan.FromMilliseconds(200));
grdUserButton.Visibility = Visibility.Collapsed;
}

private async void BtnFollow_Click(object sender, RoutedEventArgs e)
{
var btnSender = sender as ToggleButton;
btnSender.IsEnabled = false;
if (btnSender.IsChecked == true)
{
btnSender.IsChecked = false;
//进行关注
txtBtnFollow.Text = "请求中";
bool res;
try
{
await new PixivAppAPI(Data.OverAll.GlobalBaseAPI)
.UserFollowAdd(detail.ID.ToString());
res = true;
}
catch
{
res = false;
}
if (res)
{
btnSender.IsChecked = true;
txtBtnFollow.Text = "已关注";
}
btnSender.IsEnabled = true;
}
else
{
btnSender.IsChecked = true;
//取消关注
txtBtnFollow.Text = "请求中";
bool res;
try
{
await new PixivAppAPI(Data.OverAll.GlobalBaseAPI)
.UserFollowDelete(detail.ID.ToString());
res = true;
}
catch
{
res = false;
}
if (res)
{
btnSender.IsChecked = false;
txtBtnFollow.Text = "未关注";
}
btnSender.IsEnabled = true;
}
}
}
}

0 comments on commit 7a329cb

Please sign in to comment.