Skip to content

Commit 8cab216

Browse files
authored
fix: crash fix plus minor changes to required package versions (#161)
1 parent 241068e commit 8cab216

File tree

7 files changed

+78
-47
lines changed

7 files changed

+78
-47
lines changed

MAUI.FreakyControls/MAUI.FreakyControls/FreakyDatePicker/FreakyDatePickerHandler.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@ public FreakyDatePickerHandler()
1212
}
1313

1414
private void MapDatePicker(IDatePickerHandler datePickerHandler, IDatePicker datePicker)
15-
{
16-
if (datePicker is FreakyDatePicker freakyDatePicker &&
17-
datePickerHandler is FreakyDatePickerHandler freakyDatePickerHandler)
18-
{
19-
if (PlatformView is not null && VirtualView is not null)
20-
{
21-
if (freakyDatePicker.ImageSource != default(ImageSource))
22-
{
23-
freakyDatePickerHandler.HandleAndAlignImageSourceAsync(freakyDatePicker).RunConcurrently();
24-
}
25-
}
15+
{
16+
try
17+
{
18+
if (datePicker is FreakyDatePicker freakyDatePicker &&
19+
datePickerHandler is FreakyDatePickerHandler freakyDatePickerHandler)
20+
{
21+
if (PlatformView is not null && VirtualView is not null)
22+
{
23+
if (freakyDatePicker.ImageSource != default(ImageSource))
24+
{
25+
freakyDatePickerHandler.HandleAndAlignImageSourceAsync(freakyDatePicker).RunConcurrently();
26+
}
27+
}
28+
}
2629
}
30+
catch (Exception) { }
2731
}
2832
}
2933

MAUI.FreakyControls/MAUI.FreakyControls/FreakyEditor/FreakyEditorHandler.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.Maui.Handlers;
1+
using Microsoft.Maui.Handlers;
22

33
namespace Maui.FreakyControls;
44

@@ -11,16 +11,20 @@ public FreakyEditorHandler()
1111
}
1212

1313
private void MapFreakyEditor(IEditorHandler editorHandler, IEditor editor)
14-
{
15-
if (editor is FreakyEditor feditor && editorHandler is FreakyEditorHandler freakyEditorHandler)
16-
{
17-
if (PlatformView is not null && VirtualView is not null)
18-
{
19-
HandleAllowCopyPaste(feditor);
20-
}
14+
{
15+
try
16+
{
17+
if (editor is FreakyEditor feditor && editorHandler is FreakyEditorHandler freakyEditorHandler)
18+
{
19+
if (PlatformView is not null && VirtualView is not null)
20+
{
21+
HandleAllowCopyPaste(feditor);
22+
}
23+
}
2124
}
25+
catch(Exception) { }
2226
}
23-
}
27+
}
2428
#else
2529
public partial class FreakyEditorHandler : EditorHandler
2630
{

MAUI.FreakyControls/MAUI.FreakyControls/FreakyEntry/FreakyEntryHandler.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Maui.FreakyControls.Extensions;
1+
using Maui.FreakyControls.Extensions;
22
using Microsoft.Maui.Handlers;
33

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

1515
private void MapFreakyEntry(IEntryHandler entryHandler, IEntry entry)
1616
{
17-
if (entry is FreakyEntry freakyEntry && entryHandler is FreakyEntryHandler freakyEntryHandler)
17+
try
1818
{
19-
if (PlatformView is not null && VirtualView is not null)
19+
if (entry is FreakyEntry freakyEntry && entryHandler is FreakyEntryHandler freakyEntryHandler)
2020
{
21-
if (freakyEntry.ImageSource != default(ImageSource))
21+
if (PlatformView is not null && VirtualView is not null)
2222
{
23-
freakyEntryHandler.HandleAndAlignImageSourceAsync(freakyEntry).RunConcurrently();
23+
if (freakyEntry.ImageSource != default(ImageSource))
24+
{
25+
freakyEntryHandler.HandleAndAlignImageSourceAsync(freakyEntry).RunConcurrently();
26+
}
27+
HandleAllowCopyPaste(freakyEntry);
2428
}
25-
HandleAllowCopyPaste(freakyEntry);
2629
}
2730
}
31+
catch (Exception) { }
2832
}
2933
}
3034

MAUI.FreakyControls/MAUI.FreakyControls/FreakyPicker/FreakyPickerHandler.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,21 @@ public FreakyPickerHandler()
1313

1414
private void MapPicker(IPickerHandler pickerHandler, IPicker picker)
1515
{
16-
if (picker is FreakyPicker freakyTimePicker &&
17-
pickerHandler is FreakyPickerHandler freakyTimePickerHandler)
16+
try
1817
{
19-
if (PlatformView is not null && VirtualView is not null)
18+
if (picker is FreakyPicker freakyTimePicker &&
19+
pickerHandler is FreakyPickerHandler freakyTimePickerHandler)
2020
{
21-
if (freakyTimePicker.ImageSource != default(ImageSource))
21+
if (PlatformView is not null && VirtualView is not null)
2222
{
23-
freakyTimePickerHandler.HandleAndAlignImageSourceAsync(freakyTimePicker).RunConcurrently();
23+
if (freakyTimePicker.ImageSource != default(ImageSource))
24+
{
25+
freakyTimePickerHandler.HandleAndAlignImageSourceAsync(freakyTimePicker).RunConcurrently();
26+
}
2427
}
2528
}
2629
}
30+
catch (Exception) { }
2731
}
2832
}
2933
#else

MAUI.FreakyControls/MAUI.FreakyControls/FreakyTextInputLayout/FreakyTextInputLayout.xaml.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ public partial class FreakyTextInputLayout : ContentView, IDisposable
1010
private int _leftMargin;
1111
private double _placeholderFontSize = 18;
1212
private double _titleFontSize = 14;
13-
13+
private bool _isLoading;
14+
1415
public FreakyTextInputLayout()
1516
{
1617
InitializeComponent();
@@ -696,7 +697,7 @@ private static void BorderTypePropertyChanged(BindableObject bindable, object ol
696697

697698
private static void OnOutlineTitleBackgroundColorProperty(BindableObject bindable, object oldValue, object newValue)
698699
{
699-
if (bindable is FreakyTextInputLayout til && newValue is Color color)
700+
if (bindable is FreakyTextInputLayout til && newValue is Color color && til.LabelTitle is not null)
700701
{
701702
til.LabelTitle.BackgroundColor = til.BorderType ==
702703
BorderType.Outlined ? color : Colors.Transparent;
@@ -755,8 +756,9 @@ private static void OnImageWidthChanged(BindableObject bindable, object oldValue
755756

756757
private async void Handle_Focused(object sender, FocusEventArgs e)
757758
{
758-
if (string.IsNullOrEmpty(Text))
759+
if (string.IsNullOrEmpty(Text) && LabelTitle.Height > 0)
759760
{
761+
//don't transition if labeltitle height is 0 (not initialized fully)
760762
await TransitionToTitle(true);
761763
}
762764
}
@@ -791,6 +793,8 @@ private async Task TransitionToTitle(bool animated)
791793
LabelTitle.TranslationY = yoffset;
792794
LabelTitle.FontSize = _titleFontSize;
793795
}
796+
797+
_isLoading = false;
794798
}
795799

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

867871
private async void EntryField_OnPropertyChanged(object sender, PropertyChangedEventArgs e)
868872
{
869-
if (e.PropertyName == nameof(Height) && !string.IsNullOrEmpty(EntryField?.Text))
873+
if (e.PropertyName == nameof(IsFocused) && LabelTitle.Height <= 0)
874+
{
875+
//entry receives focus before it is fully initialized (0 height)
876+
_isLoading = true;
877+
}
878+
else if (e.PropertyName == nameof(Height) && (!string.IsNullOrEmpty(EntryField?.Text) || _isLoading))
870879
{
871-
//Make label floating if the entry field already has text it in when it is loaded
880+
//Make label floating if the entry field already has text in it when it is loaded or
881+
// has focus when the app starts (if focus is applied on app load)
872882
await TransitionToTitle(false);
873883
}
874884
}

MAUI.FreakyControls/MAUI.FreakyControls/Maui.FreakyControls.csproj

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
<ItemGroup>
8585
<None Remove="Platforms\iOS\" />
8686
<None Remove="Platforms\Android\" />
87+
<None Remove="Shared\Enums\" />
8788
<None Remove="Platforms\Android\NativeControls\" />
8889
<None Remove="SkiaSharp.Views.Maui.Core" />
8990
<None Remove="SkiaSharp.Views.Maui.Controls" />
@@ -98,7 +99,6 @@
9899
<None Remove="Platforms\Android\NativeControls\Signature\" />
99100
<None Remove="Platforms\iOS\NativeControls\Signature\" />
100101
<None Remove="clear_icon.svg" />
101-
<None Remove="CommunityToolkit.Mvvm" />
102102
</ItemGroup>
103103
<ItemGroup>
104104
<Folder Include="Platforms\Android\NativeControls\Helpers\" />
@@ -139,15 +139,20 @@
139139
<Folder Include="Wrappers\" />
140140
</ItemGroup>
141141
<ItemGroup>
142-
<PackageReference Include="SkiaSharp.Views.Maui.Controls" Version="2.88.6" />
142+
<PackageReference Include="SkiaSharp.Views.Maui.Controls" Version="2.88.9" />
143143
<PackageReference Include="Svg.Skia" Version="1.0.0.19" />
144144
<PackageReference Include="FreakyEffects" Version="0.1.2" />
145-
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.3" />
146-
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.3" />
145+
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.82" />
146+
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.82" />
147147
</ItemGroup>
148148
<ItemGroup>
149+
<MauiXaml Update="Shared\FreakySignatureView\SignaturePadView.xaml">
150+
<SubType>
151+
</SubType>
152+
</MauiXaml>
149153
<MauiXaml Condition=" '$(EnableDefaultXamlItems)' == 'true' " Update="FreakyTextInputLayout\FreakyTextInputLayout.xaml">
150-
<SubType></SubType>
154+
<SubType>
155+
</SubType>
151156
</MauiXaml>
152157
</ItemGroup>
153158
<ItemGroup>
@@ -165,8 +170,8 @@
165170
</None>
166171
</ItemGroup>
167172
<ItemGroup>
168-
<Compile Update="Dotnet\FreakySignatureCanvasViewHandler.dotnet.cs">
169-
<ExcludeFromCurrentConfiguration>true</ExcludeFromCurrentConfiguration>
170-
</Compile>
173+
<Compile Update="Dotnet\FreakySignatureCanvasViewHandler.dotnet.cs">
174+
<ExcludeFromCurrentConfiguration>true</ExcludeFromCurrentConfiguration>
175+
</Compile>
171176
</ItemGroup>
172-
</Project>
177+
</Project>

MAUI.FreakyControls/Samples/Samples.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@
8787
<ItemGroup>
8888
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
8989
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.0" />
90-
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.40" />
91-
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.40" />
90+
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.100" />
91+
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.100" />
9292
</ItemGroup>
9393
<ItemGroup>
9494
<MauiImage Remove="Resources\Images\dotnet_bot.svg" />

0 commit comments

Comments
 (0)