Example #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title =
                new UILabel(new CGRect(60, 0, NavigationController.Toolbar.Frame.Width,
                                       NavigationController.Toolbar.Frame.Height))
            {
                TextColor       = Style.Header.TextColor,
                BackgroundColor = UIColor.Clear
            };

            GoBackButton = new UIButton(new CGRect(0, 0, 60, NavigationController.Toolbar.Frame.Height))
            {
                TintColor = Style.Header.TextColor,
                Hidden    = true
            };

            GoBackButton.TouchDown += OnClickGoBack;
            GoBackButton.SetImage(UIImage.FromBundle("back").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIControlState.Normal);

            GalleryView = new UIView()
            {
                Hidden = true
            };

            ChoosePicture       = UIButton.FromType(UIButtonType.RoundedRect);
            ChoosePicture.Frame = new CGRect(0, 0, View.Frame.Width / 2, 40);

            ChoosePicture.TintColor       = Style.Header.TextColor;
            ChoosePicture.BackgroundColor = UIColor.LightGray;

            ChoosePicture.SetTitle(Translator.GetText("choose_picture"), UIControlState.Normal);

            ChoosePicture.TouchDown += OnClickChoosePicture;

            TakePicture       = UIButton.FromType(UIButtonType.RoundedRect);
            TakePicture.Frame = new CGRect(View.Frame.Width / 2, 0, View.Frame.Width / 2, 40);

            TakePicture.TintColor       = Style.Header.TextColor;
            TakePicture.BackgroundColor = UIColor.LightGray;

            TakePicture.SetTitle(Translator.GetText("take_picture"), UIControlState.Normal);

            TakePicture.TouchDown += OnClickTakePicture;

            GalleryView.AddSubviews(ChoosePicture, TakePicture);

            NavigationController.NavigationBar.AddSubviews(GoBackButton);

            NavigationController.NavigationBar.TintColor    = Style.Header.TextColor;
            NavigationController.NavigationBar.BarTintColor = Style.Header.BackgroundColor;

            NavigationController.NavigationBar.AddSubviews(Title);

            var scrollView = new UIScrollView(View.Frame)
            {
                ShowsHorizontalScrollIndicator = false,
                AutoresizingMask = UIViewAutoresizing.FlexibleHeight
            };

            WebView = new UIWebView
            {
                ScalesPageToFit = true
            };

            scrollView.AddSubviews(WebView, GalleryView);

            Add(scrollView);

            View.AddConstraints(
                scrollView.AtLeftOf(View),
                scrollView.AtTopOf(View),
                scrollView.WithSameWidth(View),
                scrollView.WithSameHeight(View),

                WebView.AtLeftOf(scrollView),
                WebView.AtTopOf(scrollView),
                WebView.WithSameWidth(scrollView),
                WebView.WithSameHeight(scrollView),

                GalleryView.AtLeftOf(scrollView),
                GalleryView.AtTopOf(scrollView),
                GalleryView.WithSameWidth(scrollView),
                GalleryView.WithSameHeight(scrollView),

                TakePicture.AtLeftOf(GalleryView),
                TakePicture.AtTopOf(GalleryView),

                ChoosePicture.AtRightOf(GalleryView),
                ChoosePicture.AtTopOf(GalleryView)
                );

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            scrollView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            MenuClickEvent.AddListener(this);

            var menuItem = MenuViewModel.MenuItems.First();

            OnMenuItemClick(menuItem.menu_title, menuItem.url, 0);

            _spinner = new Spinner(View);

            WebView.Delegate = new WebViewDelegate(_spinner, this);
        }