Skip to content

Commit

Permalink
Version 3.2.0 with Lazy/Delayed views LoadingView, code cleanup, and …
Browse files Browse the repository at this point in the history
…binding context fixes
  • Loading branch information
roubachof committed Oct 24, 2024
1 parent d3a60ce commit 07f3072
Show file tree
Hide file tree
Showing 20 changed files with 1,271 additions and 1,329 deletions.
8 changes: 4 additions & 4 deletions Maui.Tabs/Maui.Tabs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

<PropertyGroup>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<AssemblyVersion>3.1.1</AssemblyVersion>
<AssemblyFileVersion>3.1.1</AssemblyFileVersion>
<Version>3.1.1</Version>
<AssemblyVersion>3.2.0</AssemblyVersion>
<AssemblyFileVersion>3.2.0</AssemblyFileVersion>
<Version>3.2.0</Version>
<PackOnBuild>true</PackOnBuild>
<NeutralLanguage>en</NeutralLanguage>

Expand All @@ -41,7 +41,7 @@
<PackageReadmeFile>docs\ReadMe.md</PackageReadmeFile>
<PackageTags>maui dotnetmaui xamarin.forms android ios uwp netstandard tabs segmented control bottombar fixed tabs scrollable tabs badge</PackageTags>
<PackageReleaseNotes>
Fixes for touch effects on tabs
Added loading view for Lazy and Delayed view.
</PackageReleaseNotes>

<Title>"Pure" MAUI Tabs (no renderers)</Title>
Expand Down
13 changes: 12 additions & 1 deletion MauiSample/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<ContentPage x:Class="MauiSample.MainPage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:SkiaSharp.Extended.UI.Controls;assembly=SkiaSharp.Extended.UI"
xmlns:tabs="http://sharpnado.com"
xmlns:viewModels="clr-namespace:MauiSample.Presentation.ViewModels"
xmlns:views="clr-namespace:MauiSample.Presentation.Views"
Expand Down Expand Up @@ -48,7 +49,17 @@
AccentColor="{StaticResource Primary}"
Animate="True"
BindingContext="{Binding HomePageViewModel}"
UseActivityIndicator="True" />
DelayInMilliseconds="5000"
UseActivityIndicator="True">
<tabs:DelayedView.LoadingView>
<controls:SKLottieView WidthRequest="200"
HeightRequest="200"
HorizontalOptions="Center"
VerticalOptions="Center"
RepeatCount="-1"
Source="dino_pink.json" />
</tabs:DelayedView.LoadingView>
</tabs:DelayedView>
<tabs:DelayedView x:TypeArguments="views:TabA"
AccentColor="{StaticResource Primary}"
Animate="True"
Expand Down
3 changes: 3 additions & 0 deletions MauiSample/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using MauiSample.Presentation.ViewModels;
using Sharpnado.Tabs;

using SkiaSharp.Views.Maui.Controls.Hosting;

namespace MauiSample;

public static class MauiProgram
Expand All @@ -15,6 +17,7 @@ public static MauiApp CreateMauiApp()
builder
.UseMauiApp<App>()
.UseSharpnadoTabs(loggerEnable: true, debugLogEnable: true)
.UseSkiaSharp()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Bold.ttf", "OpenSansBold");
Expand Down
2 changes: 2 additions & 0 deletions MauiSample/MauiSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,15 @@
<None Remove="Resources\Images\theme_96.png" />
<None Remove="Resources\Images\the_internet.png" />
<None Remove="Resources\Images\will_ferrell.jpg" />
<None Remove="Resources\Raw\dino.json" />
<None Remove="Resources\Splash\logo.png" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Sharpnado.Maui.TaskLoaderView" Version="2.5.1" />
<PackageReference Include="SimpleInjector" Version="5.4.0" />
<PackageReference Include="SkiaSharp.Extended.UI.Maui" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions MauiSample/Resources/Raw/dino_pink.json

Large diffs are not rendered by default.

62 changes: 30 additions & 32 deletions MauiSample/Resources/Styles/Styles.xaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?xaml-comp compile="true" ?>
<ResourceDictionary
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<ResourceDictionary xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">

<Style TargetType="ActivityIndicator">
<Setter Property="Color" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" />
</Style>

<Style TargetType="IndicatorView">
<Setter Property="IndicatorColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray500}}"/>
<Setter Property="SelectedIndicatorColor" Value="{AppThemeBinding Light={StaticResource Gray950}, Dark={StaticResource Gray100}}"/>
<Setter Property="IndicatorColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray500}}" />
<Setter Property="SelectedIndicatorColor" Value="{AppThemeBinding Light={StaticResource Gray950}, Dark={StaticResource Gray100}}" />
</Style>

<Style TargetType="Border">
<Setter Property="Stroke" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray500}}" />
<Setter Property="StrokeShape" Value="Rectangle"/>
<Setter Property="StrokeThickness" Value="1"/>
<Setter Property="StrokeShape" Value="Rectangle" />
<Setter Property="StrokeThickness" Value="1" />
</Style>

