IntroQuestionView.m 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // _____ _
  2. // |_ _| |_ _ _ ___ ___ _ __ __ _
  3. // | | | ' \| '_/ -_) -_) ' \/ _` |_
  4. // |_| |_||_|_| \___\___|_|_|_\__,_(_)
  5. //
  6. // Threema iOS Client
  7. // Copyright (c) 2015-2020 Threema GmbH
  8. //
  9. // This program is free software: you can redistribute it and/or modify
  10. // it under the terms of the GNU Affero General Public License, version 3,
  11. // as published by the Free Software Foundation.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU Affero General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Affero General Public License
  19. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. #import "IntroQuestionView.h"
  21. #import "BundleUtil.h"
  22. @implementation IntroQuestionView
  23. - (void)awakeFromNib {
  24. [self setup];
  25. [super awakeFromNib];
  26. }
  27. - (void)setShowOnlyOkButton:(BOOL)showOnlyOkButton {
  28. _alertPane.hidden = (showOnlyOkButton == NO);
  29. _okButton.hidden = (showOnlyOkButton == NO);
  30. _confirmPane.hidden = showOnlyOkButton;
  31. _yesButton.hidden = showOnlyOkButton;
  32. _noButton.hidden = showOnlyOkButton;
  33. }
  34. - (BOOL)showOnlyOkButton {
  35. return _yesButton.hidden;
  36. }
  37. - (void)setTitle:(NSString *)title {
  38. _questionTitle.hidden = ([title isEqual: @""]);
  39. _questionTitle.text = title;
  40. }
  41. - (void)setup {
  42. self.backgroundColor = [UIColor clearColor];
  43. _yesButton.layer.cornerRadius = 3;
  44. _okButton.layer.cornerRadius = 3;
  45. _yesButton.backgroundColor = [Colors mainThemeDark];
  46. [_yesButton setTitleColor:[Colors white] forState:UIControlStateNormal];
  47. _okButton.backgroundColor = [Colors mainThemeDark];
  48. [_okButton setTitleColor:[Colors white] forState:UIControlStateNormal];
  49. _noButton.layer.borderWidth = 1;
  50. _noButton.layer.borderColor = _yesButton.backgroundColor.CGColor;
  51. _noButton.layer.cornerRadius = 3;
  52. [_yesButton setTitle:[BundleUtil localizedStringForKey:@"yes"] forState:UIControlStateNormal];
  53. [_noButton setTitle:[BundleUtil localizedStringForKey:@"no"] forState:UIControlStateNormal];
  54. [_okButton setTitle:[BundleUtil localizedStringForKey:@"ok"] forState:UIControlStateNormal];
  55. [_noButton setTitleColor:[Colors mainThemeDark] forState:UIControlStateNormal];
  56. }
  57. - (IBAction)yesAction:(id)sender {
  58. [_delegate selectedYes:self];
  59. }
  60. - (IBAction)noAction:(id)sender {
  61. [_delegate selectedNo:self];
  62. }
  63. - (IBAction)okAction:(id)sender {
  64. [_delegate selectedOk:self];
  65. }
  66. #pragma mark - accessability
  67. - (BOOL)isAccessibilityElement {
  68. return NO;
  69. }
  70. @end