host_setup_footer_view.mm 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #import "remoting/ios/app/host_setup_footer_view.h"
  5. #import <MaterialComponents/MaterialButtons.h>
  6. #import <MaterialComponents/MaterialTypography.h>
  7. #import "remoting/ios/app/app_delegate.h"
  8. #import "remoting/ios/app/remoting_theme.h"
  9. #include "remoting/base/string_resources.h"
  10. #include "ui/base/l10n/l10n_util.h"
  11. #if !defined(__has_feature) || !__has_feature(objc_arc)
  12. #error "This file requires ARC support."
  13. #endif
  14. static const CGFloat kTopPadding = 6.f;
  15. @implementation HostSetupFooterView
  16. - (instancetype)initWithFrame:(CGRect)frame {
  17. if (self = [super initWithFrame:frame]) {
  18. [self commonInit];
  19. }
  20. return self;
  21. }
  22. - (void)commonInit {
  23. self.backgroundColor = RemotingTheme.setupListBackgroundColor;
  24. MDCRaisedButton* raisedButton = [[MDCRaisedButton alloc] init];
  25. [raisedButton
  26. setTitle:l10n_util::GetNSString(IDS_EMAIL_LINKS_AND_INSTRUCTIONS)
  27. forState:UIControlStateNormal];
  28. [raisedButton setTitleColor:RemotingTheme.buttonTextColor
  29. forState:UIControlStateNormal];
  30. [raisedButton setBackgroundColor:RemotingTheme.buttonBackgroundColor
  31. forState:UIControlStateNormal];
  32. [raisedButton sizeToFit];
  33. [raisedButton addTarget:self
  34. action:@selector(didTapEmailInstructions:)
  35. forControlEvents:UIControlEventTouchUpInside];
  36. [self addSubview:raisedButton];
  37. raisedButton.translatesAutoresizingMaskIntoConstraints = NO;
  38. [NSLayoutConstraint activateConstraints:@[
  39. [raisedButton.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
  40. [raisedButton.topAnchor constraintEqualToAnchor:self.topAnchor
  41. constant:kTopPadding],
  42. ]];
  43. }
  44. - (void)didTapEmailInstructions:(id)button {
  45. [AppDelegate.instance emailSetupInstructions];
  46. }
  47. @end