changeset 2425:60a459df758d

iOS: Account for the special area at the bottom of certain devies. We may need to do this conditionally based on the device type, but for now just moving up the bottom of the window view by 24 points to account. Also fix a few deprecations and other code warnings.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 04 Apr 2021 18:22:27 +0000
parents 6b302a8c856f
children 6220f0580088
files ios/dw.m
diffstat 1 files changed, 22 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/ios/dw.m	Sun Apr 04 15:40:25 2021 +0000
+++ b/ios/dw.m	Sun Apr 04 18:22:27 2021 +0000
@@ -1319,8 +1319,12 @@
     if(![object isMemberOfClass:[DWView class]])
         [object setHidden:YES];
     /* Adjust the frame to account for the status bar */
-    NSInteger sbheight = [UIApplication sharedApplication].statusBarFrame.size.height;
+    NSInteger sbheight = [[[window windowScene] statusBarManager] statusBarFrame].size.height;
     frame.size.height -= sbheight;
+    /* Account for the special area on iPhone X and iPad Pro
+     * https://blog.maxrudberg.com/post/165590234593/ui-design-for-iphone-x-bottom-elements
+     */
+    frame.size.height -= 24;
     frame.origin.y += sbheight;
     [view setFrame:frame];
     [view windowResized:frame.size];
@@ -7789,29 +7793,31 @@
                 [label setLineBreakMode:NSLineBreakByTruncatingTail];
         }
     }
-#if 0 /* TODO: See if we can change alignment... */
-    else if([object isMemberOfClass:[UITextView class]])
-    {
-        UITextView *tv = handle;
-        [tv setAlignment:(style & mask)];
-    }
-#endif
+    else if([object isMemberOfClass:[DWMLE class]])
+    {
+        DWMLE *mle = handle;
+        [mle setTextAlignment:(style & mask)];
+    }
     else if([object isMemberOfClass:[DWMenuItem class]])
     {
+        DWMenuItem *menuitem = object;
+
         if(mask & (DW_MIS_CHECKED | DW_MIS_UNCHECKED))
         {
             if(style & DW_MIS_CHECKED)
-                [object setState:UIMenuElementStateOn];
+                [menuitem setState:UIMenuElementStateOn];
             else if(style & DW_MIS_UNCHECKED)
-                [object setState:UIMenuElementStateOff];
-        }
+                [menuitem setState:UIMenuElementStateOff];
+        }
+#if 0 /* Disabled menu items not available on iOS currently */
         if(mask & (DW_MIS_ENABLED | DW_MIS_DISABLED))
         {
             if(style & DW_MIS_ENABLED)
-                [object setEnabled:YES];
+                [menuitem setEnabled:YES];
             else if(style & DW_MIS_DISABLED)
-                [object setEnabled:NO];
-        }
+                [menuitem setEnabled:NO];
+        }
+#endif
     }
     DW_FUNCTION_RETURN_NOTHING;
 }
@@ -8127,7 +8133,8 @@
         UIControl *control = object;
         NSString *nsstr = [control text];
 
-        retval = strdup([ nsstr UTF8String ]);
+        if(nsstr && [nsstr length] > 0)
+            retval = strdup([ nsstr UTF8String ]);
     }
     DW_FUNCTION_RETURN_THIS(retval);
 }