钱包页面开发

This commit is contained in:
zeng 2025-04-28 15:00:29 +08:00
parent 1807584f6d
commit 490dc77b1e
25 changed files with 375 additions and 1 deletions

View File

@ -8,6 +8,38 @@
import UIKit import UIKit
extension AppDelegate {
func registerAPNS() {
let center = UNUserNotificationCenter.current()
center.delegate = self
center.requestAuthorization(options: [.badge, .sound, .alert]) { grant, error in
if grant {
SPRewardsAPI.requestUploadOpenNotify(completer: nil)
}
}
UIApplication.shared.registerForRemoteNotifications()
}
}
extension AppDelegate: UNUserNotificationCenterDelegate {
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
// NIMSDK.shared().updateApnsToken(deviceToken)
}
///APP
// func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
// completionHandler([.badge])
// }
///app
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
completionHandler()
}
}
extension SceneDelegate { extension SceneDelegate {

View File

@ -15,6 +15,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
self.appConfig() self.appConfig()
///
registerAPNS()
SPLoginManager.manager.requestVisitorLogin(completer: nil) SPLoginManager.manager.requestVisitorLogin(completer: nil)
/// ///

View File

@ -13,7 +13,8 @@ class SPTableView: UITableView {
override init(frame: CGRect, style: UITableView.Style) { override init(frame: CGRect, style: UITableView.Style) {
super.init(frame: frame, style: style) super.init(frame: frame, style: style)
// separatorColor = .lineColor() separatorColor = .colorFFFFFF(alpha: 0.1)
separatorInset = .init(top: 0, left: 16, bottom: 0, right: 16)
self.backgroundColor = .clear self.backgroundColor = .clear
self.contentInsetAdjustmentBehavior = .never self.contentInsetAdjustmentBehavior = .never

View File

@ -13,6 +13,7 @@ class SPMineViewController: SPViewController {
let arr = [ let arr = [
// SPMineItem(type: .language, iconImage: UIImage(named: "language_icon_01"), title: "Language".localized), // SPMineItem(type: .language, iconImage: UIImage(named: "language_icon_01"), title: "Language".localized),
SPMineItem(type: .feedBack, iconImage: UIImage(named: "feed_back_icon_01"), title: "FeedBack".localized), SPMineItem(type: .feedBack, iconImage: UIImage(named: "feed_back_icon_01"), title: "FeedBack".localized),
SPMineItem(type: .settings, iconImage: UIImage(named: "settings_icon_01"), title: "Settings".localized),
SPMineItem(type: .privacyPolicy, iconImage: UIImage(named: "privacy_policy_icon_01"), title: "Privacy Policy".localized), SPMineItem(type: .privacyPolicy, iconImage: UIImage(named: "privacy_policy_icon_01"), title: "Privacy Policy".localized),
SPMineItem(type: .userAgreement, iconImage: UIImage(named: "user_agreement_icon_01"), title: "User Agreement".localized), SPMineItem(type: .userAgreement, iconImage: UIImage(named: "user_agreement_icon_01"), title: "User Agreement".localized),
SPMineItem(type: .aboutUs, iconImage: UIImage(named: "about_us_icon_01"), title: "About Us".localized), SPMineItem(type: .aboutUs, iconImage: UIImage(named: "about_us_icon_01"), title: "About Us".localized),
@ -121,6 +122,9 @@ extension SPMineViewController: UITableViewDelegate, UITableViewDataSource {
let vc = SPFeedbackViewController() let vc = SPFeedbackViewController()
self.navigationController?.pushViewController(vc, animated: true) self.navigationController?.pushViewController(vc, animated: true)
// case .settings:
default: default:
break break
} }

View File

@ -0,0 +1,96 @@
//
// SPWalletViewController.swift
// MoviaBox
//
// Created by on 2025/4/28.
//
import UIKit
class SPWalletViewController: SPViewController {
private lazy var dataArr: [SPMineItem] = {
let arr = [
SPMineItem(type: .consumptionRecords, iconImage: UIImage(named: "records_icon_01"), title: "Consumption records".localized),
SPMineItem(type: .purchaseRecords, iconImage: UIImage(named: "records_icon_02"), title: "Purchase records".localized),
SPMineItem(type: .rewardCoins, iconImage: UIImage(named: "coin_icon_03"), title: "Reward Coins".localized),
SPMineItem(type: .feedBack, iconImage: UIImage(named: "feed_back_icon_03"), title: "FeedBack".localized),
]
return arr
}()
//MARK: UI
private lazy var tableView: SPTableView = {
let tableView = SPTableView(frame: .zero, style: .plain)
tableView.delegate = self
tableView.dataSource = self
tableView.rowHeight = 48
SPWalletCell.registerCell(tableView: tableView)
return tableView
}()
private lazy var headerView: SPWalletHeaderView = {
let view = SPWalletHeaderView(frame: .init(x: 0, y: 0, width: kSPScreenWidth, height: 152))
return view
}()
override func viewDidLoad() {
super.viewDidLoad()
self.edgesForExtendedLayout = .top
self.title = "Details".localized
_setupUI()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.setNavigationBarHidden(false, animated: true)
self.setNavigationNormalStyle(backgroundColor: .clear, isTranslucent: true)
}
}
extension SPWalletViewController {
private func _setupUI() {
self.tableView.tableHeaderView = self.headerView
view.addSubview(tableView)
tableView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(kSPNavBarHeight)
make.left.right.bottom.equalToSuperview()
}
}
}
//MARK: -------------- UITableViewDelegate & UITableViewDataSource --------------
extension SPWalletViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = SPWalletCell.dequeueReusableCell(tableView: tableView, indexPath: indexPath)
cell.item = dataArr[indexPath.row]
return cell
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return dataArr.count
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let item = dataArr[indexPath.row]
switch item.type {
case .feedBack:
let vc = SPFeedbackViewController()
self.navigationController?.pushViewController(vc, animated: true)
default:
break
}
}
}

View File

@ -31,6 +31,14 @@ struct SPMineItem {
case persoInforDisclosure case persoInforDisclosure
/// ///
case feedBack case feedBack
///
case settings
///
case consumptionRecords
///
case purchaseRecords
///
case rewardCoins
} }

View File

@ -24,6 +24,7 @@ class SPMineWalletView: UIView {
private lazy var moreButton: UIButton = { private lazy var moreButton: UIButton = {
let button = UIButton(type: .custom) let button = UIButton(type: .custom)
button.addTarget(self, action: #selector(handleWalletButton), for: .touchUpInside)
return button return button
}() }()
@ -52,6 +53,7 @@ class SPMineWalletView: UIView {
button.setTitle("Store".localized, for: .normal) button.setTitle("Store".localized, for: .normal)
button.setTitleColor(.colorFFFFFF(), for: .normal) button.setTitleColor(.colorFFFFFF(), for: .normal)
button.titleLabel?.font = .fontMedium(ofSize: 18) button.titleLabel?.font = .fontMedium(ofSize: 18)
button.addTarget(self, action: #selector(handleStoreButton), for: .touchUpInside)
return button return button
}() }()
@ -90,6 +92,18 @@ class SPMineWalletView: UIView {
} }
} }
extension SPMineWalletView {
@objc private func handleStoreButton() {
let vc = SPWalletViewController()
self.viewController?.navigationController?.pushViewController(vc, animated: true)
}
@objc private func handleWalletButton() {
let vc = SPWalletViewController()
self.viewController?.navigationController?.pushViewController(vc, animated: true)
}
}
extension SPMineWalletView { extension SPMineWalletView {
private func _setupUI() { private func _setupUI() {

View File

@ -0,0 +1,61 @@
//
// SPWalletCell.swift
// MoviaBox
//
// Created by on 2025/4/28.
//
import UIKit
class SPWalletCell: SPTableViewCell {
var item: SPMineItem? {
didSet {
iconImageView.image = item?.iconImage
titleLabel.text = item?.title
}
}
//MARK: UI
private lazy var iconImageView: UIImageView = {
let imageView = UIImageView()
return imageView
}()
private lazy var titleLabel: UILabel = {
let label = UILabel()
label.font = .fontMedium(ofSize: 16)
label.textColor = .colorFFFFFF()
return label
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.showIndicator = true
_setupUI()
}
@MainActor required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension SPWalletCell {
private func _setupUI() {
contentView.addSubview(iconImageView)
contentView.addSubview(titleLabel)
iconImageView.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.left.equalToSuperview().offset(18)
}
titleLabel.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.left.equalTo(iconImageView.snp.right).offset(8)
}
}
}

View File

@ -0,0 +1,41 @@
//
// SPWalletHeaderView.swift
// MoviaBox
//
// Created by on 2025/4/28.
//
import UIKit
class SPWalletHeaderView: UIView {
//MARK: UI
private lazy var contentView: SPMineWalletView = {
let view = SPMineWalletView()
return view
}()
override init(frame: CGRect) {
super.init(frame: frame)
_setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension SPWalletHeaderView {
private func _setupUI() {
addSubview(contentView)
contentView.snp.makeConstraints { make in
make.left.equalToSuperview()
make.centerX.equalToSuperview()
make.top.equalToSuperview().offset(10)
}
}
}

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 783 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 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: 421 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 703 B

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 778 B

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: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -21,6 +21,7 @@
"Save" = "Save"; "Save" = "Save";
"Added" = "Added"; "Added" = "Added";
"FeedBack" = "FeedBack"; "FeedBack" = "FeedBack";
"Settings" = "Settings";
"Language" = "Language"; "Language" = "Language";
"Privacy Policy" = "Privacy Policy"; "Privacy Policy" = "Privacy Policy";
"User Agreement" = "User Agreement"; "User Agreement" = "User Agreement";
@ -59,6 +60,10 @@
"My wallet" = "My wallet"; "My wallet" = "My wallet";
"Store" = "Store"; "Store" = "Store";
"Rewards" = "Rewards"; "Rewards" = "Rewards";
"Details" = "Details";
"Consumption records" = "Consumption records";
"Purchase records" = "Purchase records";
"Reward Coins" = "Reward Coins";
"kLoginAgreementText" = "By continuing, you agree to the User Agreement and Privacy Policy"; "kLoginAgreementText" = "By continuing, you agree to the User Agreement and Privacy Policy";