Permalink
Browse files

Added ResetTheme and fixed ThemeSampleView

  • Loading branch information...
1 parent 6a2987a commit de049f6c27d59a29cf11150c3ed737b603af7fe0 @RobertKozak committed Dec 27, 2011
@@ -218,7 +218,7 @@ public override void Draw(RectangleF rect)
if (ListSource != null)
{
Theme.Cell = this;
-
+
TextLabel.BackgroundColor = UIColor.Clear;
if (DetailTextLabel != null)
DetailTextLabel.BackgroundColor = UIColor.Clear;
@@ -507,42 +507,6 @@ public override void ViewWillAppear(bool animated)
SetScrollEnabled();
- if (Theme != null)
- {
- var nav = ParentViewController as UINavigationController;
- if (nav != null)
- {
- nav.NavigationBar.Opaque = false;
-
- if (Theme.BarStyle.HasValue)
- {
- nav.NavigationBar.BarStyle = Theme.BarStyle.Value;
- }
-
- // if (!string.IsNullOrEmpty(_Root.NavbarImage))
- // {
- // UIView view = new UIView(new RectangleF(0f, 0f, nav.NavigationBar.Frame.Width, nav.NavigationBar.Frame.Height));
- // view.BackgroundColor = UIColor.FromPatternImage(UIImage.FromBundle(_Root.NavbarImage).ImageToFitSize(view.Bounds.Size));
- // nav.NavigationBar.InsertSubview(view, 0);
- // }
- // else
- nav.NavigationBar.Translucent = Theme.BarTranslucent;
- nav.NavigationBar.TintColor = Theme.BarTintColor;
-
- nav.Toolbar.Translucent = Theme.BarTranslucent;
- nav.Toolbar.TintColor = Theme.BarTintColor;
- }
-
- var separatorColor = Theme.SeparatorColor;
- if (separatorColor != null)
- TableView.SeparatorColor = separatorColor;
-
- var separatorStyle = Theme.SeparatorStyle;
- if (separatorStyle.HasValue)
- TableView.SeparatorStyle = separatorStyle.Value;
- }
-
- ConfigureBackgroundImage();
ReloadData();
}
@@ -568,37 +532,6 @@ public override void ViewDidAppear(bool animated)
if (activation != null)
activation.Activated();
}
-
-// var source = TableView.Source as BaseDialogViewSource;
-// if (source != null)
-// {
-// foreach (var section in source.Sections.Values)
-// {
-// foreach (var viewList in section.Views.Values)
-// {
-// foreach(var view in viewList)
-// {
-// var dc = view as IDataContext<MemberData>;
-// if (dc != null)
-// {
-// var notifyPropertyChanged = dc.DataContext.DataContextSource as INotifyPropertyChanged;
-// if (notifyPropertyChanged != null)
-// {
-// notifyPropertyChanged.PropertyChanged -= HandleNotifyPropertyChanged;
-// notifyPropertyChanged.PropertyChanged += HandleNotifyPropertyChanged;
-// }
-//
-// notifyPropertyChanged = dc.DataContext.Source as INotifyPropertyChanged;
-// if (notifyPropertyChanged != null)
-// {
-// notifyPropertyChanged.PropertyChanged -= HandleNotifyPropertyChanged;
-// notifyPropertyChanged.PropertyChanged += HandleNotifyPropertyChanged;
-// }
-// }
-// }
-// }
-// }
-// }
}
private void ConfigureToolbarItems()
@@ -804,16 +737,75 @@ public void UpdateSource()
public void ReloadData()
{
-// if (TableView != null)
-// {
- // UpdateSource();
+ if (Theme != null)
+ {
+ var nav = ParentViewController as UINavigationController;
+ if (nav != null)
+ {
+ nav.NavigationBar.Opaque = false;
+
+ if (Theme.BarStyle.HasValue)
+ {
+ nav.NavigationBar.BarStyle = Theme.BarStyle.Value;
+ }
+
+ nav.NavigationBar.Translucent = Theme.BarTranslucent;
+ nav.NavigationBar.TintColor = Theme.BarTintColor;
+
+ nav.Toolbar.Translucent = Theme.BarTranslucent;
+ nav.Toolbar.TintColor = Theme.BarTintColor;
+ }
+
+ var separatorColor = Theme.SeparatorColor;
+ if (separatorColor != null)
+ TableView.SeparatorColor = separatorColor;
+
+ var separatorStyle = Theme.SeparatorStyle;
+ if (separatorStyle.HasValue)
+ TableView.SeparatorStyle = separatorStyle.Value;
+ }
+
+ ConfigureBackgroundImage();
+
if (TableView != null)
TableView.ReloadData();
-// }
_Dirty = false;
}
+ public void ResetTheme(Theme newTheme)
+ {
+ this.Theme.MergeTheme(newTheme);
+
+ var source = TableView.Source as BaseDialogViewSource;
+
+ foreach(var cell in TableView.VisibleCells)
+ {
+ var listCell = cell as ComposableViewListCell;
+ if (listCell != null)
+ {
+ listCell.Theme.MergeTheme(newTheme);
+ }
+ }
+
+ foreach (var section in source.Sections.Values)
+ {
+ foreach (var viewList in section.Views.Values)
+ {
+ foreach (var view in viewList)
+ {
+ var themeable = view as IThemeable;
+ if (themeable != null)
+ {
+ themeable.Theme.MergeTheme(Theme);
+ }
+ }
+ }
+ }
+
+ ReloadData();
+ }
+
public void Flip()
{
var oldTB = TableView;
View
@@ -6,8 +6,7 @@ public class Application : MonoMobileApplication
{
public new static void Main(string[] args)
{
- Run("Sample", typeof(MovieListView), args);
- // Run("AppDelegate", args);
+ Run("Sample", typeof(ThemeSampleView), args);
}
}
}
@@ -38,12 +38,18 @@ public class DenimTheme: Theme
{
public DenimTheme()
{
- CellBackgroundColor = UIColor.ScrollViewTexturedBackgroundColor;
+ CellBackgroundColor = UIColor.FromWhiteAlpha(1.0f, 0.2f);
+
TextColor = UIColor.White;
TextShadowColor = UIColor.Black;
TextShadowOffset = new SizeF(0, 1);
DetailTextColor = UIColor.LightTextColor;
+ BarTintColor = UIColor.FromRGB(50, 100, 200);
+ BarStyle = UIBarStyle.Default;
+
+ BackgroundColor = UIColor.ScrollViewTexturedBackgroundColor;
+
Name = "Denim";
}
}
@@ -20,7 +20,7 @@ public class ThemeSampleViewModel : ViewModel
public ObservableCollection<Theme> Themes { get; set; }
- public int Selected { get; set; }
+ public Theme Selected { get; set; }
public ThemeSampleViewModel()
{
@@ -8,7 +8,8 @@ namespace Samples
[Theme(typeof(HoneyDoTheme))]
public class ListTest : View
{
- protected new ObservableCollection<MovieViewModel> DataContext
+ [List]
+ public new ObservableCollection<MovieViewModel> DataContext
{
get { return (ObservableCollection<MovieViewModel>)GetDataContext(); }
set { SetDataContext(value); }
@@ -31,8 +32,7 @@ public void Add()
var dataModel = new MovieDataModel();
dataModel.Load(20);
Console.WriteLine("Data Loaded " + DateTime.Now);
- DataContext = dataModel.Movies;
-
+ DataContext = dataModel.Movies;
}
[ToolbarButton]
@@ -9,15 +9,22 @@ namespace Samples
[Preserve(AllMembers = true)]
public class ThemeSampleView: View
{
- public Theme Selected { get; set; }
-
- [List(SelectionAction = SelectionAction.Multiselection, SelectedItemMemberName = "Selected")]
+ private Theme Selected;
+
+ [List(SelectionAction = SelectionAction.Selection, SelectedItemMemberName = "Selected")]
public ObservableCollection<Theme> Themes { get; set; }
public ThemeSampleView()
{
DataContext = new ThemeSampleViewModel();
}
+
+ [Section]
+ [Button]
+ public void SetSelectedTheme()
+ {
+ Application.CurrentDialogViewController.ResetTheme(Selected);
+ }
}
}

0 comments on commit de049f6

Please sign in to comment.