123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- //
- // TSSetingVC.swift
- // TSLiveWallpaper
- //
- // Created by 100Years on 2024/12/20.
- //
- class TSMineVC: TSBaseVC, UITableViewDataSource, UITableViewDelegate {
- lazy var dataArray:[TSBasicSectionModel] = {
- var dataArray = [TSBasicSectionModel]()
- let sectionModel = TSBasicSectionModel()
- dataArray.append(sectionModel)
-
- sectionModel.addSubItemModel(
- TSBasicItemModel.createItemModel(
- leftTitle: "Rate us".localized,
- rightViewStyle: 0,
- rightString: "",
- rightIsHave: true,
- height: 80,
- rectCorner:.allCorners,
- tapBlock: {[weak self] itemModel, index, view in
-
- guard let self = self else { return }
- let appStoreLink = "itms-apps://itunes.apple.com/app/id\(TSConfig.appid)"
- if let url = URL(string: appStoreLink + "?action=write-review"),
- UIApplication.shared.canOpenURL(url) {
- UIApplication.shared.open(url)
- }
- }))
-
- sectionModel.addSubItemModel(
- TSBasicItemModel.createItemModel(
- leftTitle: "Share us".localized,
- rightViewStyle: 0,
- rightString: "",
- rightIsHave: true,
- height: 80,
- rectCorner:.allCorners,
- tapBlock: {[weak self] itemModel, index, view in
- guard let self = self else { return }
- let httpAppStoreLink = "https://apps.apple.com/app/id\(TSConfig.appid)"
- let text = "I'm using Sweeter to decorate my phone, there are not only themes, wallpapers, widgets, but also dynamic island and super useful tools, come and try with me!".localized
- let url = URL(string: httpAppStoreLink)!
- let image = UIImage(named: "App-Icon")!
- let vc = UIActivityViewController(activityItems: [image, text, url], applicationActivities: nil)
- vc.completionWithItemsHandler = { activity, value, _, error in
- if let type = activity, type == .copyToPasteboard {
- UIPasteboard.general.string = httpAppStoreLink
- }
- }
-
- if UIDevice.isPad {
- vc.modalPresentationStyle = .popover
- }
-
- self.present(vc, animated: true)
-
- }))
-
- sectionModel.addSubItemModel(
- TSBasicItemModel.createItemModel(
- leftTitle: "Privacy Policy".localized,
- rightViewStyle: 0,
- rightString: "",
- rightIsHave: true,
- height: 80,
- rectCorner:.allCorners,
- tapBlock: {[weak self] itemModel, index, view in
- guard let self = self else { return }
- let vc = TSBusinessWebVC(urlType: .privacy)
- vc.hidesBottomBarWhenPushed = true
- navigationController?.pushViewController(vc, animated: true)
- }))
-
- sectionModel.addSubItemModel(
- TSBasicItemModel.createItemModel(
- leftTitle: "Terms of Service".localized,
- rightViewStyle: 0,
- rightString: "",
- rightIsHave: true,
- height: 80,
- rectCorner:.allCorners,
- tapBlock: {[weak self] itemModel, index, view in
- guard let self = self else { return }
- let vc = TSBusinessWebVC(urlType: .terms)
- vc.hidesBottomBarWhenPushed = true
- navigationController?.pushViewController(vc, animated: true)
- }))
-
- sectionModel.addSubItemModel(
- TSBasicItemModel.createItemModel(
- leftTitle: "About us".localized,
- rightViewStyle: 0,
- rightString: appVersion(),
- rightIsHave: false,
- height: 80,
- rectCorner:.allCorners,
- tapBlock: {[weak self] itemModel, index, view in
- guard let self = self else { return }
- let vc = TSAboutUsVC()
- vc.hidesBottomBarWhenPushed = true
- navigationController?.pushViewController(vc, animated: true)
- }))
-
- return dataArray
-
- }()
-
- lazy var tableView:UITableView = {
- let tableView = UITableView()
- tableView.initBaseTableView(reuseClass: ["TSMineCell"], isUseMJRefresh: false, delegate: self)
- return tableView
- }()
-
- lazy var navBarView: TSBaseNavContentBarView = {
- let navBarView = TSBaseNavContentBarView()
- let titleImageView = UIImageView.createImageView(imageName: "nav_title_setting",contentMode: .scaleToFill)
-
- navBarView.barView.addSubview(titleImageView)
- titleImageView.snp.makeConstraints { make in
- make.centerY.equalToSuperview()
- make.left.equalTo(16)
- make.width.equalTo(101)
- make.height.equalTo(24)
- }
- return navBarView
- }()
-
- override func createData() {
-
- }
-
- override func createView() {
-
- setViewBgImageNamed(named: "view_main_bg")
-
- navBarContentView.addSubview(navBarView)
- navBarView.snp.makeConstraints { make in
- make.edges.equalToSuperview()
- }
-
- contentView.addSubview(tableView)
- tableView.snp.makeConstraints { make in
- make.leading.equalTo(16)
- make.trailing.equalTo(-16)
- make.top.bottom.equalTo(0)
- }
- }
- }
- extension TSMineVC {
-
- func numberOfSections(in tableView: UITableView) -> Int {
- return dataArray.count
- }
-
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- if let sectionModel = dataArray.safeObj(At: section){
- return sectionModel.itemsArray.count
- }
- return 0
- }
-
- func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
- if let sectionModel = dataArray.safeObj(At: indexPath.section),let itemModel = sectionModel.itemsArray.safeObj(At: indexPath.row){
- return itemModel.height
- }
- return 0
- }
-
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: "TSMineCell") as! TSMineCell
- if let sectionModel = dataArray.safeObj(At: indexPath.section),let itemModel = sectionModel.itemsArray.safeObj(At: indexPath.row){
- cell.itemModel = itemModel
- }
- return cell
- }
-
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
- if let sectionModel = dataArray.safeObj(At: indexPath.section),let itemModel = sectionModel.itemsArray.safeObj(At: indexPath.row){
- itemModel.tapBlock?(itemModel,indexPath.row,nil)
- }
- }
- }
|