Ejemplo n.º 1
0
		public static void Setup()
		{
			var theme = new Theme();
			CurrentTheme = theme;
			Theme.CurrentTheme = theme;

            var backgroundImg = CreateBackgroundImage(Theme.CurrentTheme.PrimaryColor);
            var barTypes = new [] { typeof(MainNavigationController), typeof(ThemedNavigationController) };
            foreach (var bar in barTypes.Select(x => UINavigationBar.AppearanceWhenContainedIn(x)))
                SetApperance(bar, backgroundImg, Theme.CurrentTheme.PrimaryColor);

            var menuColor = UIColor.FromRGB(50, 50, 50);
            var menuImg = CreateBackgroundImage(menuColor);
            var menuApp = UINavigationBar.AppearanceWhenContainedIn(typeof(MenuNavigationController));
            SetApperance(menuApp, menuImg, menuColor);

            foreach (var buttonItem in barTypes.Select(x => UIBarButtonItem.AppearanceWhenContainedIn(x)))
            {
                buttonItem.SetBackButtonTitlePositionAdjustment(new UIOffset(0, -64), UIBarMetrics.LandscapePhone);
                buttonItem.SetBackButtonTitlePositionAdjustment(new UIOffset(0, -64), UIBarMetrics.Default);
            }

            UISegmentedControl.AppearanceWhenContainedIn(typeof(UIToolbar)).TintColor = Theme.CurrentTheme.PrimaryColor;

            UITableViewHeaderFooterView.Appearance.TintColor = UIColor.FromRGB(228, 228, 228);
            UILabel.AppearanceWhenContainedIn(typeof(UITableViewHeaderFooterView)).TextColor = UIColor.FromRGB(136, 136, 136);
            UILabel.AppearanceWhenContainedIn(typeof(UITableViewHeaderFooterView)).Font = UIFont.SystemFontOfSize(13f);

            UIToolbar.Appearance.BarTintColor = UIColor.FromRGB(245, 245, 245);

            UIBarButtonItem.AppearanceWhenContainedIn(typeof(UISearchBar)).SetTitleTextAttributes(new UITextAttributes {TextColor  = UIColor.White }, UIControlState.Normal);

            UIImageView.AppearanceWhenContainedIn(typeof(UITableViewCell), typeof(MainNavigationController)).TintColor = Theme.CurrentTheme.IconColor;

            EmptyListView.DefaultColor = Theme.CurrentTheme.PrimaryColor;
		}
