Commit e79bbfb5 authored by CZ1004's avatar CZ1004

Merge branch 'develop_0409' into charge

* develop_0409:
  内购
  4-8-2
parents eed9a6af 2584358c
......@@ -14,19 +14,19 @@
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
0496DEFD2D9E3F59005B2834 /* PBXContainerItemProxy */ = {
0493223D2DA5314500E037A5 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = EB388E532D8A61A800629B0D /* Project object */;
proxyType = 1;
remoteGlobalIDString = 0496DEF12D9E3F57005B2834;
remoteInfo = widgetExtension;
remoteGlobalIDString = 041E01052DA3E865000F6C81;
remoteInfo = ChargeShow;
};
04D1E8032DA52AD10035D838 /* PBXContainerItemProxy */ = {
0496DEFD2D9E3F59005B2834 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = EB388E532D8A61A800629B0D /* Project object */;
proxyType = 1;
remoteGlobalIDString = 041E01052DA3E865000F6C81;
remoteInfo = ChargeShow;
remoteGlobalIDString = 0496DEF12D9E3F57005B2834;
remoteInfo = widgetExtension;
};
/* End PBXContainerItemProxy section */
......@@ -70,19 +70,19 @@
/* End PBXFileReference section */
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
0496DF032D9E3F59005B2834 /* Exceptions for "widget" folder in "widgetExtension" target */ = {
0493223E2DA531CC00E037A5 /* Exceptions for "ChargeShow" folder in "ChargeShow" target */ = {
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
membershipExceptions = (
Info.plist,
);
target = 0496DEF12D9E3F57005B2834 /* widgetExtension */;
target = 041E01052DA3E865000F6C81 /* ChargeShow */;
};
04D1E8062DA52C000035D838 /* Exceptions for "ChargeShow" folder in "ChargeShow" target */ = {
0496DF032D9E3F59005B2834 /* Exceptions for "widget" folder in "widgetExtension" target */ = {
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
membershipExceptions = (
Info.plist,
);
target = 041E01052DA3E865000F6C81 /* ChargeShow */;
target = 0496DEF12D9E3F57005B2834 /* widgetExtension */;
};
EB388E6D2D8A61AA00629B0D /* Exceptions for "PhoneManager" folder in "PhoneManager" target */ = {
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
......@@ -97,7 +97,7 @@
041E01082DA3E865000F6C81 /* ChargeShow */ = {
isa = PBXFileSystemSynchronizedRootGroup;
exceptions = (
04D1E8062DA52C000035D838 /* Exceptions for "ChargeShow" folder in "ChargeShow" target */,
0493223E2DA531CC00E037A5 /* Exceptions for "ChargeShow" folder in "ChargeShow" target */,
);
path = ChargeShow;
sourceTree = "<group>";
......@@ -399,7 +399,7 @@
041E010D2DA3E865000F6C81 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 041E01052DA3E865000F6C81 /* ChargeShow */;
targetProxy = 04D1E8032DA52AD10035D838 /* PBXContainerItemProxy */;
targetProxy = 0493223D2DA5314500E037A5 /* PBXContainerItemProxy */;
};
0496DEFE2D9E3F59005B2834 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
......@@ -447,7 +447,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = 6K23946NQ5;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ChargeShow/Info.plist;
......@@ -511,11 +511,9 @@
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
CODE_SIGN_ENTITLEMENTS = widgetExtension.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 6K23946NQ5;
DEVELOPMENT_TEAM = 6K23946NQ5;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = widget/Info.plist;
......@@ -531,7 +529,6 @@
PRODUCT_BUNDLE_IDENTIFIER = com.app.phonemanager.bswidget;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = phonemanager_widget_dev;
SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
......@@ -588,11 +585,9 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = PhoneManager/PhoneManager.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 6K23946NQ5;
DEVELOPMENT_TEAM = 6K23946NQ5;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = PhoneManager/Info.plist;
INFOPLIST_KEY_NSCameraUsageDescription = "We need camera access to access image storage information";
......@@ -613,7 +608,6 @@
PRODUCT_BUNDLE_IDENTIFIER = com.app.phonemanager;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = phonemanager_dev1;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OBJC_BRIDGING_HEADER = "PhoneManager/Class/Tool/Class/OC/PhoneManager-Bridging-Header.h";
SWIFT_VERSION = 5.0;
......
......@@ -19,7 +19,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
window = UIWindow(frame: UIScreen.main.bounds)
window?.backgroundColor = UIColor.colorWithHex(hexStr: launchColor)
window?.overrideUserInterfaceStyle = .light
let Ssoryboard = UIStoryboard(name: "LauchVC", bundle: nil)
if let current = Ssoryboard.instantiateViewController(identifier: "LauchVCID") as? LauchVC {
......@@ -36,7 +36,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
private func setupDefault() {
HomePayModel.share.checkTrialStatus()
HomePayModel.share.loadLocalData()
NetStatusManager.manager.startNet { status in
switch status {
......
{
"images" : [
{
"filename" : "ic_idsp_unlock.png",
"filename" : "ic_unsel_com.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_idsp_unlock@2x.png",
"filename" : "ic_unsel_com@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_idsp_unlock@3x.png",
"filename" : "ic_unsel_com@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
......
{
"images" : [
{
"filename" : "icon_close__pingfen_pop.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon_close__pingfen_pop@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon_close__pingfen_pop@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "img_bj_quanxian.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "img_bj_quanxian@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "img_bj_quanxian@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "img_pro_quanxian.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "img_pro_quanxian@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "img_pro_quanxian@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_naal_unlock.png",
"filename" : "star_01.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_naal_unlock@2x.png",
"filename" : "star_01@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_naal_unlock@3x.png",
"filename" : "star_01@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
......
{
"images" : [
{
"filename" : "ic_sbst_unlock.png",
"filename" : "star_02.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_sbst_unlock@2x.png",
"filename" : "star_02@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_sbst_unlock@3x.png",
"filename" : "star_02@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
......
......@@ -287,6 +287,8 @@ class CompressQualityController : BaseViewController{
HomeNoAdsViewController.show {
actionBlock()
}
}else{
actionBlock()
}
}
......
......@@ -35,6 +35,7 @@ class LandingVC:UIViewController {
configureGradientView()
setupUI()
self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false
}
override func viewDidAppear(_ animated: Bool) {
......
......@@ -13,14 +13,23 @@ class HomeNoAdsViewController: UIViewController, NoAdsStackDataSource {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
HomePayModel.share.storeCall = {[weak self] product in
guard let self = self else { return }
self.priceLabe?.text = "$\(product.price)/year, cancel anytime"
HomePayModel.share.storeCall = {[weak self] products in
guard let self = self ,
let p1 = products.first,
let p2 = products.last
else { return }
self.yearNorBtn.setTitles(["\(p1!.localizedPrice)/year, cancel anytime" , "3-day FREE TRIAL"])
self.forever.setTitles(["\(p2!.localizedPrice), Lifetime"])
}
}
private var doneBlock:(()->Void) = {}
var priceLabe:UILabel?
var type = 0 {
didSet {
setIsSelect()
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
......@@ -31,15 +40,18 @@ class HomeNoAdsViewController: UIViewController, NoAdsStackDataSource {
private lazy var stack:NoAdsStackView = {
let s = NoAdsStackView(3)
view.addSubview(s)
contentScroll.addSubview(s)
s.spacing = 3
s.dataSource = self
return s
}()
private lazy var scroll: UIScrollView = {
let scroll = UIScrollView()
view.addSubview(scroll)
contentScroll.addSubview(scroll)
scroll.delegate = self;
scroll.backgroundColor = .colorWithHex(hexStr: "#F2F6FC")
scroll.layer.cornerRadius = 12
scroll.showsHorizontalScrollIndicator = false
scroll.isPagingEnabled = true
scroll.clipsToBounds = true
......@@ -59,16 +71,31 @@ class HomeNoAdsViewController: UIViewController, NoAdsStackDataSource {
private lazy var NoAdTitle: UILabel = {
let no = UILabel()
no.text = "Unlock all usage permissions"
no.font = UIFont.boldSystemFont(ofSize: 24)
no.font = UIFont.boldSystemFont(ofSize: 18)
no.textAlignment = .center
no.numberOfLines = 0
no.textColor = .black
no.textColor = .white
view.addSubview(no)
return no
}()
private lazy var info: UIImageView = {
let info = UIImageView(image: UIImage(named: "img_pro_quanxian"))
info.contentMode = .scaleToFill
view.addSubview(info)
return info
}()
private lazy var topBackimg: UIImageView = {
let img = UIImageView(image: UIImage(named: "img_bj_quanxian"))
img.contentMode = .scaleToFill
view.addSubview(img)
return img
}()
private lazy var closeBtn: UIButton = {
let close = UIButton(type: .custom)
close.setImage(UIImage(named: "home_pay_close"), for: .normal)
close.setImage(UIImage(named: "icon_close__pingfen_pop"), for: .normal)
view.addSubview(close)
close.addTarget(self, action: #selector(closeTouch), for: .touchUpInside)
return close
......@@ -79,47 +106,46 @@ class HomeNoAdsViewController: UIViewController, NoAdsStackDataSource {
page.currentPageIndicatorTintColor = .colorWithHex(hexStr: "#0082FF")
page.pageIndicatorTintColor = .colorWithHex(hexStr: "#C6CEE0")
page.numberOfPages = 3
view.addSubview(page)
contentScroll.addSubview(page)
return page
}()
private lazy var contentScroll: UIScrollView = {
let scroll = UIScrollView()
scroll.backgroundColor = .clear
scroll.showsHorizontalScrollIndicator = false
scroll.showsVerticalScrollIndicator = false
scroll.clipsToBounds = true
view.addSubview(scroll)
return scroll
}()
private lazy var buybut: UIButton = {
let buy = UIButton(type: .custom)
buy.backgroundColor = UIColor.colorWithHex(hexStr: "#0082FF")
buy.setTitle("Start my 3-day free trial", for: .normal)
buy.layer.cornerRadius = 8
view.addSubview(buy)
contentScroll.addSubview(buy)
buy.addTarget(self, action: #selector(paypuase), for: .touchUpInside)
return buy
}()
private lazy var bottomContentView: UIView = {
let content = UIView()
content.layer.cornerRadius = 12;
content.layer.borderColor = UIColor.colorWithHex(hexStr: "#0082FF").cgColor
content.layer.borderWidth = 1
view.addSubview(content)
let t = UILabel()
t.font = UIFont.systemFont(ofSize: 14)
t.textColor = .black
self.priceLabe = t;
content.addSubview(t)
private lazy var yearNorBtn: PMButton = {
let btn = PMButton(type: .custom)
btn.backgroundColor = .colorWithHex(hexStr: "#F2F6FC")
btn.setTitles(["3 days free trial",""])
btn.addTarget(self, action: #selector(TheFrial), for: .touchUpInside)
contentScroll.addSubview(btn)
return btn
}()
let b = UILabel()
b.text = " 3-day FREE TRIAL"
b.font = UIFont.systemFont(ofSize: 12)
b.textColor = .colorWithHex(hexStr: "#666666")
content.addSubview(b)
t.snp.makeConstraints { make in
make.bottom.equalTo(content.snp.centerY).offset(-2)
make.left.equalToSuperview().offset(10)
}
b.snp.makeConstraints { make in
make.top.equalTo(content.snp.centerY)
make.left.equalToSuperview().offset(10)
}
return content
private lazy var forever: PMButton = {
let fever = PMButton(type: .custom)
fever.setTitles([""])
fever.backgroundColor = .colorWithHex(hexStr: "#F2F6FC")
fever.addTarget(self, action: #selector(FreeTrial), for: .touchUpInside)
contentScroll.addSubview(fever)
return fever
}()
private lazy var ppBtn:UIButton = {
......@@ -143,7 +169,7 @@ class HomeNoAdsViewController: UIViewController, NoAdsStackDataSource {
sview.setAttributedTitle(attributedString, for: .normal)
sview.addTarget(self, action: #selector(terms), for: .touchUpInside)
sview.sizeToFit()
view.addSubview(sview)
contentScroll.addSubview(sview)
return sview
}()
......@@ -168,28 +194,70 @@ class HomeNoAdsViewController: UIViewController, NoAdsStackDataSource {
sview.setAttributedTitle(attributedString, for: .normal)
sview.addTarget(self, action: #selector(restore), for: .touchUpInside)
sview.sizeToFit()
view.addSubview(sview)
contentScroll.addSubview(sview)
return sview
}()
private let data:[[String:String]] = [
["icon":"ic_idsp_unlock","t":"Intelligent cleaning of similar photos"],
["icon":"ic_naal_unlock","t":"Unlimited usage times"],
["icon":"ic_sbst_unlock","t":"A more private space"],
["icon":"ic_unsel_com","t":"Intelligent cleaning of similar photos"],
["icon":"ic_unsel_com","t":"Unlimited usage times"],
["icon":"ic_unsel_com","t":"A more private space"],
]
private let descp:[String] = [
"That is great! Scan, remove similar photos, and compress videos. Simple and effective. Don't worry about the storage space decreasing",
"I have tried so many times to clean up storage on myphone but it always takes forever and never seems to beenough. This app has made it so much easier and faster",
"Thank goodness, all the storage space I use is slow.. I'm afraid of browsing and deleting unusable videos and photos, which makes things so simple"
]
private var descp:[ReviewModel] {
get {
let dict = [
["descp":"That is great! Scan, remove similar photos, and compress videos. Simple and effective. Don't worry about the storage space decreasing",
"name":"Angelina",
"review":(4),
"title":"Just use it to clean your phone!"
],
["descp":"I have tried so many times to clean up storage on myphone but it always takes forever and never seems to beenough. This app has made it so much easier and faster",
"name":"Forever",
"review":(5),
"title":"Very practical!"
],["descp":"Thank goodness, all the storage space I use is slow.. I'm afraid of browsing and deleting unusable videos and photos, which makes things so simple",
"name":"Mary",
"review":(5),
"title":"I love it!"]]
do{
let data = try JSONSerialization.data(withJSONObject: dict)
return try JSONDecoder().decode([ReviewModel].self, from: data)
}catch{
return []
}
}
}
}
struct ReviewModel:Codable {
let title:String
let name:String
let review:Int
let descp:String
}
extension HomeNoAdsViewController : UIScrollViewDelegate {
private func setIsSelect() -> Void {
yearNorBtn.isSelect = type == 0
forever.isSelect = type == 1
buybut.setTitle(type == 0 ? "Start my 3-day free trial" : "Start Planning", for: .normal)
}
/** 包年 */
@objc func TheFrial() -> Void {
type = 0
}
/** 终身会员 */
@objc func FreeTrial() -> Void {
type = 1
}
@objc func paypuase() -> Void {
HomePayModel.share.purchase()
HomePayModel.share.purchase((type == 0) ? .Subscribe : .NonConsum )
}
@objc func restore() -> Void {
......@@ -226,41 +294,85 @@ extension HomeNoAdsViewController : UIScrollViewDelegate {
stackview.addArrangedSubview(descp)
return stackview
}else if content == stack1 {
let stackview = UIStackView()
stackview.axis = .vertical
stackview.spacing = 0
stackview.alignment = .center
stackview.distribution = .fillProportionally
let content = UIView()
content.backgroundColor = .clear
let t = UILabel()
t.text = descp[idx].title
t.textColor = .colorWithHex(hexStr: "#333333")
t.font = UIFont.boldSystemFont(ofSize: 14)
content.addSubview(t)
t.snp.makeConstraints { make in
make.left.top.equalToSuperview().inset(16)
}
let r = UILabel()
r.text = descp[idx].name
r.textColor = .colorWithHex(hexStr: "#666666")
r.font = UIFont.systemFont(ofSize: 14)
content.addSubview(r)
r.snp.makeConstraints { make in
make.right.top.equalToSuperview().inset(16)
}
let staridx = descp[idx].review
let star = yQzSnStarView()
star.currentStar = staridx
content.addSubview(star)
star.snp.makeConstraints { make in
make.left.equalTo(t)
make.top.equalTo(t.snp.bottom).offset(5)
}
let label = UILabel()
label.text = descp[idx]
label.textAlignment = .center
label.numberOfLines = 0
label.text = descp[idx].descp
label.textAlignment = .left
label.numberOfLines = 2
label.textColor = .colorWithHex(hexStr: "#333333")
label.font = UIFont.boldSystemFont(ofSize: 14)
stackview.addArrangedSubview(label)
return stackview
label.font = UIFont.systemFont(ofSize: 12)
content.addSubview(label)
label.snp.makeConstraints { make in
make.top.equalTo(star.snp.bottom).offset(5)
make.left.right.bottom.equalToSuperview().inset(16)
}
return content
}else{
return UIView()
}
}
private func setUI() -> Void {
topBackimg.snp.makeConstraints { make in
make.left.right.top.equalToSuperview()
}
closeBtn.snp.makeConstraints { make in
make.left.top.equalTo(view).inset(UIEdgeInsets(top: 35, left: 13, bottom: 0, right: 0))
}
NoAdTitle.snp.makeConstraints { make in
make.left.right.equalToSuperview().inset(20)
make.top.equalTo(closeBtn.snp.bottom).offset(22)
make.centerX.equalToSuperview().inset(20)
make.centerY.equalTo(closeBtn.snp.centerY)
}
info.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.centerY.equalTo(topBackimg.snp.bottom).offset(-10)
}
contentScroll.snp.makeConstraints { make in
make.left.bottom.right.equalToSuperview()
make.top.equalTo(info.snp.bottom).offset(7)
}
stack.snp.makeConstraints { make in
make.left.right.equalToSuperview().inset(36)
make.top.equalTo(NoAdTitle.snp.bottom).offset(24)
make.left.equalToSuperview().inset(36)
make.width.equalTo(contentScroll.snp.width).offset(-36*2.0)
make.top.equalTo(contentScroll.snp.top)
}
scroll.snp.makeConstraints { make in
make.left.right.equalToSuperview().inset(30)
make.top.equalTo(stack.snp.bottom).offset(70)
make.height.equalTo(80)
make.left.right.equalTo(stack)
make.top.equalTo(stack.snp.bottom).offset(25)
make.height.equalTo(110)
}
stack1.snp.makeConstraints { make in
make.left.top.equalToSuperview()
......@@ -268,38 +380,44 @@ extension HomeNoAdsViewController : UIScrollViewDelegate {
make.width.equalTo(scroll.snp.width).multipliedBy(3.0)
}
pageCtrol.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.centerX.equalTo(stack)
make.top.equalTo(stack1.snp.bottom).offset(15)
}
bottomContentView.snp.makeConstraints { make in
make.left.right.equalTo(buybut)
make.bottom.equalTo(buybut.snp.top).offset(-10)
yearNorBtn.snp.makeConstraints { make in
make.left.right.equalTo(stack)
make.top.equalTo(pageCtrol.snp.bottom).offset(10)
make.height.equalTo(65)
}
forever.snp.makeConstraints { make in
make.left.right.equalTo(stack)
make.top.equalTo(yearNorBtn.snp.bottom).offset(10)
make.height.equalTo(65)
}
buybut.snp.makeConstraints { make in
make.left.right.equalToSuperview().inset(15)
make.bottom.equalTo(ppBtn.snp.top).offset(-20)
make.left.right.equalTo(stack)
make.top.equalTo(forever.snp.bottom).offset(20)
make.height.equalTo(46)
}
ppBtn.snp.makeConstraints { make in
make.bottom.equalToSuperview().offset(-10)
make.top.equalTo(buybut.snp.bottom).offset(10)
make.left.equalToSuperview().offset(15)
}
restoreBtn.snp.makeConstraints { make in
make.bottom.equalToSuperview().offset(-10)
make.right.equalToSuperview().offset(-15)
make.centerY.equalTo(ppBtn)
make.right.equalTo(stack.snp.right).offset(-10)
}
DispatchQueue.main.async {
self.type = 0
self.view.layoutIfNeeded()
DispatchQueue.main.asyncAfter(deadline: .now()+0.1) {
self.buybut.layer.cornerRadius = CGRectGetHeight(self.buybut.frame) / 2.0
self.scroll.contentSize = CGSize(width: CGRectGetWidth(self.scroll.frame) * 3.0, height: 0)
self.bottomContentView.gradient(colors: [.colorWithHex(hexStr: "#FFFFFF") , .colorWithHex(hexStr: "#E3EDFC")])
let height = CGRectGetMaxY(self.restoreBtn.frame)
self.contentScroll.contentSize = CGSize(width: 0, height: height + 30)
}
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let width = scrollView.width
let offset = scrollView.contentOffset.x
......
......@@ -13,6 +13,15 @@ class HomePayModel: NSObject ,SKProductsRequestDelegate ,SKPaymentTransactionObs
static let share:HomePayModel = HomePayModel()
enum PayState {
case Subscribe // 订阅
case NonConsum // 非消耗型
}
var state:PayState = .Subscribe
private let productIdentifiers:[String] = ["com.app.phonemanager.year.member" , "com.app.phonemanager.lifetime.member"]
var isNoAd:Bool {
get {
guard let noabd = UserDefaults.standard.object(forKey: "noabd") as? Bool else { return false }
......@@ -25,9 +34,29 @@ class HomePayModel: NSObject ,SKProductsRequestDelegate ,SKPaymentTransactionObs
}
}
var storeCall:((_ product:SKProduct) -> Void) = { prod in }
var storeCall:((_ product:[SKProduct?]) -> Void) = { prod in }
public func loadLocalData() -> Void {
verifyReceiptWithApple { receipt in
guard let json = receipt else {
self.refreshReceipt()
return
}
let sub = self.checkSubscriptionStatus(receiptInfo: json)
if sub.0 == true {
let extDate = sub.2
self.isNoAd = true
#if DEBUG
let s = DateFormatter()
s.dateFormat = "yyyyMMdd HHmmss"
Print("ext : %@", s.string(from: extDate ?? Date()))
#endif
}
}
}
func checkTrialStatus() -> Void {
private func checkTrialStatus() -> Void {
if state == .Subscribe { // 订阅型
verifyReceiptWithApple { receipt in
self.alert.dismiss()
guard let json = receipt else {
......@@ -47,41 +76,58 @@ class HomePayModel: NSObject ,SKProductsRequestDelegate ,SKPaymentTransactionObs
self.isNoAd = false
}
}
}else{
self.alert.dismiss()
self.isNoAd = true
}
}
func fetchProducts() {
let request = SKProductsRequest(productIdentifiers: ["com.app.phonemanager.year.member"])
let request = SKProductsRequest(productIdentifiers: Set(productIdentifiers))
request.delegate = self
request.start()
Print("获取商品信息")
}
var product:SKProduct?
private var product:[SKProduct?]?
/** 获取商品列表 */
func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
let products = response.products
guard let product = products.first else {
return
var ps:[SKProduct?] = [nil,nil]
if products.count >= 2 {
if products.first?.productIdentifier == productIdentifiers.first {
ps[0] = products.first
ps[1] = products.last
}else{
ps[1] = products.first
ps[0] = products.last
}
DispatchQueue.main.async {
self.product = product
self.storeCall(product)
}else{
ps = products
}
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2, execute: {
self.product = ps
Print("获取商品信息成功")
self.storeCall(ps)
})
}
/** 购买 */
func purchase() -> Void {
guard let prod = product,
func purchase(_ states:PayState = .Subscribe) -> Void {
guard let p1 = product?.first,
let p2 = product?.last,
SKPaymentQueue.canMakePayments()
else { return }
let payment = SKPayment(product: prod)
self.state = states
let payment = SKPayment(product: states == .Subscribe ? p1! : p2!)
SKPaymentQueue.default().add(payment)
alert.show()
}
/** 恢复 */
func restore() -> Void {
func restore(_ states:PayState = .Subscribe) -> Void {
self.state = states
SKPaymentQueue.default().restoreCompletedTransactions()
alert.show()
}
......@@ -245,6 +291,11 @@ extension HomePayModel {
checkTrialStatus()
}
/** 恢复失败 */
func paymentQueue(_ queue: SKPaymentQueue, restoreCompletedTransactionsFailedWithError error: any Error) {
alert.dismiss()
}
/** 刷新收据 */
func refreshReceipt() {
let request = SKReceiptRefreshRequest()
......
......@@ -20,11 +20,7 @@ class HomePayView:UIView {
private var icloudImage:UIImageView?
private var photoLabel:UILabel?
private var icloudLabel:UILabel?
private var contentView1:UIView?
private var animationLabel:UILabel?
private var contentView1Title:UILabel?
private var contentView1Tip1:UILabel?
private var contentView1Tip2:UILabel?
private var contentView2:UIView?
private var contentView2Title:UILabel?
private var contentView2Switch:UISwitch?
......@@ -42,6 +38,11 @@ class HomePayView:UIView {
private var normalContentTitle:UILabel?
private var normalContentMoney:UILabel?
var type = 0 {
didSet {
setIsSelect()
}
}
lazy var ppBtn:UIButton = {
......@@ -103,17 +104,34 @@ class HomePayView:UIView {
return animationView
}()
private lazy var yearNorBtn: PMButton = {
let btn = PMButton(type: .custom)
btn.backgroundColor = .colorWithHex(hexStr: "#F2F6FC")
btn.setTitles(["3 days free trial",""])
btn.addTarget(self, action: #selector(TheFrial), for: .touchUpInside)
addSubview(btn)
return btn
}()
private lazy var forever: PMButton = {
let fever = PMButton(type: .custom)
fever.setTitles([""])
fever.backgroundColor = .colorWithHex(hexStr: "#F2F6FC")
fever.addTarget(self, action: #selector(FreeTrial), for: .touchUpInside)
addSubview(fever)
return fever
}()
var callBack:callBack<Any> = {text in}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
......@@ -253,19 +271,6 @@ class HomePayView:UIView {
self.addSubview(animationLabel!)
contentView1 = UIView()
contentView1?.backgroundColor = UIColor.colorWithHex(hexStr: "#F2F6FC")
self.addSubview(contentView1!)
contentView1?.snp.makeConstraints({ make in
make.top.equalTo(animationView.snp.bottom).offset(76)
make.centerX.equalToSuperview()
make.width.equalToSuperview().offset(-30)
make.height.equalTo(125)
})
contentView1?.layer.cornerRadius = 12
contentView1?.layer.masksToBounds = true
animationLabel?.snp.makeConstraints({ make in
......@@ -273,53 +278,50 @@ class HomePayView:UIView {
make.centerX.equalToSuperview()
})
contentView1Title = UILabel()
contentView1Title?.text = "Cleanup Pro"
contentView1Title?.font = UIFont.systemFont(ofSize: 16, weight: .bold)
contentView1Title?.textColor = UIColor.colorWithHex(hexStr: black3Color)
self.contentView1?.addSubview(contentView1Title!)
contentView1Title?.snp.makeConstraints { make in
make.top.equalToSuperview().offset(16)
appleLabel = UILabel()
appleLabel?.text = " Secured with Apple"
appleLabel?.font = UIFont.systemFont(ofSize: 12, weight: .bold)
appleLabel?.textColor = UIColor.colorWithHex(hexStr: black3Color)
self.addSubview(appleLabel!)
appleLabel?.snp.makeConstraints { make in
make.bottom.equalToSuperview().offset(-10 - safeHeight)
make.centerX.equalToSuperview()
make.width.equalToSuperview().offset(-32)
make.height.equalTo(22)
}
self.addSubview(ppBtn)
ppBtn.snp.makeConstraints { make in
contentView1Tip1 = UILabel()
contentView1Tip1?.text = "Smart Cleaning, Video Compressor, Secret Storage, No Ads and Limits."
contentView1Tip1?.font = UIFont.systemFont(ofSize: 12, weight: .regular)
contentView1Tip1?.textColor = UIColor.colorWithHex(hexStr: black6Color)
contentView1Tip1?.numberOfLines = 2
self.contentView1?.addSubview(contentView1Tip1!)
contentView1Tip1?.snp.makeConstraints { make in
make.top.equalTo(contentView1Title!.snp.bottom).offset(12)
make.centerX.equalToSuperview()
make.width.equalToSuperview().offset(-32)
make.height.equalTo(34)
make.centerY.equalTo(appleLabel!)
make.left.equalToSuperview().offset(marginLR)
}
self.addSubview(touBtn)
touBtn.snp.makeConstraints { make in
contentView1Tip1?.setlineSpacing(font: contentView1Tip1!.font, lineSpacing: 3, width: contentView1Tip1!.width, numberOfLines: contentView1Tip1!.numberOfLines, content: contentView1Tip1!.text ?? "")
contentView1Tip2 = UILabel()
contentView1Tip2?.font = UIFont.systemFont(ofSize: 12, weight: .regular)
contentView1Tip2?.textColor = UIColor.colorWithHex(hexStr: black6Color)
contentView1Tip2?.numberOfLines = 1
self.contentView1?.addSubview(contentView1Tip2!)
contentView1Tip2?.snp.makeConstraints { make in
make.top.equalTo(contentView1Tip1!.snp.bottom).offset(8)
make.centerX.equalToSuperview()
make.width.equalToSuperview().offset(-32)
make.centerY.equalTo(appleLabel!)
make.right.equalToSuperview().offset(-marginLR)
}
payButton = UIButton()
payButton?.setTitle("Try Free", for: .normal)
payButton?.setTitleColor(UIColor.colorWithHex(hexStr: whiteColor), for: .normal)
payButton?.titleLabel?.font = UIFont.systemFont(ofSize: 16, weight: .bold)
payButton?.backgroundColor = UIColor.colorWithHex(hexStr: mColor)
payButton?.addTarget(self, action: #selector(payButtonClick), for: .touchUpInside)
self.addSubview(payButton!)
payButton?.snp.makeConstraints({ make in
make.centerX.equalToSuperview()
make.bottom.equalTo(appleLabel!.snp.top).offset(-20)
make.width.equalToSuperview().offset(-30)
make.height.equalTo(46)
})
payButton?.layer.cornerRadius = 8
payButton?.layer.masksToBounds = true
contentView2 = UIView()
contentView2?.backgroundColor = UIColor.colorWithHex(hexStr: "#F2F6FC")
self.addSubview(contentView2!)
contentView2?.snp.makeConstraints({ make in
make.top.equalTo(contentView1!.snp.bottom).offset(12)
make.bottom.equalTo(payButton!.snp.top).offset(-12)
make.centerX.equalToSuperview()
make.width.equalToSuperview().offset(-30)
make.height.equalTo(60)
......@@ -340,13 +342,11 @@ class HomePayView:UIView {
make.width.equalToSuperview().offset(-32)
make.height.equalTo(22)
}
contentView2Switch = UISwitch()
contentView2Switch?.onTintColor = UIColor.colorWithHex(hexStr: mColor)
contentView2Switch?.tintColor = .white
contentView2Switch?.backgroundColor = .clear
contentView2Switch?.isOn = true
contentView2Switch?.isUserInteractionEnabled = false
self.contentView2?.addSubview(contentView2Switch!)
contentView2Switch?.snp.makeConstraints { make in
......@@ -355,156 +355,20 @@ class HomePayView:UIView {
make.width.equalTo(46)
make.height.equalTo(28)
}
contentView2Switch?.addTarget(self, action: #selector(switchValueChanged(_:)), for: .valueChanged)
appleLabel = UILabel()
appleLabel?.text = " Secured with Apple"
appleLabel?.font = UIFont.systemFont(ofSize: 12, weight: .bold)
appleLabel?.textColor = UIColor.colorWithHex(hexStr: black3Color)
self.addSubview(appleLabel!)
appleLabel?.snp.makeConstraints { make in
make.bottom.equalToSuperview().offset(-3 - safeHeight)
make.centerX.equalToSuperview()
}
appleLabel?.sizeToFit()
ppLabel = UILabel()
appleLabel?.text = " Secured with Apple"
appleLabel?.font = UIFont.systemFont(ofSize: 12, weight: .bold)
appleLabel?.textColor = UIColor.colorWithHex(hexStr: black3Color)
self.addSubview(appleLabel!)
appleLabel?.snp.makeConstraints { make in
make.bottom.equalToSuperview().offset(-3 - safeHeight)
make.centerX.equalToSuperview()
forever.snp.makeConstraints { make in
make.left.right.equalTo(self.contentView2!)
make.bottom.equalTo(self.contentView2!.snp.top).offset(-12)
make.height.equalTo(69)
}
appleLabel?.sizeToFit()
self.addSubview(ppBtn)
ppBtn.snp.makeConstraints { make in
make.centerY.equalTo(appleLabel!)
make.left.equalToSuperview().offset(marginLR)
yearNorBtn.snp.makeConstraints { make in
make.left.right.equalTo(self.contentView2!)
make.bottom.equalTo(forever.snp.top).offset(-12)
make.height.equalTo(69)
}
self.addSubview(touBtn)
touBtn.snp.makeConstraints { make in
make.centerY.equalTo(appleLabel!)
make.right.equalToSuperview().offset(-marginLR)
}
payButton = UIButton()
payButton?.setTitle("Try Free", for: .normal)
payButton?.setTitleColor(UIColor.colorWithHex(hexStr: whiteColor), for: .normal)
payButton?.titleLabel?.font = UIFont.systemFont(ofSize: 16, weight: .bold)
payButton?.backgroundColor = UIColor.colorWithHex(hexStr: mColor)
payButton?.addTarget(self, action: #selector(payButtonClick), for: .touchUpInside)
self.addSubview(payButton!)
payButton?.snp.makeConstraints({ make in
make.centerX.equalToSuperview()
make.bottom.equalTo(appleLabel!.snp.top).offset(-20)
make.width.equalToSuperview().offset(-30)
make.height.equalTo(46)
})
payButton?.layer.cornerRadius = 8
payButton?.layer.masksToBounds = true
freeContent = UIView()
freeContent?.backgroundColor = .clear
self.addSubview(freeContent!)
freeContent?.snp.makeConstraints({ make in
make.top.equalTo(contentView2!.snp.bottom).offset(16)
make.left.equalTo(30)
make.height.equalTo(21)
make.width.equalToSuperview().offset(-45)
})
freeContentTitle = UILabel()
freeContentTitle?.text = "Due today"
freeContentTitle?.font = UIFont.systemFont(ofSize: 14, weight: .bold)
freeContentTitle?.textColor = UIColor.colorWithHex(hexStr: black3Color)
freeContent?.addSubview(freeContentTitle!)
freeContentTitle?.snp.makeConstraints({ make in
make.centerY.equalToSuperview()
make.left.equalToSuperview()
})
freeContentTitle?.sizeToFit()
freeContentMoney = UILabel()
freeContentMoney?.text = "$0.00"
freeContentMoney?.font = UIFont.systemFont(ofSize: 12, weight: .bold)
freeContentMoney?.textColor = UIColor.colorWithHex(hexStr: black3Color)
freeContentMoney?.textAlignment = .right
freeContent?.addSubview(freeContentMoney!)
freeContentMoney?.sizeToFit()
freeContentMoney?.snp.makeConstraints({ make in
make.centerY.equalToSuperview()
make.right.equalToSuperview()
})
freeContentTip = UILabel()
freeContentTip?.text = "3 days free"
freeContentTip?.font = UIFont.systemFont(ofSize: 12, weight: .bold)
freeContentTip?.textColor = UIColor.colorWithHex(hexStr: whiteColor)
freeContentTip?.backgroundColor = UIColor.colorWithHex(hexStr: "#52C776")
freeContentTip?.textAlignment = .center
freeContent?.addSubview(freeContentTip!)
freeContentTip?.sizeToFit()
freeContentTip?.snp.makeConstraints({ make in
make.centerY.equalToSuperview()
make.right.equalTo(freeContentMoney!.snp.left).offset(-6)
make.height.equalTo(21)
make.width.equalTo(85)
})
freeContentTip?.layer.cornerRadius = 21 / 2
freeContentTip?.layer.masksToBounds = true
normalContent = UIView()
normalContent?.backgroundColor = .clear
self.addSubview(normalContent!)
normalContent?.snp.makeConstraints({ make in
make.top.equalTo(freeContent!.snp.bottom).offset(8)
make.left.equalTo(30)
make.height.equalTo(21)
make.width.equalToSuperview().offset(-45)
})
normalContentTitle = UILabel()
let date:String = Date().operation(1)?.string("MMMM dd yyyy") ?? ""
normalContentTitle?.text = "Due \(date)"
normalContentTitle?.font = UIFont.systemFont(ofSize: 12, weight: .regular)
normalContentTitle?.textColor = UIColor.colorWithHex(hexStr: black6Color)
normalContent?.addSubview(normalContentTitle!)
normalContentTitle?.snp.makeConstraints({ make in
make.centerX.equalToSuperview()
make.left.equalToSuperview()
})
normalContentTitle?.sizeToFit()
normalContentMoney = UILabel()
normalContentMoney?.text = "$0.00"
normalContentMoney?.font = UIFont.systemFont(ofSize: 12, weight: .bold)
normalContentMoney?.textColor = UIColor.colorWithHex(hexStr: black3Color)
normalContentMoney?.textAlignment = .right
normalContent?.addSubview(normalContentMoney!)
normalContentMoney?.sizeToFit()
normalContentMoney?.snp.makeConstraints({ make in
make.centerX.equalToSuperview()
make.right.equalToSuperview()
})
self.layoutIfNeeded()
setIsSelect()
}
func playAnimationWithDelay() {
......@@ -522,17 +386,37 @@ class HomePayView:UIView {
var product : SKProduct? {
didSet{
guard let prod = product else { return }
normalContentMoney?.text = "$\(prod.price)"
contentView1Tip2?.text = "Free trial for 3 days, $\(prod.price) per year thereafter"
yearNorBtn.setTitles(["3 days free trial","Then \(prod.localizedPrice) per year"])
}
}
var product1 : SKProduct? {
didSet{
guard let prod = product1 else { return }
forever.setTitles(["\(prod.localizedPrice), Lifetime"])
}
}
private func setIsSelect() -> Void {
yearNorBtn.isSelect = type == 0
forever.isSelect = type == 1
contentView2Switch?.isOn = type == 0
payButton?.setTitle(type == 0 ? "Try Free" : "Start Planning", for: .normal)
}
@objc private func FreeTrial() -> Void {
type = 1
}
@objc private func TheFrial() {
type = 0
}
@objc func closeBtnClick() {
callBack(OperStatus.close)
}
@objc func ppBtnClick(btn:UIButton) {
callBack(CommonPush.pp)
}
......@@ -541,7 +425,7 @@ class HomePayView:UIView {
}
@objc func switchValueChanged(_ sender: UISwitch) {
callBack(CommonPush.swit)
type = sender.isOn ? 0 : 1
}
@objc func restoreTouch() -> Void {
......
......@@ -16,7 +16,7 @@ class HomePayViewController:UIViewController {
private var doneBlock:(()->Void) = {}
var currentProduct:SKProduct? {
var currentProduct:[SKProduct?]? {
didSet {
setPrice()
}
......@@ -26,12 +26,12 @@ class HomePayViewController:UIViewController {
super.viewDidLoad()
view.backgroundColor = .green
addViews()
HomePayModel.share.fetchProducts()
storeKeD()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
storeKeD()
HomePayModel.share.fetchProducts()
}
override func viewDidAppear(_ animated: Bool) {
......@@ -47,7 +47,6 @@ class HomePayViewController:UIViewController {
guard let self else {return}
if let operstatus = status as? OperStatus {
switch operstatus {
case .close:
self.dismiss(animated: true)
......@@ -58,7 +57,6 @@ class HomePayViewController:UIViewController {
}
if let commonPush = status as? CommonPush {
switch commonPush {
case .pp:
self.ppClick()
......@@ -68,7 +66,7 @@ class HomePayViewController:UIViewController {
self.payTouch()
break
case .swit:
self.disjunctorTouch()
break
case .restore:
self.restoreClick()
......@@ -77,31 +75,29 @@ class HomePayViewController:UIViewController {
}
}
}
}
extension HomePayViewController {
private func setPrice() -> Void {
guard currentProduct != nil else { return }
homePayView?.product = currentProduct
guard currentProduct != nil ,
let p1 = currentProduct?.first,
let p2 = currentProduct?.last
else { return }
homePayView?.product = p1
homePayView?.product1 = p2
}
private func storeKeD() -> Void {
HomePayModel.share.storeCall = {[weak self] product in
HomePayModel.share.storeCall = {[weak self] products in
guard let self = self else { return }
self.currentProduct = product
}
self.currentProduct = products
}
private func disjunctorTouch() -> Void {
self.disjunctor = !self.disjunctor
setPrice()
}
private func payTouch() -> Void {
HomePayModel.share.purchase()
HomePayModel.share.purchase( (homePayView?.type == 0) ? .Subscribe : .NonConsum )
}
private func ppClick() {
......
......@@ -144,7 +144,7 @@ class SecretViewController: BaseViewController {
}
secretDesc.snp.makeConstraints { make in
make.left.equalTo(secretTL.snp.left)
make.top.equalTo(secretTL.snp.bottom).offset(2)
make.top.equalTo(secretTL.snp.bottom).offset(12)
}
secretLock.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-28)
......
......@@ -852,6 +852,7 @@ class SecretPhotoManager: NSObject, PhotoPickerControllerDelegate , CameraContro
if type == 0 {
let config = CameraConfiguration()
let vc = CameraController(config: config, type: .all, delegate: self)
vc.modalPresentationStyle = .overFullScreen
guard let root = cWindow?.rootViewController else { return }
root.present(vc, animated: true)
}else{
......@@ -859,6 +860,7 @@ class SecretPhotoManager: NSObject, PhotoPickerControllerDelegate , CameraContro
config.selectMode = .multiple
config.maximumSelectedCount = 4
let vc = PhotoPickerController(picker: config, delegate: self)
vc.modalPresentationStyle = .overFullScreen
guard let root = cWindow?.rootViewController else { return }
root.present(vc, animated: true)
}
......
......@@ -40,7 +40,12 @@ class PMAlertView: UIViewController {
func show() -> Void {
DispatchQueue.main.async {
guard let rt = UIViewController.topMostViewController() else { return }
Print("显示弹窗")
guard let rt = UIViewController.topMostViewController()
else { return }
if let vc = rt as? PMAlertView {
return
}
self.modalPresentationStyle = .overFullScreen
self.modalTransitionStyle = .crossDissolve
rt.present(self, animated: true)
......@@ -49,6 +54,7 @@ class PMAlertView: UIViewController {
func dismiss() -> Void {
DispatchQueue.main.async {
Print("关闭弹窗")
self.dismiss(animated: true)
}
}
......
//
// PMButton.swift
// PhoneManager
//
// Created by edy on 2025/4/8.
//
import UIKit
class PMButton: UIButton {
override init(frame: CGRect) {
super.init(frame: frame)
self.layer.cornerRadius = 12
self.clipsToBounds = true
}
var isSelect:Bool = false {
didSet {
if isSelect {
self.layer.borderColor = UIColor.colorWithHex(hexStr: "#266BFF").cgColor
self.layer.borderWidth = 1
self.gradient(colors: [UIColor.colorWithHex(hexStr: "#FFFFFF"),UIColor.colorWithHex(hexStr: "#E3E9FC")])
}else{
self.layer.borderColor = UIColor.clear.cgColor
self.layer.borderWidth = 0
self.gradient(colors: [.clear])
}
}
}
var labels : [UILabel] = []
func setTitles(_ titles: [String] ) {
if labels.count == titles.count {
for i in 0..<titles.count {
let lb:UILabel = labels[i]
lb.text = titles[i]
}
return
}
if titles.count > 1 {
let t = UILabel()
t.text = titles[0]
t.textColor = .colorWithHex(hexStr: "#333333")
t.font = UIFont.boldSystemFont(ofSize: 16)
self.addSubview(t)
t.snp.makeConstraints { make in
make.left.equalToSuperview().offset(10)
make.bottom.equalTo(self.snp.centerY).offset(-2)
}
let b = UILabel()
b.text = titles[1]
b.textColor = .colorWithHex(hexStr: "#666666")
b.font = UIFont.boldSystemFont(ofSize: 12)
addSubview(b)
b.snp.makeConstraints { make in
make.left.equalToSuperview().offset(10)
make.top.equalTo(self.snp.centerY)
}
labels.append(t)
labels.append(b)
}else if titles.count == 1 {
let t = UILabel()
t.text = titles[0]
t.textColor = .colorWithHex(hexStr: "#333333")
t.font = UIFont.boldSystemFont(ofSize: 16)
self.addSubview(t)
t.snp.makeConstraints { make in
make.left.equalToSuperview().offset(10)
make.centerY.equalToSuperview()
}
labels.append(t)
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
......@@ -8,6 +8,7 @@
import UIKit
class PMPageControl: UIPageControl {
private let activeWidth: CGFloat = 16.0
private let inactiveWidth: CGFloat = 8.0
private let dotSpacing: CGFloat = 8.0
......@@ -15,6 +16,7 @@ class PMPageControl: UIPageControl {
override func layoutSubviews() {
super.layoutSubviews()
// for (index, dot) in subviews.enumerated() {
// Print("Page : %d",index)
// let isCurrentPage = index == currentPage
// let targetWidth = isCurrentPage ? activeWidth : inactiveWidth
// let previousDotsWidth = CGFloat(index) * (inactiveWidth + dotSpacing)
......
//
// yQzSnStarView.swift
// PhoneManager
//
// Created by edy on 2025/4/9.
//
import UIKit
class yQzSnStarView: UIView {
var maxStar = 5 {
didSet {
reloadView()
}
}
var spacing:CGFloat = 5 {
didSet {
starStack.spacing = self.spacing
}
}
var axis:NSLayoutConstraint.Axis = .vertical {
didSet {
starStack.axis = axis
}
}
var currentStar = 5 {
didSet {
reloadView()
}
}
private func reloadView() -> Void {
for v in starStack.arrangedSubviews {
starStack.removeArrangedSubview(v)
}
for i in 0..<maxStar {
let iconName = i < currentStar ? "star_01" : "star_02"
let icon = UIImageView(image: UIImage(named: iconName))
icon.contentMode = .scaleToFill
starStack.addArrangedSubview(icon)
icon.snp.makeConstraints { make in
make.width.equalTo(icon.snp.height)
}
}
}
private func setupUI() -> Void {
starStack.snp.makeConstraints { make in
make.left.top.bottom.right.equalToSuperview()
}
}
private lazy var starStack: UIStackView = {
let star = UIStackView()
star.axis = .horizontal
star.spacing = 5
star.alignment = .center
star.distribution = .fillEqually
addSubview(star)
return star
}()
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
......@@ -6,6 +6,8 @@
//
import UIKit
import StoreKit
extension UIView {
......@@ -244,3 +246,16 @@ extension Date {
}
}
extension SKProduct {
var localizedPrice: String {
let formatter = NumberFormatter()
formatter.numberStyle = .currency
formatter.locale = priceLocale
formatter.maximumFractionDigits = 2
guard let priceNumber:NSNumber = price as? NSNumber else {
return ""
}
return formatter.string(from: priceNumber) ?? ""
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment