-
Notifications
You must be signed in to change notification settings - Fork 109
/
FeedView.xaml
309 lines (275 loc) · 15.4 KB
/
FeedView.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<!--
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// The MIT License (MIT)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-->
<Page x:Class="RssReader.Views.FeedView"
NavigationCacheMode="Required"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:RssReader.Views"
xmlns:common="using:RssReader.Common"
xmlns:controls="using:RssReader.Controls"
xmlns:vm="using:RssReader.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:MUXC="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d">
<Page.Resources>
<DataTemplate x:Key="ArticleItemViewTemplate"
x:DataType="vm:ArticleViewModel">
<Grid>
<Grid>
<StackPanel Background="{ThemeResource Background60WhiteBrush}">
<Grid Padding="12,12,12,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0"
Text="{x:Bind PublishedDateFormatted}"
TextWrapping="NoWrap"
Foreground="{ThemeResource Foreground100SalmonBrush}"
Style="{StaticResource CaptionTextBlockStyle}" />
<TextBlock Grid.Row="1"
Margin="0,10,0,0"
Text="{x:Bind Title}"
TextWrapping="Wrap"
MaxLines="2"
TextTrimming="CharacterEllipsis"
Foreground="{ThemeResource Foreground100BlackBrush}"
Style="{StaticResource SubtitleTextBlockStyle}" />
<TextBlock Grid.Row="2"
Margin="0,4,0,12"
Text="{x:Bind Summary}"
TextWrapping="Wrap"
MaxLines="2"
TextTrimming="CharacterEllipsis"
Foreground="{ThemeResource Foreground100BlackBrush}"
Style="{StaticResource BodyTextBlockStyle}" />
</Grid>
<Rectangle x:Name="BorderBottom"
Grid.Row="2"
Height="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom"
Fill="{ThemeResource Border20SalmonBrush}" />
</StackPanel>
</Grid>
<ToggleButton Content=""
Click="{x:Bind SyncFavoritesFeed}"
IsChecked="{x:Bind IsStarred, Mode=TwoWay}"
IsThreeState="False"
HorizontalAlignment="Right"
Style="{StaticResource ToggleFavorite}" />
</Grid>
</DataTemplate>
</Page.Resources>
<Grid Background="{ThemeResource Background100CloudBrush}"
Padding="0,0,0,12">
<!--Bad feed content-->
<Grid x:Name="FeedErrorMessage"
x:DeferLoadStrategy="Lazy"
Visibility="{x:Bind ViewModel.CurrentFeed.IsInErrorAndEmpty, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="96" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Background="{ThemeResource Background100PastelOrangeBrush}"
HorizontalAlignment="Stretch">
<Image Width="140"
Height="96"
Source="ms-appx:///Assets/icon_feederror1.png"
VerticalAlignment="Center"
HorizontalAlignment="Center" />
</Grid>
<TextBlock Grid.Row="1"
Margin="24,12"
Text="Oh no! It looks like this feed is down."
TextWrapping="Wrap"
Foreground="{ThemeResource Foreground100CrimsonBrush}"
Style="{ThemeResource SubtitleTextBlockStyle}" />
<Rectangle Grid.Row="2"
Margin="24,0.333,24,0"
Height="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom"
Fill="{ThemeResource Border100PaleRoseBrush}" />
<TextBlock Grid.Row="3"
Margin="24,24,24,12"
Text="You should try refreshing it. Either the feed's server is down or your connection to the internet isn't working. Sorry, friend! :("
TextWrapping="Wrap"
Foreground="{ThemeResource Foreground100DimGrayBrush}"
Style="{ThemeResource BodyTextBlockStyle}" />
<Grid Grid.Row="4"
Margin="24,24">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Button x:Name="RefreshFeed"
Grid.Column="0"
Content="Refresh"
Click="{x:Bind ViewModel.RefreshCurrentFeed}"
Style="{StaticResource ButtonStyle2}"
Width="120"
HorizontalAlignment="Left" />
<Button x:Name="RemoveFeed"
Grid.Column="1"
Content="Remove"
Click="{x:Bind ViewModel.RemoveBadFeed}"
Style="{StaticResource ButtonStyle2}"
HorizontalAlignment="Right"
Width="120"
Margin="20,0,0,0" />
</Grid>
</Grid>
<!--Feed-is-empty content-->
<Grid Visibility="{x:Bind ViewModel.CurrentFeed.IsEmpty, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}">
<!--Favorites-is-empty content-->
<Grid x:Name="FavoritesIsEmptyMessage"
x:DeferLoadStrategy="Lazy"
Visibility="{x:Bind ViewModel.CurrentFeed.IsFavoritesFeed, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="96" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Background="{ThemeResource Background100OceanGrayBrush}"
HorizontalAlignment="Stretch">
<Image Width="140"
Height="96"
Source="ms-appx:///Assets/icon_nofavs.png"
VerticalAlignment="Center"
HorizontalAlignment="Center" />
</Grid>
<TextBlock Grid.Row="1"
Margin="24,12"
Text="No favorites yet!"
TextWrapping="Wrap"
Foreground="{ThemeResource Foreground100CrimsonBrush}"
Style="{ThemeResource SubtitleTextBlockStyle}" />
<Rectangle Grid.Row="2"
Margin="24,0.333,24,0"
Height="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom"
Fill="{ThemeResource Border100PaleRoseBrush}" />
<TextBlock Grid.Row="3"
Margin="24,24,24,12"
Text="You can favorite an article by clicking or tapping the star. When you're ready to remove it, simply click or tap the star again."
TextWrapping="Wrap"
Foreground="{ThemeResource Foreground100DimGrayBrush}"
Style="{ThemeResource BodyTextBlockStyle}" />
</Grid>
<!--Non-favorites-is-empty (not yet loaded) content-->
<Grid Visibility="{x:Bind ViewModel.CurrentFeed.IsNotFavoritesOrInError, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<controls:PageHeader>
<controls:PageHeader.HeaderContent>
<TextBlock Text="{x:Bind ViewModel.CurrentFeed.Name, Mode=OneWay}"
HorizontalAlignment="Left"
TextWrapping="NoWrap"
TextTrimming="CharacterEllipsis"
Foreground="{ThemeResource Foreground100CrimsonBrush}"
Style="{ThemeResource SubtitleTextBlockStyle}" />
</controls:PageHeader.HeaderContent>
</controls:PageHeader>
<Rectangle Margin="24,0.333,24,0"
Height="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom"
Fill="{ThemeResource Border100PaleRoseBrush}" />
<MUXC:ProgressBar Grid.Row="1"
Margin="24,8"
IsIndeterminate="True"
Style="{ThemeResource ProgressBarStyle1}" />
</Grid>
</Grid>
<!--Normal feed view content-->
<Grid x:Name="NormalFeedView"
x:DeferLoadStrategy="Lazy"
Visibility="{x:Bind ViewModel.CurrentFeed.IsNotEmpty, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="3" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<controls:PageHeader>
<controls:PageHeader.HeaderContent>
<TextBlock Text="{x:Bind ViewModel.CurrentFeed.Name, Mode=OneWay}"
HorizontalAlignment="Left"
TextWrapping="NoWrap"
TextTrimming="CharacterEllipsis"
Foreground="{ThemeResource Foreground100CrimsonBrush}"
Style="{ThemeResource SubtitleTextBlockStyle}" />
</controls:PageHeader.HeaderContent>
</controls:PageHeader>
<!--Feed-refresh error state content-->
<Grid Grid.Row="1"
Tapped="{x:Bind ViewModel.RefreshCurrentFeed}"
Background="{ThemeResource Background100PastelOrangeBrush}"
Visibility="{x:Bind ViewModel.CurrentFeed.IsInErrorAndNotEmpty, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}">
<SymbolIcon Symbol="Clock"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="20,10,5,10" />
<TextBlock Text="{x:Bind ViewModel.CurrentFeed.FeedDownMessage, Mode=OneWay}"
TextWrapping="WrapWholeWords"
HorizontalAlignment="Left"
Margin="48,10,12,10" />
</Grid>
<Rectangle Visibility="{x:Bind ViewModel.CurrentFeed.IsInErrorAndNotEmpty, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=Reverse}"
Margin="24,0.333,24,0"
Grid.Row="2"
Height="1"
HorizontalAlignment="Stretch"
Fill="{ThemeResource Border100PaleRoseBrush}" />
<MUXC:ProgressBar Visibility="{x:Bind ViewModel.CurrentFeed.IsLoadingAndNotEmpty, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}"
Margin="24,1,24,0"
Grid.Row="2"
IsIndeterminate="True"
Style="{ThemeResource ProgressBarStyle1}" />
<controls:NavMenuListView x:Name="ArticlesListView"
Grid.Row="3"
Padding="12,0"
ItemsSource="{x:Bind ViewModel.CurrentFeed.ArticlesAsObject, Mode=OneWay}"
SelectedItem="{x:Bind ViewModel.CurrentArticleAsObject, Mode=OneWay}"
CanReorderItems="{x:Bind ViewModel.IsCurrentFeedFavoritesFeed, Mode=OneWay}"
AllowDrop="True"
IsSwipeEnabled="True"
IsItemClickEnabled="True"
ItemInvoked="ArticlesListView_ItemInvoked"
ItemContainerStyle="{StaticResource FeedView}"
ItemTemplate="{StaticResource ArticleItemViewTemplate}"
Visibility="{x:Bind ViewModel.CurrentFeed.IsEmpty, Mode=OneWay, ConverterParameter=Reverse, Converter={StaticResource BooleanToVisibilityConverter}}" />
</Grid>
</Grid>
</Page>