Commit f8504d8c authored by yqz's avatar yqz

邮件功能完成

parent 7550e2e4
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "icon_set_secret_ChangePin.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon_set_secret_ChangePin@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon_set_secret_ChangePin@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "icon_set_secret_Del.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon_set_secret_Del@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon_set_secret_Del@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "icon_set_secret_Email_l.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon_set_secret_Email_l@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon_set_secret_Email_l@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "icon_set_secret_FAQ.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon_set_secret_FAQ@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon_set_secret_FAQ@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "icon_set_secret_Face.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon_set_secret_Face@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon_set_secret_Face@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "icon_set_secret_Hint.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon_set_secret_Hint@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon_set_secret_Hint@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "icon_set_secret_Info.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon_set_secret_Info@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon_set_secret_Info@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "icon_set_secret_Off.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon_set_secret_Off@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon_set_secret_Off@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "icon_set_secret_On.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon_set_secret_On@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon_set_secret_On@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "icon_set_secret_Privacy.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon_set_secret_Privacy@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon_set_secret_Privacy@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "icon_set_secret__vibration_setting.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon_set_secret__vibration_setting@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon_set_secret__vibration_setting@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "icon_set_secret_about_us.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon_set_secret_about_us@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon_set_secret_about_us@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "icon_set_secret_keep.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon_set_secret_keep@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon_set_secret_keep@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "icon_set_secret_lock.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon_set_secret_lock@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon_set_secret_lock@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "icon_set_secret_restore.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon_set_secret_restore@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon_set_secret_restore@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "icon_set_secret_widget.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon_set_secret_widget@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon_set_secret_widget@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -22,6 +22,13 @@ class DelSuccessViewController: UIViewController {
var fileCount:Int = 0
var fileSzie:Int64 = 0
enum delsuccessType {
case email
case other
}
var type:delsuccessType = .other
override func viewDidLoad() {
super.viewDidLoad()
bottomBtn.layer.cornerRadius = 15
......@@ -71,9 +78,15 @@ class DelSuccessViewController: UIViewController {
points.text = "Save 10 points"
delText.text = "\(fileCount) \(delType)(\(FileTool().formatBytes(size)))"
bottomText.text = "Clear the \"Recently Deleted\" album on iPhone to free up \(FileTool().formatBytes(size)) of space."
if type == .email {
bottomText.isHidden = true
delText.text = "\(fileCount) email\(fileCount > 1 ? "s" : "" )"
return
}else{
delText.text = "\(fileCount) \(delType)(\(FileTool().formatBytes(size)))"
bottomText.text = "Clear the \"Recently Deleted\" album on iPhone to free up \(FileTool().formatBytes(size)) of space."
bottomText.isHidden = false
}
// 设置 points 标签
let pointsAttributedString = NSMutableAttributedString(string: "Save 10 points")
......
......@@ -19,55 +19,54 @@ struct SettingModel {
struct RowInfoModel{
var imageName : String
var selectimageName : String?
var title: String
init(imageName: String, title: String) {
var isSwitch:Bool = false
init(imageName: String, selectimageName: String? = nil, title: String, isSwitch: Bool = false) {
self.imageName = imageName
self.selectimageName = selectimageName
self.title = title
self.isSwitch = isSwitch
}
}
func getSettingViewInfo() -> [SettingModel] {
return [
// SettingModel(sectionTitle: "",rowInfo: [RowInfoModel(imageName: "",title: "")]),
// SettingModel(sectionTitle: "FROM DEVELOPER",rowInfo:
// [RowInfoModel(imageName: "ic_more_setting",title: "More Apps From Us")]),
// SettingModel(sectionTitle: "EMAIL",rowInfo:
// [RowInfoModel(imageName: "ic_out_setting",title: "Sign Out")]),
// SettingModel(sectionTitle: "UTILITIES",rowInfo:
// [RowInfoModel(imageName: "ic_widgets_setting",title: "Widgets")]),
// SettingModel(sectionTitle: "SECRET SPACE",rowInfo: [
// RowInfoModel(imageName: "ic_pin_setting",title: "Use PIN"),
// RowInfoModel(imageName: "ic_delete_setting",title: "Remove After lmport")]),
// SettingModel(sectionTitle: "OTHERS",rowInfo:
// [RowInfoModel(imageName: "ic_vibration_setting",title: "Vibration"),
// RowInfoModel(imageName: "ic_list_setting",title: "Keep List"),
// RowInfoModel(imageName: "ic_hints_setting",title: "Hints")]),
// SettingModel(sectionTitle: "SUPPORT",rowInfo:
// [RowInfoModel(imageName: "ic_faq_setting",title: "FAQ"),
// RowInfoModel(imageName: "ic_email_setting",title: "Email Support"),
// RowInfoModel(imageName: "ic_restore_setting",title: "Restore Purchase"),
// RowInfoModel(imageName: "ic_about_setting",title: "About Us"),
// RowInfoModel(imageName: "ic_privacy_setting",title: "Privacy Policy")]),
// SettingModel(sectionTitle: "STAY IN TOUCH",rowInfo:
// [RowInfoModel(imageName: "ic_rate_setting",title: "Rate App"),
// RowInfoModel(imageName: "ic_share_setting",title: "Share App"),
// RowInfoModel(imageName: "ic_ins_setting",title: "Follow on Instagram")])]
SettingModel(sectionTitle: "",rowInfo: [RowInfoModel(imageName: "",title: "")]),
SettingModel(sectionTitle: "SECRET SPACE",rowInfo: [RowInfoModel(imageName: "icon_set_secret_lock",title: "Use PIN" , isSwitch:true),
RowInfoModel(imageName: "icon_set_secret_Face",title: "Use Face ID",isSwitch:true),
RowInfoModel(imageName: "icon_set_secret_ChangePin",title: "Change PIN"),
RowInfoModel(imageName: "icon_set_secret_Del",title: "Remove After Import",isSwitch:true)]),
SettingModel(sectionTitle: "E-mail",rowInfo: [RowInfoModel(imageName: "icon_set_secret_Email_l", title: "Log in")]),
SettingModel(sectionTitle: "UTILITIES",rowInfo: [RowInfoModel(imageName: "icon_set_secret_Email_l", title: "Widgets")]),
SettingModel(sectionTitle: "OTHERS",rowInfo: [RowInfoModel(imageName: "icon_set_secret_Email_l", title: "Hints"),
RowInfoModel(imageName: "icon_set_secret_Email_l", title: "Keen List"),
RowInfoModel(imageName: "icon_set_secret_Email_l", title: "Vibration",isSwitch:true)]),
SettingModel(sectionTitle: "SUPPORT",rowInfo: [RowInfoModel(imageName: " ", title: "Email Support"),
RowInfoModel(imageName: " ", title: "Restore Purchase"),
RowInfoModel(imageName: " ", title: "About Us"),
RowInfoModel(imageName: " ", title: "FAQ"),
RowInfoModel(imageName: " ", title: "Privacy Policy"),]),
]
SettingModel(sectionTitle: "",rowInfo: [RowInfoModel(imageName: "",title: "")]),
SettingModel(sectionTitle: "FROM DEVELOPER",rowInfo:
[RowInfoModel(imageName: "ic_more_setting",title: "More Apps From Us")]),
SettingModel(sectionTitle: "UTILITIES",rowInfo:
[RowInfoModel(imageName: "ic_widgets_setting",title: "Widgets")]),
SettingModel(sectionTitle: "OTHERS",rowInfo:
[RowInfoModel(imageName: "ic_list_setting",title: "Keep List")]),
// SettingModel(sectionTitle: "SECRET SPACE",rowInfo: [
// RowInfoModel(imageName: "ic_pin_setting",title: "Use PIN")]),
SettingModel(sectionTitle: "STAY IN TOUCH",rowInfo:
[RowInfoModel(imageName: "ic_rate_setting",title: "Rate App"),
RowInfoModel(imageName: "ic_share_setting",title: "Share App"),
/*RowInfoModel(imageName: "ic_ins_setting",title: "Follow on Instagram")*/]),
SettingModel(sectionTitle: "STAY IN TOUCH",rowInfo:
[RowInfoModel(imageName: "ic_email_setting",title: "Email support") ])]
// SettingModel(sectionTitle: "FROM DEVELOPER",rowInfo:
// [RowInfoModel(imageName: "ic_more_setting",title: "More Apps From Us")]),
//
// SettingModel(sectionTitle: "UTILITIES",rowInfo:
// [RowInfoModel(imageName: "ic_widgets_setting",title: "Widgets")]),
// SettingModel(sectionTitle: "OTHERS",rowInfo:
// [RowInfoModel(imageName: "ic_list_setting",title: "Keep List")]),
// SettingModel(sectionTitle: "STAY IN TOUCH",rowInfo:
// [RowInfoModel(imageName: "ic_rate_setting",title: "Rate App"),
// RowInfoModel(imageName: "ic_share_setting",title: "Share App"),
// /*RowInfoModel(imageName: "ic_ins_setting",title: "Follow on Instagram")*/]),
// SettingModel(sectionTitle: "STAY IN TOUCH",rowInfo:
// [RowInfoModel(imageName: "ic_email_setting",title: "Email support") ])]
}
......@@ -106,15 +106,14 @@ class SettingViewController : BaseViewController , UITableViewDelegate, UITableV
}
return cell
}
}
}
func numberOfSections(in tableView: UITableView) -> Int {
return modelData!.count
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if section == 0{
return 0
......@@ -125,7 +124,6 @@ class SettingViewController : BaseViewController , UITableViewDelegate, UITableV
let view = UIView()
view.frame = CGRect(x: 0, y: 0, width: view.width, height: 49)
view.backgroundColor = .clear
let titleLabel = UILabel()
titleLabel.text = modelData![section].sectionTitle
titleLabel.font = UIFont(name: "PingFang SC-Bold", size: 12)
......@@ -149,48 +147,53 @@ class SettingViewController : BaseViewController , UITableViewDelegate, UITableV
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch indexPath.section {
case 0:
break
case 1:
break
case 2: // 小组件
let widget = WidgetViewController()
self.navigationController?.pushViewController(widget, animated: true)
break
case 3:
// 保留列表
break
case 4:
if indexPath.row == 0 { // 评分
self.review()
}else if indexPath.row == 1 { // 分享
self.PhoneShare()
}
break
case 5:
if indexPath.row == 0 { // 邮件登录和退出
if PMEmailManager.shareManager.loginUser != nil {
let alert = EmailContentDelAlert(state: .list)
alert.callblock = { idx in
if idx == 1 {
PMEmailManager.shareManager.signOut { success in
if success {
}
}
}
}
alert.show()
}else{
let vc:EmailLoginController = EmailLoginController()
vc.state = .set
self.navigationController?.pushViewController(vc, animated: true)
}
}
default:
break
}
let model : SettingModel = modelData![indexPath.section]
let detailModel : RowInfoModel = model.rowInfo[indexPath.row]
// switch indexPath.section {
// case 0:
// break
// case 1:
// break
// case 2: // 小组件
// let widget = WidgetViewController()
// self.navigationController?.pushViewController(widget, animated: true)
// break
// case 3:
// // 保留列表
// break
// case 4:
// if indexPath.row == 0 { // 评分
// self.review()
// }else if indexPath.row == 1 { // 分享
// self.PhoneShare()
// }
// break
// case 5:
// if indexPath.row == 0 { // 邮件登录和退出
// if PMEmailManager.shareManager.loginUser != nil {
// let alert = EmailContentDelAlert(state: .emailSignOut)
// alert.callblock = { idx in
// if idx == 1 {
// PMEmailManager.shareManager.signOut { success in
// if success {
// EmailFilterManager.share.signOut()
// }
// }
// }
// }
// alert.show()
// }else{
// let vc:EmailLoginController = EmailLoginController()
// vc.state = .set
// self.navigationController?.pushViewController(vc, animated: true)
// }
// }
// default:
// break
// }
}
......
......@@ -21,7 +21,7 @@
<rect key="frame" x="15" y="0.0" width="326" height="89"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XwR-Ch-R1t">
<rect key="frame" x="6" y="15.000000000000004" width="44" height="44.333333333333343"/>
<rect key="frame" x="6" y="15" width="44" height="44"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="waN-0f-ZFP"/>
</constraints>
......@@ -34,7 +34,7 @@
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="G" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Lkh-fE-u5M">
<rect key="frame" x="50" y="17.333333333333329" width="40" height="40"/>
<rect key="frame" x="50" y="17" width="40" height="40"/>
<color key="backgroundColor" red="0.0" green="0.50980392156862742" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" constant="40" id="WQp-b1-7L9"/>
......@@ -50,7 +50,7 @@
</userDefinedRuntimeAttributes>
</label>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" spacing="2" translatesAutoresizingMaskIntoConstraints="NO" id="tF1-pU-1Ak">
<rect key="frame" x="100" y="15.666666666666668" width="216" height="53.333333333333329"/>
<rect key="frame" x="100" y="15.333333333333332" width="216" height="53.333333333333343"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="aXC-da-48n">
<rect key="frame" x="0.0" y="0.0" width="216" height="19.333333333333332"/>
......@@ -80,16 +80,19 @@
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" translatesAutoresizingMaskIntoConstraints="NO" id="5Cl-XH-rD8">
<rect key="frame" x="166" y="3.0000000000000018" width="50" height="12.999999999999998"/>
<rect key="frame" x="118" y="3.3333333333333339" width="98" height="13.000000000000002"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="11 Nov" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2zo-ld-bPP">
<rect key="frame" x="0.0" y="0.0" width="37" height="13"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="11 Nov" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2zo-ld-bPP">
<rect key="frame" x="0.0" y="0.0" width="85" height="13"/>
<constraints>
<constraint firstAttribute="width" constant="85" id="Vjb-uy-Rbn"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" red="0.70196078431372544" green="0.70196078431372544" blue="0.70196078431372544" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_left_setting_grey" translatesAutoresizingMaskIntoConstraints="NO" id="ubl-ns-bXJ">
<rect key="frame" x="37" y="0.0" width="13" height="13"/>
<rect key="frame" x="85" y="0.0" width="13" height="13"/>
<constraints>
<constraint firstAttribute="width" constant="13" id="YdB-iz-Nwc"/>
<constraint firstAttribute="width" secondItem="ubl-ns-bXJ" secondAttribute="height" multiplier="1:1" id="nFl-sn-e8h"/>
......@@ -100,7 +103,7 @@
</subviews>
</stackView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Google Payments:您的付款处于暂停状..." textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8Mr-iL-2qm">
<rect key="frame" x="0.0" y="21.333333333333336" width="216" height="15.666666666666664"/>
<rect key="frame" x="0.0" y="21.333333333333329" width="216" height="15.666666666666664"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" red="0.40000000000000002" green="0.40000000000000002" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
......@@ -154,7 +157,7 @@
</tableViewCell>
</objects>
<resources>
<image name="ic_sel_com" width="24" height="24.333333969116211"/>
<image name="ic_sel_com" width="24" height="24"/>
<image name="ic_unsel_com_red" width="24" height="24"/>
<image name="icon_left_setting_grey" width="20" height="20"/>
</resources>
......
......@@ -36,16 +36,23 @@ class EmailKeyWordItemsCell: UITableViewCell {
private func reloadItems() -> Void {
self.EmailFilterKeywordCollection.reloadData()
self.layoutIfNeeded()
DispatchQueue.main.asyncAfter(deadline: .now()+0.1, execute: {
Print("fefsfsfsf \(self.EmailFilterKeywordCollection.contentSize.height)")
let height = self.EmailFilterKeywordCollection.height
DispatchQueue.main.asyncAfter(deadline: .now()+0.05, execute: {
if self.datasoure.count > 0 {
self.collectHeightConstraint.constant = self.EmailFilterKeywordCollection.contentSize.height
}else{
self.collectHeightConstraint.constant = 0
self.collectHeightConstraint.constant = 0.0
}
if height != self.EmailFilterKeywordCollection.contentSize.height {
self.callblock()
self.layoutIfNeeded()
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.01) {
let height = self.EmailFilterKeywordCollection.height
Print("keywordCell: \(self.EmailFilterKeywordCollection.contentSize.height) height:\(height)")
if height != self.EmailFilterKeywordCollection.contentSize.height {
if (self.datasoure.count == 0 && height <= 44) {
}else{
self.callblock()
}
}
}
})
}
......
......@@ -21,7 +21,7 @@
<rect key="frame" x="0.0" y="0.0" width="362" height="96"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" id="wh6-On-2nF"/>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="1" id="wh6-On-2nF"/>
</constraints>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="nsY-D4-rsQ" customClass="EmailKeywordCollectionFlowLayout" customModule="PhoneManager" customModuleProvider="target">
<size key="itemSize" width="128" height="128"/>
......
......@@ -8,12 +8,13 @@
import UIKit
class EmailContentDelAlert: UIViewController {
class EmailContentDelAlert: UIViewController, UIViewControllerTransitioningDelegate {
enum EmailStateAlert {
case group
case list
case emailSignOut
case emailApply
}
var callblock:((Int)->Void) = { idx in}
......@@ -23,15 +24,18 @@ class EmailContentDelAlert: UIViewController {
@IBOutlet weak var EmailContentAction1: UIButton!
@IBOutlet weak var EmailContentAction2: UIButton!
@IBOutlet weak var tipsLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.colorWithHex(hexStr: "#000000", alpha: 0.5)
self.transitioningDelegate = self
view.backgroundColor = .clear //UIColor.colorWithHex(hexStr: "#000000", alpha: 0.5)
switch state {
case .group:
EmailContentMessage.text = "Do you want to apply filters\nfirst or delete mails\nimmediately?"
EmailContentAction1.setTitle("Open Filters", for: .normal)
EmailContentAction2.setTitle("Delete Mails", for: .normal)
EmailContentMessage.text = "Are you sure you want to delete\nthe selected message?"
EmailContentAction1.setTitle("Delete", for: .normal)
EmailContentAction2.setTitle("Cancel", for: .normal)
tipsLabel.text = "This process cannot be revoked!"
break
case .list:
EmailContentMessage.text = "Are you sure you want to delete\nthe selected message?"
......@@ -43,9 +47,18 @@ class EmailContentDelAlert: UIViewController {
EmailContentAction1.setTitle("Yes", for: .normal)
EmailContentAction2.setTitle("Cancel", for: .normal)
break
case .emailApply:
EmailContentMessage.text = "Are you sure you want to apply filters?"
EmailContentAction1.setTitle("Yes", for: .normal)
EmailContentAction2.setTitle("Cancel", for: .normal)
break
}
}
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return customDismissAnimator()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}
......@@ -56,8 +69,9 @@ class EmailContentDelAlert: UIViewController {
}
@IBAction func openAction(_ sender: Any) {
callblock(1)
self.dismiss(animated: true)
self.dismiss(animated: true) {
self.callblock(1)
}
}
@IBAction func delMails(_ sender: Any) {
......
......@@ -14,6 +14,7 @@
<outlet property="EmailContentAction1" destination="H0G-H1-Hx9" id="UGo-uz-h5v"/>
<outlet property="EmailContentAction2" destination="jnJ-Cn-DN9" id="kvy-Tn-fkZ"/>
<outlet property="EmailContentMessage" destination="LvN-1W-NqV" id="Njf-Gw-nPY"/>
<outlet property="tipsLabel" destination="yqI-kg-YyJ" id="icK-lR-aEA"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
......@@ -23,7 +24,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="pSS-8M-78U">
<rect key="frame" x="15" y="324" width="363" height="204"/>
<rect key="frame" x="15" y="319.66666666666669" width="363" height="213.00000000000006"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Do you want to apply filters first or delete mails immediately?" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LvN-1W-NqV">
<rect key="frame" x="30" y="28" width="303" height="48"/>
......@@ -31,8 +32,14 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yqI-kg-YyJ">
<rect key="frame" x="30" y="86" width="303" height="0.0"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.59999999999999998" green="0.59999999999999998" blue="0.59999999999999998" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="H0G-H1-Hx9">
<rect key="frame" x="20" y="92" width="323" height="46"/>
<rect key="frame" x="20" y="101" width="323" height="46"/>
<color key="backgroundColor" red="0.0" green="0.50980392156862742" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="46" id="5di-G4-1L2"/>
......@@ -50,7 +57,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="jnJ-Cn-DN9">
<rect key="frame" x="20" y="142" width="323" height="46"/>
<rect key="frame" x="20" y="151" width="323" height="46"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="46" id="nV9-Zl-cHG"/>
......@@ -73,15 +80,18 @@
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="jnJ-Cn-DN9" firstAttribute="trailing" secondItem="H0G-H1-Hx9" secondAttribute="trailing" id="4ng-Lt-WbX"/>
<constraint firstAttribute="trailing" secondItem="yqI-kg-YyJ" secondAttribute="trailing" constant="30" id="5OO-6z-B78"/>
<constraint firstAttribute="trailing" secondItem="H0G-H1-Hx9" secondAttribute="trailing" constant="20" id="905-Xu-9S0"/>
<constraint firstItem="jnJ-Cn-DN9" firstAttribute="leading" secondItem="H0G-H1-Hx9" secondAttribute="leading" id="LEk-uf-rgE"/>
<constraint firstAttribute="bottom" secondItem="jnJ-Cn-DN9" secondAttribute="bottom" constant="16" id="Md6-lU-fDx"/>
<constraint firstAttribute="trailing" secondItem="LvN-1W-NqV" secondAttribute="trailing" constant="30" id="NSl-d7-q7R"/>
<constraint firstItem="H0G-H1-Hx9" firstAttribute="leading" secondItem="pSS-8M-78U" secondAttribute="leading" constant="20" id="Ug2-zL-HbE"/>
<constraint firstItem="LvN-1W-NqV" firstAttribute="top" secondItem="pSS-8M-78U" secondAttribute="top" constant="28" id="WEG-CD-zit"/>
<constraint firstItem="H0G-H1-Hx9" firstAttribute="top" secondItem="LvN-1W-NqV" secondAttribute="bottom" constant="16" id="iri-xQ-fNU"/>
<constraint firstItem="jnJ-Cn-DN9" firstAttribute="top" secondItem="H0G-H1-Hx9" secondAttribute="bottom" constant="4" id="lRP-Ui-Mbq"/>
<constraint firstItem="yqI-kg-YyJ" firstAttribute="leading" secondItem="pSS-8M-78U" secondAttribute="leading" constant="30" id="m9o-xP-U3F"/>
<constraint firstItem="LvN-1W-NqV" firstAttribute="leading" secondItem="pSS-8M-78U" secondAttribute="leading" constant="30" id="nXB-dD-AvZ"/>
<constraint firstItem="yqI-kg-YyJ" firstAttribute="top" secondItem="LvN-1W-NqV" secondAttribute="bottom" constant="10" id="s9a-5Y-GQc"/>
<constraint firstItem="H0G-H1-Hx9" firstAttribute="top" secondItem="yqI-kg-YyJ" secondAttribute="bottom" constant="15" id="vnj-F4-jli"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="Radius">
......
......@@ -18,6 +18,7 @@ class EmailSaveController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor.colorWithHex(hexStr: "#000000", alpha: 0.5)
}
@IBOutlet weak var messageBox: UILabel!
......
......@@ -12,11 +12,14 @@ class EmailCleanController: BaseViewController {
override func viewDidLoad() {
super.viewDidLoad()
setup()
PMEmailManager.shareManager.fetchEmails {
self.contentView.datasource = PMEmailManager.shareManager.allMessage
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
PMEmailManager.shareManager.fetchEmails()
self.contentView.datasource = PMEmailManager.shareManager.allMessage
}
private func setup() -> Void {
......@@ -29,8 +32,15 @@ class EmailCleanController: BaseViewController {
private lazy var contentView: EmailContentView = {
let content = EmailContentView(self)
view.addSubview(content)
content.callblock = { [weak self] show in
guard let self = self else { return }
if show {
self.view.showBlur()
}else{
self.view.hideBlur()
}
}
return content
}()
}
......@@ -16,16 +16,34 @@ class EmailCleanListController: BaseViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
titleView.model.isBackBtnShow = true
tableView.indexPath = indexPath
datasoure = PMEmailManager.shareManager.allMessage[indexPath?.row ?? 0].child
setup()
}
var indexPath:IndexPath?
var datasoure:[EmailMessageModel] = [] {
didSet {
tableView.datasource = datasoure
seletedAllBtn.isHidden = !(datasoure.count > 0)
seletedAllBtn.isSelected = EmailFilterManager.share.SelectEmailSet[indexPath?.row ?? 0].count == datasoure.count
}
}
@objc func seletedAllBtnClick() {
DispatchQueue.main.async {[weak self] in
guard let self else {return}
seletedAllBtn.isUserInteractionEnabled = false
seletedAllBtn.isSelected = !seletedAllBtn.isSelected
UIView.animate(withDuration: 0.1) {
UIView.animate(withDuration: 0.2) {
self.seletedAllBtn.width = self.seletedAllBtn.isSelected ? 131 : 115
self.seletedAllBtn.x = self.titleView.width - marginLR - self.seletedAllBtn.width
} completion: { su in
if su {
self.seletedAllBtn.isUserInteractionEnabled = true
}
}
tableView.changeSelectAll(seletedAllBtn.isSelected)
}
......@@ -46,9 +64,9 @@ class EmailCleanListController: BaseViewController {
seletedAllBtn.x = titleView.width - marginLR - seletedAllBtn.width
}
private lazy var titleLabel: UILabel = {
lazy var titleLabel: UILabel = {
let label = UILabel()
label.text = "Social Media"
label.text = ""
label.font = UIFont.systemFont(ofSize: 20, weight: .bold)
label.textColor = .black
label.textAlignment = .left
......@@ -63,6 +81,14 @@ class EmailCleanListController: BaseViewController {
guard let self = self else { return }
self.seletedAllBtn.isSelected = select
}
tab.callBlur = { [weak self] show in
guard let self = self else { return }
if show {
self.view.showBlur()
}else{
self.view.hideBlur()
}
}
return tab
}()
......
......@@ -14,6 +14,8 @@ class EmailFilterController: BaseViewController {
setup()
}
var filter = EmailFilterManager.share.FilterSet
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.tableView.reloadData()
......@@ -27,7 +29,7 @@ class EmailFilterController: BaseViewController {
}
}
var datasource:[EmailFilterModel] = EmailFilterManager.share.filter()
var datasource:[EmailFilterModel] = EmailFilterManager.share.EmailfilterHeaders()
private func setup() -> Void {
titleLabel.snp.makeConstraints({ make in
......@@ -68,6 +70,7 @@ class EmailFilterController: BaseViewController {
tab.sectionHeaderHeight = 50
tab.register(UINib(nibName: EmailFilterSelectCell.id, bundle: nil), forCellReuseIdentifier: EmailFilterSelectCell.id)
tab.register(UINib(nibName: EmailFilterFAVORITECell.id, bundle: nil), forCellReuseIdentifier: EmailFilterFAVORITECell.id)
tab.register(UINib(nibName: EmailFilterFAVORITECell.id, bundle: nil), forCellReuseIdentifier: EmailFilterFAVORITECell.id + "Sub")
tab.register(UINib(nibName: EmailFilterKeywordCell.id, bundle: nil), forCellReuseIdentifier: EmailFilterKeywordCell.id)
tab.register(UINib(nibName: EmailKeyWordItemsCell.id, bundle: nil), forCellReuseIdentifier: EmailKeyWordItemsCell.id)
if #available(iOS 15.0, *) {
......@@ -90,38 +93,28 @@ class EmailFilterController: BaseViewController {
view.addSubview(emailLogin)
return emailLogin
}()
private func timeSet(_ indexPath:IndexPath) -> Void {
var btnts = self.datasource[indexPath.section].child ?? []
var modify:[EmailFilterChildModel] = []
for (row,var objc) in btnts.enumerated() {
if row == indexPath.row {
objc.isSelect = true
}else{
objc.isSelect = false
}
modify.append(objc)
}
self.datasource[indexPath.section].child = modify
}
private func readUnread(_ indexPath:IndexPath ,isselect:Bool) -> Void {
var btnts = self.datasource[indexPath.section].child ?? []
if isselect {
self.datasource[indexPath.section].child?[indexPath.row].isSelect = isselect
if indexPath.row == 0 {
self.filter.read = isselect
}else{
self.filter.unread = isselect
}
}else{
self.datasource[indexPath.section].child?[indexPath.row].isSelect = isselect
if indexPath.row == 0 {
guard var vab = (self.datasource[indexPath.section].child?[1]) else { return }
if vab.isSelect == false {
vab.isSelect = true
self.datasource[indexPath.section].child?[1] = vab
if self.filter.unread == false {
self.filter.unread = true
self.filter.read = isselect
}else{
self.filter.read = isselect
}
}else{
guard var vab = (self.datasource[indexPath.section].child?[0]) else { return }
if vab.isSelect == false {
vab.isSelect = true
self.datasource[indexPath.section].child?[0] = vab
if self.filter.read == false {
self.filter.read = true
self.filter.unread = isselect
}else{
self.filter.unread = isselect
}
}
}
......@@ -132,14 +125,25 @@ class EmailFilterController: BaseViewController {
extension EmailFilterController : UITableViewDelegate,UITableViewDataSource {
@objc func ApplyAction() -> Void {
guard var path = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return }
path = path.appendingPathComponent("EmailFilter.json")
do{
let data = try JSONEncoder().encode(datasource)
try data.write(to: path)
}catch{
let alert = EmailContentDelAlert(state: .emailApply)
alert.show()
self.view.showBlur()
alert.callblock = { [weak self] idx in
guard let self = self else { return }
self.view.hideBlur()
if idx == 1 {
EmailFilterManager.share.FilterSet = self.filter
let save = EmailSaveController()
save.modalTransitionStyle = .crossDissolve
save.modalPresentationStyle = .overFullScreen
self.present(save, animated: true)
DispatchQueue.main.asyncAfter(deadline: .now()+1.5) {
save.dismiss(animated: true) {
self.navigationController?.popViewController(animated: true)
}
}
}
}
self.navigationController?.popViewController(animated: true)
}
func numberOfSections(in tableView: UITableView) -> Int {
......@@ -160,32 +164,45 @@ extension EmailFilterController : UITableViewDelegate,UITableViewDataSource {
if datasource[indexPath.section].header == "TIME" {
let cell = tableView.dequeueReusableCell(withIdentifier: EmailFilterSelectCell.id, for: indexPath) as! EmailFilterSelectCell
cell.titleL.text = data?.title ?? ""
cell.selectBtn.isSelected = data?.isSelect ?? false
cell.selectBtn.isSelected = (filter.date == indexPath.row)
cell.top = (indexPath.row == 0)
cell.bot = (indexPath.row == (dataA?.count ?? 0 - 1))
cell.bot = (indexPath.row == ((dataA?.count ?? 1) - 1))
cell.callblock = {[weak self] select in
guard let self = self else { return }
self.timeSet(indexPath)
self.filter.date = indexPath.row
tableView.reloadData()
}
cell.selectionStyle = .none
cell.reload()
return cell
}else if datasource[indexPath.section].header == "FAVORITE" ||
datasource[indexPath.section].header == "READ & UNREAD" {
}else if datasource[indexPath.section].header == "FAVORITE" {
let cell = tableView.dequeueReusableCell(withIdentifier: EmailFilterFAVORITECell.id, for: indexPath) as! EmailFilterFAVORITECell
cell.titleL.text = data?.title ?? ""
cell.emSwtich.isOn = data?.isSelect ?? false
cell.emSwtich.isOn = filter.start
cell.top = (indexPath.row == 0)
cell.selectionStyle = .none
cell.bot = (indexPath.row == (dataA?.count ?? 0 - 1))
cell.bot = (indexPath.row == ((dataA?.count ?? 1) - 1))
cell.callblock = {[weak self] select in
guard let self = self else { return }
if self.datasource[indexPath.section].header == "FAVORITE" {
self.datasource[indexPath.section].child?[indexPath.row].isSelect = select
}else{
self.readUnread(indexPath,isselect: select)
}
self.filter.start = select
tableView.reloadData()
}
cell.reload()
return cell
}else if datasource[indexPath.section].header == "READ & UNREAD" {
let cell = tableView.dequeueReusableCell(withIdentifier: EmailFilterFAVORITECell.id + "Sub", for: indexPath) as! EmailFilterFAVORITECell
cell.titleL.text = data?.title ?? ""
if indexPath.row == 0 {
cell.emSwtich.isOn = filter.read
}else{
cell.emSwtich.isOn = filter.unread
}
cell.top = (indexPath.row == 0)
cell.selectionStyle = .none
cell.bot = (indexPath.row == ((dataA?.count ?? 1) - 1))
cell.callblock = {[weak self] select in
guard let self = self else { return }
self.readUnread(indexPath,isselect: select)
tableView.reloadData()
}
cell.reload()
......@@ -193,21 +210,23 @@ extension EmailFilterController : UITableViewDelegate,UITableViewDataSource {
}else{
let cell = tableView.dequeueReusableCell(withIdentifier: EmailFilterKeywordCell.id, for: indexPath) as! EmailFilterKeywordCell
cell.kwTitleL.text = data?.title ?? ""
cell.emSwitch.isOn = data?.isSelect ?? false
cell.emSwitch.isOn = filter.keyword
cell.top = (indexPath.row == 0)
cell.selectionStyle = .none
cell.bot = (indexPath.row == (dataA?.count ?? 0 - 1))
cell.callblock = {[weak self] event, select in
guard let self = self else { return }
if event == "switch" {
self.datasource[indexPath.section].child?[indexPath.row].isSelect = select
self.filter.keyword = select
tableView.reloadData()
}else{
self.view.showBlur()
let keyword = EmailKeywordController()
keyword.modalPresentationStyle = .overFullScreen
keyword.callblock = { text in
var keywords = EmailFilterManager.share.keyword
keywords.append(text)
self.view.hideBlur()
EmailFilterManager.share.keyword = keywords
tableView.reloadData()
}
......
......@@ -12,7 +12,6 @@ class EmailKeywordController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = .clear
self.view.addSubview(blur)
setup()
NotificationCenter.default.addObserver(self, selector: #selector(keyBoardShow(_:)), name: UIApplication.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyBoardHide(_:)), name: UIApplication.keyboardWillHideNotification, object: nil)
......@@ -52,19 +51,11 @@ class EmailKeywordController: UIViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
DispatchQueue.main.async {
self.blur.frame = self.view.bounds
self.textInput.becomeFirstResponder()
self.content.cornerCut(radius: 16, corner: [.topLeft,.topRight])
}
}
private lazy var blur: UIVisualEffectView = {
let blurEffect = UIBlurEffect(style: .systemChromeMaterialDark)
let blurView = UIVisualEffectView(effect: blurEffect)
blurView.alpha = 0.8
return blurView
}()
private func setup() -> Void {
content.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
......@@ -107,7 +98,6 @@ class EmailKeywordController: UIViewController {
self.dismiss(animated: true)
}
}
}else{
self.dismiss(animated: true)
}
......
......@@ -6,15 +6,91 @@
//
import UIKit
import WebKit
class EmailListDetailController: BaseViewController {
private let scrollView = UIScrollView()
private let contentStack = UIStackView()
private let textView = UITextView()
private let webView = WKWebView()
override func viewDidLoad() {
super.viewDidLoad()
setup()
}
func setup() -> Void {
var detail:EmailMessageModel?
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
setdetail()
setRead()
}
private func setRead() -> Void {
if detail?.labelids?.contains("UNREAD") ?? false {
let msgid = detail?.messageId ?? ""
PMEmailManager.shareManager.markMessageAsRead(messageId: msgid) {[weak self] success, error in
guard let self = self else { return }
if success {
var all = PMEmailManager.shareManager.messageFilter
for (i,var child) in all.enumerated() {
if var data:[EmailMessageModel] = child.child as? [EmailMessageModel] {
for (j,var d) in data.enumerated() {
if d.messageId == msgid {
var labels:NSMutableSet = NSMutableSet(array: d.labelids ?? [])
labels.remove("UNREAD")
d.labelids = labels.allObjects as? [String] ?? []
data[j] = d
child.child = data
all[i] = child
break
}
}
}
}
PMEmailManager.shareManager.messageFilter = all
PMEmailManager.shareManager.allMessage = all
}
}
}
}
private func setdetail() -> Void {
let send = detail?.payload?.headers?.from ?? " "
LT.text = (send.count > 0 ? send.substring(to: send.index(send.startIndex, offsetBy: 1)) : "")
SendL.text = send.components(separatedBy: " ").first
ToEmail.text = "To:\(detail?.payload?.headers?.to ?? "")"
dateL.text = detail?.payload?.headers?.date?.EmailDateFromat().string("dd MMM")
titleL.text = detail?.payload?.headers?.subject
loadMessageData()
}
private func loadMessageData() {
// 解析正文
let (plainText, html) = (detail?.payload?.body.plainText,detail?.payload?.body.html)
if let html = html {
webView.isHidden = false
textView.isHidden = true
webView.loadHTMLString(html, baseURL: nil)
} else if let plainText = plainText {
webView.isHidden = true
textView.isHidden = false
textView.text = plainText
textView.sizeToFit()
self.view.layoutIfNeeded()
DispatchQueue.main.async {
self.textView.snp.makeConstraints { make in
make.height.equalTo(self.textView.contentSize.height)
}
self.scrollView.contentSize = CGSizeMake(0, self.textView.contentSize.height + 10)
}
}
}
private func setup() -> Void {
line.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(titleView.snp.bottom).offset(20)
......@@ -49,6 +125,42 @@ class EmailListDetailController: BaseViewController {
make.left.right.equalToSuperview().inset(marginLR)
make.top.equalTo(line1.snp.bottom).offset(20)
}
view.addSubview(scrollView)
scrollView.contentInsetAdjustmentBehavior = .never
scrollView.showsVerticalScrollIndicator = false
scrollView.showsHorizontalScrollIndicator = false
scrollView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview().inset(UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 15))
make.top.equalTo(titleL.snp.bottom).offset(15)
}
contentStack.axis = .vertical
contentStack.spacing = 16
contentStack.alignment = .fill
scrollView.addSubview(contentStack)
contentStack.snp.makeConstraints { make in
make.top.equalToSuperview()
make.leading.equalTo(scrollView.snp.leading)
make.width.equalTo(scrollView.snp.width)
}
textView.isEditable = false
textView.font = .systemFont(ofSize: 14)
textView.textColor = UIColor.colorWithHex(hexStr: "#666666")
textView.isScrollEnabled = false
textView.textContainerInset = .zero
// WebView配置
webView.isHidden = true
webView.navigationDelegate = self
let script = """
var meta = document.createElement('meta');
meta.name = 'viewport';
meta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no';
document.getElementsByTagName('head')[0].appendChild(meta);
"""
webView.evaluateJavaScript(script)
contentStack.addArrangedSubview(textView)
contentStack.addArrangedSubview(webView)
}
......@@ -66,7 +178,7 @@ class EmailListDetailController: BaseViewController {
private lazy var SendL: UILabel = {
let l = UILabel()
l.text = "Google Play Support"
l.text = ""
l.font = UIFont.systemFont(ofSize: 16, weight: .bold)
l.textColor = UIColor.colorWithHex(hexStr: "#333333")
view.addSubview(l)
......@@ -75,7 +187,7 @@ class EmailListDetailController: BaseViewController {
private lazy var ToEmail: UILabel = {
let l = UILabel()
l.text = "To:zxcvbnm@gmail.com"
l.text = ""
l.font = UIFont.systemFont(ofSize: 14, weight: .regular)
l.textColor = UIColor.colorWithHex(hexStr: "#666666")
view.addSubview(l)
......@@ -84,7 +196,7 @@ class EmailListDetailController: BaseViewController {
private lazy var dateL: UILabel = {
let l = UILabel()
l.text = "20 Dec"
l.text = ""
l.textAlignment = .right
l.font = UIFont.systemFont(ofSize: 12, weight: .regular)
l.textColor = UIColor.colorWithHex(hexStr: "#B3B3B3")
......@@ -94,7 +206,8 @@ class EmailListDetailController: BaseViewController {
private lazy var titleL: UILabel = {
let l = UILabel()
l.text = "Notification from Google Play"
l.text = ""
l.numberOfLines = 2
l.font = UIFont.systemFont(ofSize: 16, weight: .bold)
l.textColor = UIColor.colorWithHex(hexStr: "#333333")
view.addSubview(l)
......@@ -116,3 +229,28 @@ class EmailListDetailController: BaseViewController {
}()
}
extension EmailListDetailController: WKNavigationDelegate {
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.02) {
Print(webView.scrollView.contentSize)
webView.snp.makeConstraints { make in
make.height.equalTo(webView.scrollView.contentSize.height+10)
}
self.scrollView.contentSize = CGSizeMake(0, webView.scrollView.contentSize.height + 10)
}
}
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
// 禁止外部链接跳转
if navigationAction.navigationType == .linkActivated {
Print(navigationAction.request.url?.absoluteString)
decisionHandler(.cancel)
} else {
decisionHandler(.allow)
}
}
}
......@@ -11,6 +11,37 @@ class EmailFilterManager: NSObject {
static let share = EmailFilterManager()
var SelectEmailSet:[NSMutableSet] = [NSMutableSet(),
NSMutableSet(),
NSMutableSet(),
NSMutableSet(),
NSMutableSet()]
var FilterSet:EmailFilterData {
get {
return self.getFilterSet()
}
set{
guard var path = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return }
path = path.appendingPathComponent("EmailFilter.json")
do{
let data = try JSONEncoder().encode(newValue)
try data.write(to: path)
}catch{
}
}
}
func signOut() -> Void {
keyword = []
guard let path = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return }
let path1 = path.appendingPathComponent("EmailFilter.json")
do{
try FileManager.default.removeItem(at: path1)
}catch{ }
}
var keyword:[String] {
set {
guard let path = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return }
......@@ -33,39 +64,32 @@ class EmailFilterManager: NSObject {
}
}
func filter() -> [EmailFilterModel] {
let data = [ ["header":"TIME","child":[ ["title":"Delete all mails from selected categories",
"isSelect":true],
["title":"Delete 1 week and older mails",
"isSelect":false],
["title":"Delete 1 month and older mails",
"isSelect":false],
["title":"Delete 1 year and older mails",
"isSelect":false] ]
],
["header":"FAVORITE","child":[ ["title":"Delete stared mails",
"isSelect":false] ]
],
["header":"READ & UNREAD","child":[ ["title":"Delete read mails",
"isSelect":true],
["title":"Delete unread mails",
"isSelect":false]]
],
["header":"KEYWORDS","child":[ ["title":"Do not delete mails that contains the keywords below",
"isSelect":false,
"keyword":[] ] ]
]
]
guard let path = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return [] }
func getFilterSet() -> EmailFilterData {
guard let path = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return EmailFilterData() }
let path1 = path.appendingPathComponent("EmailFilter.json")
do {
let dataFile = try Data(contentsOf: path1)
let decode = try JSONDecoder().decode([EmailFilterModel].self, from:dataFile)
let decode = try JSONDecoder().decode(EmailFilterData.self, from:dataFile)
return decode
}catch{
return EmailFilterData()
}
}
func EmailfilterHeaders() -> [EmailFilterModel] {
let data = [ ["header":"TIME","child":[ ["title":"Delete all mails from selected categories"],
["title":"Delete 1 week and older mails"],
["title":"Delete 1 month and older mails"],
["title":"Delete 1 year and older mails"] ]
],
["header":"FAVORITE","child":[ ["title":"Delete stared mails" ] ]
],
["header":"READ & UNREAD","child":[ ["title":"Delete read mails"],
["title":"Delete unread mails"] ]
],
["header":"KEYWORDS","child":[ ["title":"Do not delete mails that contains the keywords below" ] ]
]
]
do{
let encode = try JSONSerialization.data(withJSONObject: data)
let decode = try JSONDecoder().decode([EmailFilterModel].self, from: encode)
......@@ -77,7 +101,6 @@ class EmailFilterManager: NSObject {
}
struct EmailFilterModel: Codable {
var header:String?
var child:[EmailFilterChildModel]?
......@@ -85,6 +108,78 @@ struct EmailFilterModel: Codable {
struct EmailFilterChildModel:Codable {
var title:String?
var isSelect:Bool = false
}
struct EmailFilterData:Codable {
var date:Int = 0
var start:Bool = false
var read:Bool = true
var unread:Bool = false
var keyword:Bool = false
}
func PmEmailData() -> [EmailDetailModel] {
let data = [["label":"Social Media","child":[] ],
["label":"Promotions","child":[] ],
["label":"Updates","child":[] ],
["label":"Forum","child":[] ],
["label":"Spam","child":[] ] ]
do{
let d = try JSONSerialization.data(withJSONObject: data)
let ret = try JSONDecoder().decode([EmailDetailModel].self, from: d)
return ret
}catch{
return []
}
}
struct EmailDetailModel : Codable {
var label:String = ""
var child:[EmailMessageModel] = []
}
struct EmailMessageModel:Codable {
var messageId:String? // 消息id
var labelids:[String]? // 标签
var snippet:String? //
var payload:EmailMessagepayLoadModel?
}
struct EmailMessagepayLoadModel : Codable {
var body:EmailMessageBodyModel = EmailMessageBodyModel()
var headers:EmailMessageHeadersModel?
}
struct EmailMessageBodyModel:Codable {
var plainText:String? // 内容 text
var html:String? // 内容 html
}
struct EmailMessageHeadersModel : Codable {
var from:String? // 发件人
var subject:String? // 主题
var date:String? // 时间
var to:String? // 收件人
}
extension String {
func date(_ format:String) -> Date {
let dateformatter = DateFormatter()
dateformatter.calendar = Calendar(identifier: .gregorian)
dateformatter.dateFormat = format
return dateformatter.date(from: self) ?? Date()
}
func GetddMM() -> String {
return self.EmailDateFromat().string("dd MMM yyyy")
}
func EmailDateFromat() -> Date {
return self.date("EEE, dd MMM yyyy HH:mm:ss zzz")
}
}
......@@ -10,6 +10,8 @@ import UIKit
class EmailCleanListView: UIView {
var callblock:((Bool)->Void) = { select in }
var callBlur:((Bool)->Void) = { show in }
var indexPath:IndexPath?
private func setup() -> Void {
tableView.snp.makeConstraints { make in
......@@ -22,18 +24,24 @@ class EmailCleanListView: UIView {
}
}
var mailset = NSMutableSet()
var datasource:[String] = ["","","","","","","",""]
var datasource:[EmailMessageModel] = [] {
didSet {
botAction.numberMails = EmailFilterManager.share.SelectEmailSet[indexPath?.row ?? 0].count
self.tableView.reloadData()
}
}
func changeSelectAll(_ select:Bool) -> Void {
let set = EmailFilterManager.share.SelectEmailSet[indexPath?.row ?? 0]
if select {
for i in 0..<datasource.count {
self.mailset.add(i)
set.add(i)
}
}else{
self.mailset.removeAllObjects()
set.removeAllObjects()
}
botAction.numberMails = self.mailset.count
EmailFilterManager.share.SelectEmailSet[indexPath?.row ?? 0] = set
botAction.numberMails = set.count
tableView.reloadData()
}
......@@ -58,7 +66,6 @@ class EmailCleanListView: UIView {
if #available(iOS 15.0, *) {
tab.sectionHeaderTopPadding = 0
} else {
// Fallback on earlier versions
}
addSubview(tab)
return tab
......@@ -68,12 +75,16 @@ class EmailCleanListView: UIView {
let bot = EmailContentBottonAction(state: .EmailList)
bot.clipsToBounds = false
addSubview(bot)
bot.numberMails = 0
bot.numberMails = EmailFilterManager.share.SelectEmailSet[indexPath?.row ?? 0].count
bot.callblock = { [weak self] in
guard let self = self else { return }
self.callBlur(true)
let alert = EmailContentDelAlert(state: .list)
alert.callblock = { idx in
if idx == 1 {
self.deleteEmail()
}
self.callBlur(false)
}
alert.show()
}
......@@ -83,6 +94,76 @@ class EmailCleanListView: UIView {
extension EmailCleanListView : UITableViewDataSource,UITableViewDelegate {
private func deleteEmail() -> Void {
let num = EmailFilterManager.share.SelectEmailSet[indexPath?.row ?? 0].count
let callblock = {[weak self] in
PMLoadingHUD.share.show()
PMEmailManager.shareManager.deleteEmail(self?.indexPath?.row ?? 0) { sucess in
guard let self = self else { return }
PMLoadingHUD.share.disMiss()
if sucess {
self.datasource = PMEmailManager.shareManager.allMessage[self.indexPath?.row ?? 0].child
self.botAction.numberMails = EmailFilterManager.share.SelectEmailSet[self.indexPath?.row ?? 0].count
self.tableView.reloadData()
self.showDeleteSuccess(fileCount: num, fileSize: 0)
}
}
}
if IAPManager.share.isSubscribed == false {
// 弹出内购页面
HomePayViewController.show {
// 再次判断下
if IAPManager.share.isSubscribed == false {
// 弹出提示框
let alertView = AdvTipSelectView(frame: self.bounds)
alertView.selectType = .selectTypeSetAnimation
alertView.getOtherInfoByType()
self.addSubview(alertView)
alertView.selectClickCallback = {isSure in
self.popAdverTisement()
AdvManager.shared.finisedCallBack = {
callblock()
}
}
}else{
callblock()
}
}
}else {
callblock()
}
}
// 删除成功页面
func showDeleteSuccess(fileCount:Int,fileSize:Int64){
DispatchQueue.main.async {
let vc = DelSuccessViewController()
vc.type = .email
vc.delType = fileCount > 1 ? "photos" : "photo"
vc.fileSzie = fileSize
vc.fileCount = fileCount
vc.modalPresentationStyle = .fullScreen
UIViewController.topMostViewController()?.present(vc, animated: true)
}
}
// 广告
func popAdverTisement(){
AdvManager.shared.showInterstitialAd(vc: UIViewController.topMostViewController() ?? UIViewController())
}
private func selectSet(_ indexPath:IndexPath) -> Void {
let set = EmailFilterManager.share.SelectEmailSet[self.indexPath?.row ?? 0]
if set.contains(indexPath.row) {
set.remove(indexPath.row)
}else{
set.add(indexPath.row)
}
self.botAction.numberMails = set.count
callblock(set.count == self.datasource.count)
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return datasource.count
}
......@@ -90,16 +171,19 @@ extension EmailCleanListView : UITableViewDataSource,UITableViewDelegate {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: EmailCleanListViewCell.id, for: indexPath) as! EmailCleanListViewCell
cell.selectionStyle = .none
cell.selectBtn.isSelected = self.mailset.contains(indexPath.row)
let data = datasource[indexPath.row]
let send = data.payload?.headers?.from ?? " "
cell.ListFirstL.text = (send.count > 0 ? send.substring(to:send.index(send.startIndex, offsetBy: 1)) : "")
cell.groupName.text = send as String
cell.EmailTimeL.text = data.payload?.headers?.date?.GetddMM()
cell.descpText.text = data.payload?.headers?.subject
cell.descpText1.text = data.payload?.body.plainText?.removeEscapeCharacters()
let set = EmailFilterManager.share.SelectEmailSet[self.indexPath?.row ?? 0]
cell.selectBtn.isSelected = set.contains(indexPath.row)
cell.ListDot.isHidden = !((data.labelids?.contains("UNREAD")) ?? false)
cell.callblock = {[weak self] in
guard let self = self else { return }
if self.mailset.contains(indexPath.row) {
self.mailset.remove(indexPath.row)
}else{
self.mailset.add(indexPath.row)
}
self.botAction.numberMails = self.mailset.count
callblock(self.mailset.count == self.datasource.count)
self.selectSet(indexPath)
tableView.reloadData()
}
return cell
......@@ -107,6 +191,8 @@ extension EmailCleanListView : UITableViewDataSource,UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let detail = EmailListDetailController()
detail.detail = datasource[indexPath.row]
UIViewController.topMostViewController()?.navigationController?.pushViewController(detail, animated: true)
}
}
......@@ -6,12 +6,12 @@
//
import UIKit
import MJRefresh
class EmailContentView: UIView {
var parent:UIViewController?
var mailset = NSMutableSet()
var callblock:((Bool)->Void) = { show in}
private func setup() -> Void {
topItem.snp.makeConstraints { make in
......@@ -19,10 +19,14 @@ class EmailContentView: UIView {
make.top.equalTo(self.snp.top).offset(0)
make.height.equalTo(60)
}
topLabel.snp.makeConstraints { make in
make.left.right.equalToSuperview().inset(15)
make.top.equalTo(topItem.snp.bottom)
}
tableView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.bottom.equalTo(botAction.snp.top)
make.top.equalTo(topItem.snp.bottom)
make.top.equalTo(topLabel.snp.bottom).offset(15)
}
botAction.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
......@@ -44,6 +48,16 @@ class EmailContentView: UIView {
super.init(coder: coder)
}
private lazy var topLabel: UILabel = {
let headerT = UILabel()
headerT.text = "Cleans the mails in the categories you choose,according to the filters you applied."
headerT.numberOfLines = 0
headerT.font = UIFont.systemFont(ofSize: 14)
headerT.textColor = UIColor(hex: "#333333")
addSubview(headerT)
return headerT
}()
private lazy var topItem: EmailCleanTopView = {
let item = EmailCleanTopView()
addSubview(item)
......@@ -63,6 +77,7 @@ class EmailContentView: UIView {
tab.separatorInset = UIEdgeInsets()
tab.rowHeight = 74 + 12
tab.sectionHeaderHeight = 40 + 12
tab.mj_header = mj_header
tab.register(UINib(nibName: EmailContentTabCell.id, bundle: nil), forCellReuseIdentifier: EmailContentTabCell.id)
if #available(iOS 15.0, *) {
tab.sectionHeaderTopPadding = 0
......@@ -71,6 +86,19 @@ class EmailContentView: UIView {
return tab
}()
@objc func refresh() -> Void {
EmailFilterManager.share.SelectEmailSet = [
NSMutableSet(),
NSMutableSet(),
NSMutableSet(),
NSMutableSet(),
NSMutableSet()
]
PMEmailManager.shareManager.fetchEmails {
self.datasource = PMEmailManager.shareManager.allMessage
}
}
private lazy var botAction: EmailContentBottonAction = {
let bot = EmailContentBottonAction(state: .EmailGroup)
bot.clipsToBounds = false
......@@ -78,35 +106,136 @@ class EmailContentView: UIView {
bot.numberMails = 0
bot.callblock = { [weak self] in
guard let self = self else { return }
self.callblock(true)
let alert = EmailContentDelAlert(state: .group)
alert.callblock = { idx in
if idx == 1 {
self.deleteEmail()
}
self.callblock(false)
}
alert.show()
}
return bot
}()
var datasource:[EmailDetailModel] = PMEmailManager.shareManager.allMessage {
didSet {
DispatchQueue.main.async {
self.mj_header.endRefreshing()
self.tableView.reloadData()
self.Total()
}
}
}
private lazy var mj_header: MJRefreshNormalHeader = {
let header = MJRefreshNormalHeader(refreshingTarget: self, refreshingAction: #selector(refresh))
return header
}()
}
extension EmailContentView :UITableViewDelegate,UITableViewDataSource{
private func deleteEmail() -> Void {
var num = 0
for set in EmailFilterManager.share.SelectEmailSet {
num += set.count
}
let callblock = {[weak self] in
PMLoadingHUD.share.show()
PMEmailManager.shareManager.deleteEmail { success in
guard let self = self else { return }
PMLoadingHUD.share.disMiss()
if success {
self.datasource = PMEmailManager.shareManager.allMessage
self.showDeleteSuccess(fileCount: num, fileSize: 0)
self.Total()
}
}
}
if IAPManager.share.isSubscribed == false {
// 弹出内购页面
HomePayViewController.show {
// 再次判断下
if IAPManager.share.isSubscribed == false {
// 弹出提示框
let alertView = AdvTipSelectView(frame: self.bounds)
alertView.selectType = .selectTypeSetAnimation
alertView.getOtherInfoByType()
self.addSubview(alertView)
alertView.selectClickCallback = {isSure in
self.popAdverTisement()
AdvManager.shared.finisedCallBack = {
callblock()
}
}
}else{
callblock()
}
}
}else {
callblock()
}
}
// 删除成功页面
func showDeleteSuccess(fileCount:Int,fileSize:Int64){
DispatchQueue.main.async {
let vc = DelSuccessViewController()
vc.type = .email
vc.delType = fileCount > 1 ? "photos" : "photo"
vc.fileSzie = fileSize
vc.fileCount = fileCount
vc.modalPresentationStyle = .fullScreen
UIViewController.topMostViewController()?.present(vc, animated: true)
}
}
// 广告
func popAdverTisement(){
AdvManager.shared.showInterstitialAd(vc: UIViewController.topMostViewController() ?? UIViewController())
}
private func Total() -> Void {
var num = 0
for set in EmailFilterManager.share.SelectEmailSet {
num += set.count
}
self.botAction.numberMails = num
}
private func selectAll(_ indexPath:IndexPath) -> Void {
let set = EmailFilterManager.share.SelectEmailSet[indexPath.row]
let data = datasource[indexPath.row]
if set.count == data.child.count {
set.removeAllObjects()
}else{
for i in 0..<data.child.count {
set.add(i)
}
}
EmailFilterManager.share.SelectEmailSet[indexPath.row] = set
Total()
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 2
return datasource.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let data = datasource[indexPath.row]
let cell = tableView.dequeueReusableCell(withIdentifier: EmailContentTabCell.id, for: indexPath) as! EmailContentTabCell
cell.selectionStyle = .none
cell.selectBtn.isSelected = self.mailset.contains(indexPath.row)
let set = EmailFilterManager.share.SelectEmailSet[indexPath.row]
cell.selectBtn.isSelected = (set.count == data.child.count && set.count > 0)
cell.groupName.text = data.label
cell.groupNumbers.text = "\(data.child.count) Emails" + (set.count > 0 ? " · \(set.count) Selected" : "")
cell.callblock = {[weak self] in
guard let self = self else { return }
if self.mailset.contains(indexPath.row) {
self.mailset.remove(indexPath.row)
}else{
self.mailset.add(indexPath.row)
}
self.botAction.numberMails = self.mailset.count
self.selectAll(indexPath)
tableView.reloadData()
}
return cell
......@@ -114,23 +243,11 @@ extension EmailContentView :UITableViewDelegate,UITableViewDataSource{
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let vc = EmailCleanListController()
let data = datasource[indexPath.row].child
vc.titleLabel.text = datasource[indexPath.row].label
vc.datasoure = data
vc.indexPath = indexPath
parent?.navigationController?.pushViewController(vc, animated: true)
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let header = UIView()
header.backgroundColor = .white
let headerT = UILabel()
headerT.text = "Cleans the mails in the categories you choose,according to the filters you applied."
headerT.numberOfLines = 0
headerT.font = UIFont.systemFont(ofSize: 14)
headerT.textColor = UIColor(hex: "#333333")
headerT.numberOfLines = 0
header.addSubview(headerT)
headerT.snp.makeConstraints { make in
make.left.right.top.equalToSuperview().inset(UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 15))
}
return header
}
}
......@@ -20,9 +20,11 @@ class EmailEmptyView: UIView {
let touch = ges.location(in: descpLabel)
let content = CGRectMake((descpLabel.width - 100) / 2.0, descpLabel.height - 25, 100, 25)
if CGRectContainsPoint(content, touch) {
let web = BaseWebViewController()
web.LoadWithUrl(url: "")
UIViewController.topMostViewController()?.navigationController?.pushViewController(web, animated: true)
let vc:PrivacyPolicyWebViewController = PrivacyPolicyWebViewController()
UIViewController.topMostViewController()?.navigationController?.pushViewController(vc, animated: true)
// let web = BaseWebViewController()
// web.LoadWithUrl(url: "")
// UIViewController.topMostViewController()?.navigationController?.pushViewController(web, animated: true)
}
}
......
//
// TableViewCell.swift
// PhoneManager
//
// Created by edy on 2025/5/14.
//
import UIKit
class customDismissAnimator: NSObject, UIViewControllerAnimatedTransitioning {
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.4
}
// 定义动画效果
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
guard let fromVC = transitionContext.viewController(forKey: .from) else { return }
_ = transitionContext.containerView
let duration = transitionDuration(using: transitionContext)
UIView.animate(withDuration: duration, animations: {
fromVC.view.transform = CGAffineTransform(translationX: 0, y: ScreenH)
}) { _ in
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
}
}
}
......@@ -162,6 +162,17 @@ extension Array {
}
return self[index] // 返回对应的元素
}
mutating func removeStr(_ objc:String) -> Array {
for (i,v) in self.enumerated() {
if let value = v as? String,
value == objc {
return self.remove(at: i) as? Array ?? []
break
}
}
return self
}
}
......
......@@ -190,8 +190,9 @@ extension UIView {
get {
var blurs = objc_getAssociatedObject(self, &blurKey) as? UIVisualEffectView
if blurs == nil {
let blurEffect = UIBlurEffect(style: .systemUltraThinMaterialDark)
let blurEffect = UIBlurEffect(style: .dark)
blurs = UIVisualEffectView(effect: blurEffect)
blurs?.alpha = 0
self.blur = blurs!
}
return blurs!
......@@ -200,26 +201,20 @@ extension UIView {
func showBlur() -> Void {
self.addSubview(blur)
var frame = self.bounds
frame.origin.y = frame.height
blur.frame = frame
UIView.animate(withDuration: 0.1) {
frame.origin.y = 0
self.blur.frame = frame
blur.frame = self.bounds
UIView.animate(withDuration: 0.4) {
self.blur.alpha = 1
}
}
func hideBlur() -> Void {
var frame = self.blur.frame
frame.origin.y = frame.height
UIView.animate(withDuration: 0.1) {
self.blur.frame = frame
UIView.animate(withDuration: 0.4) {
self.blur.alpha = 0
} completion: { su in
self.blur.removeFromSuperview()
}
}
/// 视图最右边的x坐标(origin.x + width)
var rightX: CGFloat {
return frame.maxX
......@@ -273,20 +268,21 @@ extension Date {
return dateforametter.string(from: self)
}
func operation(_ year:Int = 0,
_ month:Int = 0,
_ day:Int = 0,
_ houre:Int = 0,
_ minte:Int = 0,
_ sec:Int = 0,
_ week:Int = 0) -> Date? {
func operation( year:Int = 0,
month:Int = 0,
day:Int = 0,
houre:Int = 0,
minte:Int = 0,
sec:Int = 0,
week:Int = 0) -> Date? {
let calendar = Calendar.current
let currentDate = self
var dateComponent:DateComponents = calendar.dateComponents([.year,.month,.day,.hour,.minute,.second,.weekday], from: currentDate)
dateComponent.year! += year
dateComponent.month! += month
dateComponent.month! += day
dateComponent.day! += day
dateComponent.hour! += houre
dateComponent.minute! += minte
dateComponent.second! += sec
dateComponent.weekday! += week
guard let toDate = calendar.date(from: dateComponent) else { return self }
......
......@@ -131,6 +131,14 @@ extension String {
}
}
func removeEscapeCharacters() -> String {
var cleaned = self
cleaned = cleaned.replacingOccurrences(of: "\n", with: "")
.replacingOccurrences(of: "\t", with: "")
.replacingOccurrences(of: "\r", with: "")
return cleaned
}
}
extension URL {
......
......@@ -17,7 +17,7 @@ target 'PhoneManager' do
pod 'SVProgressHUD'
pod 'Google-Mobile-Ads-SDK'
pod 'GoogleSignIn'
pod 'MJRefresh' , '3.7.9'
pod 'GoogleAPIClientForREST/Gmail'
post_install do |installer|
......
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