Skip to content

Commit

Permalink
Merge pull request #163 from muak/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
muak authored Apr 30, 2021
2 parents e24ca2c + 268a523 commit dde17cb
Show file tree
Hide file tree
Showing 7 changed files with 295 additions and 217 deletions.
22 changes: 22 additions & 0 deletions SettingsView/Cells/CellBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,28 @@ public double IconRadius
get { return (double)GetValue(IconRadiusProperty); }
set { SetValue(IconRadiusProperty, value); }
}

/// <summary>
/// The IsVisible property.
/// </summary>
public static BindableProperty IsVisibleProperty =
BindableProperty.Create(
nameof(IsVisible),
typeof(bool),
typeof(Section),
true,
defaultBindingMode: BindingMode.OneWay
);

/// <summary>
/// Gets or sets a value indicating whether this <see cref="CellBase"/> is visible.
/// </summary>
/// <value><c>true</c> if is visible; otherwise, <c>false</c>.</value>
public bool IsVisible
{
get { return (bool)GetValue(IsVisibleProperty); }
set { SetValue(IsVisibleProperty, value); }
}

/// <summary>
/// Gets or sets the section.
Expand Down
21 changes: 21 additions & 0 deletions SettingsView/Cells/PickerCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,27 @@ public bool UsePickToClose {
set { SetValue(UsePickToCloseProperty, value); }
}

/// <summary>
/// The padding property.
/// </summary>
public static BindableProperty PaddingProperty =
BindableProperty.Create(
nameof(Padding),
typeof(Thickness),
typeof(PickerCell),
new Thickness(0, 0, 0, 0),
defaultBindingMode: BindingMode.OneWay
);

/// <summary>
/// Gets or sets the padding property.
/// </summary>
/// <value>Padding in device-independent pixels</value>
public Thickness Padding {
get { return (Thickness)GetValue(PaddingProperty); }
set { SetValue(PaddingProperty, value); }
}

internal IList MergedSelectedList {
get {
if (SelectionMode == SelectionMode.Single)
Expand Down
6 changes: 6 additions & 0 deletions SettingsView/Platforms/Android/Cells/PickerCellRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ void CreateDialog()
_listView = new AListView(_context);
_listView.Focusable = false;
_listView.DescendantFocusability = Android.Views.DescendantFocusability.AfterDescendants;
_listView.SetPadding(
(int) _context.ToPixels(_PickerCell.Padding.Left),
(int) _context.ToPixels(_PickerCell.Padding.Top),
(int) _context.ToPixels(_PickerCell.Padding.Right),
(int) _context.ToPixels(_PickerCell.Padding.Bottom)
);
_listView.SetDrawSelectorOnTop(true);
_listView.ChoiceMode = _PickerCell.MaxSelectedNumber == 1 ? Android.Widget.ChoiceMode.Single : Android.Widget.ChoiceMode.Multiple;
_adapter = new PickerAdapter(_context, _PickerCell, _listView);
Expand Down
8 changes: 6 additions & 2 deletions SettingsView/Platforms/Android/SettingsViewRecyclerAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,22 @@ public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int positi

var vHolder = holder as ViewHolder;
vHolder.RowInfo = rowInfo;

bool cellVisible = (rowInfo.Cell as CellBase)?.IsVisible ?? true;

if(!rowInfo.Section.IsVisible ||
!cellVisible ||
(rowInfo.ViewType == ViewType.CustomFooter && !rowInfo.Section.FooterVisible))
{
vHolder.ItemView.Visibility = ViewStates.Gone;
vHolder.ItemView.SetMinimumHeight(0);
vHolder.ItemView.LayoutParameters.Height = 0;
return;
}

vHolder.ItemView.Visibility = ViewStates.Visible;

vHolder.ItemView.LayoutParameters.Height = -2; //wrap_content

switch (rowInfo.ViewType)
{
case ViewType.TextHeader:
Expand Down
Loading

0 comments on commit dde17cb

Please sign in to comment.