[Page] Change alert dialog message text wrap type
authorPiotr Czaja <p.czaja@samsung.com>
Tue, 3 Jan 2017 13:32:08 +0000 (14:32 +0100)
committerKangho Hur <kangho.hur@samsung.com>
Mon, 24 Apr 2017 04:36:53 +0000 (13:36 +0900)
Note:
Alert dialog message text was not wrapped, so long strings did not
fit on the screen.

Change-Id: I820a262888969ae97e45e0b4a57d683b44a8322d
Signed-off-by: Piotr Czaja <p.czaja@samsung.com>
Xamarin.Forms.Platform.Tizen/FormsApplication.cs [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index fe8c4fd..806f6a8
@@ -165,17 +165,33 @@ namespace Xamarin.Forms.Platform.Tizen
                        MessagingCenter.Subscribe<Page, AlertArguments>(this, Page.AlertSignalName, delegate (Page sender, AlertArguments arguments)
                                {
                                        Native.Dialog alert = new Native.Dialog(Forms.Context.MainWindow);
-
                                        alert.Title = arguments.Title;
                                        var label = new ELabel(alert)
                                        {
                                                Text = "<span font_size=30 color=#000000>" + arguments.Message + "<\\span>",
                                        };
+
                                        label.Show();
 
                                        var box = new Box(alert);
-                                       box.PackEnd(label);
                                        box.Show();
+
+                                       bool labelAdded = false;
+                                       box.Resized += (s, e) =>
+                                       {
+                                               label.LineWrapType = WrapType.Word;
+                                               //set 2% padding for alert text message width
+                                               label.LineWrapWidth = (int)Math.Round(box.Geometry.Width * 0.98);
+                                               if (!labelAdded)
+                                               {
+                                                       /*Adding label to the box (box.PackEnd(label)) has been placed in box.Resized()
+                                                       event due to get better performance. For some reason (probably EFL bug) when
+                                                       it's placed outside of it, box.Resized() event is called far too many times.*/
+                                                       box.PackEnd(label);
+                                                       labelAdded = true;
+                                               }
+                                       };
+
                                        alert.Content = box;
 
                                        Native.Button cancel = new Native.Button(alert) { Text = arguments.Cancel };