forked from google/GoogleSignIn-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGIDSignInButton.m
More file actions
647 lines (522 loc) · 20.7 KB
/
GIDSignInButton.m
File metadata and controls
647 lines (522 loc) · 20.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#import <TargetConditionals.h>
#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION
#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignInButton.h"
#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h"
#import "GoogleSignIn/Sources/GIDScopes.h"
#import "GoogleSignIn/Sources/GIDSignInInternalOptions.h"
#import "GoogleSignIn/Sources/GIDSignInStrings.h"
#import "GoogleSignIn/Sources/GIDSignIn_Private.h"
#import "GoogleSignIn/Sources/NSBundle+GID3PAdditions.h"
NS_ASSUME_NONNULL_BEGIN
#pragma mark - Constants
// Standard accessibility identifier.
static NSString *const kAccessibilityIdentifier = @"GIDSignInButton";
// The name of the font for button text.
static NSString *const kFontNameRobotoBold = @"Roboto-Bold";
// Button text font size.
static const CGFloat kFontSize = 14;
#pragma mark - Icon Constants
// The name of the image for the Google "G"
static NSString *const kGoogleImageName = @"google";
// Keys used for NSCoding.
static NSString *const kStyleKey = @"style";
static NSString *const kColorSchemeKey = @"color_scheme";
static NSString *const kButtonState = @"state";
#pragma mark - Sizing Constants
// The corner radius of the button
static const int kCornerRadius = 2;
// The standard height of the sign in button.
static const int kButtonHeight = 48;
// The width of the icon part of the button in points.
static const int kIconWidth = 40;
// Left and right text padding.
static const int kTextPadding = 14;
// The icon (UIImage)'s frame.
static const CGRect kIconFrame = { {9, 10}, {29, 30} };
#pragma mark - Appearance Constants
static const CGFloat kBorderWidth = 4;
static const CGFloat kHaloShadowAlpha = 12.0 / 100.0;
static const CGFloat kHaloShadowBlur = 2;
static const CGFloat kDropShadowAlpha = 24.0 / 100.0;
static const CGFloat kDropShadowBlur = 2;
static const CGFloat kDropShadowYOffset = 2;
static const CGFloat kDisabledIconAlpha = 40.0 / 100.0;
#pragma mark - Colors
// All colors in hex RGBA format (0xRRGGBBAA)
static const NSUInteger kColorGoogleBlue = 0x4285f4ff;
static const NSUInteger kColorGoogleDarkBlue = 0x3367d6ff;
static const NSUInteger kColorWhite = 0xffffffff;
static const NSUInteger kColorLightestGrey = 0x00000014;
static const NSUInteger kColorLightGrey = 0xeeeeeeff;
static const NSUInteger kColorDisabledGrey = 0x00000066;
static const NSUInteger kColorDarkestGrey = 0x00000089;
static NSUInteger kColors[12] = {
// |Background|, |Foreground|,
kColorGoogleBlue, kColorWhite, // Dark Google Normal
kColorLightestGrey, kColorDisabledGrey, // Dark Google Disabled
kColorGoogleDarkBlue, kColorWhite, // Dark Google Pressed
kColorWhite, kColorDarkestGrey, // Light Google Normal
kColorLightestGrey, kColorDisabledGrey, // Light Google Disabled
kColorLightGrey, kColorDarkestGrey, // Light Google Pressed
};
// The state of the button:
typedef NS_ENUM(NSUInteger, GIDSignInButtonState) {
kGIDSignInButtonStateNormal = 0,
kGIDSignInButtonStateDisabled = 1,
kGIDSignInButtonStatePressed = 2,
};
static NSUInteger const kNumGIDSignInButtonStates = 3;
// Used to lookup specific colors from the kColors table:
typedef NS_ENUM(NSUInteger, GIDSignInButtonStyleColor) {
kGIDSignInButtonStyleColorBackground = 0,
kGIDSignInButtonStyleColorForeground = 1,
};
static NSUInteger const kNumGIDSignInButtonStyleColors = 2;
// This method just pulls the correct value out of the kColors table and returns it as a UIColor.
static UIColor *colorForStyleState(GIDSignInButtonColorScheme style,
GIDSignInButtonState state,
GIDSignInButtonStyleColor color) {
NSUInteger stateWidth = kNumGIDSignInButtonStyleColors;
NSUInteger styleWidth = kNumGIDSignInButtonStates * stateWidth;
NSUInteger index = (style * styleWidth) + (state * stateWidth) + color;
NSUInteger colorValue = kColors[index];
return [UIColor colorWithRed:(CGFloat)(((colorValue & 0xff000000) >> 24) / 255.0f) \
green:(CGFloat)(((colorValue & 0x00ff0000) >> 16) / 255.0f) \
blue:(CGFloat)(((colorValue & 0x0000ff00) >> 8) / 255.0f) \
alpha:(CGFloat)(((colorValue & 0x000000ff) >> 0) / 255.0f)];
}
#pragma mark - UIImage Category Forward Declaration
@interface UIImage (GIDAdditions_Private)
- (UIImage *)gid_imageWithBlendMode:(CGBlendMode)blendMode color:(UIColor *)color;
@end
#pragma mark - GIDSignInButton Private Properties
@interface GIDSignInButton ()
// The state (normal, pressed, disabled) of the button.
@property(nonatomic, assign) GIDSignInButtonState buttonState;
@end
#pragma mark -
@implementation GIDSignInButton {
UIImageView *_icon;
}
#pragma mark - Object lifecycle
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self sharedInit];
}
return self;
}
- (void)sharedInit {
self.clipsToBounds = YES;
self.backgroundColor = [UIColor clearColor];
// Accessibility settings:
self.isAccessibilityElement = YES;
self.accessibilityTraits = UIAccessibilityTraitButton;
self.accessibilityIdentifier = kAccessibilityIdentifier;
// Default style settings.
_style = kGIDSignInButtonStyleStandard;
_colorScheme = kGIDSignInButtonColorSchemeLight;
_buttonState = kGIDSignInButtonStateNormal;
// Icon for branding image:
_icon = [[UIImageView alloc] initWithFrame:kIconFrame];
_icon.contentMode = UIViewContentModeCenter;
_icon.userInteractionEnabled = NO;
[self addSubview:_icon];
// Load font for "Sign in with Google" text
[NSBundle gid_registerFonts];
// Setup normal/highlighted state transitions:
[self addTarget:self
action:@selector(setNeedsDisplay)
forControlEvents:UIControlEventAllTouchEvents];
[self addTarget:self
action:@selector(switchToPressed)
forControlEvents:UIControlEventTouchDown |
UIControlEventTouchDragInside |
UIControlEventTouchDragEnter];
[self addTarget:self
action:@selector(switchToNormal)
forControlEvents:UIControlEventTouchDragExit |
UIControlEventTouchDragOutside |
UIControlEventTouchCancel |
UIControlEventTouchUpInside];
// Update the icon, etc.
[self updateUI];
}
#pragma mark - NSCoding
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[self sharedInit];
if ([aDecoder containsValueForKey:kStyleKey]) {
_style = [aDecoder decodeIntegerForKey:kStyleKey];
}
if ([aDecoder containsValueForKey:kColorSchemeKey]) {
_colorScheme = [aDecoder decodeIntegerForKey:kColorSchemeKey];
}
if ([aDecoder containsValueForKey:kButtonState]) {
_buttonState = [aDecoder decodeIntegerForKey:kButtonState];
}
}
return self;
}
- (void)encodeWithCoder:(NSCoder *)aCoder {
[super encodeWithCoder:aCoder];
[aCoder encodeInteger:_style forKey:kStyleKey];
[aCoder encodeInteger:_colorScheme forKey:kColorSchemeKey];
[aCoder encodeInteger:_buttonState forKey:kButtonState];
}
#pragma mark - UI
- (void)updateUI {
// Reload the icon.
[self loadIcon];
// Set a useful accessibility label here even if we're not showing text.
// Get localized button text from bundle.
self.accessibilityLabel = [self buttonText];
// Force constrain frame sizes:
[self setFrame:self.frame];
[self setNeedsUpdateConstraints];
[self setNeedsDisplay];
}
- (void)loadIcon {
NSString *resourceName = kGoogleImageName;
NSBundle *gidBundle = [NSBundle gid_frameworkBundle];
NSString *resourcePath = [gidBundle pathForResource:resourceName ofType:@"png"];
UIImage *image = [UIImage imageWithContentsOfFile:resourcePath];
if (_buttonState == kGIDSignInButtonStateDisabled) {
_icon.image = [image gid_imageWithBlendMode:kCGBlendModeMultiply
color:[UIColor colorWithWhite:0
alpha:kDisabledIconAlpha]];
} else {
_icon.image = image;
}
}
#pragma mark - State Transitions
- (void)switchToPressed {
[self setButtonState:kGIDSignInButtonStatePressed];
}
- (void)switchToNormal {
[self setButtonState:kGIDSignInButtonStateNormal];
}
- (void)switchToDisabled {
[self setButtonState:kGIDSignInButtonStateDisabled];
}
#pragma mark - Properties
- (void)setStyle:(GIDSignInButtonStyle)style {
if (style == _style) {
return;
}
_style = style;
[self updateUI];
}
- (void)setColorScheme:(GIDSignInButtonColorScheme)colorScheme {
if (colorScheme == _colorScheme) {
return;
}
_colorScheme = colorScheme;
[self updateUI];
}
- (void)setEnabled:(BOOL)enabled {
if (enabled == self.enabled) {
return;
}
[super setEnabled:enabled];
if (enabled) {
[self switchToNormal];
} else {
[self switchToDisabled];
}
[self updateUI];
}
- (void)setButtonState:(GIDSignInButtonState)buttonState {
if (buttonState == _buttonState) {
return;
}
_buttonState = buttonState;
[self setNeedsDisplay];
}
- (void)setFrame:(CGRect)frame {
// Constrain the frame size to sizes we want.
frame.size = [self sizeThatFits:frame.size];
if (CGRectEqualToRect(frame, self.frame)) {
return;
}
[super setFrame:frame];
[self setNeedsUpdateConstraints];
[self setNeedsDisplay];
}
#pragma mark - Helpers
- (CGFloat)minWidth {
if (_style == kGIDSignInButtonStyleIconOnly) {
return kIconWidth + (kBorderWidth * 2);
}
NSString *text = [self buttonText];
CGSize textSize = [[self class] textSize:text withFont:[[self class] buttonTextFont]];
return ceil(kIconWidth + (kTextPadding * 2) + textSize.width + (kBorderWidth * 2));
}
- (BOOL)isConstraint:(NSLayoutConstraint *)constraintA
equalToConstraint:(NSLayoutConstraint *)constraintB {
return constraintA.priority == constraintB.priority &&
constraintA.firstItem == constraintB.firstItem &&
constraintA.firstAttribute == constraintB.firstAttribute &&
constraintA.relation == constraintB.relation &&
constraintA.secondItem == constraintB.secondItem &&
constraintA.secondAttribute == constraintB.secondAttribute &&
constraintA.multiplier == constraintB.multiplier &&
constraintA.constant == constraintB.constant;
}
#pragma mark - Overrides
- (CGSize)sizeThatFits:(CGSize)size {
switch (_style) {
case kGIDSignInButtonStyleIconOnly:
return CGSizeMake([self minWidth], kButtonHeight);
case kGIDSignInButtonStyleStandard:
case kGIDSignInButtonStyleWide: {
return CGSizeMake(MAX(size.width, [self minWidth]), kButtonHeight);
}
}
}
- (void)updateConstraints {
NSLayoutRelation widthConstraintRelation;
// For icon style, we want to ensure a fixed width
if (_style == kGIDSignInButtonStyleIconOnly) {
widthConstraintRelation = NSLayoutRelationEqual;
} else {
widthConstraintRelation = NSLayoutRelationGreaterThanOrEqual;
}
// Define a width constraint ensuring that we don't go below our minimum width
NSLayoutConstraint *widthConstraint =
[NSLayoutConstraint constraintWithItem:self
attribute:NSLayoutAttributeWidth
relatedBy:widthConstraintRelation
toItem:nil
attribute:NSLayoutAttributeNotAnAttribute
multiplier:1.0
constant:[self minWidth]];
widthConstraint.identifier = @"buttonWidth - auto generated by GIDSignInButton";
// Define a height constraint using our constant height
NSLayoutConstraint *heightConstraint =
[NSLayoutConstraint constraintWithItem:self
attribute:NSLayoutAttributeHeight
relatedBy:NSLayoutRelationEqual
toItem:nil
attribute:NSLayoutAttributeNotAnAttribute
multiplier:1.0
constant:kButtonHeight];
heightConstraint.identifier = @"buttonHeight - auto generated by GIDSignInButton";
// By default, add our width and height constraints
BOOL addWidthConstraint = YES;
BOOL addHeightConstraint = YES;
for (NSLayoutConstraint *constraint in self.constraints) {
// If it is equivalent to our width or height constraint, don't add ours later
if ([self isConstraint:constraint equalToConstraint:widthConstraint]) {
addWidthConstraint = NO;
continue;
}
if ([self isConstraint:constraint equalToConstraint:heightConstraint]) {
addHeightConstraint = NO;
continue;
}
if (constraint.firstItem == self) {
// If it is a height constraint of any relation, remove it
if (constraint.firstAttribute == NSLayoutAttributeHeight) {
[self removeConstraint:constraint];
}
// If it is a width constraint of any relation, remove it if it will conflict with ours
if (constraint.firstAttribute == NSLayoutAttributeWidth &&
(constraint.constant < [self minWidth] || _style == kGIDSignInButtonStyleIconOnly)) {
[self removeConstraint:constraint];
}
}
}
if (addWidthConstraint) {
[self addConstraint:widthConstraint];
}
if (addHeightConstraint) {
[self addConstraint:heightConstraint];
}
[super updateConstraints];
}
#pragma mark - Rendering
- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextRetain(context);
if (context == NULL) {
return;
}
// Draw the button background
[self drawButtonBackground:context];
// Draw the text
[self drawButtonText:context];
CGContextRelease(context);
context = NULL;
}
#pragma mark - Button Background Rendering
- (void)drawButtonBackground:(CGContextRef)context {
CGContextSaveGState(context);
// Normalize the coordinate system of our graphics context
// (0,0) -----> +x
// |
// |
// \/ +y
CGContextScaleCTM(context, 1, -1);
CGContextTranslateCTM(context, 0, -self.bounds.size.height);
// Get the colors for the current state and configuration
UIColor *background = colorForStyleState(_colorScheme,
_buttonState,
kGIDSignInButtonStyleColorBackground);
// Create rounded rectangle for button background/outline
CGMutablePathRef path = CGPathCreateMutable();
CGPathAddRoundedRect(path,
NULL,
CGRectInset(self.bounds, kBorderWidth, kBorderWidth),
kCornerRadius,
kCornerRadius);
// Fill the background and apply halo shadow
CGContextSaveGState(context);
CGContextAddPath(context, path);
CGContextSetFillColorWithColor(context, background.CGColor);
// If we're not in the disabled state, we want a shadow
if (_buttonState != kGIDSignInButtonStateDisabled) {
// Draw halo shadow around button
CGContextSetShadowWithColor(context,
CGSizeMake(0, 0),
kHaloShadowBlur,
[UIColor colorWithWhite:0 alpha:kHaloShadowAlpha].CGColor);
}
CGContextFillPath(context);
CGContextRestoreGState(context);
if (_buttonState != kGIDSignInButtonStateDisabled) {
// Fill the background again to apply drop shadow
CGContextSaveGState(context);
CGContextAddPath(context, path);
CGContextSetFillColorWithColor(context, background.CGColor);
CGContextSetShadowWithColor(context,
CGSizeMake(0, kDropShadowYOffset),
kDropShadowBlur,
[UIColor colorWithWhite:0 alpha:kDropShadowAlpha].CGColor);
CGContextFillPath(context);
CGContextRestoreGState(context);
}
if (_colorScheme == kGIDSignInButtonColorSchemeDark &&
_buttonState != kGIDSignInButtonStateDisabled) {
// Create rounded rectangle container for the "G"
CGMutablePathRef gContainerPath = CGPathCreateMutable();
CGPathAddRoundedRect(gContainerPath,
NULL,
CGRectInset(CGRectMake(0, 0, kButtonHeight, kButtonHeight),
kBorderWidth + 1,
kBorderWidth + 1),
kCornerRadius,
kCornerRadius);
CGContextAddPath(context, gContainerPath);
CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
CGContextFillPath(context);
CGPathRelease(gContainerPath);
}
CGPathRelease(path);
CGContextRestoreGState(context);
}
#pragma mark - Text Rendering
- (void)drawButtonText:(CGContextRef)context {
if (_style == kGIDSignInButtonStyleIconOnly) {
return;
}
NSString *text = self.accessibilityLabel;
UIColor *foregroundColor = colorForStyleState(_colorScheme,
_buttonState,
kGIDSignInButtonStyleColorForeground);
UIFont *font = [[self class] buttonTextFont];
CGSize textSize = [[self class] textSize:text withFont:font];
// Draw the button text at the right position with the right color.
CGFloat textLeft = kIconWidth + kTextPadding;
CGFloat textTop = round((self.bounds.size.height - textSize.height) / 2);
[text drawAtPoint:CGPointMake(textLeft, textTop)
withAttributes:@{ NSFontAttributeName : font,
NSForegroundColorAttributeName : foregroundColor }];
}
#pragma mark - Button Text Selection / Localization
- (NSString *)buttonText {
switch (_style) {
case kGIDSignInButtonStyleWide:
return [GIDSignInStrings signInWithGoogleString];
case kGIDSignInButtonStyleStandard:
case kGIDSignInButtonStyleIconOnly:
return [GIDSignInStrings signInString];
}
}
+ (UIFont *)buttonTextFont {
UIFont *font = [UIFont fontWithName:kFontNameRobotoBold size:kFontSize];
if (!font) {
font = [UIFont boldSystemFontOfSize:kFontSize];
}
return font;
}
+ (CGSize)textSize:(NSString *)text withFont:(UIFont *)font {
return [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
options:0
attributes:@{ NSFontAttributeName : font }
context:nil].size;
}
@end
#pragma mark - UIImage GIDAdditions_Private Category
@implementation UIImage (GIDAdditions_Private)
- (UIImage *)gid_imageWithBlendMode:(CGBlendMode)blendMode color:(UIColor *)color {
CGSize size = [self size];
CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height);
UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0.0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetShouldAntialias(context, true);
CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
CGContextScaleCTM(context, 1, -1);
CGContextTranslateCTM(context, 0, -rect.size.height);
CGContextClipToMask(context, rect, self.CGImage);
CGContextDrawImage(context, rect, self.CGImage);
CGContextSetBlendMode(context, blendMode);
CGFloat alpha = 1.0;
if (blendMode == kCGBlendModeMultiply) {
CGFloat red, green, blue;
BOOL success = [color getRed:&red green:&green blue:&blue alpha:&alpha];
if (success) {
color = [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
} else {
CGFloat grayscale;
success = [color getWhite:&grayscale alpha:&alpha];
if (success) {
color = [UIColor colorWithWhite:grayscale alpha:1.0];
}
}
}
CGContextSetFillColorWithColor(context, color.CGColor);
CGContextFillRect(context, rect);
if (blendMode == kCGBlendModeMultiply && alpha != 1.0) {
// Modulate by the alpha.
color = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:alpha];
CGContextSetBlendMode(context, kCGBlendModeDestinationIn);
CGContextSetFillColorWithColor(context, color.CGColor);
CGContextFillRect(context, rect);
}
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
if (self.capInsets.bottom > 0 || self.capInsets.top > 0 ||
self.capInsets.left > 0 || self.capInsets.left > 0) {
image = [image resizableImageWithCapInsets:self.capInsets];
}
return image;
}
@end
NS_ASSUME_NONNULL_END
#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION