Skip to content
This repository was archived by the owner on Aug 15, 2023. It is now read-only.

Commit acebf27

Browse files
committed
Alpha 0.2.3 #5
统一ContentDialog
1 parent 969abb4 commit acebf27

29 files changed

+195
-517
lines changed

App.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "pch.h"
22

33
#include "App.h"
4-
#include "MainPage.h"
4+
#include "Pages/MainPage.h"
55

66

77
using namespace winrt;

Package.appxmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Identity
44
Name="216498b6-651f-448d-99f4-4633881a4315"
55
Publisher="CN=KitUIN"
6-
Version="0.2.0.0" />
6+
Version="0.2.3.0" />
77
<mp:PhoneIdentity PhoneProductId="216498b6-651f-448d-99f4-4633881a4315" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
88
<Properties>
99
<DisplayName>bikabika</DisplayName>

ClassificationPage.cpp renamed to Pages/ClassificationPage.cpp

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -24,47 +24,7 @@ namespace winrt::bikabika::implementation
2424
{
2525
return m_classBlockView;
2626
}
27-
Windows::Foundation::IAsyncAction ClassificationPage::ContentDialogShow(hstring const& mode, hstring const& message)
28-
{
29-
Windows::ApplicationModel::Resources::ResourceLoader resourceLoader{ Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView() };
30-
if (mode == L"Timeout") {
31-
auto show{ PicErrorDialog().ShowAsync() };
32-
}
33-
else {
34-
HttpContentDialog().Title(box_value(resourceLoader.GetString(L"FailHttpTitle")));
35-
HttpContentDialog().CloseButtonText(resourceLoader.GetString(L"FailCloseButtonText"));
36-
if (mode == L"Error")
37-
{
38-
HttpContentDialog().Content(box_value(message));
39-
40-
auto show{ co_await HttpContentDialog().ShowAsync() };
41-
42-
}
43-
else if (mode == L"Unknown")
44-
{
45-
Windows::Data::Json::JsonObject resp = Windows::Data::Json::JsonObject::Parse(message);
46-
HttpContentDialog().Content(box_value(to_hstring(resp.GetNamedNumber(L"code")) + L":" + resp.GetNamedString(L"message")));
47-
HttpContentDialog().IsTextScaleFactorEnabled(true);
48-
auto show{ co_await HttpContentDialog().ShowAsync() };
49-
50-
}
51-
else if (mode == L"1005")
52-
{
53-
HttpContentDialog().Content(box_value(resourceLoader.GetString(L"FailAuth")));
54-
HttpContentDialog().IsTextScaleFactorEnabled(true);
55-
extern bool m_login;
56-
m_login = false;
57-
auto show{ co_await HttpContentDialog().ShowAsync() };
58-
if (show == winrt::Windows::UI::Xaml::Controls::ContentDialogResult::None)
59-
{
60-
auto loginTeachingTip = Frame().Parent().as<Microsoft::UI::Xaml::Controls::NavigationView>().Parent().as<Windows::UI::Xaml::Controls::Grid>().Children().GetAt(3).as<Microsoft::UI::Xaml::Controls::TeachingTip>();
61-
loginTeachingTip.Title(resourceLoader.GetString(L"LoginButton/Content"));
62-
loginTeachingTip.IsOpen(true);
63-
}
64-
}
65-
}
66-
ErrorTip().IsOpen(true);
67-
}
27+
6828
Windows::Foundation::IAsyncAction ClassificationPage::Init()
6929
{
7030
Windows::ApplicationModel::Resources::ResourceLoader resourceLoader{ Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView() };
@@ -74,10 +34,10 @@ if (mode == L"Timeout") {
7434
LayoutMessage().IsOpen(false);
7535
if (res[1] == 'T')
7636
{
77-
co_await ContentDialogShow(L"Timeout", L"");
37+
rootPage.ContentDialogShow(L"Timeout", L"");
7838
}
7939
else if (res[1] == 'E') {
80-
co_await ContentDialogShow(L"Error", res);
40+
rootPage.ContentDialogShow(L"Error", res);
8141
}
8242
else
8343
{
@@ -102,12 +62,12 @@ if (mode == L"Timeout") {
10262
//缺少鉴权
10363
else if (code == (double)401 && resp.GetNamedString(L"error") == L"1005")
10464
{
105-
co_await ContentDialogShow(L"1005", L"");
65+
rootPage.ContentDialogShow(L"1005", L"");
10666
}
10767
//未知
10868
else
10969
{
110-
co_await ContentDialogShow(L"Unknown", res);
70+
rootPage.ContentDialogShow(L"Unknown", res);
11171
}
11272
}
11373

ClassificationPage.h renamed to Pages/ClassificationPage.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ namespace winrt::bikabika::implementation
1010
{
1111
ClassificationPage();
1212
bikabika::ClassBlockViewModel ClassBlockView();
13-
Windows::Foundation::IAsyncAction ContentDialogShow(hstring const& mode, hstring const& message);
1413
Windows::Foundation::IAsyncAction Init();
1514
void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs const& e);
1615
bikabika::BikaHttp BikaHttpAPI();
File renamed without changes.

ClassificationPage.xaml renamed to Pages/ClassificationPage.xaml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,7 @@
88
mc:Ignorable="d">
99

1010
<Grid x:Name="RootGrid">
11-
<ContentDialog x:Name="PicErrorDialog" x:Uid="PicErrorDialog"
12-
Background="{StaticResource SystemAccentColorLight2}">
13-
<ContentDialog.TitleTemplate>
14-
<DataTemplate>
15-
<Image x:Name="ErrorPic" x:Uid="ErrorPic" Source="ms-appx:///Assets//Picacgs//icon_unknown_error.png" Width="270" Height="270" HorizontalAlignment="Center"/>
16-
</DataTemplate>
17-
</ContentDialog.TitleTemplate>
18-
<StackPanel HorizontalAlignment="Center">
19-
<TextBlock IsTextSelectionEnabled="True" x:Uid="ErrorText1" HorizontalAlignment="Center" FontWeight="Bold"/>
20-
<TextBlock IsTextSelectionEnabled="True" x:Uid="ErrorText2" HorizontalAlignment="Center"/>
21-
<TextBlock IsTextSelectionEnabled="True" HorizontalAlignment="Center" FontWeight="Bold"/>
22-
<TextBlock IsTextSelectionEnabled="True" HorizontalAlignment="Center" FontWeight="Bold"/>
23-
</StackPanel>
24-
</ContentDialog >
25-
<ContentDialog x:Name="HttpContentDialog" x:Uid="HttpContentDialog" Background="{StaticResource SystemAccentColorLight2}">
26-
<ContentDialog.TitleTemplate>
27-
<DataTemplate>
28-
<Image Source="ms-appx:///Assets//Picacgs//icon_exclamation_error.png" Width="270" Height="270" HorizontalAlignment="Center"/>
29-
</DataTemplate>
30-
</ContentDialog.TitleTemplate>
31-
</ContentDialog >
11+
3212
<muxc:TeachingTip x:Uid="ErrorTip" Background="{StaticResource SystemAccentColorLight3}" ActionButtonClick="ErrorTip_ActionButtonClick" Title="Loading Error!" x:Name="ErrorTip" PreferredPlacement="BottomRight" IsLightDismissEnabled="False">
3313
<muxc:TeachingTip.Content>
3414
<TextBlock x:Uid="ErrorText" Margin="0,10,0,0" Text=" Maybe You Want To Refresh" FontSize="18" FontWeight="Black" Foreground="{ThemeResource SystemAccentColorDark3}"/>

Pages/ComicsPage.cpp

Lines changed: 13 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ namespace winrt::bikabika::implementation
1212
ComicsPage::ComicsPage()
1313
{
1414
InitializeComponent();
15-
NavigationCacheMode(Windows::UI::Xaml::Navigation::NavigationCacheMode::Enabled);
1615
}
1716

1817

@@ -34,46 +33,7 @@ namespace winrt::bikabika::implementation
3433
return m_typeBlocks;
3534
}
3635

37-
Windows::Foundation::IAsyncAction ComicsPage::ContentDialogShow(hstring const& mode, hstring const& message)
38-
{
39-
Windows::ApplicationModel::Resources::ResourceLoader resourceLoader{ Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView() };
40-
if (mode == L"Timeout") {
41-
auto show{ PicErrorDialog().ShowAsync() };
42-
}
43-
else {
44-
HttpContentDialog().Title(box_value(resourceLoader.GetString(L"FailHttpTitle")));
45-
HttpContentDialog().CloseButtonText(resourceLoader.GetString(L"FailCloseButtonText"));
46-
if (mode == L"Error")
47-
{
48-
HttpContentDialog().Content(box_value(message));
49-
50-
auto show{ co_await HttpContentDialog().ShowAsync() };
51-
52-
}
53-
else if (mode == L"Unknown")
54-
{
55-
Windows::Data::Json::JsonObject resp = Windows::Data::Json::JsonObject::Parse(message);
56-
HttpContentDialog().Content(box_value(to_hstring(resp.GetNamedNumber(L"code")) + L":" + resp.GetNamedString(L"message")));
57-
HttpContentDialog().IsTextScaleFactorEnabled(true);
58-
auto show{ co_await HttpContentDialog().ShowAsync() };
59-
60-
}
61-
else if (mode == L"1005")
62-
{
63-
HttpContentDialog().Content(box_value(resourceLoader.GetString(L"FailAuth")));
64-
HttpContentDialog().IsTextScaleFactorEnabled(true);
65-
extern bool m_login;
66-
m_login = false;
67-
auto show{ co_await HttpContentDialog().ShowAsync() };
68-
if (show == winrt::Windows::UI::Xaml::Controls::ContentDialogResult::None)
69-
{
70-
auto loginTeachingTip = Frame().Parent().as<Microsoft::UI::Xaml::Controls::NavigationView>().Parent().as<Windows::UI::Xaml::Controls::Grid>().Children().GetAt(3).as<Microsoft::UI::Xaml::Controls::TeachingTip>();
71-
loginTeachingTip.Title(resourceLoader.GetString(L"LoginButton/Content"));
72-
loginTeachingTip.IsOpen(true);
73-
}
74-
}
75-
}
76-
}
36+
7737
// Init
7838
Windows::Foundation::IAsyncAction ComicsPage::OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs const& e)
7939
{
@@ -154,10 +114,10 @@ namespace winrt::bikabika::implementation
154114
hstring res{ co_await m_bikaHttp.Comics(index,title,mode) };
155115
if (res[1] == 'T')
156116
{
157-
co_await ContentDialogShow(L"Timeout", L"");
117+
rootPage.ContentDialogShow(L"Timeout", L"");
158118
}
159119
else if (res[1] == 'E') {
160-
co_await ContentDialogShow(L"Error", res);
120+
rootPage.ContentDialogShow(L"Error", res);
161121
}
162122
else
163123
{
@@ -182,12 +142,12 @@ namespace winrt::bikabika::implementation
182142
//缺少鉴权
183143
else if (code == (double)401 && resp.GetNamedString(L"error") == L"1005")
184144
{
185-
co_await ContentDialogShow(L"1005", L"");
145+
rootPage.ContentDialogShow(L"1005", L"");
186146
}
187147
//未知
188148
else
189149
{
190-
co_await ContentDialogShow(L"Unknown", res);
150+
rootPage.ContentDialogShow(L"Unknown", res);
191151
}
192152
}
193153

@@ -200,10 +160,10 @@ namespace winrt::bikabika::implementation
200160
hstring res{ co_await m_bikaHttp.Search(keywords, mode, categories, index) };
201161
if (res[1] == 'T')
202162
{
203-
ContentDialogShow(L"Timeout", L"");
163+
rootPage.ContentDialogShow(L"Timeout", L"");
204164
}
205165
else if (res[1] == 'E') {
206-
ContentDialogShow(L"Error", res);
166+
rootPage.ContentDialogShow(L"Error", res);
207167
}
208168
else
209169
{
@@ -227,12 +187,12 @@ namespace winrt::bikabika::implementation
227187
//缺少鉴权
228188
else if (code == (double)401 && resp.GetNamedString(L"error") == L"1005")
229189
{
230-
ContentDialogShow(L"1005", L"");
190+
rootPage.ContentDialogShow(L"1005", L"");
231191
}
232192
//未知
233193
else
234194
{
235-
ContentDialogShow(L"Unknown", res);
195+
rootPage.ContentDialogShow(L"Unknown", res);
236196
}
237197
}
238198
}
@@ -245,10 +205,10 @@ namespace winrt::bikabika::implementation
245205

246206
if (res[1] == 'T')
247207
{
248-
ContentDialogShow(L"Timeout", L"");
208+
rootPage.ContentDialogShow(L"Timeout", L"");
249209
}
250210
else if (res[1] == 'E') {
251-
ContentDialogShow(L"Error", res);
211+
rootPage.ContentDialogShow(L"Error", res);
252212
}
253213
else
254214
{
@@ -272,12 +232,12 @@ namespace winrt::bikabika::implementation
272232
//缺少鉴权
273233
else if (code == (double)401 && resp.GetNamedString(L"error") == L"1005")
274234
{
275-
ContentDialogShow(L"1005", L"");
235+
rootPage.ContentDialogShow(L"1005", L"");
276236
}
277237
//未知
278238
else
279239
{
280-
ContentDialogShow(L"Unknown", res);
240+
rootPage.ContentDialogShow(L"Unknown", res);
281241
}
282242
}
283243
}

