Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Compatibility/Core/src/Windows/TableViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
[Obsolete("Use Microsoft.Maui.Controls.Handlers.Compatibility.TableViewRenderer instead")]
#pragma warning disable CS0618 // Type or member is obsolete
public partial class TableViewRenderer : ViewRenderer<TableView, Microsoft.UI.Xaml.Controls.ListView>
#pragma warning restore CS0618 // Type or member is obsolete
{
bool _ignoreSelectionEvent;
bool _disposed;
Expand All @@ -21,7 +23,9 @@ public override SizeRequest GetDesiredSize(double widthConstraint, double height
return result;
}

#pragma warning disable CS0618 // Type or member is obsolete
protected override void OnElementChanged(ElementChangedEventArgs<TableView> e)
#pragma warning restore CS0618 // Type or member is obsolete
{
if (e.OldElement != null)
{
Expand Down
4 changes: 4 additions & 0 deletions src/Controls/src/Core/Cells/Cell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ public double RenderHeight
{
get
{
#pragma warning disable CS0618 // Type or member is obsolete
var table = RealParent as TableView;
#pragma warning restore CS0618 // Type or member is obsolete
if (table != null)
return table.HasUnevenRows && Height > 0 ? Height : table.RowHeight;

Expand All @@ -163,11 +165,13 @@ public void ForceUpdateSize()
if (_nextCallToForceUpdateSizeQueued)
return;

#pragma warning disable CS0618 // Type or member is obsolete
if ((Parent as ListView)?.HasUnevenRows == true || (Parent as TableView)?.HasUnevenRows == true)
{
_nextCallToForceUpdateSizeQueued = true;
OnForceUpdateSizeRequested();
}
#pragma warning restore CS0618 // Type or member is obsolete
}

public event EventHandler Tapped;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ public static AView GetCell(Cell item, AView convertView, ViewGroup parent, Cont
{
// If the convert view coming in is null that means this cell is going to need a new view generated for it
// This should probably be copied over to ListView once all sets of these TableView changes are propagated There
#pragma warning disable CS0618 // Type or member is obsolete
if (item.Handler is IElementHandler handler && convertView is null && view is TableView)
{
handler.DisconnectHandler();
}
#pragma warning restore CS0618 // Type or member is obsolete

CellRenderer renderer = CellRenderer.GetRenderer(item);
if (renderer == null)
Expand All @@ -33,15 +35,19 @@ public static AView GetCell(Cell item, AView convertView, ViewGroup parent, Cont

AView result = renderer.GetCell(item, convertView, parent, context);

#pragma warning disable CS0618 // Type or member is obsolete
if (view is TableView)
UpdateMinimumHeightFromParent(context, result, (TableView)view);
else if (view is ListView)
UpdateMinimumHeightFromParent(context, result, (ListView)view);
#pragma warning restore CS0618 // Type or member is obsolete

return result;
}

#pragma warning disable CS0618 // Type or member is obsolete
static void UpdateMinimumHeightFromParent(Context context, AView view, TableView table)
#pragma warning restore CS0618 // Type or member is obsolete
{
if (!table.HasUnevenRows && table.RowHeight > 0)
view.SetMinimumHeight((int)context.ToPixels(table.RowHeight));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ protected override AView GetCellCore(Cell item, AView convertView, ViewGroup par
}

BindableProperty unevenRows = null, rowHeight = null;
#pragma warning disable CS0618 // Type or member is obsolete
if (ParentView is TableView)
{
unevenRows = TableView.HasUnevenRowsProperty;
Expand All @@ -40,6 +41,7 @@ protected override AView GetCellCore(Cell item, AView convertView, ViewGroup par
unevenRows = ListView.HasUnevenRowsProperty;
rowHeight = ListView.RowHeightProperty;
}
#pragma warning restore CS0618 // Type or member is obsolete

if (cell.View == null)
throw new InvalidOperationException($"ViewCell must have a {nameof(cell.View)}");
Expand All @@ -49,6 +51,7 @@ protected override AView GetCellCore(Cell item, AView convertView, ViewGroup par

// If the convertView is null we don't want to return the same view, we need to return a new one.
// We should probably do this for ListView as well
#pragma warning disable CS0618 // Type or member is obsolete
if (ParentView is TableView)
{
view.ToPlatform().RemoveFromParent();
Expand All @@ -60,6 +63,7 @@ protected override AView GetCellCore(Cell item, AView convertView, ViewGroup par
if (c != null)
return c;
}
#pragma warning restore CS0618 // Type or member is obsolete

var newContainer = new ViewCellContainer(context, (IPlatformViewHandler)cell.View.Handler, cell, ParentView, unevenRows, rowHeight);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ namespace Microsoft.Maui.Controls.Handlers.Compatibility
{
public class TableViewModelRenderer : CellAdapter
{
#pragma warning disable CS0618 // Type or member is obsolete
readonly TableView _view;
#pragma warning restore CS0618 // Type or member is obsolete
protected readonly Context Context;
ITableViewController Controller => _view;
Cell _restoreFocus;
Expand Down Expand Up @@ -75,7 +77,9 @@ int DividerResourceId
}
}

#pragma warning disable CS0618 // Type or member is obsolete
public TableViewModelRenderer(Context context, AListView listView, TableView view) : base(context)
#pragma warning restore CS0618 // Type or member is obsolete
{
_view = view;
Context = context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@

namespace Microsoft.Maui.Controls.Handlers.Compatibility
{
#pragma warning disable CS0618 // Type or member is obsolete
public class TableViewRenderer : ViewRenderer<TableView, AListView>
#pragma warning restore CS0618 // Type or member is obsolete
{
#pragma warning disable CS0618 // Type or member is obsolete
public static PropertyMapper<TableView, TableViewRenderer> Mapper =
new PropertyMapper<TableView, TableViewRenderer>(VisualElementRendererMapper);
#pragma warning restore CS0618 // Type or member is obsolete


#pragma warning disable CS0618 // Type or member is obsolete
public static CommandMapper<TableView, TableViewRenderer> CommandMapper =
new CommandMapper<TableView, TableViewRenderer>(VisualElementRendererCommandMapper);

#pragma warning restore CS0618 // Type or member is obsolete
TableViewModelRenderer _adapter;
bool _reattached;
bool _disposed;
Expand All @@ -28,7 +32,9 @@ public TableViewRenderer(Context context) : base(context, Mapper, CommandMapper)
AutoPackage = false;
}

#pragma warning disable CS0618 // Type or member is obsolete
protected virtual TableViewModelRenderer GetModelRenderer(AListView listView, TableView view)
#pragma warning restore CS0618 // Type or member is obsolete
{
return new TableViewModelRenderer(Context, listView, view);
}
Expand All @@ -43,7 +49,9 @@ protected override AListView CreateNativeControl()
return new AListView(Context);
}

#pragma warning disable CS0618 // Type or member is obsolete
protected override void OnElementChanged(ElementChangedEventArgs<TableView> e)
#pragma warning restore CS0618 // Type or member is obsolete
{
base.OnElementChanged(e);

Expand All @@ -57,7 +65,9 @@ protected override void OnElementChanged(ElementChangedEventArgs<TableView> e)
listView.Focusable = false;
listView.DescendantFocusability = DescendantFocusability.AfterDescendants;

#pragma warning disable CS0618 // Type or member is obsolete
TableView view = e.NewElement;
#pragma warning restore CS0618 // Type or member is obsolete

_adapter = GetModelRenderer(listView, view);
listView.Adapter = _adapter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

namespace Microsoft.Maui.Controls.Handlers.Compatibility
{
#pragma warning disable CS0618 // Type or member is obsolete
public partial class TableViewRenderer : ViewRenderer<TableView, Microsoft.UI.Xaml.Controls.ListView>
#pragma warning restore CS0618 // Type or member is obsolete
{
bool _ignoreSelectionEvent;
bool _disposed;
Expand All @@ -24,7 +26,9 @@ protected override Size MinimumSize()
return new Size(40, 40);
}

#pragma warning disable CS0618 // Type or member is obsolete
protected override void OnElementChanged(ElementChangedEventArgs<TableView> e)
#pragma warning restore CS0618 // Type or member is obsolete
{
if (e.OldElement != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,27 @@ public class TableViewModelRenderer : UITableViewSource
protected TableView View;

WeakReference<UITableView> _platformView;
#pragma warning disable CS0618 // Type or member is obsolete
WeakReference<TableView> _tableView;
#pragma warning restore CS0618 // Type or member is obsolete

UITableView PlatformView
{
get => _platformView is not null && _platformView.TryGetTarget(out var t) ? t : null;
set => _platformView = value is not null ? new(value) : null;
}

#pragma warning disable CS0618 // Type or member is obsolete
internal TableView TableView
#pragma warning restore CS0618 // Type or member is obsolete
{
get => _tableView is not null && _tableView.TryGetTarget(out var t) ? t : null;
set => _tableView = value is not null ? new(value) : null;
}

#pragma warning disable CS0618 // Type or member is obsolete
public TableViewModelRenderer(TableView model)
#pragma warning restore CS0618 // Type or member is obsolete
{
TableView = model;
model.ModelChanged += (s, e) => PlatformView?.ReloadData();
Expand All @@ -48,8 +54,10 @@ public TableViewModelRenderer(TableView model)

public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
#pragma warning disable CS0618 // Type or member is obsolete
if (TableView is not TableView table)
return null;
#pragma warning restore CS0618 // Type or member is obsolete
var cell = table.Model.GetCell(indexPath.Section, indexPath.Row);
var nativeCell = CellTableViewCell.GetPlatformCell(tableView, cell);

Expand All @@ -58,8 +66,10 @@ public override UITableViewCell GetCell(UITableView tableView, NSIndexPath index

public override nfloat GetHeightForHeader(UITableView tableView, nint section)
{
#pragma warning disable CS0618 // Type or member is obsolete
if (TableView is not TableView table)
return 0;
#pragma warning restore CS0618 // Type or member is obsolete
if (!_headerCells.ContainsKey((int)section))
_headerCells[section] = table.Model.GetHeaderCell((int)section);

Expand All @@ -70,8 +80,10 @@ public override nfloat GetHeightForHeader(UITableView tableView, nint section)

public override UIView GetViewForHeader(UITableView tableView, nint section)
{
#pragma warning disable CS0618 // Type or member is obsolete
if (TableView is not TableView table)
return null;
#pragma warning restore CS0618 // Type or member is obsolete
if (!_headerCells.ContainsKey((int)section))
_headerCells[section] = table.Model.GetHeaderCell((int)section);

Expand All @@ -93,6 +105,7 @@ public override UIView GetViewForHeader(UITableView tableView, nint section)

public override void WillDisplayHeaderView(UITableView tableView, UIView headerView, nint section)
{
#pragma warning disable CS0618 // Type or member is obsolete
if (headerView is UITableViewHeaderFooterView header && TableView is TableView table)
{
var sectionHeaderTextColor = table.Model.GetSectionTextColor((int)section);
Expand All @@ -106,6 +119,7 @@ public override void WillDisplayHeaderView(UITableView tableView, UIView headerV
#pragma warning restore CA1416, CA1422
}
}
#pragma warning restore CS0618 // Type or member is obsolete
}

public void LongPress(UILongPressGestureRecognizer gesture)
Expand Down Expand Up @@ -175,14 +189,18 @@ void Tap(UITapGestureRecognizer gesture)

public class UnEvenTableViewModelRenderer : TableViewModelRenderer
{
#pragma warning disable CS0618 // Type or member is obsolete
public UnEvenTableViewModelRenderer(TableView model) : base(model)
#pragma warning restore CS0618 // Type or member is obsolete
{
}

public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
{
#pragma warning disable CS0618 // Type or member is obsolete
if (TableView is not TableView table)
return 0;
#pragma warning restore CS0618 // Type or member is obsolete

var cell = table.Model.GetCell(indexPath.Section, indexPath.Row);
var h = cell.Height;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

namespace Microsoft.Maui.Controls.Handlers.Compatibility
{
#pragma warning disable CS0618 // Type or member is obsolete
public class TableViewRenderer : ViewRenderer<TableView, UITableView>
#pragma warning restore CS0618 // Type or member is obsolete
{
const int DefaultRowHeight = 44;
UIView _originalBackgroundView;
Expand Down Expand Up @@ -65,7 +67,9 @@ protected UITableViewStyle GetTableViewStyle(TableIntent intent)
return intent == TableIntent.Data ? UITableViewStyle.Plain : UITableViewStyle.Grouped;
}

#pragma warning disable CS0618 // Type or member is obsolete
protected override void OnElementChanged(ElementChangedEventArgs<TableView> e)
#pragma warning restore CS0618 // Type or member is obsolete
{
if (e.NewElement != null)
{
Expand Down Expand Up @@ -96,12 +100,16 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE
{
base.OnElementPropertyChanged(sender, e);

#pragma warning disable CS0618 // Type or member is obsolete
#pragma warning disable CS0618 // Type or member is obsolete
if (e.PropertyName == TableView.RowHeightProperty.PropertyName)
UpdateRowHeight();
else if (e.PropertyName == TableView.HasUnevenRowsProperty.PropertyName)
SetSource();
else if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName || e.PropertyName == VisualElement.BackgroundProperty.PropertyName)
UpdateBackgroundView();
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning restore CS0618 // Type or member is obsolete
}

protected override void UpdateNativeWidget()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ internal static NSIndexPath GetIndexPath(this Cell self)

NSIndexPath path;

#pragma warning disable CS0618 // Type or member is obsolete
if (self.RealParent is ListView)
{
var section = 0;
Expand All @@ -31,6 +32,7 @@ internal static NSIndexPath GetIndexPath(this Cell self)
}
else
throw new NotSupportedException("Unknown cell parent type");
#pragma warning restore CS0618 // Type or member is obsolete

return path;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Controls/src/Core/Hosting/AppHostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ internal static IMauiHandlersCollection AddControlsHandlers(this IMauiHandlersCo
handlersCollection.AddHandler(typeof(ViewCell), typeof(Handlers.Compatibility.ViewCellRenderer));
handlersCollection.AddHandler(typeof(SwitchCell), typeof(Handlers.Compatibility.SwitchCellRenderer));
#endif
#pragma warning disable CS0618 // Type or member is obsolete
handlersCollection.AddHandler(typeof(TableView), typeof(Handlers.Compatibility.TableViewRenderer));
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning disable CS0618 // Type or member is obsolete
handlersCollection.AddHandler(typeof(Frame), typeof(Handlers.Compatibility.FrameRenderer));
#pragma warning restore CS0618 // Type or member is obsolete
Expand Down
2 changes: 2 additions & 0 deletions src/Controls/src/Core/Internals/CellExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public static class CellExtensions
/// <include file="../../../docs/Microsoft.Maui.Controls.Internals/CellExtensions.xml" path="//Member[@MemberName='GetPath']/Docs/*" />
public static Tuple<int, int> GetPath(this Cell cell)
{
#pragma warning disable CS0618 // Type or member is obsolete
return TableView.TableSectionModel.GetPath(cell);
#pragma warning restore CS0618 // Type or member is obsolete
}
}
}
1 change: 1 addition & 0 deletions src/Controls/src/Core/TableView/TableView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Microsoft.Maui.Controls
{
/// <include file="../../docs/Microsoft.Maui.Controls/TableView.xml" path="Type[@FullName='Microsoft.Maui.Controls.TableView']/Docs/*" />
[Obsolete("Please use CollectionView instead.")]
[ContentProperty(nameof(Root))]
public class TableView : View, ITableViewController, IElementConfiguration<TableView>, IVisualTreeElement
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ await InvokeOnMainThreadAsync(async () =>

// Wait for image to load and force the grid to measure itself again
await Task.Delay(1000);
#pragma warning disable CS0618 // Type or member is obsolete
layout.Measure(double.PositiveInfinity, double.PositiveInfinity);
#pragma warning restore CS0618 // Type or member is obsolete

await handler.ToPlatform().AssertContainsColor(Colors.Blue, MauiContext); // Grid renders
await handler.ToPlatform().AssertContainsColor(Colors.Red, MauiContext); // Image within button renders
Expand Down
Loading
Loading