123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- //
- // XYAboutViewController.m
- // Starbuds
- //
- // Created by 翟玉磊 on 2020/1/15.
- // Copyright © 2020 翟玉磊. All rights reserved.
- //
- #import "XYAboutViewController.h"
- #import "XYAboutViewModel.h"
- #import "XYDevelopmentModeViewController.h"
- @interface XYAboutViewController ()
- @property (nonatomic, strong) XYAboutViewModel *viewModel;
- @property (nonatomic, readwrite, strong) UIImageView *logoImageView;
- @property (nonatomic, readwrite, strong) UILabel *appNameLabel;
- @property (nonatomic, readwrite, strong) UILabel *versionLabel;
- @property (nonatomic, readwrite, strong) UILabel *channelLabel;
- @property (nonatomic, readwrite, strong) UILabel *introduceLabel;
- @property (nonatomic, assign) NSInteger tapIndex;
- @end
- @implementation XYAboutViewController
- /// 重写init方法,配置你想要的属性
- - (instancetype)init
- {
- self = [super init];
- if (self) {
-
- }
- return self;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- /// 设置
- [self _setup];
-
- /// 设置导航栏
- [self _setupNavigationItem];
-
- /// 设置子控件
- [self _setupSubViews];
-
- /// 布局子空间
- [self _makeSubViewsConstraints];
- }
- #pragma mark — Override
- - (void)bindViewModel {
- self.viewModel = XYAboutViewModel.new;
- }
- - (UIEdgeInsets)contentInset {
- return UIEdgeInsetsMake(NAVGATION_HEIGHT + 250.0f, 0, 0, 0);
- }
- - (void)requestRemoteData {
- [self.viewModel loadData:^(id _Nullable responseModel) {
- [self reloadData];
- } failure:^(ZYLNetworkError * _Nullable error) {
-
- }];
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
- return [EmptyTableViewCell cellWithTableView:tableView];
- }
- - (void)configureCell:(EmptyTableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
- [cell configureModel:object];
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- EmptyCellModel *model = self.viewModel.dataSource[indexPath.row];
- return model.cellHeight;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
-
- EmptyCellModel *model = self.viewModel.dataSource[indexPath.row];
- if ([model.title isEqualToString:@"软件更新"]) {
- [ApplicationDelegate checkVersionUpdates:YES];
- }else if ([model.title isEqualToString:@"开发模式"]) {
- [self.navigationController pushViewController:XYDevelopmentModeViewController.new animated:YES];
- }
- }
- #pragma mark - 事件处理Or辅助方法
- - (void)logoImageTapAction:(id)sender {
- _tapIndex++;
- if (_tapIndex == 5) {
- _tapIndex = 0;
- self.viewModel.developmentMode = YES;
- [self requestRemoteData];
- }
- }
- #pragma mark - 初始化
- - (void)_setup{
- self.title = kLocalizedString(@"关于我们");
- self.view.backgroundColor = Color_White;
-
- self.tableView.scrollEnabled = NO;
- }
- #pragma mark - 设置导航栏
- - (void)_setupNavigationItem{
-
- }
- #pragma mark - 设置子控件
- - (void)_setupSubViews{
- [self.view addSubview:self.logoImageView];
- [self.view addSubview:self.appNameLabel];
- [self.view addSubview:self.versionLabel];
- [self.view addSubview:self.channelLabel];
- [self.view addSubview:self.introduceLabel];
-
- self.logoImageView.image = ImageNamed(@"icon_logo_114");
- self.appNameLabel.text = APP_NAME;
- self.versionLabel.text = [NSString stringWithFormat:@"v%@_%@", APP_VERSION, APP_BUILD];
- self.channelLabel.text = [NSString stringWithFormat:@"c%@", APP_Channel_Id];
- self.introduceLabel.text = APP_Introduce;
-
- }
- #pragma mark - 布局子控件
- - (void)_makeSubViewsConstraints{
-
- [self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.view).offset(NAVGATION_HEIGHT + 32.0f);
- make.centerX.equalTo(self.view);
- make.width.height.equalTo(@80.0f);
- }];
- [self.appNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.view).offset(SPACING_EDGE);
- make.right.equalTo(self.view).offset(-SPACING_EDGE);
- make.top.equalTo(self.logoImageView.mas_bottom).offset(14.0f);
- make.height.equalTo(@25.0f);
- }];
- [self.versionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.view).offset(SPACING_EDGE);
- make.right.equalTo(self.view).offset(-SPACING_EDGE);
- make.top.equalTo(self.appNameLabel.mas_bottom).offset(10.0f);
- make.height.equalTo(@20.0f);
- }];
- [self.channelLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.view).offset(SPACING_EDGE);
- make.right.equalTo(self.view).offset(-SPACING_EDGE);
- make.top.equalTo(self.versionLabel.mas_bottom).offset(0.0f);
- make.height.equalTo(@20.0f);
- }];
- [self.introduceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.view).offset(SPACING_EDGE);
- make.right.equalTo(self.view).offset(-SPACING_EDGE);
- make.top.equalTo(self.channelLabel.mas_bottom).offset(20.0f);
- make.bottom.lessThanOrEqualTo(self.view).offset(-20.0f);
- }];
-
- [self.logoImageView addViewBorder:Color_Clear redian:5];
- }
- #pragma mark - Setter & Getter
- - (UIImageView *)logoImageView {
- if (!_logoImageView) {
- _logoImageView = [UIImageView new];
- _logoImageView.userInteractionEnabled = YES;
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(logoImageTapAction: )];
- [_logoImageView addGestureRecognizer:tap];
- }
- return _logoImageView;
- }
- - (UILabel *)appNameLabel {
- if (!_appNameLabel) {
- _appNameLabel = [UILabel createLabelTextColor:Color_TextFont fount:Font_B(18)];
- _appNameLabel.textAlignment = NSTextAlignmentCenter;
- }
- return _appNameLabel;
- }
- - (UILabel *)versionLabel {
- if (!_versionLabel) {
- _versionLabel = [UILabel createLabelTextColor:Color_TextFont fount:Font_B(15)];
- _versionLabel.textAlignment = NSTextAlignmentCenter;
- }
- return _versionLabel;
- }
- - (UILabel *)channelLabel {
- if (!_channelLabel) {
- _channelLabel = [UILabel createLabelTextColor:Color_LightGray fount:Font_B(15)];
- _channelLabel.textAlignment = NSTextAlignmentCenter;
- }
- return _channelLabel;
- }
- - (UILabel *)introduceLabel {
- if (!_introduceLabel) {
- _introduceLabel = [UILabel createLabelTextColor:Color_TextFont fount:Font(14)];
- _introduceLabel.numberOfLines = 0;
- }
- return _introduceLabel;
- }
- @end
|