Skip to content

Commit

Permalink
fix: crash fix plus minor changes to required package versions (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
FreakyAli authored Dec 15, 2024
1 parent 241068e commit 8cab216
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,22 @@ public FreakyDatePickerHandler()
}

private void MapDatePicker(IDatePickerHandler datePickerHandler, IDatePicker datePicker)
{
if (datePicker is FreakyDatePicker freakyDatePicker &&
datePickerHandler is FreakyDatePickerHandler freakyDatePickerHandler)
{
if (PlatformView is not null && VirtualView is not null)
{
if (freakyDatePicker.ImageSource != default(ImageSource))
{
freakyDatePickerHandler.HandleAndAlignImageSourceAsync(freakyDatePicker).RunConcurrently();
}
}
{
try
{
if (datePicker is FreakyDatePicker freakyDatePicker &&
datePickerHandler is FreakyDatePickerHandler freakyDatePickerHandler)
{
if (PlatformView is not null && VirtualView is not null)
{
if (freakyDatePicker.ImageSource != default(ImageSource))
{
freakyDatePickerHandler.HandleAndAlignImageSourceAsync(freakyDatePicker).RunConcurrently();
}
}
}
}
catch (Exception) { }
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Maui.Handlers;
using Microsoft.Maui.Handlers;

namespace Maui.FreakyControls;

Expand All @@ -11,16 +11,20 @@ public FreakyEditorHandler()
}

private void MapFreakyEditor(IEditorHandler editorHandler, IEditor editor)
{
if (editor is FreakyEditor feditor && editorHandler is FreakyEditorHandler freakyEditorHandler)
{
if (PlatformView is not null && VirtualView is not null)
{
HandleAllowCopyPaste(feditor);
}
{
try
{
if (editor is FreakyEditor feditor && editorHandler is FreakyEditorHandler freakyEditorHandler)
{
if (PlatformView is not null && VirtualView is not null)
{
HandleAllowCopyPaste(feditor);
}
}
}
catch(Exception) { }
}
}
}
#else
public partial class FreakyEditorHandler : EditorHandler
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Maui.FreakyControls.Extensions;
using Maui.FreakyControls.Extensions;
using Microsoft.Maui.Handlers;

namespace Maui.FreakyControls;
Expand All @@ -14,17 +14,21 @@ public FreakyEntryHandler()

private void MapFreakyEntry(IEntryHandler entryHandler, IEntry entry)
{
if (entry is FreakyEntry freakyEntry && entryHandler is FreakyEntryHandler freakyEntryHandler)
try
{
if (PlatformView is not null && VirtualView is not null)
if (entry is FreakyEntry freakyEntry && entryHandler is FreakyEntryHandler freakyEntryHandler)
{
if (freakyEntry.ImageSource != default(ImageSource))
if (PlatformView is not null && VirtualView is not null)
{
freakyEntryHandler.HandleAndAlignImageSourceAsync(freakyEntry).RunConcurrently();
if (freakyEntry.ImageSource != default(ImageSource))
{
freakyEntryHandler.HandleAndAlignImageSourceAsync(freakyEntry).RunConcurrently();
}
HandleAllowCopyPaste(freakyEntry);
}
HandleAllowCopyPaste(freakyEntry);
}
}
catch (Exception) { }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@ public FreakyPickerHandler()

private void MapPicker(IPickerHandler pickerHandler, IPicker picker)
{
if (picker is FreakyPicker freakyTimePicker &&
pickerHandler is FreakyPickerHandler freakyTimePickerHandler)
try
{
if (PlatformView is not null && VirtualView is not null)
if (picker is FreakyPicker freakyTimePicker &&
pickerHandler is FreakyPickerHandler freakyTimePickerHandler)
{
if (freakyTimePicker.ImageSource != default(ImageSource))
if (PlatformView is not null && VirtualView is not null)
{
freakyTimePickerHandler.HandleAndAlignImageSourceAsync(freakyTimePicker).RunConcurrently();
if (freakyTimePicker.ImageSource != default(ImageSource))
{
freakyTimePickerHandler.HandleAndAlignImageSourceAsync(freakyTimePicker).RunConcurrently();
}
}
}
}
catch (Exception) { }
}
}
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public partial class FreakyTextInputLayout : ContentView, IDisposable
private int _leftMargin;
private double _placeholderFontSize = 18;
private double _titleFontSize = 14;

private bool _isLoading;

public FreakyTextInputLayout()
{
InitializeComponent();
Expand Down Expand Up @@ -696,7 +697,7 @@ private static void BorderTypePropertyChanged(BindableObject bindable, object ol

private static void OnOutlineTitleBackgroundColorProperty(BindableObject bindable, object oldValue, object newValue)
{
if (bindable is FreakyTextInputLayout til && newValue is Color color)
if (bindable is FreakyTextInputLayout til && newValue is Color color && til.LabelTitle is not null)
{
til.LabelTitle.BackgroundColor = til.BorderType ==
BorderType.Outlined ? color : Colors.Transparent;
Expand Down Expand Up @@ -755,8 +756,9 @@ private static void OnImageWidthChanged(BindableObject bindable, object oldValue

private async void Handle_Focused(object sender, FocusEventArgs e)
{
if (string.IsNullOrEmpty(Text))
if (string.IsNullOrEmpty(Text) && LabelTitle.Height > 0)
{
//don't transition if labeltitle height is 0 (not initialized fully)
await TransitionToTitle(true);
}
}
Expand Down Expand Up @@ -791,6 +793,8 @@ private async Task TransitionToTitle(bool animated)
LabelTitle.TranslationY = yoffset;
LabelTitle.FontSize = _titleFontSize;
}

_isLoading = false;
}

private async Task TransitionToPlaceholder(bool animated)
Expand Down Expand Up @@ -866,9 +870,15 @@ private void HiddenTitle_OnPropertyChanged(object sender, PropertyChangedEventAr

private async void EntryField_OnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(Height) && !string.IsNullOrEmpty(EntryField?.Text))
if (e.PropertyName == nameof(IsFocused) && LabelTitle.Height <= 0)
{
//entry receives focus before it is fully initialized (0 height)
_isLoading = true;
}
else if (e.PropertyName == nameof(Height) && (!string.IsNullOrEmpty(EntryField?.Text) || _isLoading))
{
//Make label floating if the entry field already has text it in when it is loaded
//Make label floating if the entry field already has text in it when it is loaded or
// has focus when the app starts (if focus is applied on app load)
await TransitionToTitle(false);
}
}
Expand Down
23 changes: 14 additions & 9 deletions MAUI.FreakyControls/MAUI.FreakyControls/Maui.FreakyControls.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<ItemGroup>
<None Remove="Platforms\iOS\" />
<None Remove="Platforms\Android\" />
<None Remove="Shared\Enums\" />
<None Remove="Platforms\Android\NativeControls\" />
<None Remove="SkiaSharp.Views.Maui.Core" />
<None Remove="SkiaSharp.Views.Maui.Controls" />
Expand All @@ -98,7 +99,6 @@
<None Remove="Platforms\Android\NativeControls\Signature\" />
<None Remove="Platforms\iOS\NativeControls\Signature\" />
<None Remove="clear_icon.svg" />
<None Remove="CommunityToolkit.Mvvm" />
</ItemGroup>
<ItemGroup>
<Folder Include="Platforms\Android\NativeControls\Helpers\" />
Expand Down Expand Up @@ -139,15 +139,20 @@
<Folder Include="Wrappers\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="SkiaSharp.Views.Maui.Controls" Version="2.88.6" />
<PackageReference Include="SkiaSharp.Views.Maui.Controls" Version="2.88.9" />
<PackageReference Include="Svg.Skia" Version="1.0.0.19" />
<PackageReference Include="FreakyEffects" Version="0.1.2" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.3" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.3" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.82" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.82" />
</ItemGroup>
<ItemGroup>
<MauiXaml Update="Shared\FreakySignatureView\SignaturePadView.xaml">
<SubType>
</SubType>
</MauiXaml>
<MauiXaml Condition=" '$(EnableDefaultXamlItems)' == 'true' " Update="FreakyTextInputLayout\FreakyTextInputLayout.xaml">
<SubType></SubType>
<SubType>
</SubType>
</MauiXaml>
</ItemGroup>
<ItemGroup>
Expand All @@ -165,8 +170,8 @@
</None>
</ItemGroup>
<ItemGroup>
<Compile Update="Dotnet\FreakySignatureCanvasViewHandler.dotnet.cs">
<ExcludeFromCurrentConfiguration>true</ExcludeFromCurrentConfiguration>
</Compile>
<Compile Update="Dotnet\FreakySignatureCanvasViewHandler.dotnet.cs">
<ExcludeFromCurrentConfiguration>true</ExcludeFromCurrentConfiguration>
</Compile>
</ItemGroup>
</Project>
</Project>
4 changes: 2 additions & 2 deletions MAUI.FreakyControls/Samples/Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.0" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.40" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.40" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.100" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.100" />
</ItemGroup>
<ItemGroup>
<MauiImage Remove="Resources\Images\dotnet_bot.svg" />
Expand Down

0 comments on commit 8cab216

Please sign in to comment.