Skip to content
Snippets Groups Projects
Commit 4183e751 authored by jakobsbode's avatar jakobsbode
Browse files

Onboarding nearly done

parent 6ae35f91
No related branches found
No related tags found
No related merge requests found
......@@ -173,6 +173,8 @@ NS_ASSUME_NONNULL_END
*/
+ (nonnull instancetype)contentWithTitle:(nullable NSString *)title body:(nullable NSString *)body videoURL:(nullable NSURL *)videoURL inputView:(UIView *)inputView buttonText:(nullable NSString *)buttonText actionBlock:(nullable dispatch_block_t)actionBlock;
+ (nonnull instancetype)contentWithTitle:(nullable NSString *)title body:(nullable NSString *)body videoURL:(nullable NSURL *)videoURL inputView:(UIView *)inputView buttonText:(nullable NSString *)buttonText actionBlock:(nullable dispatch_block_t)actionBlock withPadding:(nonnull BOOL*)withPadding;
/**
* @brief Initializer for creating an onboarding content view controller with a video.
......@@ -203,6 +205,9 @@ NS_ASSUME_NONNULL_END
- (nonnull instancetype)initWithTitle:(nullable NSString *)title body:(nullable NSString *)body image:(nullable UIImage *)image videoURL:(nullable NSURL *)videoURL inputView:(nullable UIView *)inputView buttonText:(nullable NSString *)buttonText actionBlock:(nullable dispatch_block_t)actionBlock;
- (nonnull instancetype)initWithTitle:(nullable NSString *)title body:(nullable NSString *)body image:(nullable UIImage *)image videoURL:(nullable NSURL *)videoURL inputView:(nullable UIView *)inputView buttonText:(nullable NSString *)buttonText actionBlock:(nullable dispatch_block_t)actionBlock withPadding:(BOOL*)withPadding;
/**
* @brief Method used to update the alpha value for all floating subviews (image, title, body, etc.)
*/
......
......@@ -40,6 +40,8 @@ NSString * const kOnboardInputViewAccessibilityIdentifier = @"OnboardInputViewAc
@property (nonatomic) BOOL wasPreviouslyVisible;
@property (nonatomic, nullable) BOOL* withPadding;
@end
@implementation OnboardingContentViewController
......@@ -73,7 +75,10 @@ NSString * const kOnboardInputViewAccessibilityIdentifier = @"OnboardInputViewAc
+ (instancetype)contentWithTitle:(NSString *)title body:(NSString *)body videoURL:(NSURL *)videoURL inputView:(UIView *)inputView buttonText:(NSString *)buttonText actionBlock:(action_callback)actionBlock {
return [[self alloc] initWithTitle:title body:body image:nil videoURL:videoURL inputView:inputView buttonText:buttonText actionBlock:actionBlock];
}
+ (instancetype)contentWithTitle:(NSString *)title body:(NSString *)body videoURL:(NSURL *)videoURL inputView:(UIView *)inputView buttonText:(NSString *)buttonText actionBlock:(action_callback)actionBlock withPadding:(BOOL*)withPadding {
return [[self alloc] initWithTitle:title body:body image:nil videoURL:videoURL inputView:inputView buttonText:buttonText actionBlock:actionBlock withPadding:withPadding];
}
- (instancetype)initWithTitle:(NSString *)title body:(NSString *)body videoURL:(NSURL *)videoURL buttonText:(NSString *)buttonText action:(dispatch_block_t)action {
......@@ -154,6 +159,75 @@ NSString * const kOnboardInputViewAccessibilityIdentifier = @"OnboardInputViewAc
return self;
}
- (instancetype)initWithTitle:(NSString *)title body:(NSString *)body image:(UIImage *)image videoURL:(NSURL *)videoURL inputView:(UIView *)inputView buttonText:(NSString *)buttonText actionBlock:(action_callback)actionBlock withPadding:(BOOL*)withPadding{
self = [super init];
self.withPadding = withPadding;
if (self == nil) {
return nil;
}
// Icon image view
self.iconImageView = [[UIImageView alloc] initWithImage:image];
self.iconWidth = image ? image.size.width : kDefaultImageViewSize;
self.iconHeight = image ? image.size.height : kDefaultImageViewSize;
// Title label
self.titleLabel = [UILabel new];
self.titleLabel.accessibilityIdentifier = kOnboardMainTextAccessibilityIdentifier;
self.titleLabel.text = title;
self.titleLabel.textColor = DEFAULT_TEXT_COLOR;
self.titleLabel.font = [UIFont fontWithName:kDefaultOnboardingFont size:kDefaultTitleFontSize];
self.titleLabel.numberOfLines = 0;
self.titleLabel.textAlignment = NSTextAlignmentCenter;
// Body label
self.bodyLabel = [UILabel new];
self.bodyLabel.accessibilityIdentifier = kOnboardSubTextAccessibilityIdentifier;
self.bodyLabel.text = body;
self.bodyLabel.textColor = DEFAULT_TEXT_COLOR;
self.bodyLabel.font = [UIFont fontWithName:kDefaultOnboardingFont size:kDefaultBodyFontSize];
self.bodyLabel.numberOfLines = 0;
self.bodyLabel.textAlignment = NSTextAlignmentCenter;
// Input view
self.inputView = inputView;
if (self.inputView) {
self.inputView.accessibilityIdentifier = kOnboardInputViewAccessibilityIdentifier;
}
// Action button
self.actionButton = [UIButton new];
self.actionButton.accessibilityIdentifier = kOnboardActionButtonAccessibilityIdentifier;
self.actionButton.titleLabel.font = [UIFont fontWithName:kDefaultOnboardingFont size:kDefaultButtonFontSize];
[self.actionButton setTitle:buttonText forState:UIControlStateNormal];
[self.actionButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[self.actionButton addTarget:self action:@selector(handleButtonPressed) forControlEvents:UIControlEventTouchUpInside];
self.buttonActionHandler = actionBlock ?: ^(OnboardingViewController *controller){};
// Movie player
self.videoURL = videoURL;
// Auto-navigation
self.movesToNextViewController = NO;
// Default padding values
self.topPadding = kDefaultTopPadding;
self.underIconPadding = kDefaultUnderIconPadding;
self.underTitlePadding = kDefaultUnderTitlePadding;
self.bottomPadding = kDefaultBottomPadding;
self.underPageControlPadding = kDefaultUnderPageControlPadding;
// Default blocks
self.viewWillAppearBlock = ^{};
self.viewDidAppearBlock = ^{};
self.viewWillDisappearBlock = ^{};
self.viewDidDisappearBlock = ^{};
return self;
}
- (instancetype)initWithTitle:(NSString *)title body:(NSString *)body image:(UIImage *)image videoURL:(NSURL *)videoURL inputView:(UIView *)inputView buttonText:(NSString *)buttonText actionBlock:(action_callback)actionBlock {
self = [super init];
......@@ -364,8 +438,12 @@ NSString * const kOnboardInputViewAccessibilityIdentifier = @"OnboardInputViewAc
self.actionButton.frame = CGRectMake((CGRectGetMaxX(self.view.frame) / 2) - (contentWidth / 2), CGRectGetMaxY(self.view.frame) - self.underPageControlPadding - kMainPageControlHeight - kActionButtonHeight - self.bottomPadding, contentWidth, kActionButtonHeight);
CGFloat inputYOrigin = CGRectGetMaxY(self.bodyLabel.frame) + self.underTitlePadding;
if (self.withPadding != NULL) {
if (*self.withPadding == NO) {
inputYOrigin = CGRectGetMaxY(self.bodyLabel.frame);
}
}
if (self.inputView) {
self.inputView.frame = CGRectMake(xPadding, inputYOrigin, contentWidth, CGRectGetHeight(self.inputView.frame));
for (UIView *view in self.inputView.subviews){
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment