[NUI] Fix timePicker ampm internal logic
authorWoochanlee <wc0917.lee@samsung.com>
Wed, 23 Feb 2022 12:25:57 +0000 (21:25 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Fri, 4 Mar 2022 05:31:52 +0000 (14:31 +0900)
src/Tizen.NUI.Components/Controls/Picker.cs
src/Tizen.NUI.Components/Controls/TimePicker.cs

index 70eaf90..1bcf1a0 100755 (executable)
@@ -520,7 +520,11 @@ namespace Tizen.NUI.Components
 
             if (loopEnabled) startY = ((dummyItemsForLoop + startItemIdx) * itemHeight) + startScrollOffset;
             // + 2 for non loop picker center align
-            else startY = ((2 + startItemIdx) * itemHeight) + startScrollOffset;
+            else
+            {
+                startY = ((2 + startItemIdx) * itemHeight) + startScrollOffset;
+                currentValue = currentValue - minValue + 2;
+            }
             pickerScroller.ScrollTo(startY, false);
         }
 
index 67f60d6..101961f 100755 (executable)
@@ -197,7 +197,8 @@ namespace Tizen.NUI.Components
                     else 
                     {
                         isAm = true;
-                        hourPicker.CurrentValue = currentTime.Hour;
+                        if (currentTime.Hour == 0) hourPicker.CurrentValue = 12;
+                        else hourPicker.CurrentValue = currentTime.Hour;
                         ampmPicker.CurrentValue = 1;
                     }
                 }
@@ -288,14 +289,16 @@ namespace Tizen.NUI.Components
             ampmPicker.ValueChanged += OnAmpmValueChanged;
 
             currentTime = DateTime.Now;
-            Console.WriteLine(" Time " + currentTime.Hour + " " + currentTime.Minute);
             if (currentTime.Hour > 12)
             {
                 ampmPicker.CurrentValue = 2;
                 hourPicker.CurrentValue = currentTime.Hour - 12;
             }
             else
+            {
+                ampmPicker.CurrentValue = 1;
                 hourPicker.CurrentValue = currentTime.Hour;
+            }
 
             minutePicker.CurrentValue = currentTime.Minute;
 
@@ -362,12 +365,12 @@ namespace Tizen.NUI.Components
             {
                 if (isAm) 
                 {
-                    if (e.Value == 12) ChangeTime(12, 0, true);
+                    if (e.Value == 12) ChangeTime(0, 0, true);
                     else ChangeTime(e.Value, 0, true);
                 }
                 else 
                 {
-                    if (e.Value == 12) ChangeTime(0, 0, true);
+                    if (e.Value == 12) ChangeTime(12, 0, true);
                     else ChangeTime(e.Value + 12, 0, true);
                 }
             }
@@ -392,20 +395,16 @@ namespace Tizen.NUI.Components
 
             if (e.Value == 1)
             { //AM
-                if (currentTime.Hour > 12 || currentTime.Hour == 0)
-                { 
-                    if (currentTime.Hour == 0) ChangeTime(12, 0, true);
-                    else ChangeTime(currentTime.Hour - 12, 0, true);
-                }
+                if (currentTime.Hour == 12) ChangeTime(0, 0, true);
+                else ChangeTime(currentTime.Hour - 12, 0, true);
+
                 isAm = true;
             }
             else 
             { //PM
-                if (currentTime.Hour > 0 && currentTime.Hour <= 12)
-                {
-                     if (currentTime.Hour == 12) ChangeTime(0, 0, true);
-                     else ChangeTime(currentTime.Hour + 12, 0, true);
-                }
+                if (currentTime.Hour == 0) ChangeTime(12, 0, true);
+                else ChangeTime(currentTime.Hour + 12, 0, true);
+
                 isAm = false;
             }