241 lines
11 KiB
Objective-C
241 lines
11 KiB
Objective-C
//
|
|
// HBFirstStartController.m
|
|
// QinJiuTV
|
|
//
|
|
// Created by HI_LOSER on 2024/6/6.
|
|
//
|
|
|
|
#import "HBFirstStartController.h"
|
|
|
|
@interface HBFirstStartController ()
|
|
@property (strong, nonatomic) NSMutableArray<KxMenuItem*> * menuItems;
|
|
@end
|
|
|
|
@implementation HBFirstStartController
|
|
|
|
- (NSMutableArray<KxMenuItem *> *)menuItems{
|
|
if (!_menuItems) {
|
|
_menuItems = [[NSMutableArray alloc]init];
|
|
for (HBLanguageModel * model in [HBMultiLanguageManager languages]) {
|
|
KxMenuItem * element = [KxMenuItem menuItem:model.title image:nil target:self action:@selector(menuItemAction:)];
|
|
element.object = model;
|
|
[_menuItems addObject:element];
|
|
}
|
|
}
|
|
return _menuItems;
|
|
}
|
|
|
|
+ (HBNavigationController *) rootController {
|
|
return [[HBNavigationController alloc]initWithRootViewController:[HBFirstStartController new]];
|
|
}
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
self.hbd_barHidden = YES;
|
|
[self loadSubViews];
|
|
[self loadNavigationBar];
|
|
}
|
|
|
|
- (void)loadNavigationBar {
|
|
UIButton * button = [[UIButton alloc]init];
|
|
button.titleLabel.font = [UIFont systemFontOfSize:14.0 weight:UIFontWeightRegular];
|
|
[button setTitle:[@"mine_title_language" language] forState:UIControlStateNormal];
|
|
[button setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
|
|
[button addTarget:self action:@selector(changeLanguage) forControlEvents:UIControlEventTouchUpInside];
|
|
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:button];
|
|
}
|
|
|
|
- (void)loadSubViews {
|
|
UIImageView * backgroundView = [UIImageView imageNamed:@"login_background"];
|
|
backgroundView.contentMode = UIViewContentModeScaleToFill;
|
|
[self.view addSubview:backgroundView];
|
|
|
|
UIView * view = [[UIView alloc] init];
|
|
view.backgroundColor = UIColor.whiteColor;
|
|
[view acs_radiusWithRadius:18.0 corner:UIRectCornerAllCorners];
|
|
[self.view addSubview:view];
|
|
|
|
UIImageView * headerView = [UIImageView imageNamed:@"universal_frist_header"];
|
|
[view addSubview:headerView];
|
|
|
|
UILabel * titleLabel = [[UILabel alloc] init];
|
|
titleLabel.text = [@"first_start_title" language];
|
|
titleLabel.font = [UIFont systemFontOfSize:18.0 weight:UIFontWeightSemibold];
|
|
titleLabel.textAlignment = NSTextAlignmentCenter;
|
|
[view addSubview:titleLabel];
|
|
|
|
UIButton * closeButton = [[UIButton alloc]init];
|
|
closeButton.titleLabel.font = [UIFont systemFontOfSize:14.0 weight:UIFontWeightRegular];
|
|
[closeButton setTitle:[@"first_start_close" language] forState:UIControlStateNormal];
|
|
[closeButton setTitleColor:HBColor.color_999999 forState:UIControlStateNormal];
|
|
[closeButton addTarget:self action:@selector(closeAction) forControlEvents:UIControlEventTouchUpInside];
|
|
[view addSubview:closeButton];
|
|
|
|
UIButton * agreeButton = [[UIButton alloc]init];
|
|
[agreeButton acs_radiusWithRadius:20.0 corner:UIRectCornerAllCorners];
|
|
agreeButton.titleLabel.font = [UIFont systemFontOfSize:14.0 weight:UIFontWeightRegular];
|
|
[agreeButton setTitle:[@"first_start_done" language] forState:UIControlStateNormal];
|
|
[agreeButton setTitleColor:HBColor.whiteColor forState:UIControlStateNormal];
|
|
[agreeButton setBackgroundImage:[UIImage imageNamed:@"publics_gradient"] forState:UIControlStateNormal];
|
|
[agreeButton addTarget:self action:@selector(agreeAction) forControlEvents:UIControlEventTouchUpInside];
|
|
[view addSubview:agreeButton];
|
|
|
|
|
|
|
|
NSString * privacy = [@"commom_highlight_privacy" language];
|
|
NSString * agreement = [@"commom_highlight_agreement" language];
|
|
NSString * user = [@"commom_highlight_user" language];
|
|
NSString * third = [@"commom_highlight_third" language];
|
|
NSString * children = [@"commom_highlight_children" language];
|
|
NSString * teenager = [@"commom_highlight_teenager" language];
|
|
|
|
NSString * string = [NSString stringWithFormat:[@"first_start_text" language],privacy,agreement,user,third,children,teenager];
|
|
|
|
NSRange privacyRange = [string rangeOfString:privacy];
|
|
NSRange agreementRange = [string rangeOfString:agreement];
|
|
NSRange userRange = [string rangeOfString:user];
|
|
NSRange thirdRange = [string rangeOfString:third];
|
|
NSRange childrenRange = [string rangeOfString:children];
|
|
NSRange teenagerRange = [string rangeOfString:teenager];
|
|
|
|
|
|
HBWeakSelf
|
|
NSMutableAttributedString * attributedText = [[NSMutableAttributedString alloc]initWithString:string];
|
|
attributedText.yy_lineSpacing = 4.0;
|
|
attributedText.yy_font = [UIFont systemFontOfSize:14.0 weight:UIFontWeightRegular];
|
|
|
|
[attributedText yy_setTextHighlightRange:privacyRange
|
|
color:HBColor.color_FF0049
|
|
backgroundColor:nil
|
|
tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
|
[weakSelf.navigationController pushViewController:[HBWebViewController privacyPolicy] animated:YES];
|
|
|
|
}];
|
|
|
|
[attributedText yy_setTextHighlightRange:agreementRange
|
|
color:HBColor.color_FF0049
|
|
backgroundColor:nil
|
|
tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
|
[weakSelf.navigationController pushViewController:[HBWebViewController userAgreement] animated:YES];
|
|
}];
|
|
|
|
[attributedText yy_setTextHighlightRange:userRange
|
|
color:HBColor.color_FF0049
|
|
backgroundColor:nil
|
|
tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
|
[weakSelf.navigationController pushViewController:[HBWebViewController contactCustomerService] animated:YES];
|
|
}];
|
|
|
|
[attributedText yy_setTextHighlightRange:thirdRange
|
|
color:HBColor.color_FF0049
|
|
backgroundColor:nil
|
|
tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
|
[weakSelf.navigationController pushViewController:[HBWebViewController contactCustomerService] animated:YES];
|
|
}];
|
|
|
|
[attributedText yy_setTextHighlightRange:childrenRange
|
|
color:HBColor.color_FF0049
|
|
backgroundColor:nil
|
|
tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
|
[weakSelf.navigationController pushViewController:[HBWebViewController contactCustomerService] animated:YES];
|
|
}];
|
|
|
|
[attributedText yy_setTextHighlightRange:teenagerRange
|
|
color:HBColor.color_FF0049
|
|
backgroundColor:nil
|
|
tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
|
[weakSelf.navigationController pushViewController:[HBWebViewController contactCustomerService] animated:YES];
|
|
}];
|
|
|
|
YYTextView * textView = [[YYTextView alloc]init];
|
|
textView.attributedText = attributedText;
|
|
textView.editable = NO;
|
|
textView.showsVerticalScrollIndicator = NO;
|
|
textView.showsHorizontalScrollIndicator = NO;
|
|
[view addSubview:textView];
|
|
|
|
|
|
[backgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.equalTo(self.view);
|
|
}];
|
|
|
|
[view mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.offset(-36.0);
|
|
make.left.offset(36.0);
|
|
make.center.equalTo(self.view);
|
|
}];
|
|
|
|
[headerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.left.right.equalTo(view);
|
|
}];
|
|
|
|
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.bottom.right.equalTo(headerView);
|
|
}];
|
|
|
|
[closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.equalTo(view);
|
|
make.bottom.equalTo(view).offset(-16.0);
|
|
}];
|
|
|
|
[agreeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.offset(16.0);
|
|
make.right.offset(-16.0);
|
|
make.bottom.equalTo(closeButton.mas_top).offset(-12.0);
|
|
make.height.offset(40.0);
|
|
}];
|
|
|
|
[textView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.offset(16.0);
|
|
make.right.offset(-16.0);
|
|
make.top.equalTo(headerView.mas_bottom).offset(12.0);
|
|
make.bottom.equalTo(agreeButton.mas_top).offset(-18.0);
|
|
make.height.offset(240.0);
|
|
}];
|
|
}
|
|
|
|
- (void)changeLanguage {
|
|
CGRect rect = [self.navigationItem.rightBarButtonItem.customView convertRect:self.navigationItem.rightBarButtonItem.customView.bounds toView:self.view];
|
|
[KxMenu showMenuInView:self.view fromRect:rect menuItems:self.menuItems];
|
|
}
|
|
|
|
- (void)menuItemAction:(KxMenuItem *)sender {
|
|
HBLanguageModel * model = (HBLanguageModel*)sender.object;
|
|
[HBMultiLanguageManager saveCurrentLanguageAbbr:model.abbr];
|
|
}
|
|
|
|
- (void)agreeAction {
|
|
HBWeakSelf
|
|
HBResponseComplateBlock block = ^(BOOL success, id _Nonnull data, NSString * _Nonnull message) {
|
|
[HUDManager hideHUD];
|
|
if (success) {
|
|
[NSUserDefaults setBool:YES forKey:HBNotFirstStartKey];
|
|
|
|
}
|
|
};
|
|
[HUDManager showActivityHUD];
|
|
[HBNetWorkingUtility commom_deviceRegisterWithComplateBlock:block];
|
|
}
|
|
|
|
- (void)closeAction {
|
|
|
|
UIAlertAction * exitAction = [UIAlertAction actionWithTitle:[@"first_start_exit" language]
|
|
style:UIAlertActionStyleDefault
|
|
handler:^(UIAlertAction * _Nonnull action) {
|
|
exit(0);
|
|
}];
|
|
|
|
UIAlertAction * waitAction = [UIAlertAction actionWithTitle:[@"first_start_wait" language]
|
|
style:UIAlertActionStyleDestructive
|
|
handler:^(UIAlertAction * _Nonnull action) {
|
|
}];
|
|
|
|
UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"提示"
|
|
message:@"APP 即将退出"
|
|
preferredStyle:UIAlertControllerStyleAlert];
|
|
[alertController addAction:exitAction];
|
|
[alertController addAction:waitAction];
|
|
[self presentViewController:alertController animated:YES completion:nil];
|
|
}
|
|
@end
|