Skip to content

Commit

Permalink
rework video call event item
Browse files Browse the repository at this point in the history
  • Loading branch information
huynhsontung committed Dec 23, 2021
1 parent a85f850 commit 4972992
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 27 deletions.
48 changes: 37 additions & 11 deletions Indirect/Controls/ThreadItemControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -489,23 +489,49 @@
</DataTemplate>

<DataTemplate x:Key="VideoCallTemplate" x:DataType="wrappers:DirectItemWrapper">
<Border
x:Name="NotAvailableMessage"
<Grid
MinWidth="{StaticResource MediaItemMaxWidth}"
MaxWidth="{StaticResource TextItemMaxWidth}"
HorizontalAlignment="{x:Bind FromMe, Converter={StaticResource FromMeAlignmentConverter}}"
Background="Transparent"
BorderBrush="{StaticResource SystemControlForegroundBaseMediumBrush}"
BorderThickness="1"
Background="{ThemeResource FromThemItemBackground}"
CornerRadius="{x:Bind GetRelativeCornerRadius(RelativeMode), Mode=OneWay}">
<TextBlock
MaxWidth="{StaticResource TextItemMaxWidth}"
Margin="{StaticResource TextMargin}"
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border
Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="0"
Margin="10,8,0,8"
HorizontalAlignment="Center"
FontStyle="Italic"
VerticalAlignment="Center"
Background="{StaticResource SystemControlBackgroundBaseLowBrush}"
CornerRadius="99">
<SymbolIcon Margin="6" Symbol="{x:Bind GetVideoEventSymbol()}" />
</Border>
<TextBlock
Grid.Row="0"
Grid.Column="1"
Margin="10,8,8,0"
VerticalAlignment="Bottom"
FontWeight="Medium"
Text="{x:Bind Description}"
TextWrapping="Wrap" />
<TextBlock
Grid.Row="1"
Grid.Column="1"
Margin="10,0,8,8"
VerticalAlignment="Top"
Foreground="{StaticResource SystemControlForegroundBaseMediumBrush}"
Style="{ThemeResource FluentCaptionTextStyle}"
Text="{x:Bind Description}"
Text="{x:Bind MinimalTimestamp}"
TextWrapping="Wrap" />
</Border>
</Grid>
</DataTemplate>

<DataTemplate x:Key="ProfileTemplate" x:DataType="wrappers:DirectItemWrapper">
Expand Down
24 changes: 16 additions & 8 deletions Indirect/Controls/ThreadItemControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,23 @@ private void ProcessItem()

private void UpdateContextMenu()
{
if (Item.Source.ItemType == DirectItemType.ActionLog)
switch (Item.Source.ItemType)
{
ItemContainer.Visibility = Item.Source.HideInThread ? Visibility.Collapsed : Visibility.Visible;
ContextFlyout = null;
}
case DirectItemType.ActionLog:
ItemContainer.Visibility = Item.Source.HideInThread ? Visibility.Collapsed : Visibility.Visible;
ContextFlyout = null;
break;

if (Item.Source.ItemType == DirectItemType.Text)
{
MenuCopyOption.Visibility = Visibility.Visible;
case DirectItemType.VideoCallEvent:
ContextFlyout = null;
break;

case DirectItemType.Text:
MenuCopyOption.Visibility = Visibility.Visible;
break;

default:
break;
}

if (Item.VideoUri != null || Item.FullImageUri != null)
Expand Down Expand Up @@ -243,7 +251,7 @@ private void ReelShareImage_Tapped(object sender, TappedRoutedEventArgs e)

private async void Item_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
{
if (Item.ObservableReactions.MeLiked) return;
if (Item.ObservableReactions.MeLiked || Item.Source.ItemType == DirectItemType.VideoCallEvent) return;
await ViewModel.ChatService.ReactToItem(Item, Emoji.RedHeart.ToString());
}

Expand Down
18 changes: 10 additions & 8 deletions Indirect/Entities/Wrappers/DirectItemWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public RelativeItemMode RelativeMode

public LinkTextForDisplay LinkText { get; }

public string MinimalTimestamp => Source.Timestamp.ToString("t");

public bool IsReplyable => GetItemReplyable();

public HorizontalAlignment HorizontalAlignment => GetHorizontalAlignment();
Expand Down Expand Up @@ -425,14 +427,7 @@ private void SetDescriptionText()
break;

case DirectItemType.VideoCallEvent:
if (Source.VideoCallEvent?.Action == "video_call_started")
{
Description = FromMe ? "You started a video chat" : "Video chat started";
}
else
{
Description = "Video chat ended";
}
Description = Source.VideoCallEvent?.Description;
break;

case DirectItemType.Profile:
Expand Down Expand Up @@ -512,5 +507,12 @@ public CornerRadius GetRelativeCornerRadius(RelativeItemMode mode)
throw new ArgumentOutOfRangeException(nameof(mode), mode, "Unexpected RelativeItemMode");
}
}

public Windows.UI.Xaml.Controls.Symbol GetVideoEventSymbol()
{
return Source.VideoCallEvent?.Action == "video_call_ended"
? Windows.UI.Xaml.Controls.Symbol.HangUp
: Windows.UI.Xaml.Controls.Symbol.Phone;
}
}
}

0 comments on commit 4972992

Please sign in to comment.