Ejemplo n.º 2
0
        public static void Setup()
        {
            UIGraphics.BeginImageContext(new CoreGraphics.CGSize(1, 64f));
            Theme.PrimaryNavigationBarColor.SetFill();
            UIGraphics.RectFill(new CoreGraphics.CGRect(0, 0, 1, 64));
            var img = UIGraphics.GetImageFromCurrentImageContext();
            UIGraphics.EndImageContext();

            UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;

            var navBarContainers = new [] { typeof(MenuNavigationController), typeof(ThemedNavigationController), typeof(MainNavigationController) };
            foreach (var navbarAppearance in navBarContainers.Select(x => UINavigationBar.AppearanceWhenContainedIn(x)))
            {
                navbarAppearance.TintColor = Theme.PrimaryNavigationBarTextColor;
                navbarAppearance.BarTintColor = Theme.PrimaryNavigationBarColor;
                navbarAppearance.BackgroundColor = Theme.PrimaryNavigationBarColor;
                navbarAppearance.SetTitleTextAttributes(new UITextAttributes { TextColor = Theme.PrimaryNavigationBarTextColor, Font = UIFont.SystemFontOfSize(18f) });
                navbarAppearance.SetBackgroundImage(img, UIBarPosition.Any, UIBarMetrics.Default);
                navbarAppearance.BackIndicatorImage = Images.BackButton;
                navbarAppearance.BackIndicatorTransitionMaskImage = Images.BackButton;
            }

            UISegmentedControl.Appearance.TintColor = UIColor.FromRGB(110, 110, 117);
            UISegmentedControl.AppearanceWhenContainedIn(typeof(UINavigationBar)).TintColor = UIColor.White;

            UISwitch.Appearance.OnTintColor = UIColor.FromRGB(0x41, 0x83, 0xc4);

            // Composer Input Accessory Buttons
            UIButton.AppearanceWhenContainedIn(typeof(UIScrollView)).TintColor = Theme.PrimaryNavigationBarColor;

            //UITableViewHeaderFooterView.Appearance.TintColor = UIColor.FromRGB(228, 228, 228);
            var headerFooterContainers = new [] { typeof(UITableViewHeaderFooterView) };
            foreach (var navbarAppearance in headerFooterContainers)
            {
                UILabel.AppearanceWhenContainedIn(navbarAppearance).TextColor = UIColor.FromRGB(110, 110, 117);
                UILabel.AppearanceWhenContainedIn(navbarAppearance).Font = UIFont.SystemFontOfSize(14f);
            }

            StringElement.DefaultTintColor = Theme.PrimaryNavigationBarColor;

            UIToolbar.Appearance.BarTintColor = UIColor.FromRGB(245, 245, 245);

            UIBarButtonItem.AppearanceWhenContainedIn(typeof(UISearchBar)).SetTitleTextAttributes(new UITextAttributes {TextColor = UIColor.White}, UIControlState.Normal);
        }
Ejemplo n.º 3
0
//        public static readonly IDictionary<string, ThemeColors> Themes = new Dictionary<string, ThemeColors>(StringComparer.OrdinalIgnoreCase)
//        {
//            {"blue", new ThemeColors(UIColor.FromRGB(0x1D, 0x62, 0xF0), UIColor.FromRGB(0x1A, 0xD6, 0xFD))},
//            {"red", new ThemeColors(UIColor.FromRGB(231, 76, 60), UIColor.FromRGB(192, 57, 43))},
//        };
// 
        public static void SetPrimary(string colorName)
        {
            colorName = colorName ?? string.Empty;
            var primaryColor = Default.Primary;
            var secondaryColor = Default.Secondary;
            var iconColor = Default.Icon;

//            if (Themes.ContainsKey(colorName))
//            {
//                var a = Themes[colorName];
//                primaryColor = a.Primary;
//                secondaryColor = a.Secondary;
//            }

            PrimaryNavigationBarColor = primaryColor;
            MainTitleColor = secondaryColor;
            PrimaryNavigationBarTextColor = UIColor.White;

            var navBarBackground = CreateBackgroundImage(primaryColor);
            var navBarContainers = new [] { typeof(ThemedNavigationController), typeof(MainNavigationController) };
            foreach (var navbarAppearance in navBarContainers.Select(x => UINavigationBar.AppearanceWhenContainedIn(x)))
            {
                navbarAppearance.TintColor = UIColor.White;
                navbarAppearance.BarTintColor = primaryColor;
                navbarAppearance.BackgroundColor = primaryColor;
                navbarAppearance.SetTitleTextAttributes(new UITextAttributes { TextColor = UIColor.White, Font = UIFont.SystemFontOfSize(18f) });
                navbarAppearance.SetBackgroundImage(navBarBackground, UIBarPosition.Any, UIBarMetrics.Default);
                navbarAppearance.BackIndicatorImage = Images.BackButton;
                navbarAppearance.BackIndicatorTransitionMaskImage = Images.BackButton;
            }

            UISwitch.Appearance.OnTintColor = secondaryColor;
            UIImageView.AppearanceWhenContainedIn(typeof(UITableViewCell), typeof(MainNavigationController)).TintColor = iconColor;
            LoadingIndicatorView.DefaultColor = primaryColor;
            EmptyListView.DefaultColor = primaryColor;
        }