删除账号新增二次确认

This commit is contained in:
zeng 2025-05-13 15:26:20 +08:00
parent a94e3a8fd7
commit 607bcafb32
13 changed files with 256 additions and 12 deletions

View File

@ -15,6 +15,9 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return } guard let windowScene = (scene as? UIWindowScene) else { return }
SPAPPTool.windowScene = windowScene
/// ///
NotificationCenter.default.addObserver(self, selector: #selector(localizedDidChange), name: SPLocalizedManager.localizedDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(localizedDidChange), name: SPLocalizedManager.localizedDidChange, object: nil)
/// ///

View File

@ -139,11 +139,18 @@ extension SPDeleteAccountViewController {
} }
@objc private func handleDeleteButton() { @objc private func handleDeleteButton() {
SPLoginManager.manager.deleteAccount { isFinish in
if isFinish { let alert = SPAlertView(iconImage: UIImage(named: "delete_account_icon_02"), text: "movia_deleteAccountInfo".localized, cancelTitle: "movia_Cancel".localized, sureTitle: "movia_delete".localized)
self.navigationController?.popViewController(animated: true) alert.clickSureButton = {
SPLoginManager.manager.deleteAccount { [weak self] isFinish in
guard let self = self else { return }
if isFinish {
self.navigationController?.popViewController(animated: true)
}
} }
} }
alert.show()
} }
} }

View File

@ -128,17 +128,15 @@ extension SPSettingsViewController {
} }
///退 ///退
private func logout() { private func logout() {
let alert = UIAlertController(title: nil, message: "movia_confirm_logout".localized, preferredStyle: .alert) let alert = SPAlertView(iconImage: UIImage(named: "logout_icon_01"), text: "movia_logoutinfo".localized, cancelTitle: "movia_Cancel".localized, sureTitle: "movia_Log_out".localized)
alert.addAction(UIAlertAction(title: "movia_affirm".localized, style: .default, handler: { _ in alert.clickSureButton = {
SPLoginManager.manager.logout { [weak self] isFinish in SPLoginManager.manager.logout { [weak self] isFinish in
guard let self = self else { return } guard let self = self else { return }
self.dataArr = self.createDataArr() self.dataArr = self.createDataArr()
} }
})) }
alert.show()
alert.addAction(UIAlertAction(title: "movia_Cancel".localized, style: .cancel))
self.present(alert, animated: true)
} }
private func createDataArr() -> [SPMineItem] { private func createDataArr() -> [SPMineItem] {
@ -150,9 +148,9 @@ extension SPSettingsViewController {
] ]
if SPLoginManager.manager.isLogin { if SPLoginManager.manager.isLogin {
arr.append(SPMineItem(type: .deleteAccount, title: "DeleteAccount".localized))
arr.append(SPMineItem(type: .logout, title: "movia_signout".localized))
} }
arr.append(SPMineItem(type: .deleteAccount, title: "DeleteAccount".localized))
arr.append(SPMineItem(type: .logout, title: "movia_signout".localized))
return arr return arr

View File

@ -12,6 +12,8 @@ class SPAPPTool: NSObject {
///app ///app
static var isAppOpen = true static var isAppOpen = true
static var windowScene: UIWindowScene?
static var mainTabBarController: SPTabBarController? static var mainTabBarController: SPTabBarController?
static func getAppDelegate() -> AppDelegate? { static func getAppDelegate() -> AppDelegate? {

View File

@ -0,0 +1,149 @@
//
// SPAlertView.swift
// MoviaBox
//
// Created by on 2025/5/13.
//
import UIKit
class SPAlertView: UIView {
var clickSureButton: (() -> Void)?
var clickCancelButton: (() -> Void)?
private var alertWidth: CGFloat = kSPScreenWidth - 52
private var alertHeight: CGFloat = 284
//MARK: UI
private lazy var contentView: UIView = {
let view = UIView()
view.backgroundColor = .color202531()
view.layer.cornerRadius = 18
view.layer.masksToBounds = true
view.layer.borderWidth = 1
view.layer.borderColor = UIColor.color3D4556().cgColor
return view
}()
private lazy var iconImageView: UIImageView = {
let imageView = UIImageView()
return imageView
}()
private lazy var textLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 0
label.font = .fontMedium(ofSize: 20)
label.textColor = .colorFFFFFF()
label.textAlignment = .center
return label
}()
private lazy var cancelButton: UIButton = {
let button = UIButton(type: .custom)
button.setTitleColor(.colorFFFFFF(), for: .normal)
button.titleLabel?.font = .fontMedium(ofSize: 14)
button.layer.cornerRadius = 18
button.layer.masksToBounds = true
button.layer.borderWidth = 1
button.layer.borderColor = UIColor.colorFFFFFF().cgColor
button.addTarget(self, action: #selector(handleCancelButton), for: .touchUpInside)
return button
}()
private lazy var sureButton: UIButton = {
let button = UIButton(type: .custom)
button.setBackgroundImage(UIImage(color: .colorFF1F1F()), for: .normal)
button.setTitleColor(.colorFFFFFF(), for: .normal)
button.titleLabel?.font = .fontMedium(ofSize: 14)
button.layer.cornerRadius = 18
button.layer.masksToBounds = true
button.addTarget(self, action: #selector(handleSureButton), for: .touchUpInside)
return button
}()
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
init(iconImage: UIImage?, text: String, cancelTitle: String, sureTitle: String) {
super.init(frame: UIScreen.main.bounds)
self.backgroundColor = .color000000(alpha: 0.8)
alertHeight = 0
// contentView.frame = CGRect(x: 0, y: 0, width: alertWidth, height: alertHeight)
addSubview(contentView)
iconImageView.image = iconImage
let imageSize = iconImage?.size ?? .zero
contentView.addSubview(iconImageView)
iconImageView.frame = CGRect(x: (alertWidth - imageSize.width) / 2, y: 28, width: imageSize.width, height: imageSize.height)
alertHeight = iconImageView.frame.maxY
textLabel.text = text
let textSize = textLabel.sizeThatFits(CGSize(width: alertWidth - 50, height: CGFLOAT_MAX))
contentView.addSubview(textLabel)
textLabel.frame = CGRect(x: (alertWidth - textSize.width) / 2, y: alertHeight + 25, width: textSize.width, height: textSize.height)
alertHeight = textLabel.frame.maxY
cancelButton.setTitle(cancelTitle, for: .normal)
sureButton.setTitle(sureTitle, for: .normal)
let buttonWidth = (alertWidth - 60 - 10) / 2
let buttonHeight = 36.0
contentView.addSubview(cancelButton)
contentView.addSubview(sureButton)
cancelButton.frame = CGRect(x: 30, y: alertHeight + 38, width: buttonWidth, height: buttonHeight)
sureButton.frame = CGRect(x: cancelButton.frame.maxX + 10.0, y: cancelButton.frame.minY, width: buttonWidth, height: buttonHeight)
alertHeight = sureButton.frame.maxY + 34
contentView.frame = CGRect(x: 0, y: 0, width: alertWidth, height: alertHeight)
}
}
extension SPAlertView {
// MARK: -
@discardableResult func show() -> Self {
SPAlertWindowManager.manager.createWindow().addSubview(self)
creatShowAnimation()
return self
}
func dismiss() {
removeFromSuperview()
SPAlertWindowManager.manager.dismissWindow()
}
private func creatShowAnimation() {
contentView.layer.position = center
contentView.transform = CGAffineTransform(scaleX: 0.9, y: 0.9)
UIView.animate(withDuration: 0.2, animations: {
self.contentView.transform = CGAffineTransform(scaleX: 1.2, y: 1.2)
}) { finished in
UIView.animate(withDuration: 0.1, animations: {
self.contentView.transform = CGAffineTransform.identity
})
}
}
@objc private func handleSureButton() {
self.clickSureButton?()
self.dismiss()
}
@objc private func handleCancelButton() {
self.clickCancelButton?()
self.dismiss()
}
}

View File

@ -0,0 +1,38 @@
//
// SPAlertWindowManager.swift
// MoviaBox
//
// Created by on 2025/5/13.
//
import UIKit
class SPAlertWindowManager {
static let manager = SPAlertWindowManager()
private var window: UIWindow?
private var count = 0
func createWindow() -> UIWindow {
count += 1
guard let window = window else {
let window = UIWindow(windowScene: SPAPPTool.windowScene!)
window.backgroundColor = .clear
window.windowLevel = .alert
window.isHidden = false
self.window = window
return window
}
return window
}
func dismissWindow() {
count -= 1
if count == 0 {
window?.isHidden = true
window = nil
}
}
}

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Vector@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Vector@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Frame@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Frame@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

@ -103,7 +103,10 @@
"movia_play_now" = "Play Now"; "movia_play_now" = "Play Now";
"movia_login_title_facebook" = "Sign in with FaceBook"; "movia_login_title_facebook" = "Sign in with FaceBook";
"movia_login_title_apple" = "Sign in with Apple"; "movia_login_title_apple" = "Sign in with Apple";
"movia_Log_out" = "Log out";
"movia_logoutinfo" = "Are you sure you want to log out?";
"movia_delete" = "Delete";
"movia_deleteAccountInfo" = "Are you sure you want to deactivate your account?";
"movia_iap_error_toast_01" = "Invalid in-app purchase"; "movia_iap_error_toast_01" = "Invalid in-app purchase";
///没有可恢复购买 ///没有可恢复购买