Skip to content

Commit

Permalink
Minor Fixes
Browse files Browse the repository at this point in the history
Cosmetic fix for Header and Footer standard views

Added Progress Hud while performing search

Resigning First responder when performing search

Don't display Checkmark accessory when SelectionAction == SeclectionAction.None
  • Loading branch information
RobertKozak committed Jan 23, 2012
1 parent 818f3a2 commit c400a8b
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 50 deletions.
6 changes: 3 additions & 3 deletions Dialog/DialogViewController/BaseDialogViewSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ public override float GetHeightForHeader(UITableView tableView, int sectionIndex
headerLabel.Font = UIFont.BoldSystemFontOfSize(UIFont.LabelFontSize);
var size = headerLabel.StringSize(section.HeaderText, headerLabel.Font);

var height = (float)(size.Height * (headerLabel.Font.NumberOfLines(section.HeaderText, width) + 0.5));
var height = (float)Math.Floor((float)(size.Height * (headerLabel.Font.NumberOfLines(section.HeaderText, width) + 0.5))) + 1;

return height;
}
Expand Down Expand Up @@ -517,7 +517,7 @@ public override float GetHeightForFooter(UITableView tableView, int sectionIndex
footerLabel.Font = UIFont.SystemFontOfSize(15);
var size = footerLabel.StringSize(section.FooterText, footerLabel.Font);

var height = size.Height * (footerLabel.Font.NumberOfLines(section.FooterText, width));
var height = size.Height * (footerLabel.Font.NumberOfLines(section.FooterText, width)) + 1;

return height;
}
Expand Down Expand Up @@ -560,7 +560,7 @@ private UIView CreateHeaderView(UITableView tableView, string caption)
var headerLabel = new UILabel() { Font = UIFont.BoldSystemFontOfSize(UIFont.LabelFontSize) };

var size = headerLabel.StringSize(caption, headerLabel.Font);
var height = (float)(size.Height * (headerLabel.Font.NumberOfLines(caption, width) + 0.5));
var height = (float)Math.Floor((float)(size.Height * (headerLabel.Font.NumberOfLines(caption, width) + 0.5)));

var frame = new RectangleF(tableView.Bounds.X + (indentation + 10), 0, width, height);

Expand Down
88 changes: 46 additions & 42 deletions Dialog/DialogViewController/DialogViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,63 +325,67 @@ public void PerformFilter(string text)
if (_OriginalSections == null)
return;

var index = 0;
foreach(var section in _OriginalSections.Values)
var progress = new ProgressHud() { TitleText = string.Format("Searching for {0}", text) , GraceTime = 0.5f };
progress.ShowWhileExecuting(()=>
{
section.DataContext = _OriginalDataContext[index++] as IList;
}

OnSearchTextChanged(text);

var newSections = new Dictionary<int, Section>();

var searchable = TableView.Source as ISearchBar;
if (searchable != null)
{
if (searchable.SearchCommand == null)
var index = 0;
foreach(var section in _OriginalSections.Values)
{
index = 0;
foreach(var section in _OriginalSections.Values)
section.DataContext = _OriginalDataContext[index++] as IList;
}
OnSearchTextChanged(text);
var newSections = new Dictionary<int, Section>();
var searchable = TableView.Source as ISearchBar;
if (searchable != null)
{
if (searchable.SearchCommand == null)
{
if (TableView.Source is ListSource)
index = 0;
foreach(var section in _OriginalSections.Values)
{
var newList = new List<object>();
var list = section.DataContext as IEnumerable;
if (list != null)
if (TableView.Source is ListSource)
{
foreach(var item in list)
var newList = new List<object>();
var list = section.DataContext as IEnumerable;
if (list != null)
{
var caption = item as ICaption;
var searchableItem = item as ISearchable;
if ((searchableItem != null && searchableItem.Matches(text)) ||
(caption != null && !string.IsNullOrEmpty(caption.Caption)) ||
item.ToString().ToLower().Contains(text.ToLower()))
foreach(var item in list)
{
newList.Add(item);

if (!newSections.ContainsKey(index))
var caption = item as ICaption;
var searchableItem = item as ISearchable;
if ((searchableItem != null && searchableItem.Matches(text)) ||
(caption != null && !string.IsNullOrEmpty(caption.Caption)) ||
item.ToString().ToLower().Contains(text.ToLower()))
{
newSections.Add(index, section);
newList.Add(item);
if (!newSections.ContainsKey(index))
{
newSections.Add(index, section);
}
}
}
}
section.DataContext = newList;
}

section.DataContext = newList;
index++;
}

index++;
}
else
{
newSections = searchable.SearchCommand.Execute(_OriginalSections, text);
}
}
else
{
newSections = searchable.SearchCommand.Execute(_OriginalSections, text);
}
}

((BaseDialogViewSource)TableView.Source).Sections = newSections;

ReloadData();
((BaseDialogViewSource)TableView.Source).Sections = newSections;
InvokeOnMainThread(()=>ReloadData());
}, true);
}

public virtual void SearchButtonClicked(string text)
Expand Down
6 changes: 3 additions & 3 deletions Dialog/DialogViewController/DialogViewSearchDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ public override void SearchButtonClicked(UISearchBar searchbar)
_Container.SearchButtonClicked(searchbar.Text);
var searchable = _Container.TableView.Source as ISearchBar;

if (searchable != null && searchable.IncrementalSearch)
searchbar.ResignFirstResponder();
else
searchbar.ResignFirstResponder();

if (searchable != null)
_Container.PerformFilter(searchbar.Text);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Dialog/DialogViewController/ListSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ private void SetItems()
protected override void SetSelectionAccessory(UITableViewCell cell, NSIndexPath indexPath)
{
var sectionData = GetSectionData(0);
cell.Accessory = SelectionAction == SelectionAction.Custom ? UITableViewCellAccessory.None : cell.Accessory;
cell.Accessory = SelectionAction == SelectionAction.Custom || SelectionAction == SelectionAction.None ? UITableViewCellAccessory.None : cell.Accessory;

if (SelectionAction != SelectionAction.NavigateToView)
{
Expand All @@ -793,7 +793,7 @@ protected override void SetSelectionAccessory(UITableViewCell cell, NSIndexPath

base.SetSelectionAccessory(cell, indexPath);

if (IsSelectable)
if (IsSelectable && SelectionAction != SelectionAction.None)
{
var selectedIndex = sectionData.IndexOf(SelectedItem);
UIView selectedAccessoryView = SelectedAccessoryViews.Count > 0 ? SelectedAccessoryViews[cell] : null;
Expand Down

0 comments on commit c400a8b

Please sign in to comment.