return request.Request.Height;
}
- public override void Dispose()
+ public override void Destroy()
{
IVisualElementRenderer renderer;
if (_rendererRef != null && _rendererRef.TryGetTarget(out renderer) && renderer.Element != null)
_rendererRef = null;
}
- base.Dispose();
+ base.Destroy();
}
protected override void UpdateCell()
private void Close()
{
Helpers.GrabHelper.RemoveGrab(this);
- this.Dispose();
- this.Destroy();
+ Destroy();
}
private void NotifyDateChanged()
}
}
- public override void Dispose()
+ public override void Destroy()
{
- base.Dispose();
-
+ base.Destroy();
_label = null;
_image = null;
_imageAndLabelContainer = null;
_selectionColor = DefaultSelectionColor;
}
+ public override void Destroy()
+ {
+ _store?.Dispose();
+ _store = null;
+ _root = null;
+ _refreshButton = null;
+ _refreshLabel = null;
+ _headerContainer = null;
+ _header = null;
+ _list = null;
+ _footerContainer = null;
+ _footer = null;
+ _viewPort = null;
+ _refreshHeader = null;
+ base.Destroy();
+ }
+
public static Gdk.Color DefaultSelectionColor = Color.FromHex("#3498DB").ToGtkColor();
public Widget Header
namespace Xamarin.Forms.Platform.GTK.Controls
{
- public class NavigationChildPage : Gtk.Object
+ public class NavigationChildPage : IDisposable
{
bool _disposed;
Identifier = Guid.NewGuid().ToString();
}
- public override void Dispose()
+ public void Dispose()
{
if (!_disposed)
{
_disposed = true;
Page = null;
}
-
- base.Dispose();
}
public string Identifier { get; set; }
GLib.Source.Remove(_timerId);
}
- public override void Dispose()
+ public override void Destroy()
{
- base.Dispose();
+ base.Destroy();
if (_glWidget != null)
{
- _glWidget.Dispose();
+ _glWidget.Destroy();
}
}
Children.Last().Show();
}
- public override void Dispose()
+ public override void Destroy()
{
- base.Dispose();
-
+ base.Destroy();
if (_contentContainerWrapper != null)
{
_contentContainerWrapper.SizeAllocated -= OnContentContainerWrapperSizeAllocated;
+ _contentContainerWrapper = null;
}
+ _contentContainer = null;
+ _image = null;
+ _toolbar = null;
+ _content = null;
+ _headerContainer = null;
}
private void BuildPage()
private void RefreshToolbar(HBox newToolbar)
{
- _headerContainer.RemoveFromContainer(_toolbar);
+ _toolbar.Destroy();
_toolbar = newToolbar;
_headerContainer.Add(_toolbar);
_toolbar.ShowAll();
private void RefreshContent(GtkFormsContainer newContent)
{
- _contentContainer.RemoveFromContainer(_content);
+ _content.Destroy();
_content = newContent;
_contentContainer.Add(_content);
_content.ShowAll();
}
}
- public override void Dispose()
+ public override void Destroy()
{
- base.Dispose();
+ base.Destroy();
if (_entryWrapper?.Entry != null)
{
IVisualElementRenderer childRenderer = Platform.GetRenderer(visual);
if (childRenderer != null)
{
- childRenderer.Dispose();
+ ((Gtk.Widget)childRenderer).Destroy();
Platform.SetRenderer(visual, null);
}
}
if (renderer != null)
{
- renderer.Dispose();
+ ((Gtk.Widget)renderer).Destroy();
Platform.SetRenderer(self, null);
}
}
{
foreach (var child in _toolbarSection.Children)
{
+ child.Destroy();
_toolbarSection.Remove(child);
}
if (NavigationPage.GetHasNavigationBar(currentPage))
{
- _toolbar = ConfigureToolbar();
-
- _toolbarIcon = new ImageControl
+ if (_toolbar == null)
{
- WidthRequest = 1,
- Aspect = ImageAspect.AspectFit
- };
- _toolbarTitleSection.PackStart(_toolbarIcon, false, false, 8);
+ _toolbar = ConfigureToolbar();
+
+ _toolbarIcon = new ImageControl
+ {
+ WidthRequest = 1,
+ Aspect = ImageAspect.AspectFit
+ };
+ _toolbarTitleSection.PackStart(_toolbarIcon, false, false, 8);
- _toolbarTitle = new Gtk.Label();
- _toolbarTitleSection.PackEnd(_toolbarTitle, true, true, 0);
+ _toolbarTitle = new Gtk.Label();
+ _toolbarTitleSection.PackEnd(_toolbarTitle, true, true, 0);
+ }
FindParentMasterDetail();
renderer = GetRenderer((VisualElement)view);
- renderer?.Dispose();
-
+ (renderer as Widget)?.Destroy();
view.ClearValue(RendererProperty);
}
MessagingCenter.Unsubscribe<Page, AlertArguments>(this, Page.AlertSignalName);
MessagingCenter.Unsubscribe<Page, bool>(this, Page.BusySetSignalName);
- DisposeModelAndChildrenRenderers(Page);
foreach (var modal in _modals)
DisposeModelAndChildrenRenderers(modal);
+ DisposeModelAndChildrenRenderers(Page);
- PlatformRenderer.Dispose();
+ PlatformRenderer.Destroy();
}
internal void SetPage(Page newRoot)
VisualElement oldElement = Element;
Element = element;
- if (element != null)
- {
- element.PropertyChanged += _propertyChangedHandler;
- }
-
OnElementChanged(new VisualElementChangedEventArgs(oldElement, element));
EffectUtilities.RegisterEffectControlProvider(this, oldElement, element);
return Container.GetDesiredSize(widthConstraint, heightConstraint);
}
- public override void Dispose()
+ public override void Destroy()
{
- base.Dispose();
+ base.Destroy();
if (!_disposed)
{
PageController.SendAppearing();
}
- protected override void OnDestroyed()
- {
- base.OnDestroyed();
-
- if (!_appeared || _disposed)
- return;
-
- _appeared = false;
-
- PageController.SendDisappearing();
- }
-
protected override void OnSizeAllocated(Gdk.Rectangle allocation)
{
base.OnSizeAllocated(allocation);
{
_listView.OnItemTapped -= OnItemTapped;
_listView.OnRefresh -= OnRefresh;
+ _listView.Destroy();
+ _listView = null;
}
if (_footerRenderer != null)
{
public class MasterDetailPageRenderer : AbstractPageRenderer<Controls.MasterDetailPage, MasterDetailPage>
{
+ Page _currentMaster;
+ Page _currentDetail;
+
public MasterDetailPageRenderer()
{
MessagingCenter.Subscribe(this, Forms.BarTextColor, (NavigationPage sender, Color color) =>
{
Gtk.Application.Invoke(async delegate
{
- Page.Master.PropertyChanged -= HandleMasterPropertyChanged;
await UpdateHamburguerIconAsync();
-
- if (Platform.GetRenderer(Page.Master) == null)
- Platform.SetRenderer(Page.Master, Platform.CreateRenderer(Page.Master));
- if (Platform.GetRenderer(Page.Detail) == null)
- Platform.SetRenderer(Page.Detail, Platform.CreateRenderer(Page.Detail));
-
- Widget.Master = Platform.GetRenderer(Page.Master).Container;
- Widget.Detail = Platform.GetRenderer(Page.Detail).Container;
- Widget.MasterTitle = Page.Master?.Title ?? string.Empty;
-
+ if (Page.Master != _currentMaster)
+ {
+ if (_currentMaster != null)
+ {
+ _currentMaster.PropertyChanged -= HandleMasterPropertyChanged;
+ }
+ if (Platform.GetRenderer(Page.Master) == null)
+ Platform.SetRenderer(Page.Master, Platform.CreateRenderer(Page.Master));
+ Widget.Master = Platform.GetRenderer(Page.Master).Container;
+ Widget.MasterTitle = Page.Master?.Title ?? string.Empty;
+ Page.Master.PropertyChanged += HandleMasterPropertyChanged;
+ _currentMaster = Page.Master;
+ }
+ if (Page.Detail != _currentDetail)
+ {
+ if (Platform.GetRenderer(Page.Detail) == null)
+ Platform.SetRenderer(Page.Detail, Platform.CreateRenderer(Page.Detail));
+ Widget.Detail = Platform.GetRenderer(Page.Detail).Container;
+ _currentDetail = Page.Detail;
+ }
UpdateBarTextColor();
UpdateBarBackgroundColor();
-
- Page.Master.PropertyChanged += HandleMasterPropertyChanged;
});
}
if (_currentPage != null)
{
_currentPage.PropertyChanged -= OnCurrentPagePropertyChanged;
+ _currentPage = null;
+ }
+ if (_currentStack != null)
+ {
+ _currentStack.ForEach(s => s.Dispose());
+ _currentStack = null;
}
}
if (Control.Vadjustment != null)
Control.Vadjustment.ValueChanged -= OnScrollEvent;
}
+ if (_viewPort != null)
+ {
+ _viewPort.Destroy();
+ _viewPort = null;
+ }
base.Dispose(disposing);
}
protected override void Dispose(bool disposing)
{
- base.Dispose(disposing);
-
if (Control != null)
{
- Control.Dispose();
+ Control.Destroy();
Control = null;
}
+ base.Dispose(disposing);
}
protected override void OnElementChanged(ElementChangedEventArgs<TView> e)
UpdateIsVisible();
}
- public override void Dispose()
+ public override void Destroy()
{
- base.Dispose();
-
+ base.Destroy();
Dispose(true);
}
_control.ButtonPressEvent -= OnControlButtonPressEvent;
}
- Container.Dispose();
+ Container.Destroy();
Container = null;
}