ThemedViewController.m 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // _____ _
  2. // |_ _| |_ _ _ ___ ___ _ __ __ _
  3. // | | | ' \| '_/ -_) -_) ' \/ _` |_
  4. // |_| |_||_|_| \___\___|_|_|_\__,_(_)
  5. //
  6. // Threema iOS Client
  7. // Copyright (c) 2018-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 "ThemedViewController.h"
  21. #import "VoIPHelper.h"
  22. @interface ThemedViewController ()
  23. @end
  24. @implementation ThemedViewController
  25. - (void)viewDidLoad {
  26. [self.view setBackgroundColor:[Colors background]];
  27. [Colors setTextColor:[Colors fontNormal] inView:self.view];
  28. }
  29. - (void)viewWillAppear:(BOOL)animated {
  30. [super viewWillAppear:animated];
  31. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callInBackgroundTimeChanged:) name:kNotificationCallInBackgroundTimeChanged object:nil];
  32. self.navigationItem.prompt = [[VoIPHelper shared] currentPromtString:nil];
  33. }
  34. - (void)viewWillDisappear:(BOOL)animated {
  35. [super viewWillDisappear:animated];
  36. [[NSNotificationCenter defaultCenter] removeObserver:self name:kNotificationCallInBackgroundTimeChanged object:nil];
  37. }
  38. - (void)callInBackgroundTimeChanged:(NSNotification*)notification {
  39. NSNumber *time = notification.object;
  40. self.navigationItem.prompt = [[VoIPHelper shared] currentPromtString:time];
  41. if (self.navigationItem.prompt == nil) {
  42. if ([self respondsToSelector:@selector(updateLayoutAfterCall)]) {
  43. double delayInSeconds = 0.3;
  44. dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
  45. dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
  46. [self performSelector:@selector(updateLayoutAfterCall)];
  47. });
  48. }
  49. }
  50. }
  51. - (void)refresh {
  52. [self.view setBackgroundColor:[Colors background]];
  53. [Colors setTextColor:[Colors fontNormal] inView:self.view];
  54. }
  55. - (void)updateLayoutAfterCall {
  56. // do nothing
  57. }
  58. @end