}
/// <summary>
- /// Gets or sets background image Style.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public ImageViewStyle Background
- {
- get;
- set;
- }
-
- /// <summary>
- /// Gets or sets text Style.
+ /// Gets or sets toast show duration time.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public TextLabelStyle Text
+ public uint? Duration
{
get;
set;
}
/// <summary>
- /// Gets or sets toast show duration time.
+ /// Text's Style.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public uint? Duration
- {
- get;
- set;
- }
+ public TextLabelStyle Text { get; set; }
/// <summary>
/// Style's clone function.
ToastStyle toastStyle = bindableObject as ToastStyle;
if (toastStyle != null)
{
- if (toastStyle.Background!= null)
- {
- Background.CopyFrom(toastStyle.Background);
- }
-
- if (toastStyle.Text!= null)
+ if (null != toastStyle.Text)
{
Text.CopyFrom(toastStyle.Text);
}
private void InitSubStyle()
{
- if (Background== null)
+ Text = new TextLabelStyle()
{
- Background= new ImageViewStyle();
- }
-
- if (Text== null)
- {
- Text= new TextLabelStyle();
- }
+ PositionUsesPivotPoint = true,
+ ParentOrigin = Tizen.NUI.ParentOrigin.Center,
+ PivotPoint = Tizen.NUI.PivotPoint.Center,
+ WidthResizePolicy = ResizePolicyType.FillToParent,
+ HeightResizePolicy = ResizePolicyType.FillToParent,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ TextColor = Color.White
+ };
}
}
}
if (newValue != null)
{
instance.strText = (string)(newValue);
- instance.textLabel.Text = instance.strText;
- instance.UpdateText();
+ instance.Style.Text.Text = instance.strText;
}
},
defaultValueCreator: (bindable) =>
}
private Window window = null;
- protected TextLabel[] textLabels = null;
-
- /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected TextLabel textLabel = null;
-
+ protected TextLabel[] textLabels = null;
+ private TextLabel textLabel = null;
private string strText = null;
- private NPatchVisual toastBackground = null;
private Timer timer = null;
- private string[] textArray = null;
-
- private readonly int maxTextAreaWidth = 808;
- private readonly int textPaddingLeft = 96;
- private readonly int textPaddingTop = 38;
private readonly uint duration = 3000;
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
/// <since_tizen> 6 </since_tizen>
public string[] TextArray
{
- get
- {
- return textArray;
- }
- set
- {
- if (null != value)
- {
- textArray = value;
- string message = "";
- foreach (string text in textArray)
- {
- message += text + "\n";
- }
- Message = message;
- }
- }
+ get;
+ set;
}
/// <summary>
window.Add(this);
this.Position.X = (window.Size.Width - this.Size.Width) / 2;
this.Position.Y = (window.Size.Height - this.Size.Height) / 2;
+ timer.Start();
}
/// <summary>
}
set
{
- if (null != value)
+ if (null != value && null != Style.Text)
{
- //CreateTextAttributes();
Style.Text.Padding.CopyFrom(value);
-
- //if (null == textPadding)
- //{
- // textPadding = new Extents((ushort start, ushort end, ushort top, ushort bottom) =>
- // {
- // toastAttributes.TextAttributes.Padding.Start = start;
- // toastAttributes.TextAttributes.Padding.End = end;
- // toastAttributes.TextAttributes.Padding.Top = top;
- // toastAttributes.TextAttributes.Padding.Bottom = bottom;
- // RelayoutRequest();
- // }, value.Start, value.End, value.Top, value.Bottom);
- //}
- //else
- //{
- // textPadding.CopyFrom(value);
- //}
-
- //RelayoutRequest();
}
}
}
}
}
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void ApplyStyle(ViewStyle viewStyle)
+ {
+ base.ApplyStyle(viewStyle);
+
+ ToastStyle toastStyle = viewStyle as ToastStyle;
+
+ if (null != toastStyle)
+ {
+ if (null == textLabel)
+ {
+ textLabel = new TextLabel();
+ this.Add(textLabel);
+ }
+ textLabel.ApplyStyle(toastStyle.Text);
+ }
+ }
+
/// <summary>
/// Dispose ToastPopup.
/// </summary>
base.Dispose(type);
}
- /// <summary>
- /// Relayout control's elements
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- private void UpdateText()
- {
- if (window == null)
- {
- //return;
- }
-
- int _textPaddingLeft = Style.Text?.Padding.Start ?? textPaddingLeft;
- int _textPaddingRight = Style.Text?.Padding.End ?? _textPaddingLeft;
- int _textPaddingTop = Style.Text?.Padding.Top ?? textPaddingTop;
- int _textPaddingBottom = Style.Text?.Padding.Bottom ?? _textPaddingTop;
-
- int _textAreaWidth = (int)Size.Width - _textPaddingLeft - _textPaddingRight;
- int _textAreaHeight = (int)Size.Height - _textPaddingTop - _textPaddingBottom;
- _textAreaWidth = _textAreaWidth > maxTextAreaWidth ? maxTextAreaWidth : _textAreaWidth;
- if (textLabel != null)
- {
- textLabel.Position = new Position(_textPaddingLeft, _textPaddingTop);
- textLabel.Size = new Size(_textAreaWidth, _textAreaHeight);
- if (LayoutDirection == ViewLayoutDirectionType.RTL)
- {
- textLabel.ParentOrigin = Tizen.NUI.ParentOrigin.TopRight;
- textLabel.PivotPoint = Tizen.NUI.PivotPoint.TopRight;
- textLabel.PositionUsesPivotPoint = true;
- }
- }
- }
-
/// <summary>
/// Get Toast attribues.
/// </summary>
private void Initialize()
{
- toastBackground = new NPatchVisual();
- if (toastBackground == null)
- {
- throw new Exception("Toast background is null.");
- }
- SetToastBackground();
-
- textLabel = new TextLabel();
if (null == textLabel)
{
- throw new Exception("Toast textLabel is null.");
+ textLabel = new TextLabel();
+ this.Add(textLabel);
}
- textLabel.TextColor = Color.White;
- this.Add(textLabel);
this.VisibilityChanged += OnVisibilityChanged;
timer = new Timer(Style.Duration ?? duration);
timer.Tick += OnTick;
- timer.Start();
}
private bool OnTick(object sender, EventArgs e)
{
if (true == e.Visibility)
{
+ window?.Add(this);
timer.Start();
}
- }
-
- private void SetToastBackground()
- {
- if (null != Style?.Background?.ResourceUrl)
- {
- toastBackground.URL = Style.Background.ResourceUrl.All;
- }
- if (null != Style?.Background?.Border)
+ else
{
- toastBackground.Border = Style.Background.Border.All;
+ window?.Remove(this);
}
- this.Background = toastBackground.OutputVisualMap;
}
}
}