infobar errors

This commit is contained in:
2024-03-09 21:53:30 +01:00
Unverified
parent 760079f26e
commit cd74725561
4 changed files with 158 additions and 148 deletions

View File

@@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ErrorInfoBar.Title" xml:space="preserve">
<value>Error</value>
</data>
<data name="OptionBarDownloadAll.Label" xml:space="preserve">
<value>Download all</value>
</data>

View File

@@ -23,13 +23,6 @@ namespace VDownload.Core.ViewModels.Home
{
#region ENUMS
public enum OptionBarMessageIconType
{
None,
ProgressRing,
Error
}
public enum OptionBarContentType
{
None,
@@ -80,6 +73,11 @@ namespace VDownload.Core.ViewModels.Home
[ObservableProperty]
private Type _mainContent;
[ObservableProperty]
private string _optionBarError;
[ObservableProperty]
private bool _optionBarIsErrorOpened;
[ObservableProperty]
private OptionBarContentType _optionBarContent;
@@ -88,7 +86,7 @@ namespace VDownload.Core.ViewModels.Home
private string _optionBarMessage;
[ObservableProperty]
private OptionBarMessageIconType _optionBarMessageIcon;
private bool _optionBarLoading;
[ObservableProperty]
private bool _optionBarLoadSubscriptionButtonChecked;
@@ -149,8 +147,10 @@ namespace VDownload.Core.ViewModels.Home
MainContent = _downloadsView;
OptionBarContent = OptionBarContentType.None;
OptionBarMessageIcon = OptionBarMessageIconType.None;
OptionBarLoading = false;
OptionBarMessage = null;
OptionBarError = null;
OptionBarIsErrorOpened = true;
OptionBarLoadSubscriptionButtonChecked = false;
OptionBarVideoSearchButtonChecked = false;
OptionBarPlaylistSearchButtonChecked = false;
@@ -164,7 +164,7 @@ namespace VDownload.Core.ViewModels.Home
public async Task LoadFromSubscription()
{
MainContent = _downloadsView;
OptionBarMessageIcon = OptionBarMessageIconType.None;
OptionBarLoading = false;
OptionBarMessage = null;
if (OptionBarLoadSubscriptionButtonChecked)
@@ -174,7 +174,7 @@ namespace VDownload.Core.ViewModels.Home
OptionBarPlaylistSearchButtonChecked = false;
OptionBarSearchNotPending = false;
OptionBarMessageIcon = OptionBarMessageIconType.ProgressRing;
OptionBarLoading = true;
OptionBarMessage = _stringResourcesService.HomeViewResources.Get("OptionBarMessageLoading");
SubscriptionsVideoList subList = new SubscriptionsVideoList { Name = _stringResourcesService.CommonResources.Get("SubscriptionVideoListName") };
@@ -217,7 +217,7 @@ namespace VDownload.Core.ViewModels.Home
}
OptionBarSearchNotPending = true;
OptionBarMessageIcon = OptionBarMessageIconType.None;
OptionBarLoading = false;
}
}
@@ -225,7 +225,7 @@ namespace VDownload.Core.ViewModels.Home
public void VideoSearchShow()
{
OptionBarSearchNotPending = true;
OptionBarMessageIcon = OptionBarMessageIconType.None;
OptionBarLoading = false;
OptionBarMessage = null;
MainContent = _downloadsView;
@@ -245,7 +245,7 @@ namespace VDownload.Core.ViewModels.Home
public void PlaylistSearchShow()
{
OptionBarSearchNotPending = true;
OptionBarMessageIcon = OptionBarMessageIconType.None;
OptionBarLoading = false;
OptionBarMessage = null;
MainContent = _downloadsView;
@@ -265,7 +265,7 @@ namespace VDownload.Core.ViewModels.Home
public async Task VideoSearchStart()
{
OptionBarSearchNotPending = false;
OptionBarMessageIcon = OptionBarMessageIconType.ProgressRing;
OptionBarLoading = true;
OptionBarMessage = _stringResourcesService.HomeViewResources.Get("OptionBarMessageLoading");
Video video;
@@ -275,9 +275,10 @@ namespace VDownload.Core.ViewModels.Home
}
catch (MediaSearchException ex)
{
OptionBarMessageIcon = OptionBarMessageIconType.Error;
OptionBarMessage = _stringResourcesService.SearchResources.Get(ex.StringCode);
OptionBarError = _stringResourcesService.SearchResources.Get(ex.StringCode);
OptionBarSearchNotPending = true;
OptionBarLoading = false;
OptionBarMessage = null;
return;
}
@@ -286,7 +287,7 @@ namespace VDownload.Core.ViewModels.Home
MainContent = _videoView;
OptionBarSearchNotPending = true;
OptionBarMessageIcon = OptionBarMessageIconType.None;
OptionBarLoading = false;
OptionBarMessage = null;
}
@@ -294,7 +295,7 @@ namespace VDownload.Core.ViewModels.Home
public async Task PlaylistSearchStart()
{
OptionBarSearchNotPending = false;
OptionBarMessageIcon = OptionBarMessageIconType.ProgressRing;
OptionBarLoading = true;
OptionBarMessage = _stringResourcesService.HomeViewResources.Get("OptionBarMessageLoading");
Playlist playlist;
@@ -304,9 +305,10 @@ namespace VDownload.Core.ViewModels.Home
}
catch (MediaSearchException ex)
{
OptionBarMessageIcon = OptionBarMessageIconType.Error;
OptionBarMessage = _stringResourcesService.SearchResources.Get(ex.StringCode);
OptionBarError = _stringResourcesService.SearchResources.Get(ex.StringCode);
OptionBarSearchNotPending = true;
OptionBarLoading = false;
OptionBarMessage = null;
return;
}
@@ -315,7 +317,7 @@ namespace VDownload.Core.ViewModels.Home
MainContent = _videoCollectionView;
OptionBarSearchNotPending = true;
OptionBarMessageIcon = OptionBarMessageIconType.None;
OptionBarLoading = false;
OptionBarMessage = null;
}
@@ -339,6 +341,13 @@ namespace VDownload.Core.ViewModels.Home
}
}
[RelayCommand]
public void CloseError()
{
OptionBarError = null;
OptionBarIsErrorOpened = true;
}
#endregion

View File

@@ -25,8 +25,10 @@
<Frame Content="{Binding MainContent, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ViewModelToViewConverter}}">
</Frame>
<Grid Grid.Row="1"
Background="{ThemeResource OptionBarBackgroundColor}"
<ctuc:SwitchPresenter Grid.Row="1"
Value="{Binding OptionBarError, Converter={StaticResource IsNotNullConverter}}">
<ctuc:Case Value="False">
<Grid Background="{ThemeResource OptionBarBackgroundColor}"
CornerRadius="10">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
@@ -106,24 +108,10 @@
</ctuc:SwitchPresenter>
<StackPanel VerticalAlignment="Center"
Orientation="Horizontal">
<StackPanel.Resources>
<x:Double x:Key="IconSize">20</x:Double>
<Thickness x:Key="IconMargin">0,0,10,0</Thickness>
</StackPanel.Resources>
<ctuc:SwitchPresenter Value="{Binding OptionBarMessageIcon, Converter={StaticResource ObjectToStringConverter}}">
<ctuc:Case Value="None"/>
<ctuc:Case Value="ProgressRing">
<ProgressRing Width="{StaticResource IconSize}"
Height="{StaticResource IconSize}"
Margin="{StaticResource IconMargin}"/>
</ctuc:Case>
<ctuc:Case Value="Error">
<Image Width="{StaticResource IconSize}"
Height="{StaticResource IconSize}"
Margin="{StaticResource IconMargin}"
Source="{StaticResource ImageHomeViewError}"/>
</ctuc:Case>
</ctuc:SwitchPresenter>
<ProgressRing Width="20"
Height="20"
Margin="0,0,10,0"
Visibility="{Binding OptionBarLoading, Converter={StaticResource BoolToVisibilityConverter}}"/>
<TextBlock Text="{Binding OptionBarMessage}"/>
</StackPanel>
</ctuc:UniformGrid>
@@ -150,5 +138,15 @@
Command="{Binding DownloadCommand}"/>
</StackPanel>
</Grid>
</ctuc:Case>
<ctuc:Case Value="True">
<InfoBar x:Uid="/VDownload.Core.Strings/HomeViewResources/ErrorInfoBar"
Severity="Error"
IsOpen="{Binding OptionBarIsErrorOpened, Mode=TwoWay}"
Message="{Binding OptionBarError}"
CloseButtonCommand="{Binding CloseErrorCommand}"/>
</ctuc:Case>
</ctuc:SwitchPresenter>
</Grid>
</Page>

View File

@@ -107,7 +107,7 @@
<ctuc:Case Value="True">
<InfoBar x:Uid="/VDownload.Core.Strings/SubscriptionsViewResources/ErrorInfoBar"
Severity="Error"
IsOpen="{Binding IsErrorOpened, Mode=TwoWay}"
IsOpen="{Binding OptionBarIsErrorOpened, Mode=TwoWay}"
Message="{Binding Error}"
CloseButtonCommand="{Binding CloseErrorCommand}"/>
</ctuc:Case>