Esempio n. 1
0
        public override void ViewDidLoad()
        {
            Crashlytics.Instance.Log("Challenges_ChallengeDetailViewController_ViewDidLoad()");

            base.ViewDidLoad();

            Reset();
            SetupFonts();
            _messageService = new PlatformServices.SmsService();
            ImageService.Instance.LoadUrl(Challenge.Image).Into(ChallengeImage);
            ChallengeTextLbl.Text = Challenge.Name;
            TimeText.Text         = Challenge.NextEventCountDown;

            if (Challenge.TypeCode == "SHARE")
            {
                SubmitButton.SetBackgroundImage(UIImage.FromBundle("challenge-btn_share"), UIControlState.Normal);
            }
            else if (Challenge.TypeCode == "INVITE")
            {
                SubmitButton.SetBackgroundImage(UIImage.FromBundle("challenge-btn_itb"), UIControlState.Normal);
            }
            else if (new List <string> {
                "POSTERING", "COLLATERAL TRACKING", "FLYERING", "MANUAL"
            }.Contains(Challenge.TypeCode))                                                                                     //else if (Challenge.TypeCode == "COLLATERAL TRACKING" && Challenge.TypeCodeDisplayName == "Postering")
            {
                SubmitButton.SetBackgroundImage(UIImage.FromBundle("challenge-btn_photo"), UIControlState.Normal);
                SetupCollateral();
            }
            else if (Challenge.TypeCode == "FB ENGAGEMENT")
            {
                SubmitButton.SetBackgroundImage(UIImage.FromBundle("challenge-btn_fb"), UIControlState.Normal);
            }

            DetailCollectionView.TranslatesAutoresizingMaskIntoConstraints = false;
            DetailCollectionView.RemoveConstraint(DetailCollectionViewAspect);
            DetailCollectionView.AddConstraint(ChallengesConstraints.ChallengesConstantHeightConstraint(DetailCollectionView, 0f));

            NSString viewportScriptString = (NSString)"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=500'); meta.setAttribute('initial-scale', '1.0'); meta.setAttribute('maximum-scale', '1.0'); meta.setAttribute('minimum-scale', '1.0'); meta.setAttribute('user-scalable', 'no'); document.getElementsByTagName('head')[0].appendChild(meta);";

            WebView.Configuration.UserContentController.AddUserScript(new WKUserScript(source: viewportScriptString, injectionTime: WKUserScriptInjectionTime.AtDocumentEnd, isForMainFrameOnly: true));

            WebView.ScrollView.ScrollEnabled            = false;
            WebView.ScrollView.Bounces                  = false;
            WebView.AllowsBackForwardNavigationGestures = false;
            Platform.ClearBrowserCache();
        }