新增app更新弹窗
This commit is contained in:
@@ -45,9 +45,6 @@
|
||||
043213B12F556DF80065C888 /* KBSkinIconMap_es.strings in Resources */ = {isa = PBXBuildFile; fileRef = 043213AB2F556DF80065C888 /* KBSkinIconMap_es.strings */; };
|
||||
043213B22F556DF80065C888 /* KBSkinIconMap_zh_hant.strings in Resources */ = {isa = PBXBuildFile; fileRef = 043213AE2F556DF80065C888 /* KBSkinIconMap_zh_hant.strings */; };
|
||||
043213B62F5582710065C888 /* spanish_words.json in Resources */ = {isa = PBXBuildFile; fileRef = 043213B52F5582710065C888 /* spanish_words.json */; };
|
||||
B7F1A1E52F90000100000001 /* english_words.json in Resources */ = {isa = PBXBuildFile; fileRef = B7F1A1E62F90000100000001 /* english_words.json */; };
|
||||
B7F1A1E12F90000100000001 /* portuguese_words.json in Resources */ = {isa = PBXBuildFile; fileRef = B7F1A1E32F90000100000001 /* portuguese_words.json */; };
|
||||
B7F1A1E22F90000100000001 /* indonesian_words.json in Resources */ = {isa = PBXBuildFile; fileRef = B7F1A1E42F90000100000001 /* indonesian_words.json */; };
|
||||
043213BD2F56A3920065C888 /* 西班牙初始皮肤.zip in Resources */ = {isa = PBXBuildFile; fileRef = 043213BC2F56A3920065C888 /* 西班牙初始皮肤.zip */; };
|
||||
043213BE2F56A3920065C888 /* 葡萄牙初始皮肤.zip in Resources */ = {isa = PBXBuildFile; fileRef = 043213BB2F56A3920065C888 /* 葡萄牙初始皮肤.zip */; };
|
||||
043213C02F56C9330065C888 /* 印度尼西亚初始皮肤.zip in Resources */ = {isa = PBXBuildFile; fileRef = 043213BF2F56C9330065C888 /* 印度尼西亚初始皮肤.zip */; };
|
||||
@@ -128,6 +125,7 @@
|
||||
047C65582EBCC06D0035E841 /* HomeRankCardCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C65572EBCC06D0035E841 /* HomeRankCardCell.m */; };
|
||||
047C655C2EBCD0F80035E841 /* UIView+KBShadow.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C655B2EBCD08E0035E841 /* UIView+KBShadow.m */; };
|
||||
047C655E2EBCD5B20035E841 /* UIImage+KBColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C655D2EBCD5B20035E841 /* UIImage+KBColor.m */; };
|
||||
04837ADC2F5830970012BDE2 /* KBAppUpdateView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04837ADB2F5830970012BDE2 /* KBAppUpdateView.m */; };
|
||||
048908BC2EBE1FCB00FABA60 /* BaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 048908BB2EBE1FCB00FABA60 /* BaseViewController.m */; };
|
||||
048908C32EBE32B800FABA60 /* KBSearchVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 048908C22EBE32B800FABA60 /* KBSearchVC.m */; };
|
||||
048908CC2EBE373500FABA60 /* KBSearchBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 048908C52EBE373500FABA60 /* KBSearchBarView.m */; };
|
||||
@@ -336,6 +334,9 @@
|
||||
B7F1A1D52F90000100000001 /* KBKeyboardLegacyLayoutProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = B7F1A1CF2F90000100000001 /* KBKeyboardLegacyLayoutProvider.m */; };
|
||||
B7F1A1D62F90000100000001 /* KBKeyboardInteractionHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = B7F1A1D82F90000100000001 /* KBKeyboardInteractionHandler.m */; };
|
||||
B7F1A1D92F90000100000001 /* KBKeyboardRowContainerBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = B7F1A1DB2F90000100000001 /* KBKeyboardRowContainerBuilder.m */; };
|
||||
B7F1A1E12F90000100000001 /* portuguese_words.json in Resources */ = {isa = PBXBuildFile; fileRef = B7F1A1E32F90000100000001 /* portuguese_words.json */; };
|
||||
B7F1A1E22F90000100000001 /* indonesian_words.json in Resources */ = {isa = PBXBuildFile; fileRef = B7F1A1E42F90000100000001 /* indonesian_words.json */; };
|
||||
B7F1A1E52F90000100000001 /* english_words.json in Resources */ = {isa = PBXBuildFile; fileRef = B7F1A1E62F90000100000001 /* english_words.json */; };
|
||||
EB72B60040437E3C0A4890FC /* KBShopThemeDetailModel.m in Sources */ = {isa = PBXBuildFile; fileRef = B9F60894E529C3EDAF6BAC3D /* KBShopThemeDetailModel.m */; };
|
||||
ECC9EE02174D86E8D792472F /* Pods_keyBoard.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 967065BB5230E43F293B3AF9 /* Pods_keyBoard.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
@@ -418,9 +419,6 @@
|
||||
043213AD2F556DF80065C888 /* KBSkinIconMap_pt.strings */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; path = KBSkinIconMap_pt.strings; sourceTree = "<group>"; };
|
||||
043213AE2F556DF80065C888 /* KBSkinIconMap_zh_hant.strings */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; path = KBSkinIconMap_zh_hant.strings; sourceTree = "<group>"; };
|
||||
043213B52F5582710065C888 /* spanish_words.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = spanish_words.json; sourceTree = "<group>"; };
|
||||
B7F1A1E32F90000100000001 /* portuguese_words.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = portuguese_words.json; sourceTree = "<group>"; };
|
||||
B7F1A1E42F90000100000001 /* indonesian_words.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = indonesian_words.json; sourceTree = "<group>"; };
|
||||
B7F1A1E62F90000100000001 /* english_words.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = english_words.json; sourceTree = "<group>"; };
|
||||
043213BB2F56A3920065C888 /* 葡萄牙初始皮肤.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = "葡萄牙初始皮肤.zip"; sourceTree = "<group>"; };
|
||||
043213BC2F56A3920065C888 /* 西班牙初始皮肤.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = "西班牙初始皮肤.zip"; sourceTree = "<group>"; };
|
||||
043213BF2F56C9330065C888 /* 印度尼西亚初始皮肤.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = "印度尼西亚初始皮肤.zip"; sourceTree = "<group>"; };
|
||||
@@ -540,6 +538,8 @@
|
||||
047C655B2EBCD08E0035E841 /* UIView+KBShadow.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIView+KBShadow.m"; sourceTree = "<group>"; };
|
||||
047C655C2EBCD5B20035E841 /* UIImage+KBColor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIImage+KBColor.h"; sourceTree = "<group>"; };
|
||||
047C655D2EBCD5B20035E841 /* UIImage+KBColor.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIImage+KBColor.m"; sourceTree = "<group>"; };
|
||||
04837ADA2F5830970012BDE2 /* KBAppUpdateView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBAppUpdateView.h; sourceTree = "<group>"; };
|
||||
04837ADB2F5830970012BDE2 /* KBAppUpdateView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBAppUpdateView.m; sourceTree = "<group>"; };
|
||||
048908BA2EBE1FCB00FABA60 /* BaseViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseViewController.h; sourceTree = "<group>"; };
|
||||
048908BB2EBE1FCB00FABA60 /* BaseViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BaseViewController.m; sourceTree = "<group>"; };
|
||||
048908C12EBE32B800FABA60 /* KBSearchVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBSearchVC.h; sourceTree = "<group>"; };
|
||||
@@ -928,6 +928,9 @@
|
||||
B7F1A1D82F90000100000001 /* KBKeyboardInteractionHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBKeyboardInteractionHandler.m; sourceTree = "<group>"; };
|
||||
B7F1A1DA2F90000100000001 /* KBKeyboardRowContainerBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBKeyboardRowContainerBuilder.h; sourceTree = "<group>"; };
|
||||
B7F1A1DB2F90000100000001 /* KBKeyboardRowContainerBuilder.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBKeyboardRowContainerBuilder.m; sourceTree = "<group>"; };
|
||||
B7F1A1E32F90000100000001 /* portuguese_words.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = portuguese_words.json; sourceTree = "<group>"; };
|
||||
B7F1A1E42F90000100000001 /* indonesian_words.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = indonesian_words.json; sourceTree = "<group>"; };
|
||||
B7F1A1E62F90000100000001 /* english_words.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = english_words.json; sourceTree = "<group>"; };
|
||||
B8CA018AB878499327504AAD /* Pods-CustomKeyboard.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CustomKeyboard.debug.xcconfig"; path = "Target Support Files/Pods-CustomKeyboard/Pods-CustomKeyboard.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
B9F60894E529C3EDAF6BAC3D /* KBShopThemeDetailModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBShopThemeDetailModel.m; sourceTree = "<group>"; };
|
||||
E2A844CD2D8584596DBE6316 /* KBShopThemeTagModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBShopThemeTagModel.m; sourceTree = "<group>"; };
|
||||
@@ -1445,6 +1448,8 @@
|
||||
042869FE2ECAEF2B00CE730C /* KBMoneyBtn.m */,
|
||||
048FFD252F28C6CF005D62AE /* KBImagePositionButton.h */,
|
||||
048FFD262F28C6CF005D62AE /* KBImagePositionButton.m */,
|
||||
04837ADA2F5830970012BDE2 /* KBAppUpdateView.h */,
|
||||
04837ADB2F5830970012BDE2 /* KBAppUpdateView.m */,
|
||||
);
|
||||
path = V;
|
||||
sourceTree = "<group>";
|
||||
@@ -2627,6 +2632,7 @@
|
||||
047C650D2EBC8A840035E841 /* KBPanModalView.m in Sources */,
|
||||
0450AC0A2EF11E4400B6AF06 /* StoreKitManager.swift in Sources */,
|
||||
0450AC0B2EF11E4400B6AF06 /* StoreKitStateConverter.swift in Sources */,
|
||||
04837ADC2F5830970012BDE2 /* KBAppUpdateView.m in Sources */,
|
||||
0450AC0C2EF11E4400B6AF06 /* SubscriptionLocale.swift in Sources */,
|
||||
0450AC0D2EF11E4400B6AF06 /* StoreKitConverter.swift in Sources */,
|
||||
0450AC0E2EF11E4400B6AF06 /* StoreKitError.swift in Sources */,
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#import "KBLoginVC.h"
|
||||
#import "KBConfig.h"
|
||||
#import "KBSkinInstallBridge.h"
|
||||
#import "KBAppUpdateView.h"
|
||||
|
||||
static NSTimeInterval const kKBSubscriptionPrefillTTL = 10 * 60.0;
|
||||
|
||||
@@ -34,6 +35,10 @@ static NSTimeInterval const kKBSubscriptionPrefillTTL = 10 * 60.0;
|
||||
// 当前工程的 CustomKeyboard target 为 com.loveKey.nyx.CustomKeyboard
|
||||
//static NSString * const kKBKeyboardExtensionBundleId = @"com.loveKey.nyx.CustomKeyboard";
|
||||
|
||||
@interface AppDelegate () <KBAppUpdateViewDelegate>
|
||||
@property (nonatomic, strong) LSTPopView *appUpdatePopView;
|
||||
@end
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
|
||||
@@ -68,6 +73,8 @@ static NSTimeInterval const kKBSubscriptionPrefillTTL = 10 * 60.0;
|
||||
// 安装默认皮肤(首次安装时)
|
||||
[self kb_installDefaultSkinIfNeeded];
|
||||
|
||||
[self kb_requestAppUpdateAndPresentIfNeeded];
|
||||
|
||||
#if !DEBUG
|
||||
/// Bugly
|
||||
BuglyConfig *buglyConfig = [BuglyConfig new];
|
||||
@@ -79,6 +86,34 @@ static NSTimeInterval const kKBSubscriptionPrefillTTL = 10 * 60.0;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)kb_requestAppUpdateAndPresentIfNeeded {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
if (self.appUpdatePopView) { return; }
|
||||
CGFloat width = KBFit(323.0);
|
||||
CGFloat height = KBFit(390.0);
|
||||
KBAppUpdateView *view = [[KBAppUpdateView alloc] initWithFrame:CGRectMake(0, 0, width, height)];
|
||||
view.backgroundImageName = @"app_update_bg";
|
||||
view.delegate = self;
|
||||
LSTPopView *pop = [LSTPopView initWithCustomView:view
|
||||
parentView:nil
|
||||
popStyle:LSTPopStyleScale
|
||||
dismissStyle:LSTDismissStyleScale];
|
||||
pop.hemStyle = LSTHemStyleCenter;
|
||||
pop.bgColor = [[UIColor blackColor] colorWithAlphaComponent:0.4];
|
||||
pop.isClickBgDismiss = NO;
|
||||
pop.cornerRadius = 0;
|
||||
self.appUpdatePopView = pop;
|
||||
[pop pop];
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - KBAppUpdateViewDelegate
|
||||
|
||||
- (void)appUpdateViewDidTapUpgrade:(KBAppUpdateView *)view {
|
||||
[self.appUpdatePopView dismiss];
|
||||
self.appUpdatePopView = nil;
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application{
|
||||
// [self kb_checkNetworkAndShowAlertIfNeeded];
|
||||
|
||||
|
||||
22
keyBoard/Assets.xcassets/Ohter/app_update_bg.imageset/Contents.json
vendored
Normal file
22
keyBoard/Assets.xcassets/Ohter/app_update_bg.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "app_update_bg@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "app_update_bg@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
keyBoard/Assets.xcassets/Ohter/app_update_bg.imageset/app_update_bg@2x.png
vendored
Normal file
BIN
keyBoard/Assets.xcassets/Ohter/app_update_bg.imageset/app_update_bg@2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 96 KiB |
BIN
keyBoard/Assets.xcassets/Ohter/app_update_bg.imageset/app_update_bg@3x.png
vendored
Normal file
BIN
keyBoard/Assets.xcassets/Ohter/app_update_bg.imageset/app_update_bg@3x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 236 KiB |
30
keyBoard/Class/Common/V/KBAppUpdateView.h
Normal file
30
keyBoard/Class/Common/V/KBAppUpdateView.h
Normal file
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// KBAppUpdateView.h
|
||||
// keyBoard
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class KBAppUpdateView;
|
||||
|
||||
@protocol KBAppUpdateViewDelegate <NSObject>
|
||||
@optional
|
||||
- (void)appUpdateViewDidTapUpgrade:(KBAppUpdateView *)view;
|
||||
@end
|
||||
|
||||
@interface KBAppUpdateView : UIView
|
||||
|
||||
@property (nonatomic, weak) id<KBAppUpdateViewDelegate> delegate;
|
||||
|
||||
@property (nonatomic, copy) NSString *backgroundImageName;
|
||||
@property (nonatomic, copy) NSString *titleText;
|
||||
@property (nonatomic, copy) NSString *versionText;
|
||||
@property (nonatomic, copy) NSString *contentTitleText;
|
||||
@property (nonatomic, copy) NSArray<NSString *> *contentItems;
|
||||
@property (nonatomic, copy) NSString *upgradeButtonTitle;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
244
keyBoard/Class/Common/V/KBAppUpdateView.m
Normal file
244
keyBoard/Class/Common/V/KBAppUpdateView.m
Normal file
@@ -0,0 +1,244 @@
|
||||
//
|
||||
// KBAppUpdateView.m
|
||||
// keyBoard
|
||||
//
|
||||
|
||||
#import "KBAppUpdateView.h"
|
||||
|
||||
@interface KBAppUpdateView ()
|
||||
@property (nonatomic, strong) UIImageView *backgroundImageView;
|
||||
@property (nonatomic, strong) UILabel *titleLabel;
|
||||
@property (nonatomic, strong) UIView *versionBadgeView;
|
||||
@property (nonatomic, strong) UILabel *versionLabel;
|
||||
@property (nonatomic, strong) UILabel *contentTitleLabel;
|
||||
@property (nonatomic, strong) UILabel *contentLabel;
|
||||
@property (nonatomic, strong) UIButton *upgradeButton;
|
||||
@end
|
||||
|
||||
@implementation KBAppUpdateView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
self.layer.cornerRadius = KBFit(22.0);
|
||||
self.layer.masksToBounds = YES;
|
||||
[self setupUI];
|
||||
[self setupConstraints];
|
||||
[self applyDefaultTexts];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder {
|
||||
if (self = [super initWithCoder:coder]) {
|
||||
self.backgroundColor = [UIColor whiteColor];
|
||||
self.layer.cornerRadius = KBFit(22.0);
|
||||
self.layer.masksToBounds = YES;
|
||||
[self setupUI];
|
||||
[self setupConstraints];
|
||||
[self applyDefaultTexts];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Setup
|
||||
|
||||
- (void)setupUI {
|
||||
[self addSubview:self.backgroundImageView];
|
||||
[self addSubview:self.titleLabel];
|
||||
[self addSubview:self.versionBadgeView];
|
||||
[self.versionBadgeView addSubview:self.versionLabel];
|
||||
[self addSubview:self.contentTitleLabel];
|
||||
[self addSubview:self.contentLabel];
|
||||
[self addSubview:self.upgradeButton];
|
||||
}
|
||||
|
||||
- (void)setupConstraints {
|
||||
[self.backgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self);
|
||||
}];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self).offset(KBFit(45.0));
|
||||
make.top.equalTo(self).offset(KBFit(70.0));
|
||||
make.right.lessThanOrEqualTo(self).offset(-KBFit(24.0));
|
||||
}];
|
||||
|
||||
[self.versionBadgeView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self).offset(KBFit(45.0));
|
||||
make.top.equalTo(self).offset(KBFit(120.0));
|
||||
make.width.mas_equalTo(KBFit(73.0));
|
||||
make.height.mas_equalTo(KBFit(23.0));
|
||||
}];
|
||||
|
||||
[self.versionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self.versionBadgeView);
|
||||
}];
|
||||
|
||||
[self.contentTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self).offset(KBFit(45.0));
|
||||
make.top.equalTo(self).offset(KBFit(181.0));
|
||||
make.right.lessThanOrEqualTo(self).offset(-KBFit(20.0));
|
||||
}];
|
||||
|
||||
[self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self).offset(KBFit(45.0));
|
||||
make.top.equalTo(self.contentTitleLabel.mas_bottom).offset(KBFit(8.0));
|
||||
make.right.lessThanOrEqualTo(self).offset(-KBFit(20.0));
|
||||
make.bottom.lessThanOrEqualTo(self.upgradeButton.mas_top).offset(-KBFit(16.0));
|
||||
}];
|
||||
|
||||
[self.upgradeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self);
|
||||
make.bottom.equalTo(self).offset(-KBFit(12.0));
|
||||
make.width.mas_equalTo(KBFit(230.0));
|
||||
make.height.mas_equalTo(KBFit(45.0));
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)applyDefaultTexts {
|
||||
self.titleText = KBLocalized(@"");
|
||||
self.versionText = @"V1.1.4";
|
||||
self.contentTitleText = KBLocalized(@"Ver. Update Content");
|
||||
self.contentItems = @[
|
||||
KBLocalized(@"AAAAAAAAAAAAAAAAAAA"),
|
||||
KBLocalized(@"SSSSSSSSSSSSSSSSSSS")
|
||||
];
|
||||
self.upgradeButtonTitle = KBLocalized(@"立即升级");
|
||||
}
|
||||
|
||||
#pragma mark - Actions
|
||||
|
||||
- (void)onTapUpgrade {
|
||||
if ([self.delegate respondsToSelector:@selector(appUpdateViewDidTapUpgrade:)]) {
|
||||
[self.delegate appUpdateViewDidTapUpgrade:self];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Setters
|
||||
|
||||
- (void)setBackgroundImageName:(NSString *)backgroundImageName {
|
||||
_backgroundImageName = [backgroundImageName copy];
|
||||
if (_backgroundImageName.length > 0) {
|
||||
self.backgroundImageView.image = [UIImage imageNamed:_backgroundImageName];
|
||||
} else {
|
||||
self.backgroundImageView.image = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setTitleText:(NSString *)titleText {
|
||||
_titleText = [titleText copy];
|
||||
self.titleLabel.text = _titleText;
|
||||
}
|
||||
|
||||
- (void)setVersionText:(NSString *)versionText {
|
||||
_versionText = [versionText copy];
|
||||
self.versionLabel.text = _versionText;
|
||||
}
|
||||
|
||||
- (void)setContentTitleText:(NSString *)contentTitleText {
|
||||
_contentTitleText = [contentTitleText copy];
|
||||
self.contentTitleLabel.text = _contentTitleText;
|
||||
}
|
||||
|
||||
- (void)setContentItems:(NSArray<NSString *> *)contentItems {
|
||||
_contentItems = [contentItems copy];
|
||||
self.contentLabel.text = [self formattedContentItems:_contentItems];
|
||||
}
|
||||
|
||||
- (void)setUpgradeButtonTitle:(NSString *)upgradeButtonTitle {
|
||||
_upgradeButtonTitle = [upgradeButtonTitle copy];
|
||||
[self.upgradeButton setTitle:_upgradeButtonTitle forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
#pragma mark - Helpers
|
||||
|
||||
- (NSString *)formattedContentItems:(NSArray<NSString *> *)items {
|
||||
if (items.count == 0) {
|
||||
return @"";
|
||||
}
|
||||
NSMutableArray<NSString *> *lines = [NSMutableArray array];
|
||||
[items enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL *stop) {
|
||||
if (![obj isKindOfClass:[NSString class]] || obj.length == 0) {
|
||||
return;
|
||||
}
|
||||
NSString *line = [NSString stringWithFormat:@"%lu、%@", (unsigned long)(idx + 1), obj];
|
||||
[lines addObject:line];
|
||||
}];
|
||||
return [lines componentsJoinedByString:@"\n"];
|
||||
}
|
||||
|
||||
#pragma mark - Lazy
|
||||
|
||||
- (UIImageView *)backgroundImageView {
|
||||
if (!_backgroundImageView) {
|
||||
_backgroundImageView = [[UIImageView alloc] init];
|
||||
_backgroundImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
_backgroundImageView.clipsToBounds = YES;
|
||||
}
|
||||
return _backgroundImageView;
|
||||
}
|
||||
|
||||
- (UILabel *)titleLabel {
|
||||
if (!_titleLabel) {
|
||||
_titleLabel = [[UILabel alloc] init];
|
||||
_titleLabel.numberOfLines = 0;
|
||||
_titleLabel.font = [KBFont bold:26.0];
|
||||
_titleLabel.textColor = [UIColor colorWithHex:0xF6FCFF];
|
||||
}
|
||||
return _titleLabel;
|
||||
}
|
||||
|
||||
- (UIView *)versionBadgeView {
|
||||
if (!_versionBadgeView) {
|
||||
_versionBadgeView = [[UIView alloc] init];
|
||||
_versionBadgeView.backgroundColor = [UIColor colorWithHex:0xFFDE67];
|
||||
_versionBadgeView.layer.cornerRadius = KBFit(11.5);
|
||||
_versionBadgeView.layer.masksToBounds = YES;
|
||||
}
|
||||
return _versionBadgeView;
|
||||
}
|
||||
|
||||
- (UILabel *)versionLabel {
|
||||
if (!_versionLabel) {
|
||||
_versionLabel = [[UILabel alloc] init];
|
||||
_versionLabel.font = [KBFont regular:14.0];
|
||||
_versionLabel.textColor = [UIColor colorWithHex:0x3D3D3D];
|
||||
_versionLabel.textAlignment = NSTextAlignmentCenter;
|
||||
}
|
||||
return _versionLabel;
|
||||
}
|
||||
|
||||
- (UILabel *)contentTitleLabel {
|
||||
if (!_contentTitleLabel) {
|
||||
_contentTitleLabel = [[UILabel alloc] init];
|
||||
_contentTitleLabel.font = [KBFont regular:18.0];
|
||||
_contentTitleLabel.textColor = [UIColor colorWithHex:0x085E59];
|
||||
}
|
||||
return _contentTitleLabel;
|
||||
}
|
||||
|
||||
- (UILabel *)contentLabel {
|
||||
if (!_contentLabel) {
|
||||
_contentLabel = [[UILabel alloc] init];
|
||||
_contentLabel.numberOfLines = 0;
|
||||
_contentLabel.font = [KBFont medium:13.0];
|
||||
_contentLabel.textColor = [UIColor colorWithHex:0x085E59];
|
||||
}
|
||||
return _contentLabel;
|
||||
}
|
||||
|
||||
- (UIButton *)upgradeButton {
|
||||
if (!_upgradeButton) {
|
||||
_upgradeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
_upgradeButton.backgroundColor = [UIColor colorWithHex:0x002339];
|
||||
_upgradeButton.layer.cornerRadius = KBFit(22.5);
|
||||
_upgradeButton.layer.masksToBounds = YES;
|
||||
_upgradeButton.titleLabel.font = [KBFont bold:14.0];
|
||||
[_upgradeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
||||
[_upgradeButton addTarget:self action:@selector(onTapUpgrade) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _upgradeButton;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user