CCIntro.m 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. //
  2. // CCIntro.m
  3. // Nextcloud iOS
  4. //
  5. // Created by Marino Faggiana on 05/11/15.
  6. // Copyright (c) 2017 TWS. All rights reserved.
  7. //
  8. // Author Marino Faggiana <m.faggiana@twsweb.it>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. #import "CCIntro.h"
  24. @interface CCIntro ()
  25. {
  26. int titlePositionY;
  27. int descPositionY;
  28. int titleIconPositionY;
  29. }
  30. @end
  31. @implementation CCIntro
  32. - (id)initWithDelegate:(id <CCIntroDelegate>)delegate delegateView:(UIView *)delegateView
  33. {
  34. self = [super init];
  35. if (self) {
  36. self.delegate = delegate;
  37. self.rootView = delegateView;
  38. }
  39. return self;
  40. }
  41. - (UIStatusBarStyle)preferredStatusBarStyle
  42. {
  43. return UIStatusBarStyleLightContent;
  44. }
  45. - (void)introWillFinish:(EAIntroView *)introView wasSkipped:(BOOL)wasSkipped
  46. {
  47. if (self.delegate && [self.delegate respondsToSelector:@selector(introWillFinish:wasSkipped:)])
  48. [self.delegate introWillFinish:introView wasSkipped:wasSkipped];
  49. }
  50. - (void)introDidFinish:(EAIntroView *)introView wasSkipped:(BOOL)wasSkipped
  51. {
  52. if (self.delegate && [self.delegate respondsToSelector:@selector(introDidFinish:wasSkipped:)])
  53. [self.delegate introDidFinish:introView wasSkipped:wasSkipped];
  54. }
  55. - (void)showIntroCryptoCloud:(CGFloat)duration
  56. {
  57. //NSString *language = [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0];
  58. CGFloat height = self.rootView.bounds.size.height;
  59. if (height <= 480) {
  60. titleIconPositionY = 20; titlePositionY = 260; descPositionY = 230;
  61. }
  62. // 812 = iPhoneX
  63. if (height > 480 && height <= 812) {
  64. titleIconPositionY = 50; titlePositionY = height / 2; descPositionY = height / 2 - 40 ;
  65. }
  66. if (height > 812) {
  67. titleIconPositionY = 100; titlePositionY = 290; descPositionY = 250;
  68. }
  69. EAIntroPage *page1 = [EAIntroPage page];
  70. page1.titleIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"intro1"]];
  71. page1.title = NSLocalizedStringFromTable(@"_intro_1_title_", @"Intro", nil);
  72. page1.desc = NSLocalizedStringFromTable(@"_intro_1_text_", @"Intro", nil);
  73. page1.titlePositionY = titlePositionY;
  74. page1.titleColor = [UIColor blackColor];
  75. page1.titleFont = [UIFont systemFontOfSize:20];
  76. page1.descPositionY = descPositionY;
  77. page1.descColor = [UIColor blackColor];
  78. page1.descFont = [UIFont systemFontOfSize:14];
  79. page1.bgImage = [UIImage imageNamed:@"bgbianco"];
  80. page1.titleIconPositionY = titleIconPositionY;
  81. page1.showTitleView = NO;
  82. EAIntroPage *page11 = [EAIntroPage page];
  83. page11.titleIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"intro11"]];
  84. page11.title = NSLocalizedStringFromTable(@"_intro_11_title_", @"Intro", nil);
  85. page11.desc = NSLocalizedStringFromTable(@"_intro_11_text_", @"Intro", nil);
  86. page11.titlePositionY = titlePositionY;
  87. page11.titleColor = [UIColor blackColor];
  88. page11.titleFont = [UIFont systemFontOfSize:20];
  89. page11.descPositionY = descPositionY;
  90. page11.descColor = [UIColor blackColor];
  91. page11.descFont = [UIFont systemFontOfSize:14];
  92. page11.bgImage = [UIImage imageNamed:@"bgbianco"];
  93. page11.titleIconPositionY = titleIconPositionY;
  94. page11.showTitleView = NO;
  95. EAIntroPage *page2 = [EAIntroPage page];
  96. page2.titleIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"intro2"]];
  97. page2.title = NSLocalizedStringFromTable(@"_intro_2_title_", @"Intro", nil);
  98. page2.desc = NSLocalizedStringFromTable(@"_intro_2_text_", @"Intro", nil);
  99. page2.titlePositionY = titlePositionY;
  100. page2.titleColor = [UIColor blackColor];
  101. page2.titleFont = [UIFont systemFontOfSize:20];
  102. page2.descPositionY = descPositionY;
  103. page2.descColor = [UIColor blackColor];
  104. page2.descFont = [UIFont systemFontOfSize:14];
  105. page2.bgImage = [UIImage imageNamed:@"bgbianco"];
  106. page2.titleIconPositionY = titleIconPositionY;
  107. page2.showTitleView = NO;
  108. EAIntroPage *page3 = [EAIntroPage page];
  109. page3.titleIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"intro3"]];
  110. page3.title = NSLocalizedStringFromTable(@"_intro_3_title_", @"Intro", nil);
  111. page3.desc = NSLocalizedStringFromTable(@"_intro_3_text_", @"Intro", nil);
  112. page3.titlePositionY = titlePositionY;
  113. page3.titleColor = [UIColor blackColor];
  114. page3.titleFont = [UIFont systemFontOfSize:20];
  115. page3.descPositionY = descPositionY;
  116. page3.descColor = [UIColor blackColor];
  117. page3.descFont = [UIFont systemFontOfSize:14];
  118. page3.bgImage = [UIImage imageNamed:@"bgbianco"];
  119. page3.titleIconPositionY = titleIconPositionY;
  120. page3.showTitleView = NO;
  121. EAIntroView *intro = [[EAIntroView alloc] initWithFrame:self.rootView.bounds];
  122. intro.tapToNext = YES;
  123. intro.pageControl.pageIndicatorTintColor = [UIColor lightGrayColor];
  124. intro.pageControl.currentPageIndicatorTintColor = [UIColor blackColor];
  125. intro.pageControl.backgroundColor = [UIColor clearColor];
  126. [intro.skipButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  127. intro.skipButton.enabled = NO;
  128. page1.onPageDidAppear = ^{
  129. intro.skipButton.enabled = YES;
  130. [UIView animateWithDuration:0.3f animations:^{
  131. intro.skipButton.alpha = 1.f;
  132. }];
  133. };
  134. page2.onPageDidDisappear = ^{
  135. intro.skipButton.enabled = NO;
  136. [UIView animateWithDuration:0.3f animations:^{
  137. intro.skipButton.alpha = 0.f;
  138. }];
  139. };
  140. [intro setDelegate:self];
  141. [intro setPages:@[page1,page11,page2,page3]];
  142. [intro showInView:self.rootView animateDuration:duration];
  143. }
  144. @end