Skip to content

Commit

Permalink
Move suggestions view to lazy load.
Browse files Browse the repository at this point in the history
  • Loading branch information
angelinn committed Dec 22, 2024
1 parent 73fb7d6 commit 09497ba
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 26 deletions.
27 changes: 1 addition & 26 deletions src/TramlineFive/TramlineFive.Maui/Pages/MapPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,7 @@

<ActivityIndicator AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="1,1,1,1" BindingContext="{Binding VirtualTablesViewModel, Source={StaticResource Locator}}" IsRunning="{Binding IsLoading}" HeightRequest="64" Color="DodgerBlue" Margin="0,100,0,0" />


<Border Stroke="Transparent" AbsoluteLayout.LayoutBounds="0,0.8,1,300" AbsoluteLayout.LayoutFlags="PositionProportional,WidthProportional" BackgroundColor="{DynamicResource BackgroundColor}" Margin="15,-5,15,0" Opacity="0.9" VerticalOptions="End" Padding="0" IsVisible="{Binding IsSearching}" HeightRequest="{Binding SuggestionsHeight}">
<Border.StrokeShape>
<RoundRectangle CornerRadius="30" />
</Border.StrokeShape>
<ListView SeparatorColor="Transparent" ItemsSource="{Binding FilteredStops}" SelectedItem="{Binding SelectedSuggestion}" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<Grid ColumnSpacing="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<Label FontFamily="MaterialIconsOutlinedRegular.otf" Text="&#xe8b6;" FontSize="23" VerticalOptions="Center" Margin="5,7,0,0" HorizontalOptions="Center" TextColor="#9aa0a6" />

<Label Grid.Column="1" Text="{Binding}" VerticalOptions="Center" Margin="0,5,0,0" FontSize="15" />
</Grid>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Border>
<mct:LazyView x:Name="LazySuggestions" x:TypeArguments="views:SuggestionsView" AbsoluteLayout.LayoutBounds="0,0.8,1,300" AbsoluteLayout.LayoutFlags="PositionProportional,WidthProportional" Margin="15,-5,15,0" VerticalOptions="End" IsVisible="{Binding IsSearching}" HeightRequest="{Binding SuggestionsHeight}" BindingContext="{Binding}" />

<mct:LazyView x:Name="LazyFab" x:TypeArguments="views:CustomFloatingActionButton"
AbsoluteLayout.LayoutFlags="PositionProportional,WidthProportional" AbsoluteLayout.LayoutBounds="1,0.80,1,58" Grid.Row="1" HorizontalOptions="End" VerticalOptions="End"
Expand Down
1 change: 1 addition & 0 deletions src/TramlineFive/TramlineFive.Maui/Pages/MapPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ protected override void OnAppearing()
LazySearchBar.LoadViewAsync();
LazyVirtualTablesView.LoadViewAsync();
LazyFab.LoadViewAsync();
LazySuggestions.LoadViewAsync();
});
});
}
Expand Down
6 changes: 6 additions & 0 deletions src/TramlineFive/TramlineFive.Maui/TramlineFive.Maui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@
<Compile Update="Themes\LightTheme.xaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
<Compile Update="Views\SuggestionsView.xaml.cs">
<DependentUpon>SuggestionsView.xaml</DependentUpon>
</Compile>
<Compile Update="Views\CustomFloatingActionButton.xaml.cs">
<DependentUpon>CustomFloatingActionButton.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -291,6 +294,9 @@
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</MauiXaml>
<MauiXaml Update="Views\SuggestionsView.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</MauiXaml>
<MauiXaml Update="Views\SearchBar.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</MauiXaml>
Expand Down
29 changes: 29 additions & 0 deletions src/TramlineFive/TramlineFive.Maui/Views/SuggestionsView.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<Border xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="TramlineFive.Maui.Views.SuggestionsView"
xmlns:cv="clr-namespace:TramlineFive.Converters"
xmlns:mct="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
BackgroundColor="{DynamicResource BackgroundColor}" Opacity="0.9" Padding="0" Stroke="Transparent">

<Border.StrokeShape>
<RoundRectangle CornerRadius="30" />
</Border.StrokeShape>
<CollectionView ItemsSource="{Binding FilteredStops}" SelectionMode="Single" SelectedItem="{Binding SelectedSuggestion}" >
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid ColumnSpacing="0" HeightRequest="48">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<Label FontFamily="MaterialIconsOutlinedRegular.otf" Text="&#xe8b6;" FontSize="23" VerticalOptions="Center" Margin="5,7,0,0" HorizontalOptions="Center" TextColor="#9aa0a6" />

<Label Grid.Column="1" Text="{Binding}" VerticalOptions="Center" Margin="0,5,0,0" FontSize="15" />
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Border>

11 changes: 11 additions & 0 deletions src/TramlineFive/TramlineFive.Maui/Views/SuggestionsView.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Mapsui.Utilities;

namespace TramlineFive.Maui.Views;

public partial class SuggestionsView : Border
{
public SuggestionsView()
{
InitializeComponent();
}
}

0 comments on commit 09497ba

Please sign in to comment.