Commit b54239ba authored by Ewann's avatar Ewann Committed by Chromium LUCI CQ

[iOS][Settings] Updates IsSmallDevice

This CL defines what we consider to be a small device.

Bug: 1152730, 922511
Change-Id: I9b7fad0b45c20f823cf1655483b5c8ccff3ccfcf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2600902Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Commit-Queue: Ewann Pellé <ewannpv@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840614}
parent 6ed4a2b6
...@@ -27,8 +27,6 @@ CGFloat CurrentScreenWidth(); ...@@ -27,8 +27,6 @@ CGFloat CurrentScreenWidth();
bool IsIPhoneX(); bool IsIPhoneX();
// Returns true if the device is considered as a small device. // Returns true if the device is considered as a small device.
// TODO(crbug.com/1152730): Define what is called a small device & update this
// method.
bool IsSmallDevice(); bool IsSmallDevice();
// Returns the approximate corner radius of the current device. // Returns the approximate corner radius of the current device.
......
...@@ -19,6 +19,15 @@ ...@@ -19,6 +19,15 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
namespace {
// The em-width value used to differentiate small and large devices.
// With Larger Text Off, Bold Text Off and the device orientation in portrait:
// iPhone 6s is considered as a small device, unlike iPhone 8 or iPhone 12 mini.
const CGFloat kSmallDeviceThreshold = 22.0;
} // namespace
bool IsIPadIdiom() { bool IsIPadIdiom() {
return ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET; return ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET;
} }
...@@ -39,7 +48,11 @@ bool IsIPhoneX() { ...@@ -39,7 +48,11 @@ bool IsIPhoneX() {
} }
bool IsSmallDevice() { bool IsSmallDevice() {
return CurrentScreenWidth() <= 375; CGSize mSize = [@"m" sizeWithAttributes:@{
NSFontAttributeName : [UIFont preferredFontForTextStyle:UIFontTextStyleBody]
}];
CGFloat emWidth = CurrentScreenWidth() / mSize.width;
return emWidth < kSmallDeviceThreshold;
} }
CGFloat DeviceCornerRadius() { CGFloat DeviceCornerRadius() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment