Skip to content

Commit

Permalink
Merge pull request #51 from Clancey/ViewTitle
Browse files Browse the repository at this point in the history
View title
  • Loading branch information
Clancey authored Jul 22, 2019
2 parents d465828 + b193056 commit 6d6961a
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 16 deletions.
5 changes: 2 additions & 3 deletions sample/HotUI.Samples/MainPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ public class MainPage : View {

public MainPage (List<MenuItem> additionalPage = null)
{
Title = "HotUI Samples";

this.Title("Main Page");
//This is only required since there is a parameter for the view
HotReloadHelper.Register(this, additionalPage);
if (additionalPage != null)
Expand All @@ -61,7 +60,7 @@ public MainPage (List<MenuItem> additionalPage = null)
new Text(page.Title),
new Spacer()
}.Frame(height:44).Padding(left:10),
}.OnSelected(page => Navigation.PerformNavigate(page.Page?.Invoke()))
}.OnSelected(page => Navigation.PerformNavigate(page.Page?.Invoke()?.Title(page.Title)))
};

}
Expand Down
4 changes: 0 additions & 4 deletions sample/HotUI.Samples/TabViewSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ namespace HotUI.Samples
{
public class TabViewSample : View
{
public TabViewSample()
{
this.Title = "TabView sample";
}

[Body]
View body() => new TabView
Expand Down
2 changes: 1 addition & 1 deletion src/HotUI.iOS/Controls/HUITabView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public override void MovedToSuperview()
{
base.MovedToSuperview();
var vc = this.GetViewController();
vc.AddChildViewController(tabViewController);
vc?.AddChildViewController(tabViewController);
}
public override void RemoveFromSuperview()
{
Expand Down
2 changes: 1 addition & 1 deletion src/HotUI.iOS/HotUIViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public View CurrentView
else
_startingCurrentView = value;

Title = value?.Title ?? "";
Title = value?.GetEnvironment<string>(EnvironmentKeys.View.Title) ?? "";
}
}

Expand Down
7 changes: 0 additions & 7 deletions src/HotUI/Controls/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ public string Tag
internal set => tag = value;
}

string title;
public string Title
{
get => title ?? parent?.Title;
protected set => title = value;
}

public View Parent
{
get => parent;
Expand Down
1 change: 1 addition & 0 deletions src/HotUI/EnvironmentData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public static class View
public const string ClipShape = "ClipShape";
public const string Shadow = "Shadow";
public const string Overlay = "Overlay";
public const string Title = "Title";
}

public static class Shape
Expand Down
3 changes: 3 additions & 0 deletions src/HotUI/Helpers/ViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,8 @@ public static List<FieldInfo> GetFieldsWithAttribute(this object obj, Type attri
var fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance).Where(x => Attribute.IsDefined(x, attribute)).ToList();
return fields;
}

public static T Title<T>(this T view, string title) where T : View =>
view.SetEnvironment(EnvironmentKeys.View.Title, title);
}
}

0 comments on commit 6d6961a

Please sign in to comment.