Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c76d20a

Browse files
Adjusted to be compatible with API 12.2
1 parent c0de8e5 commit c76d20a

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

shell/platform/darwin/ios/framework/Source/FlutterViewController.mm

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ @interface FlutterViewController () <FlutterBinaryMessenger>
3232
@property(nonatomic, readwrite, getter=isDisplayingFlutterUI) BOOL displayingFlutterUI;
3333
@end
3434

35+
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 130000
36+
typedef enum UIAccessibilityContrast : NSInteger {
37+
UIAccessibilityContrastUnspecified = 0,
38+
UIAccessibilityContrastNormal = 1,
39+
UIAccessibilityContrastHigh = 2
40+
} UIAccessibilityContrast;
41+
42+
@interface UITraitCollection(AccessibilityContrastApi)
43+
- (UIAccessibilityContrast)accessibilityContrast;
44+
@end
45+
#endif
46+
3547
@implementation FlutterViewController {
3648
std::unique_ptr<fml::WeakPtrFactory<FlutterViewController>> _weakFactory;
3749
fml::scoped_nsobject<FlutterEngine> _engine;
@@ -987,7 +999,6 @@ - (NSString*)brightnessMode {
987999
}
9881000

9891001
- (NSString*)contrastMode {
990-
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
9911002
if (@available(iOS 13, *)) {
9921003
UIAccessibilityContrast contrast = self.traitCollection.accessibilityContrast;
9931004

@@ -999,9 +1010,6 @@ - (NSString*)contrastMode {
9991010
} else {
10001011
return @"normal";
10011012
}
1002-
#else
1003-
return @"normal";
1004-
#endif
10051013
}
10061014

10071015
#pragma mark - Status Bar touch event handling

shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.m

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@
1515
@interface FlutterViewControllerTest : XCTestCase
1616
@end
1717

18+
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 130000
19+
typedef enum UIAccessibilityContrast : NSInteger {
20+
UIAccessibilityContrastUnspecified = 0,
21+
UIAccessibilityContrastNormal = 1,
22+
UIAccessibilityContrastHigh = 2
23+
} UIAccessibilityContrast;
24+
25+
@interface UITraitCollection(AccessibilityContrastApi)
26+
- (UIAccessibilityContrast)accessibilityContrast;
27+
@end
28+
#endif
29+
1830
@implementation FlutterViewControllerTest
1931

2032
- (void)testBinaryMessenger {
@@ -80,6 +92,10 @@ - (void)testItReportsPlatformBrightnessWhenViewWillAppear {
8092
}
8193

8294
- (void)testItReportsDarkPlatformBrightnessWhenTraitCollectionRequestsIt {
95+
if (!@available(iOS 13, *)) {
96+
return;
97+
}
98+
8399
// Setup test.
84100
id engine = OCMClassMock([FlutterEngine class]);
85101

@@ -121,7 +137,6 @@ - (UITraitCollection*)setupFakeUserInterfaceStyle:(UIUserInterfaceStyle)style {
121137

122138
#pragma mark - Platform Contrast
123139

124-
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
125140
- (void)testItReportsNormalPlatformContrastByDefault {
126141
if (!@available(iOS 13, *)) {
127142
return;
@@ -221,6 +236,5 @@ - (UITraitCollection*)setupFakeTraitCollectionWithContrast:(UIAccessibilityContr
221236
OCMStub([mockTraitCollection accessibilityContrast]).andReturn(UIAccessibilityContrastHigh);
222237
return mockTraitCollection;
223238
}
224-
#endif
225239

226240
@end

0 commit comments

Comments
 (0)