private bool ResolveWidgetProperty(SwrveWidget widget, Dictionary <SwrveWidget, string> cacheDest, string property, Dictionary <string, string> properties)
        {
            if (!string.IsNullOrEmpty(property))
            {
                // Need to render dynamic text
                string personalizedText = SwrveTextTemplating.Apply(property, properties);
                if (string.IsNullOrEmpty(personalizedText))
                {
                    UnityEngine.Debug.Log("Text template could not be resolved: " + property + " in given properties.");
                    return(false);
                }
                else if (SwrveTextTemplating.HasPatternMatch(personalizedText))
                {
                    UnityEngine.Debug.Log("Not showing campaign with personalization outside of Message Center / without personalization info provided.");
                    return(false);
                }
                cacheDest[widget] = personalizedText;
            }

            return(true);
        }
Example #2
0
        public SwrveMessagePersonalizedWidgetView(SwrveWidget widget, string resolvedText, SwrveInAppMessageConfig inAppConfig)
        {
            this.widget            = widget;
            content                = new GUIContent(resolvedText);
            style                  = new GUIStyle();
            style.alignment        = TextAnchor.MiddleCenter;
            style.normal.textColor = inAppConfig.PersonalizedTextForegroundColor;
            style.font             = inAppConfig.PersonalizedTextFont;
            backgroundColor        = inAppConfig.PersonalizedTextBackgroundColor;
            clickTintColor         = inAppConfig.ButtonClickTintColor;

            if (widget.Texture != null)
            {
                FitTextSizeToImage(widget.Texture.width, widget.Texture.height);
            }

            isButton = (widget is SwrveButton);
            if (isButton)
            {
                button = (SwrveButton)widget;
            }
        }