Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added optional explicit summary to RootElement. #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
22 changes: 21 additions & 1 deletion MonoTouch.Dialog/Elements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2388,6 +2388,7 @@ public class RootElement : Element, IEnumerable, IEnumerable<Section> {
static NSString rkey1 = new NSString ("RootElement1");
static NSString rkey2 = new NSString ("RootElement2");
int summarySection, summaryElement;
string explicitSummary;
internal Group group;
public bool UnevenRows;
public Func<RootElement, UIViewController> createOnSelected;
Expand All @@ -2410,6 +2411,22 @@ public RootElement (string caption) : base (caption)
Sections = new List<Section> ();
}

/// <summary>
/// Initializes a RootSection with a caption and a summary
/// </summary>
/// <param name="caption">
/// The caption to render.
/// </param>
/// <param name="summary">
/// The summary to render.
/// </param>
public RootElement (string caption, string summary) : base (caption)
{
explicitSummary = summary;
summarySection = -1;
Sections = new List<Section> ();
}

/// <summary>
/// Initializes a RootSection with a caption and a callback that will
/// create the nested UIViewController that is activated when the user
Expand Down Expand Up @@ -2732,7 +2749,7 @@ public override UITableViewCell GetCell (UITableView tv)
NSString key = summarySection == -1 ? rkey1 : rkey2;
var cell = tv.DequeueReusableCell (key);
if (cell == null){
var style = summarySection == -1 ? UITableViewCellStyle.Default : UITableViewCellStyle.Value1;
var style = summarySection == -1 && explicitSummary == null ? UITableViewCellStyle.Default : UITableViewCellStyle.Value1;

cell = new UITableViewCell (style, key);
cell.SelectionStyle = UITableViewCellSelectionStyle.Blue;
Expand Down Expand Up @@ -2776,6 +2793,9 @@ public override UITableViewCell GetCell (UITableView tv)
}
}
cell.DetailTextLabel.Text = count.ToString ();
} else if (explicitSummary != null) {
if (cell.DetailTextLabel != null)
cell.DetailTextLabel.Text = explicitSummary;
} else if (summarySection != -1 && summarySection < Sections.Count){
var s = Sections [summarySection];
if (summaryElement < s.Elements.Count && cell.DetailTextLabel != null)
Expand Down
7 changes: 6 additions & 1 deletion Sample/DemoElementApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ RootElement CreateRoot ()
new TimeElement ("Select Time", DateTime.Now),
},
new Section () {
CreateGeneralSection (),
CreateGeneralSection (),
new RootElement ("RootElement", "Explicit Summary") {
new Section ("About this test"){
new MultilineElement ("A root element with an explicit summary")
}
}
//new RootElement ("Mail, Contacts, Calendars"),
//new RootElement ("Phone"),
//new RootElement ("Safari"),
Expand Down