Pages/ComicsPage.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ namespace winrt::bikabika::implementation
1313

1414
winrt::Windows::Foundation::Collections::IObservableVector<bikabika::ComicBlock> ComicBlocks();
1515
winrt::Windows::Foundation::Collections::IObservableVector<winrt::hstring> TypeBlocks();
16-
Windows::Foundation::IAsyncAction ContentDialogShow(hstring const& mode, hstring const& message);
1716
Windows::Foundation::IAsyncAction OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs const& e);
1817
Windows::Foundation::IAsyncAction PipsPager_SelectedIndexChanged(winrt::Microsoft::UI::Xaml::Controls::PipsPager const& sender, winrt::Microsoft::UI::Xaml::Controls::PipsPagerSelectedIndexChangedEventArgs const& args);
1918
Windows::Foundation::IAsyncAction ComicsPage::Goto(int32_t const& index, hstring const& title, hstring const& mode);

Pages/ComicsPage.xaml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,27 +71,7 @@
7171
</Page.Resources>
7272

7373
<Grid Margin="0,3,0,0">
74-
<ContentDialog x:Name="PicErrorDialog" x:Uid="PicErrorDialog"
75-
Background="{StaticResource SystemAccentColorLight2}">
76-
<ContentDialog.TitleTemplate>
77-
<DataTemplate>
78-
<Image x:Name="ErrorPic" x:Uid="ErrorPic" Source="ms-appx:///Assets//Picacgs//icon_unknown_error.png" Width="270" Height="270" HorizontalAlignment="Center"/>
79-
</DataTemplate>
80-
</ContentDialog.TitleTemplate>
81-
<StackPanel HorizontalAlignment="Center">
82-
<TextBlock IsTextSelectionEnabled="True" x:Uid="ErrorText1" HorizontalAlignment="Center" FontWeight="Bold"/>
83-
<TextBlock IsTextSelectionEnabled="True" x:Uid="ErrorText2" HorizontalAlignment="Center"/>
84-
<TextBlock IsTextSelectionEnabled="True" HorizontalAlignment="Center" FontWeight="Bold"/>
85-
<TextBlock IsTextSelectionEnabled="True" HorizontalAlignment="Center" FontWeight="Bold"/>
86-
</StackPanel>
87-
</ContentDialog >
88-
<ContentDialog x:Name="HttpContentDialog" x:Uid="HttpContentDialog" Background="{StaticResource SystemAccentColorLight2}">
89-
<ContentDialog.TitleTemplate>
90-
<DataTemplate>
91-
<Image Source="ms-appx:///Assets//Picacgs//icon_exclamation_error.png" Width="270" Height="270" HorizontalAlignment="Center"/>
92-
</DataTemplate>
93-
</ContentDialog.TitleTemplate>
94-
</ContentDialog >
74+
9575
<ScrollViewer Margin="3,38,0,10">
9676
<StackPanel >
9777

