-
Notifications
You must be signed in to change notification settings - Fork 116
/
CategoriesPage.xaml
352 lines (327 loc) · 21.9 KB
/
CategoriesPage.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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
<!--
// 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. -->
<local:BasePage
x:Class="PhotoSharingApp.Universal.Views.CategoriesPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PhotoSharingApp.Universal.Views"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:design="using:PhotoSharingApp.Universal.ViewModels.Design"
xmlns:valueConverters="using:PhotoSharingApp.Universal.ValueConverters"
xmlns:controls="using:PhotoSharingApp.Universal.Controls"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:stateTriggers="using:PhotoSharingApp.Universal.StateTriggers"
mc:Ignorable="d"
x:Name="pageRoot"
d:DataContext="{d:DesignInstance design:CategoriesDesignViewModel, IsDesignTimeCreatable=True}">
<Page.Resources>
<valueConverters:SelectedLegendItemToColorConverter x:Key="SelectedHeroImageToColorConverter" />
<valueConverters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<DataTemplate x:Key="CategoryListItemTemplate">
<Grid Margin="0,0,0,6">
<Grid.Transitions>
<TransitionCollection>
<AddDeleteThemeTransition/>
</TransitionCollection>
</Grid.Transitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<controls:MyControl />
<TextBlock Foreground="{StaticResource AppAccentForegroundColorBrush}" FontSize="16" FontWeight="Normal"
Grid.Column="1" Margin="6,0,0,0" VerticalAlignment="Center" Text="{Binding Name}" TextWrapping="NoWrap"
Style="{ThemeResource SubheaderTextBlockStyle}" />
<Button Grid.Column="2"
Style="{ThemeResource TextBlockButtonStyle}"
Command="{Binding DataContext.CategorySelectedCommand, ElementName=LayoutRoot}"
CommandParameter="{Binding}">
<TextBlock x:Uid="CategoriesPage_ShowAllTextBlock"
Foreground="{StaticResource AppAccentForegroundColorBrush}" FontSize="16"
Text="Show all"
Style="{ThemeResource SubheaderTextBlockStyle}" />
</Button>
</Grid>
<ScrollViewer HorizontalScrollMode="Disabled"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollMode="Disabled"
VerticalScrollBarVisibility="Hidden"
Grid.Row="1"
Margin="0,6,0,0">
<ItemsControl ItemsSource="{Binding PhotoThumbnails}" IsTabStop="False">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Background="White" Padding="0"
Margin="0,0,8,4"
Command="{Binding DataContext.PhotoThumbnailSelectedCommand, ElementName=LayoutRoot}"
CommandParameter="{Binding}">
<Image Width="{Binding ThumbnailImageSideLength, ElementName=pageRoot}"
Height="{Binding ThumbnailImageSideLength, ElementName=pageRoot}" Margin="0" Source="{Binding ImageUrl}" />
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</DataTemplate>
<Style x:Key="ListViewItemContainerStyle" TargetType="ListViewItem">
<Setter Property="IsTabStop" Value="False" />
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}" />
<Setter Property="IsHoldingEnabled" Value="True" />
<Setter Property="Padding" Value="12,0,12,0" />
<Setter Property="Margin" Value="0,12,0,0" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="MinWidth" Value="{ThemeResource ListViewItemMinWidth}" />
<Setter Property="MinHeight" Value="{ThemeResource ListViewItemMinHeight}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<ListViewItemPresenter CheckBrush="{ThemeResource SystemControlForegroundBaseMediumHighBrush}"
ContentMargin="{TemplateBinding Padding}" CheckMode="Inline"
ContentTransitions="{TemplateBinding ContentTransitions}"
CheckBoxBrush="{ThemeResource SystemControlForegroundBaseMediumHighBrush}"
DragForeground="{ThemeResource ListViewItemDragForegroundThemeBrush}"
DragOpacity="{ThemeResource ListViewItemDragThemeOpacity}"
DragBackground="{ThemeResource ListViewItemDragBackgroundThemeBrush}"
DisabledOpacity="{ThemeResource ListViewItemDisabledThemeOpacity}"
FocusBorderBrush="{ThemeResource SystemControlForegroundAltHighBrush}"
FocusSecondaryBorderBrush="{ThemeResource SystemControlForegroundBaseHighBrush}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
PointerOverForeground="{ThemeResource SystemControlHighlightAltBaseHighBrush}"
PressedBackground="Transparent"
PlaceholderBackground="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}"
PointerOverBackground="Transparent"
ReorderHintOffset="{ThemeResource ListViewItemReorderHintThemeOffset}"
SelectedPressedBackground="{ThemeResource SystemControlHighlightListAccentHighBrush}"
SelectionCheckMarkVisualEnabled="True"
SelectedForeground="{ThemeResource SystemControlHighlightAltBaseHighBrush}"
SelectedPointerOverBackground="{ThemeResource SystemControlHighlightListAccentMediumBrush}"
SelectedBackground="{ThemeResource SystemControlHighlightListAccentLowBrush}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="HeroImagesLegendItemContainerStyle" TargetType="GridViewItem">
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}" />
<Setter Property="IsHoldingEnabled" Value="True" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Margin" Value="0,0,4,4" />
<Setter Property="MinWidth" Value="15" />
<Setter Property="MinHeight" Value="{ThemeResource GridViewItemMinHeight}" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="GridViewItem">
<Grid>
<!--We add the actual control in the container because we need the selection state to change
the control's color.-->
<Ellipse Width="5" Height="5"
Fill="{Binding IsSelected, RelativeSource={RelativeSource TemplatedParent},
Converter={StaticResource SelectedHeroImageToColorConverter}}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<controls:PageHeader>
<controls:PageHeader.HeaderContent>
<TextBlock Text="{Binding PageHeaderText}" Style="{ThemeResource PageTitleTextBlockStyle}" />
</controls:PageHeader.HeaderContent>
</controls:PageHeader>
<ScrollViewer Grid.Row="2" x:Name="mainScrollViewer" IsTabStop="False">
<RelativePanel>
<Grid x:Name="featuredPhotos" RelativePanel.AlignRightWithPanel="True" RelativePanel.AlignLeftWithPanel="True"
Margin="24,0,24,0" MinHeight="300">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2.1*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<controls:FeaturedPhotoControl DataContext="{Binding}" x:Name="featuredPhoto1" PhotoSource="{Binding HeroImages[0]}"
Grid.Column="0" Grid.RowSpan="2" Margin="0,0,24,0" CaptionFontSize="20" />
<controls:FeaturedPhotoControl DataContext="{Binding}" x:Name="featuredPhoto2" PhotoSource="{Binding HeroImages[1]}"
Grid.Column="1" Grid.Row="0" Margin="0,0,0,24" CaptionFontSize="15" />
<controls:FeaturedPhotoControl DataContext="{Binding}" x:Name="featuredPhoto3" PhotoSource="{Binding HeroImages[2]}"
Grid.Column="1" Grid.Row="1" CaptionFontSize="15" />
</Grid>
<FlipView VerticalAlignment="Top" MaxHeight="400" Grid.Column="1"
ItemsSource="{Binding HeroImages}" SelectedItem="{Binding SelectedHeroImage, Mode=TwoWay}"
Style="{StaticResource HeroFlipViewStyle}" x:Name="heroImagesFlipView">
<FlipView.ItemTemplate>
<DataTemplate>
<!--Using a UserControl here to make adaptive triggers work-->
<controls:HeroImageControl>
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Tapped">
<core:InvokeCommandAction
Command="{Binding DataContext.HeroImageSelectedCommand, ElementName=LayoutRoot}"
CommandParameter="{Binding}" />
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</controls:HeroImageControl>
</DataTemplate>
</FlipView.ItemTemplate>
</FlipView>
<Grid Padding="38" RelativePanel.AlignRightWithPanel="True" RelativePanel.AlignLeftWithPanel="True"
Visibility="{Binding IsStatusContainerVisible, Converter={StaticResource BooleanToVisibilityConverter}}">
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
<ProgressBar IsIndeterminate="True"
Visibility="{Binding IsBusy, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<TextBlock x:Uid="CategoriesPage_NoDataBlock" Text="No data available. Upload some photos!" FontSize="32" HorizontalAlignment="Center"
Visibility="{Binding IsEmptyDataMessageVisible, Converter={StaticResource BooleanToVisibilityConverter}}"
FontWeight="Light" TextWrapping="WrapWholeWords" />
</StackPanel>
</Grid>
<GridView x:Name="heroImagesStateIndicator" ItemsSource="{Binding HeroImages}"
RelativePanel.Below="heroImagesFlipView"
RelativePanel.AlignHorizontalCenterWithPanel="True"
SelectedItem="{Binding SelectedHeroImage, Mode=TwoWay}"
ItemContainerStyle="{StaticResource HeroImagesLegendItemContainerStyle}" />
<ListView ItemsSource="{Binding TopCategories}" RelativePanel.Below="featuredPhotos"
IsItemClickEnabled="True" SelectionMode="None"
Margin="12"
ItemTemplate="{StaticResource CategoryListItemTemplate}"
ItemContainerStyle="{StaticResource ListViewItemContainerStyle}"
x:Name="categoriesList" RelativePanel.AlignLeftWithPanel="True"
RelativePanel.AlignRightWithPanel="True"
IsTabStop="False" />
<Grid RelativePanel.Below="categoriesList" RelativePanel.AlignLeftWithPanel="True"
RelativePanel.AlignRightWithPanel="True" x:Name="goldPurchaseSignInPrompt">
<controls:GoldPurchasePromptControl
Visibility="{Binding DataContext.IsUserSignedIn, Converter={StaticResource BooleanToVisibilityConverter}, ElementName=LayoutRoot}" />
<controls:SignInPromptControl
Visibility="{Binding DataContext.IsUserSignedIn, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=True, ElementName=LayoutRoot}" />
</Grid>
<controls:UploadPhotoControl RelativePanel.Below="goldPurchaseSignInPrompt"
RelativePanel.AlignLeftWithPanel="True"
RelativePanel.AlignRightWithPanel="True"
x:Name="uploadPhotoControl" />
</RelativePanel>
</ScrollViewer>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<stateTriggers:DeviceFamilyTrigger DeviceFamily="Windows.Mobile" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="categoriesList.Margin" Value="0" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="1600" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="featuredPhoto1.PhotoDetailsContainerMargin" Value="80,120" />
<Setter Target="featuredPhoto2.PhotoDetailsContainerMargin" Value="30,50" />
<Setter Target="featuredPhoto3.PhotoDetailsContainerMargin" Value="30,50" />
<Setter Target="featuredPhotos.Visibility" Value="Visible" />
<Setter Target="heroImagesFlipView.Visibility" Value="Collapsed" />
<Setter Target="heroImagesStateIndicator.Visibility" Value="Collapsed" />
<Setter Target="categoriesList.(RelativePanel.Below)" Value="featuredPhotos" />
</VisualState.Setters>
</VisualState>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="1300" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="featuredPhoto1.PhotoDetailsContainerMargin" Value="40,80" />
<Setter Target="featuredPhoto2.PhotoDetailsContainerMargin" Value="20,30" />
<Setter Target="featuredPhoto3.PhotoDetailsContainerMargin" Value="20,30" />
<Setter Target="featuredPhoto1.CaptionFontSize" Value="18" />
<Setter Target="featuredPhoto2.CaptionFontSize" Value="14" />
<Setter Target="featuredPhoto3.CaptionFontSize" Value="14" />
<Setter Target="featuredPhotos.Visibility" Value="Visible" />
<Setter Target="heroImagesFlipView.Visibility" Value="Collapsed" />
<Setter Target="heroImagesStateIndicator.Visibility" Value="Collapsed" />
<Setter Target="categoriesList.(RelativePanel.Below)" Value="featuredPhotos" />
</VisualState.Setters>
</VisualState>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="900" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="featuredPhoto1.Margin" Value="0,0,12,0" />
<Setter Target="featuredPhoto2.Margin" Value="0,0,0,12" />
<Setter Target="featuredPhoto1.CaptionFontSize" Value="16" />
<Setter Target="featuredPhoto2.CaptionFontSize" Value="11" />
<Setter Target="featuredPhoto3.CaptionFontSize" Value="11" />
<Setter Target="featuredPhotos.Visibility" Value="Visible" />
<Setter Target="heroImagesFlipView.Visibility" Value="Collapsed" />
<Setter Target="heroImagesStateIndicator.Visibility" Value="Collapsed" />
<Setter Target="categoriesList.(RelativePanel.Below)" Value="featuredPhotos" />
</VisualState.Setters>
</VisualState>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="featuredPhotos.Visibility" Value="Collapsed" />
<Setter Target="heroImagesFlipView.Visibility" Value="Visible" />
<Setter Target="heroImagesStateIndicator.Visibility" Value="Visible" />
<Setter Target="categoriesList.(RelativePanel.Below)" Value="heroImagesStateIndicator" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</local:BasePage>