<Style TargetType="BoxView">
Expand All @@ -26,10 +24,10 @@
<Style TargetType="Button">
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Primary}}" />
<Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" />
<Setter Property="FontFamily" Value="OpenSansRegular"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="CornerRadius" Value="8"/>
<Setter Property="Padding" Value="14,10"/>
<Setter Property="FontFamily" Value="OpenSansRegular" />
<Setter Property="FontSize" Value="14" />
<Setter Property="CornerRadius" Value="8" />
<Setter Property="Padding" Value="14,10" />
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
Expand Down Expand Up @@ -64,8 +62,8 @@
<Style TargetType="DatePicker">
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource White}}" />
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="FontFamily" Value="OpenSansRegular"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="FontFamily" Value="OpenSansRegular" />
<Setter Property="FontSize" Value="14" />
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
Expand All @@ -83,7 +81,7 @@
<Style TargetType="Editor">
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}" />
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="FontFamily" Value="OpenSansRegular"/>
<Setter Property="FontFamily" Value="OpenSansRegular" />
<Setter Property="FontSize" Value="14" />
<Setter Property="PlaceholderColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray500}}" />
<Setter Property="VisualStateManager.VisualStateGroups">
Expand All @@ -103,7 +101,7 @@
<Style TargetType="Entry">
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}" />
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="FontFamily" Value="OpenSansRegular"/>
<Setter Property="FontFamily" Value="OpenSansRegular" />
<Setter Property="FontSize" Value="14" />
<Setter Property="PlaceholderColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray500}}" />
<Setter Property="VisualStateManager.VisualStateGroups">
Expand All @@ -128,9 +126,9 @@

<Style TargetType="ImageButton">
<Setter Property="Opacity" Value="1" />
<Setter Property="BorderColor" Value="Transparent"/>
<Setter Property="BorderWidth" Value="0"/>
<Setter Property="CornerRadius" Value="0"/>
<Setter Property="BorderColor" Value="Transparent" />
<Setter Property="BorderWidth" Value="0" />
<Setter Property="CornerRadius" Value="0" />
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
Expand Down Expand Up @@ -172,8 +170,8 @@
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource White}}" />
<Setter Property="TitleColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource Gray200}}" />
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="FontFamily" Value="OpenSansRegular"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="FontFamily" Value="OpenSansRegular" />
<Setter Property="FontSize" Value="14" />
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
Expand Down Expand Up @@ -206,10 +204,10 @@
</Style>

<Style TargetType="RadioButton">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Background" Value="Transparent" />
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}" />
<Setter Property="FontFamily" Value="OpenSansRegular"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="FontFamily" Value="OpenSansRegular" />
<Setter Property="FontSize" Value="14" />
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
Expand Down Expand Up @@ -288,9 +286,9 @@
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="MinimumTrackColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}"/>
<Setter Property="MaximumTrackColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}"/>
<Setter Property="ThumbColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}"/>
<Setter Property="MinimumTrackColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}" />
<Setter Property="MaximumTrackColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}" />
<Setter Property="ThumbColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
Expand Down Expand Up @@ -333,9 +331,9 @@

<Style TargetType="TimePicker">
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource White}}" />
<Setter Property="Background" Value="Transparent"/>
<Setter Property="FontFamily" Value="OpenSansRegular"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Background" Value="Transparent" />
<Setter Property="FontFamily" Value="OpenSansRegular" />
<Setter Property="FontSize" Value="14" />
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
Expand All @@ -350,12 +348,12 @@
</Setter>
</Style>

<Style TargetType="Page" ApplyToDerivedTypes="True">
<Setter Property="Padding" Value="0"/>
<Style ApplyToDerivedTypes="True" TargetType="Page">
<Setter Property="Padding" Value="0" />
<Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Black}}" />
</Style>

<Style TargetType="Shell" ApplyToDerivedTypes="True">
<Style ApplyToDerivedTypes="True" TargetType="Shell">
<Setter Property="Shell.BackgroundColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource Gray950}}" />
<Setter Property="Shell.ForegroundColor" Value="{OnPlatform WinUI={StaticResource Primary}, Default={StaticResource White}}" />
<Setter Property="Shell.TitleColor" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource White}}" />
Expand Down
5 changes: 1 addition & 4 deletions Tabs/Tabs/BottomTabItem.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

using Sharpnado.Tabs.Effects;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace Sharpnado.Tabs
{
[XamlCompilation(XamlCompilationOptions.Compile)]
Expand Down Expand Up @@ -39,7 +36,7 @@ public partial class BottomTabItem : TabTextItem
declaringType: typeof(TabTextItem),
defaultValue: null);

private readonly bool _isInitialized = false;
private readonly bool _isInitialized;

public BottomTabItem()
{
Expand Down
16 changes: 14 additions & 2 deletions Tabs/Tabs/DelayedView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,32 @@ public class DelayedView<TView> : LazyView<TView>
{
public int DelayInMilliseconds { get; set; } = 200;

private View? _currentlyBuiltView;

Check warning on line 10 in Tabs/Tabs/DelayedView.cs

View workflow job for this annotation

GitHub Actions / winBuild

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 10 in Tabs/Tabs/DelayedView.cs

View workflow job for this annotation

GitHub Actions / winBuild

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 10 in Tabs/Tabs/DelayedView.cs

View workflow job for this annotation

GitHub Actions / winBuild

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();

if (_currentlyBuiltView != null)
{
_currentlyBuiltView.BindingContext = BindingContext;
}
}

public override void LoadView()
{
TaskMonitor.Create(
async () =>
{
View? view = new TView
_currentlyBuiltView = new TView
{
BindingContext = BindingContext,
};

await Task.Delay(DelayInMilliseconds);

IsLoaded = true;
Content = view;
Content = _currentlyBuiltView;
});
}
}
Expand Down
4 changes: 0 additions & 4 deletions Tabs/Tabs/Initializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ public static class Initializer
{
public static void Initialize(bool loggerEnable, bool debugLogEnable)
{
#if !NET6_0_OR_GREATER
Shades.Initializer.Initialize(loggerEnable: false);
#endif

InternalLogger.EnableDebug = debugLogEnable;
InternalLogger.EnableLogging = loggerEnable;
}
Expand Down
Loading

0 comments on commit 07f3072

Please sign in to comment.