Pages/HomePage.cpp

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -32,44 +32,5 @@ namespace winrt::bikabika::implementation
3232
loginData.Values().Insert(L"token", box_value(L"sadf"));*/
3333

3434
}
35-
Windows::Foundation::IAsyncAction HomePage::ContentDialogShow(hstring const& mode, hstring const& message)
36-
{
37-
Windows::ApplicationModel::Resources::ResourceLoader resourceLoader{ Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView() };
38-
if (mode == L"Timeout") {
39-
auto show{ PicErrorDialog().ShowAsync() };
40-
}
41-
else {
42-
HttpContentDialog().Title(box_value(resourceLoader.GetString(L"FailHttpTitle")));
43-
HttpContentDialog().CloseButtonText(resourceLoader.GetString(L"FailCloseButtonText"));
44-
if (mode == L"Error")
45-
{
46-
HttpContentDialog().Content(box_value(message));
47-
48-
auto show{ co_await HttpContentDialog().ShowAsync() };
49-
50-
}
51-
else if (mode == L"Unknown")
52-
{
53-
Windows::Data::Json::JsonObject resp = Windows::Data::Json::JsonObject::Parse(message);
54-
HttpContentDialog().Content(box_value(to_hstring(resp.GetNamedNumber(L"code")) + L":" + resp.GetNamedString(L"message")));
55-
HttpContentDialog().IsTextScaleFactorEnabled(true);
56-
auto show{ co_await HttpContentDialog().ShowAsync() };
57-
58-
}
59-
else if (mode == L"1005")
60-
{
61-
HttpContentDialog().Content(box_value(resourceLoader.GetString(L"FailAuth")));
62-
HttpContentDialog().IsTextScaleFactorEnabled(true);
63-
extern bool m_login;
64-
m_login = false;
65-
auto show{ co_await HttpContentDialog().ShowAsync() };
66-
if (show == winrt::Windows::UI::Xaml::Controls::ContentDialogResult::None)
67-
{
68-
auto loginTeachingTip = Frame().Parent().as<Microsoft::UI::Xaml::Controls::NavigationView>().Parent().as<Windows::UI::Xaml::Controls::Grid>().Children().GetAt(3).as<Microsoft::UI::Xaml::Controls::TeachingTip>();
69-
loginTeachingTip.Title(resourceLoader.GetString(L"LoginButton/Content"));
70-
loginTeachingTip.IsOpen(true);
71-
}
72-
}
73-
}
74-
}
35+
7536
}

0 commit comments

Comments
 (0)