using Xamarin.Forms;
using Xamarin.Forms.Platform.Tizen;
using XForms = Xamarin.Forms.Forms;
-using CForms = Tizen.Wearable.CircularUI.Forms;
namespace Tizen.Wearable.CircularUI.Forms.Renderer
{
public override void SetHeader(VisualElement header)
{
base.SetHeader(header);
- if (HasHeader() && CForms.CircleListView.GetCancelEffect(header))
+ if (header != null && CircleListView.GetCancelEffect(header))
{
- FirstItem.UpdateItemClass(GetCancelEffectTemplete(), header);
+ FirstItem.UpdateItemClass(GetCancelEffectTemplete(), HeaderItemContext);
}
}
public override void SetFooter(VisualElement footer)
{
base.SetFooter(footer);
- if (HasFooter() && CForms.CircleListView.GetCancelEffect(footer))
+ if (footer != null && CircleListView.GetCancelEffect(footer))
{
- LastItem.UpdateItemClass(GetCancelEffectTemplete(), footer);
+ LastItem.UpdateItemClass(GetCancelEffectTemplete(), FooterItemContext);
}
}
{
GetContentHandler = (data, part) =>
{
- VisualElement element = data as VisualElement;
- var renderer = Platform.GetOrCreateRenderer(element);
+ var context = data as HeaderFooterItemContext;
+ if (context == null || context.Element == null)
+ return null;
- if (element.MinimumHeightRequest == -1)
+ var renderer = Platform.GetOrCreateRenderer(context.Element);
+ if (context.Element.MinimumHeightRequest == -1)
{
- SizeRequest request = element.Measure(double.PositiveInfinity, double.PositiveInfinity);
+ SizeRequest request = context.Element.Measure(double.PositiveInfinity, double.PositiveInfinity);
renderer.NativeView.MinimumHeight = XForms.ConvertToScaledPixel(request.Request.Height);
}
else
{
- renderer.NativeView.MinimumHeight = XForms.ConvertToScaledPixel(element.MinimumHeightRequest);
+ renderer.NativeView.MinimumHeight = XForms.ConvertToScaledPixel(context.Element.MinimumHeightRequest);
}
+
(renderer as LayoutRenderer)?.RegisterOnLayoutUpdated();
return renderer.NativeView;
[EditorBrowsable(EditorBrowsableState.Never)]
public void OnRequestedThemeChanged(AppThemeChangedEventArgs args)
{
- if (Device.Flags.IndexOf(ExperimentalFlags.AppThemeExperimental) == -1)
+ if (Device.Flags == null || Device.Flags.IndexOf(ExperimentalFlags.AppThemeExperimental) == -1)
return;
// On iOS the event is triggered more than once.
public const string Label = "label";
public const string SecondaryLabel = "secondaryLabel";
public const string TertiaryLabel = "tertiaryLabel";
- public const string QuaternaryLabel = "quaternaryLabellabel";
+ public const string QuaternaryLabel = "quaternaryLabel";
public const string PlaceholderText = "placeholderText";
public const string Separator = "separator";
public const string OpaqueSeparator = "opaqueSeparator";
using ElmSharp;
using Tizen.Applications;
using TSystemInfo = Tizen.System.Information;
-using TSystemSetting = Tizen.System.SystemSettings;
-using EWindow = ElmSharp.Window;
using ELayout = ElmSharp.Layout;
using DeviceOrientation = Xamarin.Forms.Internals.DeviceOrientation;
+using ElmSharp.Wearable;
using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
using PTizen = Xamarin.Forms.Platform.Tizen;
-using ElmSharp.Wearable;
+using TSystemSetting = Tizen.System.SystemSettings;
+using EWindow = ElmSharp.Window;
using Tizen.Wearable.CircularUI.Forms;
namespace Xamarin.Forms
}
static IReadOnlyList<string> s_flags;
- public static IReadOnlyList<string> Flags => s_flags ?? (s_flags = new string[0]);
+ public static IReadOnlyList<string> Flags => s_flags ?? (s_flags = new List<string>().AsReadOnly());
public static void SetFlags(params string[] flags)
{
throw new InvalidOperationException($"{nameof(SetFlags)} must be called before {nameof(Init)}");
}
- s_flags = (string[])flags.Clone();
- if (s_flags.Contains("Profile"))
- Profile.Enable();
+ s_flags = flags.ToList().AsReadOnly();
}
public static void SetTitleBarVisibility(TizenTitleBarVisibility visibility)
public static void Init(InitializationOptions options)
{
- SetupInit(Context, options);
+ SetupInit(options.Context, options);
}
static void SetupInit(CoreApplication application, InitializationOptions options = null)
{
TizenSynchronizationContext.Initialize();
}
+
Elementary.Initialize();
Elementary.ThemeOverlay();
Utility.AppendGlobalFontPath(@"/usr/share/fonts");
}
else
{
- // In .NETCore, AppDomain feature is not supported.
- // The list of assemblies returned by AppDomain.GetAssemblies() method should be registered manually.
- // The assembly of the executing application and referenced assemblies of it are added into the list here.
- TizenPlatformServices.AppDomain.CurrentDomain.RegisterAssemblyRecursively(application.GetType().GetTypeInfo().Assembly);
-
Registrar.RegisterAll(new Type[]
{
typeof(ExportRendererAttribute),
Color.SetAccent(GetAccentColor(profile));
ExpressionSearch.Default = new TizenExpressionSearch();
+
+ if (application is WatchApplication)
+ s_platformType = PlatformType.Lightweight;
+
IsInitialized = true;
}
Scroll.HorizontalPageScrollLimit = 1;
Scroll.VerticalPageScrollLimit = 1;
Scroll.SetPageSize(1.0, 1.0);
+ Scroll.HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible;
+ Scroll.VerticalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible;
}
public EScroller Scroll => base.Scroller;
+ protected override ViewHolder CreateViewHolder()
+ {
+ return new ViewHolder(this)
+ {
+ FocusedColor = ElmSharp.Color.Transparent,
+ SelectedColor = ElmSharp.Color.Transparent,
+ };
+ }
+
ESize ICollectionViewController.GetItemSize(int widthConstraint, int heightConstraint)
{
return AllocatedSize;
public CollectionView(EvasObject parent) : base(parent)
{
+ AllowFocus(true);
SetLayoutCallback(OnLayout);
Scroller = CreateScroller(parent);
Scroller.Show();
return Adaptor.MeasureItem(index, widthConstraint, heightConstraint);
}
+ protected virtual ViewHolder CreateViewHolder()
+ {
+ return new ViewHolder(this);
+ }
+
ViewHolder ICollectionViewController.RealizeView(int index)
{
if (Adaptor == null)
else
{
var content = Adaptor.CreateNativeView(index, this);
- holder = new ViewHolder(this);
+ holder = CreateViewHolder();
holder.RequestSelected += OnRequestItemSelection;
holder.Content = content;
holder.ViewCategory = Adaptor.GetViewCategory(index);
{
public class IndicatorView : Index
{
+ const int OddMiddleItem = 10;
+ const int EvenMiddleItem = 11;
List<IndexItem> _list = new List<IndexItem>();
public IndicatorView(EvasObject parent) : base(parent)
{
foreach (var item in _list)
{
- int center = 10;
- int start = center - (_list.Count / 2);
- int index = _list.IndexOf(item);
- int position = start + index;
if (_list.Count % 2 == 0)
{
+ int position = EvenMiddleItem - (_list.Count / 2) + _list.IndexOf(item);
string itemStyle = "item/even_" + position;
item.Style = itemStyle;
}
else
{
+ int position = OddMiddleItem - (_list.Count / 2) + _list.IndexOf(item);
string itemStyle = "item/odd_" + position;
item.Style = itemStyle;
}
UpdateSelectedIndex(index);
}
}
-}
+}
\ No newline at end of file
using System.ComponentModel;
using Xamarin.Forms.Internals;
using ElmSharp;
-using ElmSharp.Wearable;
using EScroller = ElmSharp.Scroller;
-using EColor = ElmSharp.Color;
namespace Xamarin.Forms.Platform.Tizen.Native
{
/// <summary>
/// Native ListView implementation for Xamarin renderer
/// </summary>
- /// <remarks>
+ /// <remarks>
/// This internally uses GenList class.
/// One should note that it is optimized for displaying many elements which may be
/// unavailable at first. This means that only currently visible elements will be constructed.
internal TemplatedItemsList<ItemsView<Cell>, Cell> ListOfSubItems;
}
+ public class HeaderFooterItemContext : ItemContext
+ {
+ public VisualElement Element;
+ }
+
class ScrollerExtension : EScroller
{
public ScrollerExtension(GenList scrollableLayout) : base(scrollableLayout)
protected readonly IDictionary<Type, CellRenderer> _groupCellRendererCache = new Dictionary<Type, CellRenderer>();
/// <summary>
- /// The header context.
- /// </summary>
- ItemContext _headerContext;
-
- /// <summary>
/// The header element.
/// </summary>
VisualElement _headerElement;
- /// <summary>
- /// The footer context.
- /// </summary>
- ItemContext _footerContext;
/// <summary>
/// The footer element.
/// </summary>
protected virtual EScroller Scroller { get; set; }
+ protected HeaderFooterItemContext HeaderItemContext { get; set; }
+
+ protected HeaderFooterItemContext FooterItemContext { get; set; }
+
/// <summary>
/// Gets or sets a value indicating whether this instance has grouping enabled.
/// </summary>
/// Adds elements to the list and defines its presentation based on Cell type.
/// </summary>
/// <param name="source">IEnumerable on Cell collection.</param>
- /// <param name="beforeCell">Cell before which new items will be placed.
+ /// <param name="beforeCell">Cell before which new items will be placed.
/// Null value may also be passed as this parameter, which results in appending new items to the end.
/// </param>
public virtual void AddSource(IEnumerable source, Cell beforeCell = null)
/// <param name="header">Header of the list.</param>
public virtual void SetHeader(VisualElement header)
{
- if (header == null)
+ _headerElement = header;
+ UpdateHeader();
+ }
+
+ protected virtual void UpdateHeader()
+ {
+ if (GetHeader() == null)
{
- if (HasHeader())
+ if (HasHeaderContext())
{
- RemoveHeader();
+ RemoveHeaderItemContext();
}
-
return;
}
- GenItemClass headerTemplate = GetHeaderFooterItemClass();
+ var headerTemplate = GetHeaderFooterItemClass();
+ if (!HasHeaderContext())
+ {
+ InitializeHeaderItemContext(headerTemplate);
+ }
+ else
+ {
+ HeaderItemContext.Element = GetHeader();
+ (HeaderItemContext.Item as GenListItem).UpdateItemClass(headerTemplate, HeaderItemContext);
+ }
+ }
- _headerElement = header;
- if (HasHeader())
+ protected void InitializeHeaderItemContext(GenItemClass headerTemplate)
+ {
+ var context = new HeaderFooterItemContext();
+ context.Element = GetHeader();
+ if (FirstItem != null)
{
- FirstItem.UpdateItemClass(headerTemplate, header);
+ context.Item = InsertBefore(headerTemplate, context, FirstItem);
}
else
{
- _headerContext = new ItemContext();
- _headerContext.Item = _itemContextList.Count > 0 ? InsertBefore(headerTemplate, header, FirstItem) : Append(headerTemplate, header);
- _headerContext.Item.SelectionMode = GenItemSelectionMode.None;
- _headerContext.Item.Deleted += HeaderDeletedHandler;
- _itemContextList.Insert(0, _headerContext);
+ context.Item = Append(headerTemplate, context);
}
+ context.Item.SelectionMode = GenItemSelectionMode.None;
+ context.Item.Deleted += OnHeaderItemDeleted;
+ HeaderItemContext = context;
+ }
+
+ void OnHeaderItemDeleted(object sender, EventArgs e)
+ {
+ HeaderItemContext = null;
}
/// <summary>
/// <param name="footer">Footer of the list.</param>
public virtual void SetFooter(VisualElement footer)
{
- if (footer == null)
+ _footerElement = footer;
+ UpdateFooter();
+ }
+
+ protected virtual void UpdateFooter()
+ {
+ if (GetFooter() == null)
{
- if (HasFooter())
+ if (HasFooterContext())
{
- RemoveFooter();
+ RemoveFooterItemContext();
}
return;
}
- GenItemClass footerTemplate = GetHeaderFooterItemClass();
-
- _footerElement = footer;
- if (HasFooter())
+ var footerTemplate = GetHeaderFooterItemClass();
+ if (!HasFooterContext())
{
- (_footerContext.Item as GenListItem).UpdateItemClass(footerTemplate, footer);
+ InitializeFooterItemContext(footerTemplate);
}
else
{
- _footerContext = new ItemContext();
- _footerContext.Item = Append(footerTemplate, footer);
- _footerContext.Item.SelectionMode = GenItemSelectionMode.None;
- _footerContext.Item.Deleted += FooterDeletedHandler;
- _itemContextList.Add(_footerContext);
+ FooterItemContext.Element = GetFooter();
+ (HeaderItemContext.Item as GenListItem).UpdateItemClass(footerTemplate, HeaderItemContext);
}
}
- /// <summary>
- /// Removes the header.
- /// </summary>
- public void RemoveHeader()
+ protected void InitializeFooterItemContext(GenItemClass headerTemplate)
{
- _itemContextList.Remove(_headerContext);
- _headerContext?.Item?.Delete();
- _headerContext = null;
- _headerElement = null;
+ var context = new HeaderFooterItemContext();
+ context.Element = GetFooter();
+ context.Item = Append(headerTemplate, context);
+ context.Item.SelectionMode = GenItemSelectionMode.None;
+ context.Item.Deleted += OnFooterItemDeleted;
+ FooterItemContext = context;
}
- /// <summary>
- /// Removes the footer.
- /// </summary>
- public void RemoveFooter()
+ void OnFooterItemDeleted(object sender, EventArgs e)
{
- _itemContextList.Remove(_footerContext);
- _footerContext?.Item?.Delete();
- _footerContext = null;
- _footerElement = null;
+ FooterItemContext = null;
}
- /// <summary>
- /// Determines whether this instance has a header.
- /// </summary>
- /// <returns><c>true</c> if the header is present.</returns>
- public bool HasHeader()
+ protected void RemoveHeaderItemContext()
{
- return _headerContext != null;
+ HeaderItemContext?.Item?.Delete();
+ HeaderItemContext = null;
}
- /// <summary>
- /// Determines whether this instance has a footer.
- /// </summary>
- /// <returns><c>true</c> if the footer is present.</returns>
- public bool HasFooter()
+ protected void RemoveFooterItemContext()
+ {
+ FooterItemContext?.Item?.Delete();
+ FooterItemContext = null;
+ }
+
+ public bool HasHeaderContext()
{
- return _footerContext != null;
+ return HeaderItemContext != null;
+ }
+
+ public bool HasFooterContext()
+ {
+ return FooterItemContext != null;
}
/// <summary>
}
/// <summary>
- /// Handles the header deleted event.
- /// </summary>
- /// <param name="sender">Sender of the event.</param>
- /// <param name="e">Empty argument.</param>
- void HeaderDeletedHandler(object sender, EventArgs e)
- {
- _itemContextList.Remove(_headerContext);
- _headerContext = null;
- }
-
- /// <summary>
- /// Handles the footer deleted event.
- /// </summary>
- /// <param name="sender">Sender of the event.</param>
- /// <param name="e">Empty argument.</param>
- void FooterDeletedHandler(object sender, EventArgs e)
- {
- _itemContextList.Remove(_footerContext);
- _footerContext = null;
- }
-
- /// <summary>
/// Called every time an object gets realized.
/// </summary>
/// <param name="sender">Sender of the event.</param>
GenListItem beforeItem = GetItemContext(beforeCell)?.Item as GenListItem;
itemContext.Item = InsertBefore(renderer.Class, itemContext, beforeItem, GenListItemType.Normal, parentItem);
}
+ else if (HasFooterContext())
+ {
+ itemContext.Item = InsertBefore(renderer.Class, itemContext, FooterItemContext.Item as GenListItem, GenListItemType.Normal, parentItem);
+ }
else
{
itemContext.Item = Append(renderer.Class, itemContext, GenListItemType.Normal, parentItem);
/// Gets the item class used for header and footer cells.
/// </summary>
/// <returns>The header and footer item class.</returns>
- GenItemClass GetHeaderFooterItemClass()
+ protected GenItemClass GetHeaderFooterItemClass()
{
if (_headerFooterItemClass == null)
{
{
GetContentHandler = (data, part) =>
{
- VisualElement element = data as VisualElement;
- var renderer = Platform.GetOrCreateRenderer(element);
+ var context = data as HeaderFooterItemContext;
+ if (context == null || context.Element == null)
+ return null;
- if (element.MinimumHeightRequest == -1)
+ var renderer = Platform.GetOrCreateRenderer(context.Element);
+ if (context.Element.MinimumHeightRequest == -1)
{
- SizeRequest request = element.Measure(double.PositiveInfinity, double.PositiveInfinity);
+ SizeRequest request = context.Element.Measure(double.PositiveInfinity, double.PositiveInfinity);
renderer.NativeView.MinimumHeight = Forms.ConvertToScaledPixel(request.Request.Height);
}
else
{
- renderer.NativeView.MinimumHeight = Forms.ConvertToScaledPixel(element.MinimumHeightRequest);
+ renderer.NativeView.MinimumHeight = Forms.ConvertToScaledPixel(context.Element.MinimumHeightRequest);
}
(renderer as LayoutRenderer)?.RegisterOnLayoutUpdated();
return _headerFooterItemClass;
}
}
-}
\ No newline at end of file
+}
{
public ToolbarItem ToolbarItem { get; set; }
}
-}
+}
\ No newline at end of file
public DateTimePickerMode Mode
{
- get
+ get
{
return _mode;
}
PickerOpened?.Invoke(this, EventArgs.Empty);
}
}
-}
+}
\ No newline at end of file
CircleGenList _circleGenList;
CircleSurface _surface;
- GenItem _headerPadding;
- GenItem _footerPadding;
-
public IntPtr CircleHandle => _circleGenList.CircleHandle;
public CircleGenList CircleGenList => _circleGenList;
public IRotaryActionWidget RotaryWidget { get => this; }
+ GenItemClass _paddingItemClass;
+ protected GenItemClass PaddingItemTemplate => _paddingItemClass ?? (_paddingItemClass = new PaddingItemClass());
+
public override ScrollBarVisiblePolicy VerticalScrollBarVisibility
{
get => _circleGenList.VerticalScrollBarVisiblePolicy;
Scroller.Scrolled += OnScrolled;
}
- public override void SetHeader(VisualElement header)
- {
- if (_headerPadding != null)
- RemovePaddingItem(_headerPadding);
-
- base.SetHeader(header);
-
- if (!HasHeader())
- AddHeaderPadding();
- }
-
- public override void SetFooter(VisualElement footer)
- {
- if(_footerPadding != null)
- RemovePaddingItem(_footerPadding);
-
- base.SetFooter(footer);
-
- if (!HasFooter())
- AddFooterPadding();
- }
-
- protected override IntPtr CreateHandle(EvasObject parent)
- {
- _circleGenList = new CircleGenList(parent, _surface);
- RealHandle = _circleGenList.RealHandle;
- return _circleGenList.Handle;
- }
-
- void RemovePaddingItem(GenItem item)
+ protected override void UpdateHeader()
{
- item?.Delete();
- item = null;
+ if (GetHeader() != null)
+ {
+ base.UpdateHeader();
+ }
+ else
+ {
+ var paddingTemplate = PaddingItemTemplate;
+ if (!HasHeaderContext())
+ {
+ InitializeHeaderItemContext(PaddingItemTemplate);
+ }
+ else
+ {
+ (HeaderItemContext.Item as GenListItem).UpdateItemClass(paddingTemplate, HeaderItemContext);
+ }
+ HeaderItemContext.Element = null;
+ }
}
- void AddHeaderPadding()
+ protected override void UpdateFooter()
{
- var cls = new WatchListView.PaddingItemClass();
-
- if (FirstItem == null)
+ if (GetHeader() != null)
{
- _headerPadding = Append(cls, null);
+ base.UpdateFooter();
}
else
{
- _headerPadding = InsertBefore(cls, null, FirstItem);
+ var paddingTemplate = PaddingItemTemplate;
+ if (!HasFooterContext())
+ {
+ InitializeFooterItemContext(PaddingItemTemplate);
+ }
+ else
+ {
+ (FooterItemContext.Item as GenListItem).UpdateItemClass(paddingTemplate, FooterItemContext);
+ }
+ FooterItemContext.Element = null;
}
}
- void AddFooterPadding()
- {
- var cls = new WatchListView.PaddingItemClass();
- if (Count > 1)
- {
- _footerPadding = Append(cls, null);
- }
+ protected override IntPtr CreateHandle(EvasObject parent)
+ {
+ _circleGenList = new CircleGenList(parent, _surface);
+ RealHandle = _circleGenList.RealHandle;
+ return _circleGenList.Handle;
}
class PaddingItemClass : GenItemClass
return _circleScroller.Handle;
}
}
-}
+}
\ No newline at end of file
RegisterPropertyHandler(Button.FontAttributesProperty, UpdateFontAttributes);
RegisterPropertyHandler(Button.TextColorProperty, UpdateTextColor);
RegisterPropertyHandler(Button.ImageSourceProperty, UpdateBitmap);
+ RegisterPropertyHandler(Button.BorderColorProperty, UpdateBorder);
+ RegisterPropertyHandler(Button.CornerRadiusProperty, UpdateBorder);
+ RegisterPropertyHandler(Button.BorderWidthProperty, UpdateBorder);
}
protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
protected override Size MinimumSize()
{
Size measured;
- if(Control is IMeasurable im)
+ if (Control is IMeasurable im)
{
measured = im.Measure(Control.MinimumWidth, Control.MinimumHeight).ToDP();
}
if (Element.ImageSource != null)
{
ib.Image = new Native.Image(Control);
- var task = ib.Image.LoadFromImageSourceAsync(Element.ImageSource);
+ if (Element.ImageSource is FileImageSource fis)
+ {
+ ib.Image.LoadFromFile(fis.File);
+ }
+ else
+ {
+ var task = ib.Image.LoadFromImageSourceAsync(Element.ImageSource);
+ }
}
else
{
}
}
}
+
+ void UpdateBorder()
+ {
+ /* The simpler way is to create some specialized theme for button in
+ * tizen-theme
+ */
+ // TODO: implement border handling
+ }
}
}
\ No newline at end of file
protected virtual void UpdateAfterLoading()
{
- _image.IsOpaque = Element.IsOpaque;
+ if (_image.IsOpaque != Element.IsOpaque)
+ _image.IsOpaque = Element.IsOpaque;
}
protected override ElmSharp.Size Measure(int availableWidth, int availableHeight)
if (Control != null)
{
- bool success = await _image.LoadFromImageSourceAsync(source);
+ bool success;
+ if (source is FileImageSource fis)
+ {
+ success = _image.LoadFromFile(fis.File);
+ }
+ else
+ {
+ success = await _image.LoadFromImageSourceAsync(source);
+ }
+
if (!IsDisposed && success)
{
(Element as IVisualElementController)?.NativeSizeChanged();
RegisterPropertyHandler(ListView.RowHeightProperty, UpdateRowHeight);
RegisterPropertyHandler(ListView.SelectedItemProperty, UpdateSelectedItem);
RegisterPropertyHandler(ListView.ItemsSourceProperty, UpdateSource);
- RegisterPropertyHandler("HeaderElement", UpdateHeader);
- RegisterPropertyHandler("FooterElement", UpdateFooter);
+ RegisterPropertyHandler(nameof(Element.HeaderElement), UpdateHeader);
+ RegisterPropertyHandler(nameof(Element.FooterElement), UpdateFooter);
RegisterPropertyHandler(ListView.SelectionModeProperty, UpdateSelectionMode);
RegisterPropertyHandler(ListView.VerticalScrollBarVisibilityProperty, UpdateVerticalScrollBarVisibility);
RegisterPropertyHandler(ListView.HorizontalScrollBarVisibilityProperty, UpdateHorizontalScrollBarVisibility);
}
/// <summary>
- /// Helper class for managing proper postion of Header and Footer element.
- /// Since both elements need to be implemented with ordinary list elements,
- /// both header and footer are removed at first, then the list is being modified
- /// and finally header and footer are prepended and appended to the list, respectively.
- /// </summary>
- class HeaderAndFooterHandler : IDisposable
- {
- VisualElement headerElement;
- VisualElement footerElement;
-
- Native.ListView Control;
-
- public HeaderAndFooterHandler(Widget control)
- {
- Control = control as Native.ListView;
-
- if (Control.HasHeader())
- {
- headerElement = Control.GetHeader();
- Control.RemoveHeader();
- }
- if (Control.HasFooter())
- {
- footerElement = Control.GetFooter();
- Control.RemoveFooter();
- }
- }
-
- public void Dispose()
- {
- Control.SetHeader(headerElement);
- Control.SetFooter(footerElement);
- }
- }
-
- /// <summary>
/// This method is called whenever something changes in list view data model.
/// Method will not be invoked for grouping mode, but for example event with
/// action reset will be handled here when switching between group and no-group mode.
/// <param name="e">NotifyCollectionChangedEventArgs.</param>
void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
- using (new HeaderAndFooterHandler(Control))
- {
if (e.Action == NotifyCollectionChangedAction.Add)
{
Cell before = null;
UpdateSource();
}
}
- }
/// <summary>
/// This method is called whenever something changes in list view data model.
/// <param name="e">NotifyCollectionChangedEventArgs.</param>
void OnGroupedCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
- using (new HeaderAndFooterHandler(Control))
- {
if (e.Action == NotifyCollectionChangedAction.Add)
{
TemplatedItemsList<ItemsView<Cell>, Cell> itemsGroup = sender as TemplatedItemsList<ItemsView<Cell>, Cell>;
Control.ResetGroup(sender as TemplatedItemsList<ItemsView<Cell>, Cell>);
}
}
- }
/// <summary>
/// Updates the source.
/// </summary>
void UpdateSource()
{
- bool hasHeader = Control.HasHeader();
- bool hasFooter = Control.HasFooter();
-
Control.Clear();
+ UpdateHeader(false);
Control.AddSource(Element.TemplatedItems);
+ UpdateFooter(false);
UpdateSelectedItem();
-
- if (hasHeader)
- UpdateHeader();
- if (hasFooter)
- UpdateFooter();
}
/// <summary>
/// Updates the header.
/// </summary>
- void UpdateHeader()
+ void UpdateHeader(bool initialize)
{
+ if (initialize)
+ return;
Control.SetHeader(((IListViewController)Element).HeaderElement as VisualElement);
}
/// <summary>
/// Updates the footer.
/// </summary>
- void UpdateFooter()
+ void UpdateFooter(bool initialize)
{
+ if (initialize)
+ return;
Control.SetFooter(((IListViewController)Element).FooterElement as VisualElement);
}
_lastSelectedItem.IsSelected = false;
_lastSelectedItem = null;
}
+ if (Control.SelectedItem != null)
+ {
+ Control.SelectedItem.IsSelected = false;
+ }
}
else
{
{
if (Device.Idiom == TargetIdiom.Watch)
{
- return new WatchSpinner(Forms.NativeParent.Parent, Forms.CircleSurface);
+ return new WatchSpinner(Forms.NativeParent, Forms.CircleSurface);
}
else
{
data.Icon = (menuItem.IconImageSource as FileImageSource)?.ToAbsPath();
}
var genitem = _naviMenu.Append(_defaultClass, data, GenListItemType.Normal);
- genitem.SetPartColor("bg", _backgroundColor);
_items.Add(genitem);
data.PropertyChanged += OnItemPropertyChanged;
}
_surfaceLayout.StackAbove(_naviMenu);
- _defaultClass = new GenItemClass("1icon_1text")
+ _defaultClass = new GenItemClass("1icon_2text")
{
GetTextHandler = (obj, part) =>
{
void UpdateBackgroundColor()
{
_naviMenu.BackgroundColor = _backgroundColor;
- foreach (var item in _items)
- {
- item.SetPartColor("bg", _backgroundColor);
- }
}
void UpdateForegroundColor()
_lastTop?.Hide();
_lastTop = InternalStack.LastOrDefault();
_lastTop.Show();
+ (_lastTop as Widget)?.SetFocus(true);
}
}
_rootPageRenderer = ShellRendererFactory.Default.CreateItemRenderer(ShellSection);
_viewStack.Push(_rootPageRenderer.NativeView);
+
+ Device.BeginInvokeOnMainThread(() =>
+ {
+ (_rootPageRenderer.NativeView as Widget)?.SetFocus(true);
+ });
}
void OnInsertRequest(NavigationRequestedEventArgs request)
var renderer = Platform.GetOrCreateRenderer(request.Page);
_viewStack.Push(renderer.NativeView);
request.Task = Task.FromResult(true);
+ Device.BeginInvokeOnMainThread(() =>
+ {
+ (renderer.NativeView as Widget)?.SetFocus(true);
+ });
}
void OnPopRequest(NavigationRequestedEventArgs request)