Music_Player3/relax.offline.mp3.music/MP/MPSideA/ViewControllers/Center(个人资源)/MPSideA_SettingViewController.swift
2024-06-19 18:32:15 +08:00

93 lines
4.0 KiB
Swift

//
// SettingViewController.swift
// MusicPlayer
//
// Created by Mr.Zhou on 2024/4/10.
//
import UIKit
class MPSideA_SettingViewController: MPSideA_BaseViewController {
@IBOutlet weak var tableView: UITableView!{
didSet{
if #available(iOS 15.0, *) {
tableView.sectionHeaderTopPadding = 0
}
tableView.rowHeight = 70*width
tableView.dataSource = self
tableView.delegate = self
tableView.register(UINib(nibName: SettingTableViewCellID, bundle: nil), forCellReuseIdentifier: SettingTableViewCellID)
}
}
private let SettingTableViewCellID = "MPSideA_SettingTableViewCell"
private lazy var titles:[String] = ["About","Feedback","Share","Privacy Policy","Terms of Use"]
var setblock:(() -> Void)?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func popClick(_ sender: UIButton) {
if setblock != nil {
setblock!()
}
navigationController?.popViewController(animated: true)
}
}
//MARK: - tableView
extension MPSideA_SettingViewController: UITableViewDataSource, UITableViewDelegate {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return titles.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: SettingTableViewCellID, for: indexPath) as! MPSideA_SettingTableViewCell
cell.title = titles[indexPath.row]
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch indexPath.row {
case 0://About
let aboutVC = MPSideA_AboutViewController()
navigationController?.pushViewController(aboutVC, animated: true)
case 1://Feedback
let alert = UIAlertController(title: "Feedback", message: "If you have any comments or suggestions, please contact us at the following e-mail address", preferredStyle: .actionSheet)
let email = UIAlertAction(title: "marketing@lux-ad.com", style: .default) { (_) in
//
UIPasteboard.general.string = "marketing@lux-ad.com"
MP_HUD.text("Successfully copied the e-mail address to the clipboard", delay: 1.0, completion: nil)
}
alert.addAction(email)
let cancel = UIAlertAction(title: "Cancel", style: .cancel)
alert.addAction(cancel)
present(alert, animated: true)
case 2://Share
//
let text = App_Name
//icon
let image = UIImage(named: "ICON")
//
let url = URL(string: "https://musiclax.mystrikingly.com/")
let activityItems = [text,image as Any,url as Any]
//
let activityViewController = UIActivityViewController(activityItems: activityItems, applicationActivities:nil)
present(activityViewController, animated: true, completion: nil)
//
activityViewController.completionWithItemsHandler = { [weak self] ( activityType, isCompleted, returnedItems, error) -> Void in
print(isCompleted ? "Share Success":"Share Failure")
}
case 3:
MP_NetWorkManager.shared.requestNetworkPermission(oberve: self) {
[weak self] in
let privacyVC = MPSideA_PrivacyViewController()
self?.navigationController?.pushViewController(privacyVC, animated: true)
}
default:
MP_NetWorkManager.shared.requestNetworkPermission(oberve: self) {
[weak self] in
let serviceVC = MPSideA_ServiceViewController()
self?.navigationController?.pushViewController(serviceVC, animated: true)
}
}
}
}