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
TODO:后退栈
  • Loading branch information
tobiichiamane committed Apr 17, 2019
1 parent 38f6865 commit 29e1411
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 5 deletions.
15 changes: 15 additions & 0 deletions PixivFSUWP/IllustDetailPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Page
x:Class="PixivFSUWP.IllustDetailPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PixivFSUWP"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ScrollViewer>
<Grid Margin="0,75,0,0">
<TextBlock x:Name="txtTitle"/>
</Grid>
</ScrollViewer>
</Page>
52 changes: 52 additions & 0 deletions PixivFSUWP/IllustDetailPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using FSharp.Data;
using PixivFS;
using PixivFSCS;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板

namespace PixivFSUWP
{
/// <summary>
/// 可用于自身或导航至 Frame 内部的空白页。
/// </summary>
public sealed partial class IllustDetailPage : Page
{
int illustID;

public IllustDetailPage()
{
this.InitializeComponent();
}

protected override void OnNavigatedTo(NavigationEventArgs e)
{
((Frame.Parent as Grid)?.Parent as MainPage)?.SelectNavPlaceholder("详情");
illustID = (int)e.Parameter;
base.OnNavigatedTo(e);
_ = loadContent();
}

private async Task loadContent()
{
var res = await Task.Run(() =>
new PixivAppAPI(Data.OverAll.GlobalBaseAPI)
.csfriendly_illust_detail(illustID.ToString()));
txtTitle.Text = res.Item("illust").Item("title").AsString();
}
}
}
1 change: 1 addition & 0 deletions PixivFSUWP/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ private async void NavControl_SelectionChanged(NavigationView sender, Navigation
switch (sender.MenuItems.IndexOf(args.SelectedItem))
{
case 0:
ContentFrame.Navigate(typeof(WaterfallPage), WaterfallPage.ListContent.Recommend);
NavPlaceholder.IsEnabled = false;
await Task.Delay(TimeSpan.FromMilliseconds(350));
NavSeparator.Visibility = Visibility.Collapsed;
Expand Down
7 changes: 7 additions & 0 deletions PixivFSUWP/PixivFSUWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
<Compile Include="Data\RecommendIllustsCollection.cs" />
<Compile Include="Data\OverAll.cs" />
<Compile Include="Data\WaterfallItem.cs" />
<Compile Include="IllustDetailPage.xaml.cs">
<DependentUpon>IllustDetailPage.xaml</DependentUpon>
</Compile>
<Compile Include="LoginPage.xaml.cs">
<DependentUpon>LoginPage.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -167,6 +170,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="IllustDetailPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="LoginPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
7 changes: 3 additions & 4 deletions PixivFSUWP/ViewModels/WaterfallItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ public class WaterfallItemViewModel
public async Task LoadImageAsync()
{
ImageSource = new BitmapImage();
Stream resStream = null;
await Task.Run(() => resStream = new PixivAppAPI(OverAll.GlobalBaseAPI).csfriendly_no_auth_requests_call_stream("GET",
ImageUri, new List<Tuple<string, string>>() { ("Referer", "https://app-api.pixiv.net/").ToTuple() })
.ResponseStream);
var resStream = await Task.Run(() => new PixivAppAPI(OverAll.GlobalBaseAPI).csfriendly_no_auth_requests_call_stream("GET",
ImageUri, new List<Tuple<string, string>>() { ("Referer", "https://app-api.pixiv.net/").ToTuple() })
.ResponseStream);
var memStream = new MemoryStream();
await resStream.CopyToAsync(memStream);
memStream.Position = 0;
Expand Down
4 changes: 3 additions & 1 deletion PixivFSUWP/WaterfallPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ private void WaterfallContent_Loaded(object sender, RoutedEventArgs e)

private void WaterfallListView_ItemClick(object sender, ItemClickEventArgs e)
{
(((Parent as Frame)?.Parent as Grid)?.Parent as MainPage)?.SelectNavPlaceholder("详情");
Frame.Navigate(typeof(IllustDetailPage),
(e.ClickedItem as ViewModels
.WaterfallItemViewModel).ItemId);
}
}
}

0 comments on commit 29e1411

Please sign in to comment.