小说绘上架版本

This commit is contained in:
xtfei2011
2021-02-07 11:24:08 +08:00
commit ee5c1c8b12
1762 changed files with 115892 additions and 0 deletions
@@ -0,0 +1,20 @@
//
// TFPushSetModel.h
// WXReader
//
// Created by 谢腾飞 on 2020/12/2.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface TFPushSetModel : NSObject
@property (nonatomic ,copy) NSString *label; // 名称
@property (nonatomic ,copy) NSString *push_key; // 开关对应key
@property (nonatomic ,assign) NSInteger status; // 状态 1-开启 0-关闭(后端默认开启)
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,13 @@
//
// TFPushSetModel.m
// WXReader
//
// Created by 谢腾飞 on 2020/12/2.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFPushSetModel.h"
@implementation TFPushSetModel
@end
@@ -0,0 +1,20 @@
//
// TFPushSetTableViewCell.h
// WXReader
//
// Created by 谢腾飞 on 2020/12/2.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFSetBasicTableViewCell.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFPushSetTableViewCell : TFSetBasicTableViewCell
@property (nonatomic ,assign) BOOL allowedPush;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,85 @@
//
// TFPushSetTableViewCell.m
// WXReader
//
// Created by 谢腾飞 on 2020/12/2.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFPushSetTableViewCell.h"
@interface TFPushSetTableViewCell ()
{
UIButton *openButton;
UIImageView *connerImageView;
}
@end
@implementation TFPushSetTableViewCell
- (void)createSubviews
{
[super createSubviews];
connerImageView = [[UIImageView alloc] init];
connerImageView.image = [UIImage imageNamed:@"public_more"];
[self.contentView addSubview:connerImageView];
[connerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
make.centerY.mas_equalTo(self.contentView.mas_centerY);
make.width.height.mas_equalTo(10);
}];
openButton = [UIButton buttonWithType:UIButtonTypeCustom];
[openButton setTitle:TFLocalizedString(@"点击开启") forState:UIControlStateNormal];
[openButton setTitleColor:kBlackColor forState:UIControlStateNormal];
[openButton.titleLabel setFont:kFont12];
[openButton addTarget:self action:@selector(permissionsClick) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:openButton];
[openButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(connerImageView.mas_left).with.offset(- kHalfMargin);
make.centerY.mas_equalTo(self.contentView.mas_centerY);
make.width.mas_equalTo(60);
make.height.mas_equalTo(self.leftTitleLabel.mas_height);
}];
}
- (void)setAllowedPush:(BOOL)allowedPush
{
_allowedPush = allowedPush;
if (allowedPush) {
[openButton setTitle:TFLocalizedString(@"已开启") forState:UIControlStateNormal];
CGFloat width = [TFViewHelper getDynamicWidthWithLabelFont:kFont12 labelHeight:30.0 labelText:TFLocalizedString(@"已开启") maxWidth:SCREEN_WIDTH / 2.0];
[openButton mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(width);
}];
[openButton setTitleColor:kGrayTextColor forState:UIControlStateNormal];
[connerImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.contentView.mas_right).with.offset(CGFLOAT_MIN);
make.width.mas_equalTo(CGFLOAT_MIN);
}];
} else {
[openButton setTitle:TFLocalizedString(@"点击开启") forState:UIControlStateNormal];
CGFloat width = [TFViewHelper getDynamicWidthWithLabelFont:kFont12 labelHeight:30.0 labelText:TFLocalizedString(@"点击开启") maxWidth:SCREEN_WIDTH / 2.0];
[openButton mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(width);
}];
[openButton setTitleColor:kBlackColor forState:UIControlStateNormal];
[connerImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
make.width.mas_equalTo(10);
}];
}
}
- (void)permissionsClick
{
if (!_allowedPush) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
}
}
@end
@@ -0,0 +1,17 @@
//
// TFPushSetViewController.h
// WXReader
//
// Created by 谢腾飞 on 2020/12/2.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface TFPushSetViewController : TFBasicViewController
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,177 @@
//
// TFPushSetViewController.m
// WXReader
//
// Created by 谢腾飞 on 2020/12/2.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFPushSetViewController.h"
#import <UserNotifications/UserNotifications.h>
#import "TFSetSwitchTableViewCell.h"
#import "TFPushSetTableViewCell.h"
#import "TFPushSetModel.h"
@interface TFPushSetViewController () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic ,assign) BOOL allowedPush;
@end
@implementation TFPushSetViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self initialize];
[self createSubviews];
[self currentNotificationStatus];
[self netRequest];
}
- (void)initialize
{
[self setNavigationBarTitle:TFLocalizedString(@"通知管理")];
self.view.backgroundColor = kGrayViewColor;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(currentNotificationStatus) name:UIApplicationDidBecomeActiveNotification object:nil];
}
- (void)createSubviews
{
self.mainTableViewGroup.delegate = self;
self.mainTableViewGroup.dataSource = self;
[self.view addSubview:self.mainTableViewGroup];
[self.mainTableViewGroup mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(0);
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT);
make.width.mas_equalTo(SCREEN_WIDTH);
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT);
}];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
if (self.allowedPush) {
return 2;
}
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 1) {
return self.dataSourceArray.count;
}
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
TFPushSetTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFPushSetTableViewCell"];
if (!cell) {
cell = [[TFPushSetTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFPushSetTableViewCell"];
}
cell.leftTitleText = TFLocalizedString(@"设置新消息通知");
cell.allowedPush = self.allowedPush;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
WS(weakSelf)
TFPushSetModel *settingModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
TFSetSwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFSetSwitchTableViewCell0"];
if (!cell) {
cell = [[TFSetSwitchTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFSetSwitchTableViewCell0"];
}
cell.leftTitleText = settingModel.label?:@"";
cell.hiddenEndLine = NO;
if (settingModel.status == 1) {
[cell.switchButton setDefaultOnState:YES];
} else {
[cell.switchButton setDefaultOnState:NO];
}
cell.switchButton.didChangeHandler = ^(BOOL isOn) {
[weakSelf switchPushStateRequest:settingModel.push_key];
};
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
//section头部间距
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return kHalfMargin;
}
//section头部视图
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *view = [[UIView alloc] init];
view.backgroundColor = [UIColor clearColor];
return view;
}
//section底部间距
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
if (section == 0) {
return 30;
}
return CGFLOAT_MIN;
}
//section底部视图
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 30)];
view.backgroundColor = [UIColor clearColor];
if (section == 0) {
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(kMargin, 0, SCREEN_WIDTH - 2 * kMargin, 30)];
label.backgroundColor = [UIColor clearColor];
label.text = [NSString stringWithFormat:TFLocalizedString(@"请在 iPhone 的“设置”-“%@”设置开启/关闭"), App_Name];
label.textColor = kGrayTextColor;
label.font = kFont10;
[view addSubview:label];
}
return view;
}
- (void)currentNotificationStatus
{
WS(weakSelf)
if (@available(iOS 10 , *)) {
[[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
if (settings.authorizationStatus == UNAuthorizationStatusDenied) {
weakSelf.allowedPush = NO;
} else {
weakSelf.allowedPush = YES;
}
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf.mainTableViewGroup reloadData];
});
}];
}
}
- (void)netRequest
{
WS(weakSelf)
[TFNetworkTools POST:User_Push_State parameters:nil model:nil success:^(BOOL isSuccess, NSDictionary *_Nullable t_model, TFNetworkRequestModel *requestModel) {
if (isSuccess) {
for (NSDictionary *t_dic in [[t_model objectForKey:@"data"] objectForKey:@"list"]) {
[weakSelf.dataSourceArray addObject:[TFPushSetModel modelWithDictionary:t_dic]];
}
[weakSelf.mainTableViewGroup reloadData];
}
} failure:nil];
}
- (void)switchPushStateRequest:(NSString *)push_key
{
[TFNetworkTools POST:User_Update_Push_State parameters:@{@"push_key":push_key?:@""} model:nil success:nil failure:nil];
}
@end