Skip to content

Commit

Permalink
NR re-activate some features after migration to MAUI 8; improve styling
Browse files Browse the repository at this point in the history
  • Loading branch information
jbe2277 committed Dec 3, 2023
1 parent 025b261 commit c5212f6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private Task ShowFeedItemView(object? parameter)

private Task EditFeed(object? parameter)
{
var feed = (Feed)parameter!;
var feed = (Feed)(parameter ?? throw new InvalidOperationException("parameter of the edit command must not be null"));
shellViewModel.SelectedFeed = feedViewModel.Value.Feed = feed;
AddEditFeedViewModel.IsEditMode = true;
AddEditFeedViewModel.FeedUrl = feed.Uri.ToString();
Expand All @@ -196,7 +196,7 @@ private Task EditFeed(object? parameter)

private async Task RemoveFeed(object? parameter)
{
var feed = (Feed)parameter!;
var feed = (Feed)(parameter ?? throw new InvalidOperationException("parameter of the remove command must not be null"));
if (await messageService.ShowYesNoQuestion(Resources.RemoveFeedQuestion, feed.Name))
{
FeedManager.Feeds.Remove(feed);
Expand Down
20 changes: 7 additions & 13 deletions src/NewsReader/NewsReader.Presentation/Views/AddEditFeedView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
<Setter Property="Title" Value="{x:Static p:Resources.EditFeed}"/>
</DataTrigger>
</ContentPage.Triggers>

<ContentPage.Content>
<Grid ColumnDefinitions="*,Auto" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto" RowSpacing="15" ColumnSpacing="10" Margin="10">
<!-- TODO: LineBreakMode does not work here. Android/Pixel 5 emulator - just one line shown and clipped. -->

<ScrollView>
<Grid ColumnDefinitions="*,Auto" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto" RowSpacing="15" ColumnSpacing="10" Margin="10" MaximumWidthRequest="600" HorizontalOptions="Start">
<Label Grid.ColumnSpan="2" Text="{x:Static p:Resources.EnterOrPasteFeedUrlBelow}" LineBreakMode="WordWrap"/>

<Entry Grid.Row="1" Text="{Binding FeedUrl}" Placeholder="{x:Static p:Resources.FeedUrl}" Keyboard="Url" ReturnCommand="{Binding LoadFeedCommand}" Unfocused="FeedUrlUnfocused"/>
Expand All @@ -29,13 +28,8 @@

<Label Grid.Row="3" Text="{Binding Feed.Title, StringFormat={x:Static p:Resources.TitleWithParam}, FallbackValue={x:Static p:Resources.Title}}" Margin="0,0,0,10"/>

<Entry Grid.Row="4" Text="{Binding Feed.Name}" Placeholder="{x:Static p:Resources.FeedName}">
<Entry.Triggers>
<DataTrigger TargetType="Entry" Binding="{Binding Feed, TargetNullValue='Null'}" Value="Null">
<Setter Property="IsEnabled" Value="False"/>
</DataTrigger>
</Entry.Triggers>
</Entry>
<Entry Grid.Row="4" Text="{Binding Feed.Name}" Placeholder="{x:Static p:Resources.FeedName}"/>

<Button Grid.Row="4" Grid.Column="1" Command="{Binding UseTitleAsNameCommand}" Text="&#xf464;" FontFamily="MaterialIcons"/>

<Label Grid.Row="5" Grid.ColumnSpan="2" Text="{Binding Feed.Errors, Converter={StaticResource ErrorsToMessageConverter}, ConverterParameter=Name}" TextColor="DarkRed"/>
Expand All @@ -46,13 +40,13 @@
<Setter Property="Text" Value="{x:Static p:Resources.Update}"/>
</DataTrigger>
<DataTrigger TargetType="Button" Binding="{Binding IsSameFeed}" Value="True">
<Setter Property="IsVisible" Value="False"/>
<Setter Property="IsEnabled" Value="False"/>
</DataTrigger>
</Button.Triggers>
</Button>

<ActivityIndicator Grid.ColumnSpan="2" Grid.RowSpan="7" IsRunning="{Binding Feed.IsLoading, FallbackValue=false}"
HorizontalOptions="Center" VerticalOptions="Start" WidthRequest="32" HeightRequest="32" Margin="10"/>
</Grid>
</ContentPage.Content>
</ScrollView>
</ContentPage>
19 changes: 9 additions & 10 deletions src/NewsReader/NewsReader.Presentation/Views/FeedView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
</ToolbarItem.IconImageSource>
</ToolbarItem>
</ContentPage.ToolbarItems>

<ContentPage.Content>
<Grid RowDefinitions="Auto,Auto,Auto,*">
<VerticalStackLayout IsVisible="{Binding Feed.LoadError, FallbackValue=false, Converter={StaticResource NullToBoolConverter}}" Padding="10,5" BackgroundColor="{StaticResource ErrorBackgroundColor}">
<Label Text="{x:Static p:Resources.LoadError}" Style="{StaticResource Title}"/>
<Label Text="{Binding Feed.LoadError.Message}" MaxLines="4"/>
</VerticalStackLayout>

<SearchBar Grid.Row="1" x:Name="searchBar" Text="{Binding SearchText}" IsVisible="False"/>

<VerticalStackLayout Grid.Row="2" IsVisible="{Binding Feed, Converter={StaticResource NullToBoolConverter}, ConverterParameter=invert}" Padding="10,5">
<Label Text="{x:Static p:Resources.SelectFeedInfo}"/>
</VerticalStackLayout>

<RefreshView Grid.Row="3" IsRefreshing="{Binding Feed.IsLoading, Mode=OneWay}" Command="{Binding RefreshCommand}">
<CollectionView x:Name="listView" ItemsSource="{Binding ItemsListView}" IsGrouped="True">
<CollectionView.GroupHeaderTemplate>
Expand All @@ -38,9 +38,8 @@
</CollectionView.GroupHeaderTemplate>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="do:FeedItem">
<!-- TODO: Remove SwipeView as it is responsible for a crash on the Windows platform. See https://github.com/dotnet/maui/issues/8870
<SwipeView>-->
<!--<SwipeView.LeftItems>
<SwipeView>
<SwipeView.LeftItems>
<SwipeItems>
<SwipeItem Command="{Binding BindingContext.ReadUnreadCommand, Source={Reference listView}}" CommandParameter="{Binding}"
Text="{Binding MarkAsRead, Converter={StaticResource MarkAsReadConverter}}" BackgroundColor="LightBlue">
Expand All @@ -49,8 +48,8 @@
</SwipeItem.IconImageSource>
</SwipeItem>
</SwipeItems>
</SwipeView.LeftItems>-->
</SwipeView.LeftItems>

<VerticalStackLayout Padding="10,5,10,10" Spacing="3" InputTransparent="False">
<FlyoutBase.ContextFlyout>
<MenuFlyout>
Expand All @@ -72,7 +71,7 @@
</Label>
<Label Text="{Binding Description}" MaxLines="3"/>
</VerticalStackLayout>
<!--</SwipeView>-->
</SwipeView>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
Expand Down
19 changes: 10 additions & 9 deletions src/NewsReader/NewsReader.Presentation/Views/SettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@
<FontImageSource Glyph="&#xf493;" FontFamily="MaterialIcons" Color="Black" Size="20"/>
</ContentPage.IconImageSource>

<ContentPage.Content>
<VerticalStackLayout Spacing="10" Margin="15,10">
<ScrollView>
<VerticalStackLayout Spacing="10" Margin="15,10" MaximumWidthRequest="600" HorizontalOptions="Start">
<Label Text="{x:Static p:Resources.DataManagement}" Style="{StaticResource Title}"/>
<Label Text="{x:Static p:Resources.StoreFeedItemsFor}"/>
<Picker ItemsSource="{Binding ItemLifetimes}" SelectedItem="{Binding SelectedItemLifetime}" ItemDisplayBinding="{Binding Converter={StaticResource LocalizeDisplayItemLifetimeConverter}}"/>
<Label Text="{x:Static p:Resources.StoreAtMaximumFeedItemsPerFeed}"/>
<Picker ItemsSource="{Binding MaxItemsLimits}" SelectedItem="{Binding SelectedMaxItemsLimit}" ItemDisplayBinding="{Binding Converter={StaticResource LocalizeDisplayMaxItemsLimitConverter}}"/>
</VerticalStackLayout>
</ContentPage.Content>
</ScrollView>
</ContentPage>

<ContentPage Title="{x:Static p:Resources.DataSync}">
<ContentPage.IconImageSource>
<FontImageSource Glyph="&#xf4e6;" FontFamily="MaterialIcons" Color="Black" Size="20"/>
</ContentPage.IconImageSource>

<ContentPage.Content>
<VerticalStackLayout Spacing="10" Margin="15,10">
<ScrollView>
<VerticalStackLayout Spacing="10" Margin="15,10" MaximumWidthRequest="600" HorizontalOptions="Start">
<Label Text="{x:Static p:Resources.DataSyncDescription}"/>
<Label Text="{x:Static p:Resources.SynchronizationDeactivated}">
<Label.Triggers>
Expand All @@ -45,15 +45,16 @@
<Button Command="{Binding SignOutCommand}" Text="{x:Static p:Resources.SignOut}" HorizontalOptions="Start"
IsVisible="{Binding WebStorageService.CurrentAccount, Converter={StaticResource NullToBoolConverter}}"/>
</VerticalStackLayout>
</ContentPage.Content>
</ScrollView>
</ContentPage>

<ContentPage Title="{x:Static p:Resources.Info}">
<ContentPage.IconImageSource>
<FontImageSource Glyph="&#xf2fd;" FontFamily="MaterialIcons" Color="Black" Size="20"/>
</ContentPage.IconImageSource>
<ContentPage.Content>
<VerticalStackLayout Spacing="10" Margin="15,10">

<ScrollView>
<VerticalStackLayout Spacing="10" Margin="15,10" MaximumWidthRequest="600" HorizontalOptions="Start">
<Label Text="{Binding AppInfo.AppName}" Style="{StaticResource Title}"/>
<Label Text="{Binding AppInfo.VersionString}">
<Label.GestureRecognizers>
Expand All @@ -71,6 +72,6 @@
<Label Text="{Binding CurrencyValue, StringFormat='Currency value: {0:C}'}"/>
</VerticalStackLayout>
</VerticalStackLayout>
</ContentPage.Content>
</ScrollView>
</ContentPage>
</TabbedPage>
5 changes: 2 additions & 3 deletions src/NewsReader/NewsReader.Presentation/Views/ShellView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<VisualState x:Name="Disabled"/>
<VisualState x:Name="Selected">
<VisualState.Setters>
<!-- Overwrite default Selected background (orange) -->
<!-- Overwrite default Selected background (orange) -->
<Setter Property="BackgroundColor" Value="{StaticResource Blue300Accent}"/>
</VisualState.Setters>
</VisualState>
Expand All @@ -39,7 +39,6 @@
<Grid RowDefinitions="Auto,Auto,*,Auto" Padding="10" BackgroundColor="White">
<Label Grid.Row="0" Text="{Binding AppName}" Style="{StaticResource Title}" Margin="0,0,0,10"/>

<!-- TODO: Reorder does not work on Android but on Windows -->
<CollectionView x:Name="listView" Grid.Row="2" ItemsSource="{Binding Feeds}" SelectedItem="{Binding SelectedFeed}" SelectionMode="Single" CanReorderItems="True">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="do:Feed">
Expand All @@ -65,14 +64,14 @@

<FlyoutBase.ContextFlyout>
<MenuFlyout>
<!-- TODO: CommandParameter Binding is not called (Windows); for SwipeItem this works (Android) -->
<MenuFlyoutItem Text="{x:Static p:Resources.Edit}" Command="{Binding BindingContext.EditFeedCommand, Source={Reference listView}}" CommandParameter="{Binding}"/>
<MenuFlyoutItem Text="{x:Static p:Resources.Remove}" Command="{Binding BindingContext.RemoveFeedCommand, Source={Reference listView}}" CommandParameter="{Binding}"/>
</MenuFlyout>
</FlyoutBase.ContextFlyout>

<SwipeView.LeftItems>
<SwipeItems>
<!-- TODO: Clipped text on Android: https://github.com/dotnet/maui/pull/11931 -->
<SwipeItem Command="{Binding BindingContext.EditFeedCommand, Source={Reference listView}}" CommandParameter="{Binding}" Text="{x:Static p:Resources.Edit}">
<SwipeItem.IconImageSource>
<FontImageSource Glyph="&#xf90b;" FontFamily="MaterialIcons"/>
Expand Down

0 comments on commit c5212f6

Please sign in to comment.