-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFileSyncListMainPage.xaml
358 lines (326 loc) · 19.8 KB
/
FileSyncListMainPage.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
353
354
355
356
357
358
<?xml version="1.0" encoding="utf-8"?>
<Page
x:Class="Coder.Desktop.App.Views.Pages.FileSyncListMainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewmodels="using:Coder.Desktop.App.ViewModels"
xmlns:converters="using:Coder.Desktop.App.Converters"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Grid
Visibility="{x:Bind ViewModel.ShowUnavailable, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}"
Padding="60,60"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<TextBlock
HorizontalAlignment="Center"
Text="{x:Bind ViewModel.UnavailableMessage, Mode=OneWay}" />
</Grid>
<Grid
Visibility="{x:Bind ViewModel.ShowLoading, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}"
Padding="60,60"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<ProgressRing
Width="32"
Height="32"
Margin="0,30"
HorizontalAlignment="Center" />
<TextBlock HorizontalAlignment="Center" Text="Loading sync sessions..." />
</Grid>
<StackPanel
Visibility="{x:Bind ViewModel.ShowError, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}"
Orientation="Vertical"
Padding="20">
<TextBlock
Margin="0,0,0,20"
Foreground="Red"
TextWrapping="Wrap"
Text="{x:Bind ViewModel.Error, Mode=OneWay}" />
<Button Command="{x:Bind ViewModel.ReloadSessionsCommand, Mode=OneWay}">
<TextBlock Text="Reload" />
</Button>
</StackPanel>
<!-- This grid lets us fix the header and only scroll the content. -->
<Grid
Visibility="{x:Bind ViewModel.ShowSessions, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel
Grid.Row="0"
Orientation="Vertical"
Padding="30,15,30,0">
<!--
We use separate grids for the header and each child because WinUI 3
doesn't support having a dynamic row count.
This unfortunately means we need to copy the resources and the
column definitions to each Grid.
-->
<Grid Margin="0,0,0,5">
<Grid.Resources>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="{ThemeResource TextFillColorSecondaryBrush}" />
</Style>
<Style TargetType="Border">
<Setter Property="Padding" Value="40,0,0,0" />
</Style>
</Grid.Resources>
<!-- Cannot use "Auto" as it won't work for multiple Grids. -->
<Grid.ColumnDefinitions>
<!-- Icon column: 14 + 5 padding + 14 + 10 padding -->
<ColumnDefinition Width="43" />
<ColumnDefinition Width="2*" MinWidth="200" />
<ColumnDefinition Width="1*" MinWidth="120" />
<ColumnDefinition Width="2*" MinWidth="200" />
<ColumnDefinition Width="1*" MinWidth="100" MaxWidth="200" />
<ColumnDefinition Width="1*" MinWidth="100" MaxWidth="200" />
</Grid.ColumnDefinitions>
<Border Grid.Column="1" Padding="10,0,0,0">
<TextBlock Text="Local Path" />
</Border>
<Border Grid.Column="2">
<TextBlock Text="Workspace" />
</Border>
<Border Grid.Column="3">
<TextBlock Text="Remote Path" />
</Border>
<Border Grid.Column="4">
<TextBlock Text="Status" />
</Border>
<Border Grid.Column="5">
<TextBlock Text="Size" />
</Border>
</Grid>
<Border
Height="1"
Margin="-30,0,-30,5"
Background="{ThemeResource ControlElevationBorderBrush}" />
</StackPanel>
<ScrollView Grid.Row="1">
<StackPanel Orientation="Vertical" Padding="30,0,30,15">
<ItemsRepeater ItemsSource="{x:Bind ViewModel.Sessions, Mode=OneWay}">
<ItemsRepeater.Layout>
<StackLayout Orientation="Vertical" />
</ItemsRepeater.Layout>
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="viewmodels:SyncSessionViewModel">
<!-- DataContext is set here so we can listen to DataContextChanged below -->
<Grid Margin="0,10" DataContext="{x:Bind Model, Mode=OneWay}">
<!-- These are (mostly) from the header Grid and should be copied here -->
<Grid.Resources>
<Style TargetType="Border">
<Setter Property="Padding" Value="40,0,0,0" />
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="43" />
<ColumnDefinition Width="2*" MinWidth="200" />
<ColumnDefinition Width="1*" MinWidth="120" />
<ColumnDefinition Width="2*" MinWidth="200" />
<ColumnDefinition Width="1*" MinWidth="100" MaxWidth="200" />
<ColumnDefinition Width="1*" MinWidth="100" MaxWidth="200" />
</Grid.ColumnDefinitions>
<Border Grid.Column="0" Padding="0" HorizontalAlignment="Right">
<StackPanel Orientation="Horizontal">
<HyperlinkButton
Padding="0"
Margin="0,0,5,0"
Command="{x:Bind PauseOrResumeSessionCommand}">
<FontIcon Glyph="{x:Bind Icon}" FontSize="15"
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}" />
</HyperlinkButton>
<HyperlinkButton
Padding="0"
Command="{x:Bind TerminateSessionCommand}">
<FontIcon Glyph="" FontSize="15"
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}" />
</HyperlinkButton>
</StackPanel>
</Border>
<Border Grid.Column="1" Padding="10,0,0,0">
<TextBlock
Text="{x:Bind Model.AlphaPath}"
TextTrimming="CharacterEllipsis"
IsTextTrimmedChanged="TooltipText_IsTextTrimmedChanged" />
</Border>
<Border Grid.Column="2">
<TextBlock
Text="{x:Bind Model.BetaName}"
TextTrimming="CharacterEllipsis"
IsTextTrimmedChanged="TooltipText_IsTextTrimmedChanged" />
</Border>
<Border Grid.Column="3">
<TextBlock
Text="{x:Bind Model.BetaPath}"
TextTrimming="CharacterEllipsis"
IsTextTrimmedChanged="TooltipText_IsTextTrimmedChanged" />
</Border>
<Border Grid.Column="4">
<Border.Resources>
<converters:StringToBrushSelector
x:Key="StatusColor"
SelectedKey="{x:Bind Path=Model.StatusCategory}">
<converters:StringToBrushSelectorItem
Value="{ThemeResource SystemFillColorCriticalBrush}" />
<converters:StringToBrushSelectorItem
Key="Paused"
Value="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
<converters:StringToBrushSelectorItem
Key="Halted"
Value="{ThemeResource SystemFillColorCriticalBrush}" />
<converters:StringToBrushSelectorItem
Key="Error"
Value="{ThemeResource SystemFillColorCriticalBrush}" />
<converters:StringToBrushSelectorItem
Key="Conflicts"
Value="{ThemeResource SystemFillColorCautionBrush}" />
<converters:StringToBrushSelectorItem
Key="Working"
Value="{ThemeResource SystemFillColorAttentionBrush}" />
<converters:StringToBrushSelectorItem
Key="Ok"
Value="{ThemeResource DefaultTextForegroundThemeBrush}" />
</converters:StringToBrushSelector>
</Border.Resources>
<!--
We cannot use a direct binding to ToolTipService.ToolTip here because these
tooltips are populated from computed properties, which seems to cause the
tooltip to update (and close) even if the text hasn't changed. Since we
update the sync session state every 5 seconds, this is super annoying.
-->
<TextBlock
Text="{x:Bind Model.StatusString}"
TextTrimming="CharacterEllipsis"
Foreground="{Binding Source={StaticResource StatusColor}, Path=SelectedObject}"
Loaded="{x:Bind OnStatusTextLoaded}"
DataContextChanged="{x:Bind OnStatusTextDataContextChanged}" />
</Border>
<Border Grid.Column="5">
<!-- Same thing happens here as it's also a computed property -->
<TextBlock
Text="{x:Bind Model.AlphaSize.SizeBytes, Converter={StaticResource FriendlyByteConverter}}"
Loaded="{x:Bind OnSizeTextLoaded}"
DataContextChanged="{x:Bind OnSizeTextDataContextChanged}" />
</Border>
</Grid>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
<!-- "New Sync" button -->
<!--
HACK: this has some random numbers for padding and margins. Since
we need to align the icon and the text to the two grid columns
above (but still have it be within the same button), this is the
best solution I could come up with.
-->
<HyperlinkButton
Margin="13,5,0,0"
Command="{x:Bind ViewModel.StartCreatingNewSessionCommand}"
Visibility="{x:Bind ViewModel.CreatingNewSession, Converter={StaticResource InverseBoolToVisibilityConverter}, Mode=OneWay}">
<StackPanel Orientation="Horizontal">
<FontIcon
FontSize="18"
Margin="0,0,10,0"
Glyph=""
Foreground="{ThemeResource SystemFillColorSuccessBrush}" />
<TextBlock
Text="New Sync"
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}" />
</StackPanel>
</HyperlinkButton>
<!-- New item Grid -->
<Grid
Margin="0,10"
Visibility="{x:Bind ViewModel.CreatingNewSession, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
<!-- These are (mostly) from the header Grid and should be copied here -->
<Grid.Resources>
<Style TargetType="Border">
<Setter Property="Padding" Value="40,0,0,0" />
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="43" />
<ColumnDefinition Width="2*" MinWidth="200" />
<ColumnDefinition Width="1*" MinWidth="120" />
<ColumnDefinition Width="2*" MinWidth="200" />
<!--
To fit the status better, the last two columns
are merged for the new sync row.
-->
<ColumnDefinition Width="2*" MinWidth="200" MaxWidth="400" />
</Grid.ColumnDefinitions>
<Border Grid.Column="0" Padding="0">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<!-- TODO: gray out the button if the form is not filled out correctly -->
<HyperlinkButton
Padding="0"
Margin="0,0,5,0"
Command="{x:Bind ViewModel.ConfirmNewSessionCommand}">
<FontIcon Glyph="" FontSize="15"
Foreground="{ThemeResource SystemFillColorSuccessBrush}" />
</HyperlinkButton>
<HyperlinkButton
Padding="0"
Command="{x:Bind ViewModel.CancelNewSessionCommand}">
<FontIcon Glyph="" FontSize="15"
Foreground="{ThemeResource SystemFillColorCriticalBrush}" />
</HyperlinkButton>
</StackPanel>
</Border>
<Border Grid.Column="1" Padding="10,0,0,0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox
Grid.Column="0"
Margin="0,0,5,0"
VerticalAlignment="Stretch"
Text="{x:Bind ViewModel.NewSessionLocalPath, Mode=TwoWay}" />
<Button
Grid.Column="1"
IsEnabled="{x:Bind ViewModel.NewSessionLocalPathDialogOpen, Converter={StaticResource InverseBoolConverter}, Mode=OneWay}"
Command="{x:Bind OpenLocalPathSelectDialogCommand}"
VerticalAlignment="Stretch">
<FontIcon Glyph="" FontSize="13" />
</Button>
</Grid>
</Border>
<Border Grid.Column="2">
<!-- TODO: use a combo box for workspace agents -->
<!--
<ComboBox
ItemsSource="{x:Bind WorkspaceAgents}"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch" />
-->
<TextBox
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Text="{x:Bind ViewModel.NewSessionRemoteHost, Mode=TwoWay}" />
</Border>
<Border Grid.Column="3">
<TextBox
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Text="{x:Bind ViewModel.NewSessionRemotePath, Mode=TwoWay}" />
</Border>
<Border Grid.Column="4">
<TextBlock
Text="{x:Bind ViewModel.NewSessionStatus, Mode=OneWay}"
VerticalAlignment="Center"
TextTrimming="CharacterEllipsis"
IsTextTrimmedChanged="TooltipText_IsTextTrimmedChanged" />
</Border>
</Grid>
</StackPanel>
</ScrollView>
</Grid>
</Grid>
</Page>