<Compile Include="GridViewRenderer.cs" />\r
<Compile Include="TizenExtension.cs" />\r
<Compile Include="Properties\AssemblyInfo.cs" />\r
+ <Compile Include="ToastImplementation.cs" />\r
</ItemGroup>\r
<ItemGroup>\r
<None Include="Tizen.Xamarin.Forms.Extension.Renderer.project.json" />\r
<_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>\r
<AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>\r
</PropertyGroup>\r
-</Project>\r
+</Project>
\ No newline at end of file
--- /dev/null
+using System;
+using Tizen.Xamarin.Forms.Extension.Renderer;
+using Xamarin.Forms;
+using EPopup = ElmSharp.Popup;
+using TForms = Xamarin.Forms.Platform.Tizen.Forms;
+
+[assembly: Dependency(typeof(ToastImplementation))]
+
+namespace Tizen.Xamarin.Forms.Extension.Renderer
+{
+ internal class ToastImplementation : IToast, IDisposable
+ {
+ static readonly string DefaultStyle = "toast";
+ static readonly string DefaultPart = "default";
+
+ int _duration = 3000;
+ string _text = string.Empty;
+ EPopup _control = null;
+ bool _isDisposed = false;
+
+ public int Duration
+ {
+ get
+ {
+ return _duration;
+ }
+ set
+ {
+ _duration = value;
+ UpdateDuration();
+ }
+ }
+
+ public string Text
+ {
+ get
+ {
+ return _text;
+ }
+ set
+ {
+ _text = value;
+ UpdateText();
+ }
+ }
+
+ public ToastImplementation()
+ {
+ _control = new EPopup(TForms.Context.MainWindow)
+ {
+ Orientation = ElmSharp.PopupOrientation.Bottom,
+ Style = DefaultStyle,
+ AllowEvents = true,
+ };
+
+ UpdateText();
+ UpdateDuration();
+ }
+
+ ~ToastImplementation()
+ {
+ Dispose(false);
+ }
+
+ public void Show()
+ {
+ _control.Show();
+ }
+
+ public void Dismiss()
+ {
+ _control.Dismiss();
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool isDisposing)
+ {
+ if (_isDisposed)
+ return;
+
+ if (isDisposing)
+ {
+ if (_control != null)
+ {
+ _control.Unrealize();
+ _control = null;
+ }
+ }
+
+ _isDisposed = true;
+ }
+
+ void UpdateDuration()
+ {
+ _control.Timeout = Duration / 1000.0;
+ }
+
+ void UpdateText()
+ {
+ _control.SetPartText(DefaultPart, Text);
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+namespace Tizen.Xamarin.Forms.Extension
+{
+ /// <summary>
+ /// This interface which defines the ability to display simple text is used internally.
+ /// </summary>
+ internal interface IToast
+ {
+ /// <summary>
+ /// Gets or sets the duration.
+ /// </summary>
+ int Duration { get; set; }
+
+ /// <summary>
+ /// Gets or sets the Text.
+ /// </summary>
+ string Text { get; set; }
+
+ /// <summary>
+ /// Show the view for the specified duration.
+ /// </summary>
+ void Show();
+
+ /// <summary>
+ /// Dismiss the specified view.
+ /// </summary>
+ void Dismiss();
+ }
+}
\ No newline at end of file
[assembly: AssemblyTrademark("")]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
-
-[assembly: InternalsVisibleTo("Tizen.Xamarin.Forms.Extension.Renderer")]
\ No newline at end of file
+[assembly: InternalsVisibleTo("Tizen.Xamarin.Forms.Extension.Renderer")]
<Compile Include="GridViewEventArgs.cs" />\r
<Compile Include="ILongTapGestureController.cs" />\r
<Compile Include="ItemsView.cs" />\r
+ <Compile Include="IToast.cs" />\r
<Compile Include="ListProxy.cs" />\r
<Compile Include="LongTapGestureRecognizer.cs" />\r
<Compile Include="LongTapUpdatedEventArgs.cs" />\r
<Compile Include="SelectedEventArgs.cs" />\r
<Compile Include="ReadOnlyListAdapter.cs" />\r
<Compile Include="TemplatedItemsList.cs" />\r
+ <Compile Include="Toast.cs" />\r
+ <Compile Include="ToastProxy.cs" />\r
</ItemGroup>\r
<ItemGroup>\r
<Reference Include="Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">\r
--- /dev/null
+namespace Tizen.Xamarin.Forms.Extension
+{
+ /// <summary>
+ /// The Toast class provides properties that show simple types of messages.
+ /// </summary>
+ /// <example>
+ /// <code>
+ /// Toast.DisplayText("Hello World", 3000)
+ /// </code>
+ /// </example>
+ public sealed class Toast
+ {
+ /// <summary>
+ /// It shows the simplest form of the message.
+ /// </summary>
+ /// <param name="text">The body text of the toast.</param>
+ /// <param name="duration">How long to display the text in milliseconds.</param>
+ public static void DisplayText(string text, int duration = 3000)
+ {
+ new ToastProxy
+ {
+ Text = text,
+ Duration = duration,
+ }.Show();
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+using System;
+using Xamarin.Forms;
+
+namespace Tizen.Xamarin.Forms.Extension
+{
+ /// <summary>
+ /// This Class is for internal use by toast.
+ /// </summary>
+ internal class ToastProxy : IToast
+ {
+ IToast _toastProxy = null;
+
+ public ToastProxy()
+ {
+ _toastProxy = DependencyService.Get<IToast>(DependencyFetchTarget.NewInstance);
+
+ if (_toastProxy == null)
+ throw new Exception("RealObject is null, Internal instance via DependecyService was not created.");
+ }
+
+ public int Duration
+ {
+ get
+ {
+ return _toastProxy.Duration;
+ }
+
+ set
+ {
+ _toastProxy.Duration = value;
+ }
+ }
+
+ public string Text
+ {
+ get
+ {
+ return _toastProxy.Text;
+ }
+
+ set
+ {
+ _toastProxy.Text = value;
+ }
+ }
+
+ public void Dismiss()
+ {
+ _toastProxy.Dismiss();
+ }
+
+ public void Show()
+ {
+ _toastProxy.Show();
+ }
+ }
+}
\ No newline at end of file