|
6 | 6 | xmlns:mconvert="using:Quarrel.Converters.DataTemplates.Messages" |
7 | 7 | xmlns:tconvert="using:Quarrel.Converters.Time" |
8 | 8 | xmlns:qc="using:Quarrel.Controls" |
| 9 | + xmlns:mcontrols="using:Quarrel.Controls.Panels.Messages" |
9 | 10 | xmlns:bindablemessages="using:Quarrel.Bindables.Messages" |
10 | 11 | xmlns:bindableembeds="using:Quarrel.Bindables.Messages.Embeds" |
11 | 12 | xmlns:markdown="using:Quarrel.Markdown" |
12 | 13 | xmlns:converters="using:Quarrel.Converters"> |
13 | 14 |
|
14 | 15 | <DataTemplate x:Key="DefaultMessageTemplate" x:DataType="bindablemessages:BindableMessage"> |
15 | | - <Grid Padding="2,12,2,4"> |
16 | | - <Grid.ColumnDefinitions> |
17 | | - <ColumnDefinition Width="64"/> |
18 | | - <ColumnDefinition Width="*"/> |
19 | | - </Grid.ColumnDefinitions> |
| 16 | + <!--Grid must be wrapped in a user control to enable the VisualStateManager--> |
| 17 | + <UserControl> |
| 18 | + <Grid x:Name="RootGrid" Padding="2,12,2,4"> |
| 19 | + <VisualStateManager.VisualStateGroups> |
| 20 | + <VisualStateGroup> |
| 21 | + <VisualState x:Name="Default"> |
| 22 | + <VisualState.StateTriggers> |
| 23 | + <StateTrigger IsActive="{x:Bind converters:InverseBoolConverter.Convert(IsContinuation), Mode=OneWay}"/> |
| 24 | + </VisualState.StateTriggers> |
| 25 | + <VisualState.Setters> |
| 26 | + <Setter Target="RootGrid.Padding" Value="2,12,2,4"/> |
| 27 | + <Setter Target="Header.Visibility" Value="Visible"/> |
| 28 | + <Setter Target="ProfileImageContainer.Visibility" Value="Visible"/> |
| 29 | + </VisualState.Setters> |
| 30 | + </VisualState> |
| 31 | + <VisualState x:Name="Continuation"> |
| 32 | + <VisualState.StateTriggers> |
| 33 | + <StateTrigger IsActive="{x:Bind IsContinuation, Mode=OneWay}"/> |
| 34 | + </VisualState.StateTriggers> |
| 35 | + <VisualState.Setters> |
| 36 | + <Setter Target="RootGrid.Padding" Value="2,2,0,2"/> |
| 37 | + <Setter Target="Header.Visibility" Value="Collapsed"/> |
| 38 | + <Setter Target="ProfileImageContainer.Visibility" Value="Collapsed"/> |
| 39 | + </VisualState.Setters> |
| 40 | + </VisualState> |
| 41 | + </VisualStateGroup> |
| 42 | + </VisualStateManager.VisualStateGroups> |
20 | 43 |
|
21 | | - <!--Image--> |
22 | | - <Border x:Name="ProfileImageContainer" Width="36" Height="36" |
23 | | - CornerRadius="18" VerticalAlignment="Top"> |
24 | | - <tc:ImageEx Source="{x:Bind Author.AvatarUri}"/> |
25 | | - </Border> |
| 44 | + <Grid.ColumnDefinitions> |
| 45 | + <ColumnDefinition Width="64"/> |
| 46 | + <ColumnDefinition Width="*"/> |
| 47 | + </Grid.ColumnDefinitions> |
26 | 48 |
|
27 | | - <Grid Grid.Column="1"> |
28 | | - <Grid.RowDefinitions> |
29 | | - <RowDefinition Height="auto"/> |
30 | | - <RowDefinition/> |
31 | | - </Grid.RowDefinitions> |
| 49 | + <!--Image--> |
| 50 | + <Border x:Name="ProfileImageContainer" Width="36" Height="36" |
| 51 | + CornerRadius="18" VerticalAlignment="Top"> |
| 52 | + <tc:ImageEx Source="{x:Bind Author.AvatarUri}"/> |
| 53 | + </Border> |
32 | 54 |
|
33 | | - <StackPanel Orientation="Horizontal" Margin="0,-2,0,0" x:Name="UsernameContainer"> |
34 | | - <HyperlinkButton Content="{x:Bind Author.User.Username}" Style="{StaticResource PlainTextHyperlinkStyle}" |
35 | | - FontSize="14"/> |
36 | | - <TextBlock Text="{x:Bind tconvert:SmartTimeFormatConverter.Convert(Message.Timestamp)}" |
37 | | - VerticalAlignment="Center" |
38 | | - FontSize="12" Opacity=".5" Margin="6,0"/> |
39 | | - </StackPanel> |
| 55 | + <Grid Grid.Column="1"> |
| 56 | + <Grid.RowDefinitions> |
| 57 | + <RowDefinition Height="auto"/> |
| 58 | + <RowDefinition/> |
| 59 | + </Grid.RowDefinitions> |
40 | 60 |
|
41 | | - <StackPanel Grid.Row="1"> |
42 | | - <markdown:MessageRenderer Text="{x:Bind Content, Mode=OneWay}" Context="{x:Bind}" |
43 | | - HorizontalAlignment="Left"/> |
| 61 | + <StackPanel x:Name="Header" Orientation="Horizontal" Margin="0,-2,0,0"> |
| 62 | + <HyperlinkButton Content="{x:Bind Author.User.Username}" Style="{StaticResource PlainTextHyperlinkStyle}" |
| 63 | + FontSize="14"/> |
| 64 | + <TextBlock Text="{x:Bind tconvert:SmartTimeFormatConverter.Convert(Message.Timestamp)}" |
| 65 | + VerticalAlignment="Center" FontSize="12" Opacity=".5" Margin="6,0"/> |
| 66 | + </StackPanel> |
44 | 67 |
|
45 | | - <ItemsControl ItemsSource="{x:Bind Attachments}" |
46 | | - HorizontalAlignment="Left"> |
47 | | - <ItemsControl.ItemTemplate> |
48 | | - <DataTemplate x:DataType="bindableembeds:BindableAttachment"> |
49 | | - <tc:ImageEx Source="{x:Bind Attachment.ProxyUrl}" MaxWidth="400" |
50 | | - CornerRadius="2"/> |
51 | | - </DataTemplate> |
52 | | - </ItemsControl.ItemTemplate> |
53 | | - </ItemsControl> |
54 | | - </StackPanel> |
55 | | - </Grid> |
56 | | - </Grid> |
57 | | - </DataTemplate> |
| 68 | + <StackPanel Grid.Row="1"> |
| 69 | + <markdown:MessageRenderer Text="{x:Bind Message.Content, Mode=OneWay}" Context="{x:Bind}" |
| 70 | + HorizontalAlignment="Left"/> |
58 | 71 |
|
59 | | - <DataTemplate x:Key="ContinuationTemplate" x:DataType="bindablemessages:BindableMessage"> |
60 | | - <StackPanel Margin="64,2,0,2"> |
61 | | - <markdown:MessageRenderer Text="{x:Bind Content, Mode=OneWay}" Context="{x:Bind}" |
62 | | - HorizontalAlignment="Left"/> |
63 | | - |
64 | | - <ItemsControl ItemsSource="{x:Bind Attachments}" |
65 | | - HorizontalAlignment="Left"> |
66 | | - <ItemsControl.ItemTemplate> |
67 | | - <DataTemplate x:DataType="bindableembeds:BindableAttachment"> |
68 | | - <tc:ImageEx Source="{x:Bind Attachment.ProxyUrl}" MaxWidth="400" |
69 | | - CornerRadius="2"/> |
70 | | - </DataTemplate> |
71 | | - </ItemsControl.ItemTemplate> |
72 | | - </ItemsControl> |
73 | | - </StackPanel> |
| 72 | + <ItemsControl ItemsSource="{x:Bind Message.Attachments}" |
| 73 | + HorizontalAlignment="Left"> |
| 74 | + <ItemsControl.ItemTemplate> |
| 75 | + <DataTemplate x:DataType="bindableembeds:BindableAttachment"> |
| 76 | + <tc:ImageEx Source="{x:Bind Attachment.ProxyUrl}" MaxWidth="400" CornerRadius="2"/> |
| 77 | + </DataTemplate> |
| 78 | + </ItemsControl.ItemTemplate> |
| 79 | + </ItemsControl> |
| 80 | + </StackPanel> |
| 81 | + </Grid> |
| 82 | + </Grid> |
| 83 | + </UserControl> |
74 | 84 | </DataTemplate> |
75 | 85 |
|
76 | 86 | <DataTemplate x:Key="InfoMessageTemplate" x:DataType="bindablemessages:BindableMessage"> |
77 | | - <Grid VerticalAlignment="Center"> |
78 | | - <Grid.ColumnDefinitions> |
79 | | - <ColumnDefinition Width="64"/> |
80 | | - <ColumnDefinition Width="auto"/> |
81 | | - <ColumnDefinition Width="auto"/> |
82 | | - </Grid.ColumnDefinitions> |
83 | | - <FontIcon Glyph="{x:Bind mconvert:InfoMessageIconConverter.Convert(Message.Type)}" |
84 | | - Foreground="{x:Bind mconvert:InfoMessageColorConverter.Convert(Message.Type)}"/> |
| 87 | + <Grid Height="32"> |
| 88 | + <Grid VerticalAlignment="Center"> |
| 89 | + <Grid.ColumnDefinitions> |
| 90 | + <ColumnDefinition Width="64"/> |
| 91 | + <ColumnDefinition Width="auto"/> |
| 92 | + <ColumnDefinition Width="auto"/> |
| 93 | + </Grid.ColumnDefinitions> |
| 94 | + <FontIcon Glyph="{x:Bind mconvert:InfoMessageIconConverter.Convert(Message.Type)}" |
| 95 | + Foreground="{x:Bind mconvert:InfoMessageColorConverter.Convert(Message.Type)}"/> |
85 | 96 |
|
86 | | - <markdown:MessageRenderer Grid.Column="1" Margin="0,-5,0,0" Context="{x:Bind}" HorizontalAlignment="Left" |
87 | | - Text="{x:Bind mconvert:InfoMessageContentConverter.Convert((bindablemessages:BindableMessage))}"/> |
| 97 | + <markdown:MessageRenderer Grid.Column="1" Margin="0,-5,0,0" Context="{x:Bind}" HorizontalAlignment="Left" |
| 98 | + Text="{x:Bind mconvert:InfoMessageContentConverter.Convert((bindablemessages:BindableMessage))}"/> |
88 | 99 |
|
89 | | - <TextBlock Grid.Column="2" Text="{x:Bind tconvert:SmartTimeFormatConverter.Convert(Message.Timestamp)}" |
90 | | - Opacity=".5" Margin="8,0"/> |
| 100 | + <TextBlock Grid.Column="2" Text="{x:Bind tconvert:SmartTimeFormatConverter.Convert(Message.Timestamp)}" |
| 101 | + Opacity=".5" Margin="8,0"/> |
| 102 | + </Grid> |
91 | 103 | </Grid> |
92 | 104 | </DataTemplate> |
93 | 105 |
|
|
0 commit comments