GIDActivityIndicatorViewController.m 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright 2023 Google LLC
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "GoogleSignIn/Sources/GIDAppCheck/UI/GIDActivityIndicatorViewController.h"
  17. #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
  18. #import <TargetConditionals.h>
  19. @implementation GIDActivityIndicatorViewController
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. // Medium gray with transparency
  23. self.view.backgroundColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:0.25];
  24. UIActivityIndicatorViewStyle style;
  25. if (@available(iOS 13.0, *)) {
  26. style = UIActivityIndicatorViewStyleLarge;
  27. } else {
  28. style = UIActivityIndicatorViewStyleGray;
  29. }
  30. _activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:style];
  31. _activityIndicator.color = UIColor.whiteColor;
  32. self.activityIndicator.translatesAutoresizingMaskIntoConstraints = NO;
  33. [self.activityIndicator startAnimating];
  34. [self.view addSubview:self.activityIndicator];
  35. NSLayoutConstraint *centerX =
  36. [self.activityIndicator.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor];
  37. NSLayoutConstraint *centerY =
  38. [self.activityIndicator.centerYAnchor constraintEqualToAnchor:self.view.centerYAnchor];
  39. [NSLayoutConstraint activateConstraints:@[centerX, centerY]];
  40. }
  41. @end
  42. #endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST