Skip to content
This repository has been archived by the owner on Sep 23, 2022. It is now read-only.

Commit

Permalink
more progress. Sould fix muak/AiForms.SettingsView#118
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakar510 committed Mar 12, 2021
1 parent f38eb1b commit d8d9c57
Show file tree
Hide file tree
Showing 44 changed files with 361 additions and 302 deletions.
1 change: 1 addition & 0 deletions src/SettingsView.Droid/BaseCell/BaseAiDescriptionCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.ComponentModel;
using Android.Runtime;
using Jakar.SettingsView.Droid.Controls;
using Jakar.SettingsView.Droid.Controls.Core;
using Xamarin.Forms;
using AContext = Android.Content.Context;

Expand Down
1 change: 1 addition & 0 deletions src/SettingsView.Droid/BaseCell/BaseAiTitledCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Android.Runtime;
using Android.Widget;
using Jakar.SettingsView.Droid.Controls;
using Jakar.SettingsView.Droid.Controls.Core;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using AContext = Android.Content.Context;
Expand Down
1 change: 1 addition & 0 deletions src/SettingsView.Droid/BaseCell/BaseAiValueCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.ComponentModel;
using Android.Runtime;
using Jakar.SettingsView.Droid.Controls;
using Jakar.SettingsView.Droid.Controls.Core;
using Xamarin.Forms;
using AContext = Android.Content.Context;

Expand Down
1 change: 1 addition & 0 deletions src/SettingsView.Droid/BaseCell/BaseValueCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Android.Views;
using Android.Widget;
using Jakar.SettingsView.Droid.Controls;
using Jakar.SettingsView.Droid.Controls.Core;
using Jakar.SettingsView.Droid.Extensions;
using Jakar.SettingsView.Shared;
using Jakar.SettingsView.Shared.Misc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using System.Diagnostics.CodeAnalysis;
using Android.Util;
using Android.Widget;
using Jakar.SettingsView.Droid.BaseCell;
using Jakar.SettingsView.Shared.CellBase;
using Jakar.SettingsView.Shared.Config;
using Jakar.SettingsView.Shared.Interfaces;
using Xamarin.Forms;
Expand All @@ -13,10 +11,9 @@
using AContext = Android.Content.Context;
using AView = Android.Views.View;
using BaseCellView = Jakar.SettingsView.Droid.BaseCell.BaseCellView;
using AiEntryCell = Jakar.SettingsView.Shared.Cells.EntryCell;

#nullable enable
namespace Jakar.SettingsView.Droid.Controls
namespace Jakar.SettingsView.Droid.Controls.Core
{
[SuppressMessage("ReSharper", "VirtualMemberCallInConstructor")]
[Android.Runtime.Preserve(AllMembers = true)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using TextAlignment = Xamarin.Forms.TextAlignment;

#nullable enable
namespace Jakar.SettingsView.Droid.Controls
namespace Jakar.SettingsView.Droid.Controls.Core
{
[Android.Runtime.Preserve(AllMembers = true)]
public class DescriptionView : BaseTextView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using TextAlignment = Xamarin.Forms.TextAlignment;

#nullable enable
namespace Jakar.SettingsView.Droid.Controls
namespace Jakar.SettingsView.Droid.Controls.Core
{
public class HintView : BaseTextView
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using BaseCellView = Jakar.SettingsView.Droid.BaseCell.BaseCellView;

#nullable enable
namespace Jakar.SettingsView.Droid.Controls
namespace Jakar.SettingsView.Droid.Controls.Core
{
[Android.Runtime.Preserve(AllMembers = true)]
public class TitleView : BaseTextView
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Android.Content;
using Android.Util;
using Android.Views;
Expand All @@ -12,7 +11,7 @@
using TextAlignment = Xamarin.Forms.TextAlignment;

#nullable enable
namespace Jakar.SettingsView.Droid.Controls
namespace Jakar.SettingsView.Droid.Controls.Core
{
[Android.Runtime.Preserve(AllMembers = true)]
public class ValueView : BaseTextView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
using Android.Widget;
using Jakar.SettingsView.Shared.Config;
using Jakar.SettingsView.Shared.Interfaces;
using Jakar.SettingsView.Shared.Misc;
using Jakar.SettingsView.Shared.sv;
using Xamarin.Forms;
using Xamarin.Forms.Internals;
using Xamarin.Forms.Platform.Android;

#nullable enable
namespace Jakar.SettingsView.Droid
namespace Jakar.SettingsView.Droid.Controls
{
[Android.Runtime.Preserve(AllMembers = true)]
public class HeaderFooterContainer : FrameLayout, INativeElementView
Expand All @@ -27,7 +28,7 @@ public class HeaderFooterContainer : FrameLayout, INativeElementView
protected IVisualElementRenderer? _Renderer { get; set; }


private ISectionFooterHeader? _content;
protected ISectionFooterHeader? _content;

protected ISectionFooterHeader? _Content
{
Expand Down Expand Up @@ -64,22 +65,21 @@ protected ISectionFooterHeader? _Content
{
_content = value;
_content.DisableLayout = true;
foreach ( var element in _content.Descendants() )
foreach ( var element in _content.View.Descendants() )
{
if ( element is VisualElement v ) v.DisableLayout = true;
}

renderer.SetElement(_content.View);

Platform.SetRenderer(_content.View, _Renderer);

_content.DisableLayout = false;
foreach ( var element in _content.Descendants() )
foreach ( var element in _content.View.Descendants() )
{
if ( element is VisualElement v ) v.DisableLayout = false;
}

var viewAsLayout = _Content as Layout;
var viewAsLayout = _content.View as Layout;
viewAsLayout?.ForceLayout();

Update();
Expand Down Expand Up @@ -143,7 +143,6 @@ protected override void OnLayout( bool changed,

_Renderer.UpdateLayout();
}

protected override void OnMeasure( int widthMeasureSpec, int heightMeasureSpec )
{
int width = MeasureSpec.GetSize(widthMeasureSpec);
Expand Down Expand Up @@ -174,16 +173,16 @@ protected override void OnMeasure( int widthMeasureSpec, int heightMeasureSpec )

public virtual void CellPropertyChanged( object sender, PropertyChangedEventArgs e )
{
if ( e.PropertyName == Cell.IsEnabledProperty.PropertyName ) { UpdateIsEnabled(); }
else if ( e.PropertyName == Section.TitleProperty.PropertyName ) { UpdateTitle(); }
else if ( e.PropertyName == Section.TextColorProperty.PropertyName ) { UpdateTextColor(); }
else if ( e.PropertyName == VisualElement.IsEnabledProperty.PropertyName ) { UpdateIsEnabled(); }
else if ( e.PropertyName == HeaderView.IsCollapsedProperty.PropertyName ) { ShowHideSection(); }
else if ( e.PropertyName == HeaderView.IsCollapsibleProperty.PropertyName ) { UpdateIsCollapsible(); }
if ( e.IsEqual(Cell.IsEnabledProperty) ) { UpdateIsEnabled(); }
else if ( e.IsEqual(Section.TitleProperty) ) { UpdateTitle(); }
else if ( e.IsEqual(Section.TextColorProperty) ) { UpdateTextColor(); }
else if ( e.IsEqual(VisualElement.IsEnabledProperty) ) { UpdateIsEnabled(); }
else if ( e.IsEqual(HeaderView.IsCollapsedProperty) ) { ShowHideSection(); }
else if ( e.IsEqual(HeaderView.IsCollapsibleProperty) ) { UpdateIsCollapsible(); }
}
private void UpdateIsCollapsible() { Clickable = _Header?.IsCollapsible ?? false; }
private void ShowHideSection() { _Content?.Section?.ShowHideSection(); }
private void UpdateTitle()
protected void UpdateIsCollapsible() { Clickable = _Header?.IsCollapsible ?? false; }
protected void ShowHideSection() { _Content?.Section?.ShowHideSection(); }
protected void UpdateTitle()
{
if ( _Content is null ) throw new NullReferenceException(nameof(_Content));
if ( _Content.Section is null ) throw new NullReferenceException(nameof(_Content.Section));
Expand All @@ -192,7 +191,7 @@ private void UpdateTitle()

if ( _Content is ISectionFooter footer ) { footer.SetText(_Content.Section.FooterText); }
}
private void UpdateTextColor()
protected void UpdateTextColor()
{
if ( _Content is null ) throw new NullReferenceException(nameof(_Content));
if ( _Content.Section is null ) throw new NullReferenceException(nameof(_Content.Section));
Expand Down
13 changes: 7 additions & 6 deletions src/SettingsView.Droid/Jakar.SettingsView.Droid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@
<Compile Include="BaseCell\BaseAiDescriptionCell.cs" />
<Compile Include="BaseCell\BaseAiTitledCell.cs" />
<Compile Include="BaseCell\BaseAiValueCell.cs" />
<Compile Include="Controls\BaseTextView.cs" />
<Compile Include="Controls\DescriptionView.cs" />
<Compile Include="Controls\HintView.cs" />
<Compile Include="Controls\Core\BaseTextView.cs" />
<Compile Include="Controls\Core\DescriptionView.cs" />
<Compile Include="Controls\Core\HintView.cs" />
<Compile Include="Controls\IconView.cs" />
<Compile Include="Controls\RadioCheck.cs" />
<Compile Include="Controls\TitleView.cs" />
<Compile Include="Controls\ValueView.cs" />
<Compile Include="Controls\Core\TitleView.cs" />
<Compile Include="Controls\Core\ValueView.cs" />
<Compile Include="Extensions\LayoutExtensions.cs" />
<Compile Include="GetIcons.cs" />
<Compile Include="Interfaces\ICellRender.cs" />
Expand Down Expand Up @@ -95,7 +95,7 @@
<Compile Include="ViewHolders.cs" />
<Compile Include="FormsViewContainer.cs" />
<Compile Include="Cells\CustomCellRenderer.cs" />
<Compile Include="HeaderFooterContainer.cs" />
<Compile Include="Controls\HeaderFooterContainer.cs" />
<Compile Include="FontUtility.cs" />
<Compile Include="SettingsViewLayoutManager.cs" />
</ItemGroup>
Expand Down Expand Up @@ -186,5 +186,6 @@
<ItemGroup>
<AndroidResource Include="Resources\drawable\ExpandSolidWhite.png" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project>
1 change: 1 addition & 0 deletions src/SettingsView.Droid/SettingsViewRecyclerAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Android.Views;
using Android.Widget;
using AndroidX.RecyclerView.Widget;
using Jakar.SettingsView.Droid.Controls;
using Jakar.SettingsView.Droid.Extensions;
using Jakar.SettingsView.Shared;
using Jakar.SettingsView.Shared.Config;
Expand Down
1 change: 1 addition & 0 deletions src/SettingsView.Droid/ViewHolders.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using Android.Widget;
using AndroidX.RecyclerView.Widget;
using Jakar.SettingsView.Droid.Controls;
using Xamarin.Forms;
using AView = Android.Views.View;

Expand Down
1 change: 1 addition & 0 deletions src/SettingsView.iOS/BaseCell/BaseAiDescriptionCell.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.ComponentModel;
using Jakar.SettingsView.iOS.Controls;
using Jakar.SettingsView.iOS.Controls.Core;
using Jakar.SettingsView.Shared.Config;
using UIKit;
using Xamarin.Forms;
Expand Down
1 change: 1 addition & 0 deletions src/SettingsView.iOS/BaseCell/BaseAiTitledCell.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.ComponentModel;
using Jakar.SettingsView.iOS.Controls;
using Jakar.SettingsView.iOS.Controls.Core;
using UIKit;
using Xamarin.Forms;

Expand Down
1 change: 1 addition & 0 deletions src/SettingsView.iOS/BaseCell/BaseAiValueCell.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.ComponentModel;
using Jakar.SettingsView.iOS.Controls;
using Jakar.SettingsView.iOS.Controls.Core;
using Xamarin.Forms;

#nullable enable
Expand Down
2 changes: 1 addition & 1 deletion src/SettingsView.iOS/BaseCell/BaseCellView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#nullable enable
namespace Jakar.SettingsView.iOS.BaseCell
{
[Foundation.Preserve(AllMembers = true)]
[Preserve(AllMembers = true)]
public abstract class BaseCellView : CellTableViewCell
{
// internal NSLayoutConstraint LeftMarginConstraint { get; private set; }
Expand Down
4 changes: 2 additions & 2 deletions src/SettingsView.iOS/BaseCell/BasePickerCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

using System.Diagnostics.CodeAnalysis;
using Foundation;
using Jakar.SettingsView.iOS.OLD_Cells;
using Jakar.SettingsView.iOS.Controls;
using UIKit;
using Xamarin.Forms;

namespace Jakar.SettingsView.iOS.BaseCell
{
[Foundation.Preserve(AllMembers = true)]
[Preserve(AllMembers = true)]
public abstract class BasePickerCell : BaseAiValueCell
{
protected NoCaretField _DummyField { get; set; }
Expand Down
1 change: 1 addition & 0 deletions src/SettingsView.iOS/BaseCell/BaseValueCell.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using Jakar.SettingsView.iOS.Controls;
using Jakar.SettingsView.iOS.Controls.Core;
using Jakar.SettingsView.Shared.Config;
using Jakar.SettingsView.Shared.Misc;
using UIKit;
Expand Down
Loading

0 comments on commit d8d9c57

Please sign in to comment.