青少年弹框

This commit is contained in:
fengshuo
2021-12-07 11:08:43 +08:00
parent 62b016fb1a
commit ecbb2cfa53
7 changed files with 39 additions and 27 deletions

View File

@@ -12,6 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface XPConstant : NSObject
UIKIT_EXTERN NSString * const kWeChatNumber;
UIKIT_EXTERN NSString * const kTeenagerAlertDatekey;
typedef NS_ENUM(NSUInteger, KeyType) {
KeyType_PasswordEncode,///密码 des 加密的

View File

@@ -10,6 +10,7 @@
@implementation XPConstant
NSString * const kWeChatNumber = @"yinyoucc";
NSString * const kTeenagerAlertDatekey = @"kTeenagerAlertDatekey";
///
NSString * const KeyWithType(KeyType type) {

View File

@@ -27,7 +27,7 @@
[[self getView] openOrCloseParentSuccessStatus:status];
} fail:^(NSInteger code, NSString * _Nullable msg) {
}] password:newpasswordDes status:@(status) uid:uid];
} showLoading:YES] password:newpasswordDes status:@(status) uid:uid];
}
@end

View File

@@ -8,19 +8,10 @@
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@protocol XPTeenagerAlertViewDelegate <NSObject>
///隐藏view
- (void)hiddeView;
///点击了去设置青年模式
- (void)didClickTeenagerButtonAction:(UIButton *)button;
@end
@interface XPTeenagerAlertView : UIView
/** */
@property (nonatomic,weak) id<XPTeenagerAlertViewDelegate> delegate;
///push 操作的控制器
@property (nonatomic,weak) UIViewController * controller;;
@end
NS_ASSUME_NONNULL_END

View File

@@ -12,6 +12,9 @@
#import "ThemeColor.h"
#import "UIImage+Utils.h"
#import "UIButton+EnlargeTouchArea.h"
#import "TTPopup.h"
#import "XPMineTeenagerViewController.h"
@interface XPTeenagerAlertView ()
@property (nonatomic, strong) UIView *bgView;
@@ -24,6 +27,7 @@
@implementation XPTeenagerAlertView
#pragma mark lifeCycle
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
@@ -82,15 +86,13 @@
#pragma mark Event Response
- (void)onClickCloseButtonAction:(UIButton *)closeButton {
if (self.delegate && [self.delegate respondsToSelector:@selector(hiddeView)]) {
[self.delegate hiddeView];
}
[TTPopup dismiss];
}
- (void)onClickTeeagersButtonAction:(UIButton *)teeagersButton {
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickTeenagerButtonAction:)]) {
[self.delegate didClickTeenagerButtonAction:teeagersButton];
}
[TTPopup dismiss];
XPMineTeenagerViewController * teenagerVC = [[XPMineTeenagerViewController alloc] init];
[self.controller.navigationController pushViewController:teenagerVC animated:YES];
}
#pragma mark Getters and Setters
@@ -125,7 +127,7 @@
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Bold" size:16];
_titleLabel.textColor = [ThemeColor mainTextColor];
_titleLabel.textColor = [ThemeColor alertTitleColor];
_titleLabel.textAlignment = NSTextAlignmentCenter;
_titleLabel.text = @"青少年保护";
}
@@ -136,11 +138,11 @@
if (!_textLabel) {
_textLabel = [[UILabel alloc] init];
_textLabel.font = [UIFont systemFontOfSize:13];
_textLabel.textColor = [ThemeColor secondTextColor];
_textLabel.textColor = [ThemeColor textThirdColor];
_textLabel.numberOfLines = 0;
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:3]; //
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"为呵护青少年健康成长,音游推出“青少年模式”,该模式下针对青少年推送精选优化的内容。"];
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"为呵护青少年健康成长,%@推出“青少年模式”,该模式下针对青少年推送精选优化的内容。", AppName]];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [attributedString length])];
_textLabel.attributedText = attributedString;
}

View File

@@ -135,10 +135,9 @@
}
#pragma mark - XPMineTeenagePwdViewControllerDelegate
///
- (void)didChangeTeenagerStatus:(BOOL)status {
UserInfoModel * userInfo = self.userInfo;
userInfo.parentMode = status;
userInfo.parentMode = status;
self.userInfo = userInfo;
}
#pragma mark - Event Response

View File

@@ -15,6 +15,8 @@
#import "UIImage+Utils.h"
#import "XCHUDTool.h"
#import "AccountInfoStorage.h"
#import "TTPopup.h"
#import "XPConstant.h"
///Model
#import "AccountModel.h"
///VC
@@ -29,6 +31,7 @@
#import "SessionListViewController.h"
#import "XPHomeContainerViewController.h"
#import "XPMiniRoomView.h"
#import "XPTeenagerAlertView.h"
///Present
#import "MainPresenter.h"
#import "MainProtocol.h"
@@ -95,6 +98,7 @@
return;
}
[self initTabs:YES];
[self showTeenagerAlertView:userInfo];
}
#pragma mark - BaseMvpProtocol
@@ -210,4 +214,18 @@
[self.view addSubview:[XPMiniRoomView shareMiniRoomView]];
}
#pragma mark -
- (void)showTeenagerAlertView:(UserInfoModel *)userInfo {
if (!userInfo || userInfo.uid <=0) return; ///
if (userInfo.parentMode) return;//
NSString * teenagerKey = [NSString stringWithFormat:@"%@_%ld", kTeenagerAlertDatekey, userInfo.uid];
NSDate * oldDate = [[NSUserDefaults standardUserDefaults] objectForKey:teenagerKey];
BOOL isSameDay = [[NSCalendar currentCalendar] isDateInToday:oldDate];
if (isSameDay) return;
XPTeenagerAlertView * teenagerView = [[XPTeenagerAlertView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth - 45, 260)];
teenagerView.controller = self;
[TTPopup popupView:teenagerView style:TTPopupStyleAlert];
[[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:teenagerKey];
}
@end