예제 #1
0
        public static UIViewController HtmlSelected(ApiNode apiNode)
        {
            var vc = new UIViewController();

            var webView = new UIWebView(UIScreen.MainScreen.Bounds)
            {
                BackgroundColor = UIColor.White,
                ScalesPageToFit = false,
                AutoresizingMask = UIViewAutoresizing.All
            };

            var html = apiNode["content"];

            if (apiNode["contentNode"] != null)
            {
                html = apiNode[apiNode["contentNode"]];
            }

            if (html != null && !html.Contains("<html"))
            {
                html = String.Format("<html><head><link href=\"main-style.css\" rel=\"stylesheet\" type=\"text/css\" /></head><body><h1>{0}</h1>{1}</body><html>", apiNode.Title, html);
            }

            if (html != null)
                webView.LoadHtmlString(html, new NSUrl("HtmlContent/", true));

            vc.NavigationItem.Title = apiNode.Title;

            vc.View.AutosizesSubviews = true;
            vc.View.AddSubview(webView);

            return vc;
        }
예제 #2
0
        public static UIViewController AudioSelected(ApiNode apiNode)
        {
            var url = apiNode["videoSrc1"];

            if (apiNode["contentNode"] != null)
            {
                url = apiNode[apiNode["contentNode"]];
            }

            //var videoController = new UIVideoController(url);

            //videoController.NavigationItem.Title = apiNode.Title;

            //return videoController;

            var vc = new UIViewController();

            var webView = new UIWebView(UIScreen.MainScreen.Bounds)
            {
                BackgroundColor = UIColor.White,
                ScalesPageToFit = true,
                AutoresizingMask = UIViewAutoresizing.All
            };

            var request = new NSUrlRequest(new NSUrl(url), NSUrlRequestCachePolicy.UseProtocolCachePolicy, 60);

            webView.LoadRequest(request);

            vc.NavigationItem.Title = apiNode.Title;

            vc.View.AutosizesSubviews = true;
            vc.View.AddSubview(webView);

            return vc;
        }
예제 #3
0
 public CustomRootElement(string title, JsonObject data)
     : base(title)
 {
     this.data = data;
     apiNode = DrupalApiParser.FromJsonObject(data);
     //apiNode = ApiNode.
 }
예제 #4
0
        private Element CreateElement(ApiNode element, ApiNode parentNode)
        {
            string childType = parentNode["childType"];
            string childAction = parentNode["childAction"];

            // if there is an item call for the api, build the url here
            if (parentNode.ApiItemUrl != null)
                element.ApiUrl = String.Format(parentNode.ApiItemUrl, element.Id);

            // copy parent values to the children
            if (parentNode["contentNode"] != null)
                element["contentNode"] = parentNode["contentNode"];

            if (parentNode["bannerImgUrl"] != null)
                element["bannerImgUrl"] = parentNode["bannerImgUrl"];

            Func<ApiNode, UIViewController> selectedAction = null;

            if (element.Title.Contains("&#039;"))
                element.Title = element.Title.Replace("&#039;","'");

            switch(childAction)
            {
                case "video":
                    selectedAction = ApiVideoElement.VideoSelected;
                    break;
                case "audio":
                    selectedAction = ApiVideoElement.AudioSelected;
                    break;
                default:
                    selectedAction = ApiVideoElement.HtmlSelected;
                    break;
            }

            switch (childType)
            {
                case "detailedImage":

                    return new DetailedImageElement(element, selectedAction);

                case "htmlContent":

                    // try to combine date and reference for a description
                    if(element.Description == null)
                        element.Description = String.Format("{0}\n{1}", element["date"], element["reference"]);

                    if(element["bannerImgUrl"] != null)
                        return new ApiBannerElement(element, selectedAction);

                    return new ApiDetailElement(element, selectedAction);

                default:
                    var strElement = new MultilineElement(element.Title, element["description"]);

                    //strElement.
                    return strElement;
            }
        }
예제 #5
0
        public DetailedImageElement(ApiNode apiNode, Func<ApiNode, UIViewController> createOnSelected)
            : base(apiNode.Title)
        {
            detailImageData = new DetailImageData()
            {
                ImageUri = new Uri(apiNode["thumbnailSml"]),
                Title = apiNode.Title,
                SubTitle = apiNode.Description
            };

            this.apiNode = apiNode;
            this.createOnSelected = createOnSelected;
        }
예제 #6
0
        public static ApiNode FromJsonObject(JsonObject json)
        {
            var apiNode = new ApiNode()
            {
                Id = GetString(json, "id")
            };

            foreach (var key in json.Keys)
            {
                apiNode[key] = GetString(json, key);
            }

            return apiNode;
        }
예제 #7
0
 public ApiBannerElement(ApiNode apiNode, Func<ApiNode, UIViewController> createOnSelected)
     : base(apiNode, createOnSelected)
 {
 }
예제 #8
0
 public ApiDetailElement(ApiNode apiNode, Func<ApiNode, UIViewController> createOnSelected)
     : base(apiNode.Title)
 {
     this.title = apiNode.Title;
     this.detail = apiNode.Description;
     this.apiNode = apiNode;
     this.createOnSelected = createOnSelected;
 }