添加键盘里的充值界面
This commit is contained in:
55
CustomKeyboard/Model/KBKeyboardSubscriptionProduct.m
Normal file
55
CustomKeyboard/Model/KBKeyboardSubscriptionProduct.m
Normal file
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// KBKeyboardSubscriptionProduct.m
|
||||
// CustomKeyboard
|
||||
//
|
||||
|
||||
#import "KBKeyboardSubscriptionProduct.h"
|
||||
#import <MJExtension/MJExtension.h>
|
||||
#import "KBLocalizationManager.h"
|
||||
|
||||
@implementation KBKeyboardSubscriptionProduct
|
||||
|
||||
+ (NSDictionary *)mj_replacedKeyFromPropertyName {
|
||||
return @{
|
||||
@"identifier": @"id",
|
||||
@"productDescription": @"description",
|
||||
};
|
||||
}
|
||||
|
||||
- (NSString *)displayTitle {
|
||||
if (self.productDescription.length > 0) {
|
||||
return self.productDescription;
|
||||
}
|
||||
NSString *name = self.name ?: @"";
|
||||
NSString *unit = self.unit ?: @"";
|
||||
if (name.length && unit.length) {
|
||||
return [NSString stringWithFormat:@"%@ %@", name, unit];
|
||||
}
|
||||
if (name.length) { return name; }
|
||||
if (unit.length) { return unit; }
|
||||
if (self.durationValue > 0 && self.durationUnit.length > 0) {
|
||||
return [NSString stringWithFormat:@"%ld %@", (long)self.durationValue, self.durationUnit];
|
||||
}
|
||||
return KBLocalized(@"Subscription");
|
||||
}
|
||||
|
||||
- (NSString *)priceDisplayText {
|
||||
double priceValue = self.price;
|
||||
if (priceValue <= 0) {
|
||||
return @"$0.00";
|
||||
}
|
||||
NSString *currency = self.currency.length ? self.currency : @"$";
|
||||
return [NSString stringWithFormat:@"%@%.2f", currency, priceValue];
|
||||
}
|
||||
|
||||
- (nullable NSString *)strikePriceDisplayText {
|
||||
double rawValue = self.originPrice;
|
||||
if (rawValue <= 0 && self.price > 0) {
|
||||
rawValue = self.price * 1.25;
|
||||
}
|
||||
if (rawValue <= 0) { return nil; }
|
||||
NSString *currency = self.currency.length ? self.currency : @"$";
|
||||
return [NSString stringWithFormat:@"%@%.2f", currency, rawValue];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user