Commit 73b3ed19 authored by yqz's avatar yqz

设置

parent f8504d8c
...@@ -741,6 +741,7 @@ ...@@ -741,6 +741,7 @@
INFOPLIST_FILE = PhoneManager/Info.plist; INFOPLIST_FILE = PhoneManager/Info.plist;
INFOPLIST_KEY_NSCameraUsageDescription = "We need to obtain your camera permission in order to save the photos you take in the private album feature"; INFOPLIST_KEY_NSCameraUsageDescription = "We need to obtain your camera permission in order to save the photos you take in the private album feature";
INFOPLIST_KEY_NSContactsUsageDescription = "Phone Manager needs access to your contacts to find and merge duplicate contacts"; INFOPLIST_KEY_NSContactsUsageDescription = "Phone Manager needs access to your contacts to find and merge duplicate contacts";
INFOPLIST_KEY_NSFaceIDUsageDescription = "The app needs to use your face ID";
INFOPLIST_KEY_NSLocalNetworkUsageDescription = "We need to access the network to load content"; INFOPLIST_KEY_NSLocalNetworkUsageDescription = "We need to access the network to load content";
INFOPLIST_KEY_NSMicrophoneUsageDescription = "We need to obtain your microphone permission in order to use it when shooting videos in the private album feature"; INFOPLIST_KEY_NSMicrophoneUsageDescription = "We need to obtain your microphone permission in order to use it when shooting videos in the private album feature";
INFOPLIST_KEY_NSPhotoLibraryAddUsageDescription = "We need to access your album in order to find the photos you want to change and update them"; INFOPLIST_KEY_NSPhotoLibraryAddUsageDescription = "We need to access your album in order to find the photos you want to change and update them";
...@@ -789,6 +790,7 @@ ...@@ -789,6 +790,7 @@
INFOPLIST_FILE = PhoneManager/Info.plist; INFOPLIST_FILE = PhoneManager/Info.plist;
INFOPLIST_KEY_NSCameraUsageDescription = "We need to obtain your camera permission in order to save the photos you take in the private album feature"; INFOPLIST_KEY_NSCameraUsageDescription = "We need to obtain your camera permission in order to save the photos you take in the private album feature";
INFOPLIST_KEY_NSContactsUsageDescription = "Phone Manager needs access to your contacts to find and merge duplicate contacts"; INFOPLIST_KEY_NSContactsUsageDescription = "Phone Manager needs access to your contacts to find and merge duplicate contacts";
INFOPLIST_KEY_NSFaceIDUsageDescription = "The app needs to use your face ID";
INFOPLIST_KEY_NSLocalNetworkUsageDescription = "We need to access the network to load content"; INFOPLIST_KEY_NSLocalNetworkUsageDescription = "We need to access the network to load content";
INFOPLIST_KEY_NSMicrophoneUsageDescription = "We need to obtain your microphone permission in order to use it when shooting videos in the private album feature"; INFOPLIST_KEY_NSMicrophoneUsageDescription = "We need to obtain your microphone permission in order to use it when shooting videos in the private album feature";
INFOPLIST_KEY_NSPhotoLibraryAddUsageDescription = "We need to access your album in order to find the photos you want to change and update them"; INFOPLIST_KEY_NSPhotoLibraryAddUsageDescription = "We need to access your album in order to find the photos you want to change and update them";
......
...@@ -22,6 +22,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -22,6 +22,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
window = UIWindow(frame: UIScreen.main.bounds) window = UIWindow(frame: UIScreen.main.bounds)
UserDefaults.standard.set(["en"], forKey: "AppleLanguages")
UserDefaults.standard.synchronize()
window?.backgroundColor = .white window?.backgroundColor = .white
window?.overrideUserInterfaceStyle = .light window?.overrideUserInterfaceStyle = .light
let Ssoryboard = UIStoryboard(name: "LauchVC", bundle: nil) let Ssoryboard = UIStoryboard(name: "LauchVC", bundle: nil)
...@@ -47,6 +50,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -47,6 +50,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// 初始化广告SDK // 初始化广告SDK
AdvManager.shared.initAdertisementSDK() AdvManager.shared.initAdertisementSDK()
PMEmailManager.shareManager.restore() PMEmailManager.shareManager.restore()
SettingConfiguration.share.initData()
return true return true
} }
...@@ -57,6 +61,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -57,6 +61,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
postContactNotification() postContactNotification()
} }
func applicationWillEnterForeground(_ application: UIApplication) {
}
func applicationWillResignActive(_ application: UIApplication) {
SettingConfiguration.share.saveData()
}
func postContactNotification(){ func postContactNotification(){
// 通知联系人重复项改变 // 通知联系人重复项改变
let dataUpdated = Notification.Name(ContactDupPreNormalView.CONTACT_MERGED) let dataUpdated = Notification.Name(ContactDupPreNormalView.CONTACT_MERGED)
......
{ {
"images" : [ "images" : [
{ {
"filename" : "emailSmall.png", "filename" : "image_48.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "1x" "scale" : "1x"
}, },
{ {
"filename" : "image_48@2x.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "2x" "scale" : "2x"
}, },
{ {
"filename" : "image_48@3x.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "3x" "scale" : "3x"
} }
......
{
"images" : [
{
"filename" : "Frame.png",
"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
}
}
{
"images" : [
{
"filename" : "Frame.png",
"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
}
}
{
"images" : [
{
"filename" : "Frame.png",
"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
}
}
{
"images" : [
{
"filename" : "icon_set_secret_ins_setting.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon_set_secret_ins_setting@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon_set_secret_ins_setting@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "icon_set_secret_rate_setting.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon_set_secret_rate_setting@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon_set_secret_rate_setting@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "icon_set_secret_share_setting.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon_set_secret_share_setting@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon_set_secret_share_setting@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
...@@ -35,7 +35,7 @@ class HomeViewController:BaseViewController { ...@@ -35,7 +35,7 @@ class HomeViewController:BaseViewController {
guard let self else {return} guard let self else {return}
// 这里需要看下是否需要PIN验证 // 这里需要看下是否需要PIN验证
let pass = UserDefaults.standard.object(forKey: SecretViewController.psKey) as? String ?? "" let pass = SettingConfiguration.share.config.secret ?? ""//UserDefaults.standard.object(forKey: SecretViewController.psKey) as? String ?? ""
if pass.count > 2{ if pass.count > 2{
let set = SecretSetViewController() let set = SecretSetViewController()
set.secretType = .verify set.secretType = .verify
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
// //
import UIKit import UIKit
import LocalAuthentication
class SecretSetViewController: BaseViewController, UITextFieldDelegate { class SecretSetViewController: BaseViewController, UITextFieldDelegate {
...@@ -13,6 +14,7 @@ class SecretSetViewController: BaseViewController, UITextFieldDelegate { ...@@ -13,6 +14,7 @@ class SecretSetViewController: BaseViewController, UITextFieldDelegate {
case create // 新建 case create // 新建
case verify // 验证 case verify // 验证
case del // 删除 case del // 删除
case change // 修改
} }
var Callback:((_ suc:Bool)->Void) = { suc in } var Callback:((_ suc:Bool)->Void) = { suc in }
...@@ -32,20 +34,54 @@ class SecretSetViewController: BaseViewController, UITextFieldDelegate { ...@@ -32,20 +34,54 @@ class SecretSetViewController: BaseViewController, UITextFieldDelegate {
self.titleView.backBtn.setImage(UIImage(named: "ic_close_charging"), for: .normal) self.titleView.backBtn.setImage(UIImage(named: "ic_close_charging"), for: .normal)
self.titleView.model.isBackBtnShow = true self.titleView.model.isBackBtnShow = true
titleView.model.title = "Secret Library" titleView.model.title = "Secret Library"
titleView.titleLabel.textColor = .black titleView.titleLabel.textColor = .black
titleView.titleLabel.textAlignment = .left titleView.titleLabel.textAlignment = .left
setUI() setUI()
ps.becomeFirstResponder() if secretType != .verify || (SettingConfiguration.share.config.faceId ?? false ) == false {
ps.becomeFirstResponder()
}else{
self.faceID()
}
collect.register(SecretSetPsCell.self, forCellWithReuseIdentifier: SecretSetPsCellID) collect.register(SecretSetPsCell.self, forCellWithReuseIdentifier: SecretSetPsCellID)
self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false
} }
func faceID() -> Void {
if PMFaceIDManger.request() {
PMFaceIDManger.authenticateWithFaceID(reason: "Unlock privacy space") {[weak self] success, error in
if success {
self?.Callback(true)
}else{
if let laError = error as? LAError {
let content = LAContext()
if laError.code == .biometryLockout ||
laError.code == .biometryNotEnrolled ||
laError.code == .biometryNotAvailable {
content.handleLAError(error ?? NSError())
}else{
self?.ps.becomeFirstResponder()
}
}else{
self?.ps.becomeFirstResponder()
}
}
}
}
}
private func PMClose() -> Void {
if self.navigationController?.children.count ?? 0 <= 0 {
self.dismiss(animated: true)
}else{
self.navigationController?.popViewController(animated: true)
}
}
override func close(animation: Bool = true) { override func close(animation: Bool = true) {
if secretType == .verify { if secretType == .verify {
self.dismiss(animated: true) self.PMClose()
return return
} }
Callback(false) Callback(false)
...@@ -58,21 +94,35 @@ class SecretSetViewController: BaseViewController, UITextFieldDelegate { ...@@ -58,21 +94,35 @@ class SecretSetViewController: BaseViewController, UITextFieldDelegate {
didSet { didSet {
collect.reloadData() collect.reloadData()
if Secret.count == 4 { if Secret.count == 4 {
if secretType == .verify || secretType == .del{ if secretType == .verify || secretType == .del || secretType == .change {
let Ps:String = UserDefaults.standard.object(forKey: SecretViewController.psKey) as? String ?? "" let Ps:String = SettingConfiguration.share.config.secret ?? ""
//UserDefaults.standard.object(forKey: SecretViewController.psKey) as? String ?? ""
if Ps != Secret { if Ps != Secret {
Secret = "" Secret = ""
self.ps.text = "" self.ps.text = ""
if secretType == .verify && (SettingConfiguration.share.config.faceId ?? false) {
self.contentView.isHidden = false
self.ps.resignFirstResponder()
}
descpLabel.text = "The entered PIN code is incorrect, please re-enter" descpLabel.text = "The entered PIN code is incorrect, please re-enter"
return return
}else{ }else{
if secretType == .del { if secretType == .del {
UserDefaults.standard.set("", forKey: SecretViewController.psKey) // UserDefaults.standard.set("", forKey: SecretViewController.psKey)
SettingConfiguration.share.config.secret = ""
let alert = UIAlertController(title: nil, message: "The PIN has been deleted", preferredStyle: .alert) let alert = UIAlertController(title: nil, message: "The PIN has been deleted", preferredStyle: .alert)
self.present(alert, animated: true) self.present(alert, animated: true)
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) { DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
alert.dismiss(animated: true) alert.dismiss(animated: true) {
self.Callback(true)
self.PMClose()
}
} }
}else if secretType == .change {
Secret = ""
self.ps.text = ""
self.secretType = .create
return
} }
} }
}else{ }else{
...@@ -82,13 +132,14 @@ class SecretSetViewController: BaseViewController, UITextFieldDelegate { ...@@ -82,13 +132,14 @@ class SecretSetViewController: BaseViewController, UITextFieldDelegate {
Secret = "" Secret = ""
self.ps.text = "" self.ps.text = ""
}else{ }else{
UserDefaults.standard.set(Secret, forKey: SecretViewController.psKey) // UserDefaults.standard.set(Secret, forKey: SecretViewController.psKey)
SettingConfiguration.share.config.secret = Secret
let alert = UIAlertController(title: nil, message: "Your space is locked", preferredStyle: .alert) let alert = UIAlertController(title: nil, message: "Your space is locked", preferredStyle: .alert)
self.present(alert, animated: true) self.present(alert, animated: true)
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) { DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
alert.dismiss(animated: true) { alert.dismiss(animated: true) {
self.Callback(true) self.Callback(true)
self.dismiss(animated: true) self.PMClose()
} }
} }
} }
...@@ -105,7 +156,7 @@ class SecretSetViewController: BaseViewController, UITextFieldDelegate { ...@@ -105,7 +156,7 @@ class SecretSetViewController: BaseViewController, UITextFieldDelegate {
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) { DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
alert.dismiss(animated: true){ alert.dismiss(animated: true){
self.Callback(true) self.Callback(true)
self.dismiss(animated: true) self.PMClose()
} }
} }
...@@ -136,6 +187,7 @@ class SecretSetViewController: BaseViewController, UITextFieldDelegate { ...@@ -136,6 +187,7 @@ class SecretSetViewController: BaseViewController, UITextFieldDelegate {
make.top.equalTo(setTitle.snp.bottom).offset(32); make.top.equalTo(setTitle.snp.bottom).offset(32);
make.height.equalTo(20) make.height.equalTo(20)
} }
contentView.isHidden = true
} }
private lazy var collect: UICollectionView = { private lazy var collect: UICollectionView = {
...@@ -178,6 +230,16 @@ class SecretSetViewController: BaseViewController, UITextFieldDelegate { ...@@ -178,6 +230,16 @@ class SecretSetViewController: BaseViewController, UITextFieldDelegate {
st.textAlignment = .center st.textAlignment = .center
return st return st
}() }()
private lazy var contentView: SecretAlertFaceID = {
let vc = SecretAlertFaceID.xib()
view.addSubview(vc)
vc.center = CGPointMake(view.width/2.0, view.height/2.0 + 30)
vc.callback = {[weak self] in
self?.faceID()
}
return vc
}()
} }
......
...@@ -15,7 +15,7 @@ class SecretViewController: BaseViewController { ...@@ -15,7 +15,7 @@ class SecretViewController: BaseViewController {
private var pass:String { private var pass:String {
get { get {
return UserDefaults.standard.object(forKey: SecretViewController.psKey) as? String ?? "" return SettingConfiguration.share.config.secret ?? "" //UserDefaults.standard.object(forKey: SecretViewController.psKey) as? String ?? ""
} }
} }
...@@ -105,7 +105,7 @@ class SecretViewController: BaseViewController { ...@@ -105,7 +105,7 @@ class SecretViewController: BaseViewController {
} }
private func deleteData() -> Void { private func deleteData() -> Void {
var DelCallBlock = { [weak self] in let DelCallBlock = { [weak self] in
guard let self = self else { return } guard let self = self else { return }
var delName:[String] = [] var delName:[String] = []
for idx in self.selectArray.allObjects { for idx in self.selectArray.allObjects {
...@@ -121,12 +121,16 @@ class SecretViewController: BaseViewController { ...@@ -121,12 +121,16 @@ class SecretViewController: BaseViewController {
self.dataSource = self.loadData() self.dataSource = self.loadData()
self.bottomm.state = .add self.bottomm.state = .add
} }
PMAlert("These photos or videos will be deleted from your private space" , ["Cancel","Delete"] , { alert, selectidx in if SettingConfiguration.share.config.removeImg {
if selectidx == 1 { PMAlert(messsage:"These photos or videos will be deleted from your private space" , action: ["Cancel","Delete"] , complate: { alert, selectidx in
DelCallBlock() if selectidx == 1 {
} DelCallBlock()
alert.dismiss(animated: true) }
}) alert.dismiss(animated: true)
})
}else{
DelCallBlock()
}
} }
@objc private func lockTouch(_ sender:UIButton) -> Void { @objc private func lockTouch(_ sender:UIButton) -> Void {
......
//
// SecretAlertFaceID.swift
// PhoneManager
//
// Created by edy on 2025/5/15.
//
import UIKit
class SecretAlertFaceID: UIView {
class func xib() -> SecretAlertFaceID {
let view = UINib(nibName: "SecretAlertFaceID", bundle: nil).instantiate(withOwner: nil).first as! SecretAlertFaceID
return view
}
override func awakeFromNib() {
super.awakeFromNib()
}
var callback:(()->Void) = { }
@IBAction func FaceIDActions(_ sender: Any) {
callback()
}
}
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="I9T-qF-rSE" customClass="SecretAlertFaceID" customModule="PhoneManager" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="205" height="60"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" alignment="center" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="8nL-7J-xiD">
<rect key="frame" x="20" y="7" width="165" height="46.333333333333336"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_Secret_faceID" translatesAutoresizingMaskIntoConstraints="NO" id="std-TK-0Yt">
<rect key="frame" x="0.0" y="10.999999999999998" width="24" height="24.333333333333329"/>
</imageView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="top" translatesAutoresizingMaskIntoConstraints="NO" id="sxJ-Rb-fyl">
<rect key="frame" x="34" y="0.0" width="131" height="46.333333333333336"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Forgot the password?" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2Zc-Cn-U0O">
<rect key="frame" x="0.0" y="0.0" width="131" height="14.333333333333334"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="12"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3uc-HR-iXv">
<rect key="frame" x="0.0" y="14.333333333333332" width="84" height="31.999999999999996"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="16"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="Try Face ID">
<color key="titleColor" red="0.0" green="0.50980392159999999" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</state>
</button>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" red="0.94901960780000005" green="0.96470588239999999" blue="0.98823529409999999" alpha="1" colorSpace="calibratedRGB"/>
</stackView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="bKW-c0-sm1">
<rect key="frame" x="0.0" y="0.0" width="205" height="60"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<connections>
<action selector="FaceIDActions:" destination="I9T-qF-rSE" eventType="touchUpInside" id="FeZ-eo-Oby"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="0.94901960784313721" green="0.96470588235294119" blue="0.9882352941176471" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="8nL-7J-xiD" firstAttribute="centerY" secondItem="I9T-qF-rSE" secondAttribute="centerY" id="5kR-L8-sy6"/>
<constraint firstItem="8nL-7J-xiD" firstAttribute="leading" secondItem="I9T-qF-rSE" secondAttribute="leading" constant="20" id="Van-Ga-geO"/>
<constraint firstAttribute="trailing" secondItem="8nL-7J-xiD" secondAttribute="trailing" constant="20" id="aeO-xf-ow2"/>
<constraint firstItem="bKW-c0-sm1" firstAttribute="top" secondItem="I9T-qF-rSE" secondAttribute="top" id="fd9-QG-rSu"/>
<constraint firstAttribute="bottom" secondItem="bKW-c0-sm1" secondAttribute="bottom" id="j0X-8n-gb3"/>
<constraint firstItem="bKW-c0-sm1" firstAttribute="leading" secondItem="I9T-qF-rSE" secondAttribute="leading" id="qt3-9t-L14"/>
<constraint firstAttribute="trailing" secondItem="bKW-c0-sm1" secondAttribute="trailing" id="u9V-ag-cBS"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="Radius">
<real key="value" value="30"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<point key="canvasLocation" x="127" y="-12"/>
</view>
</objects>
<resources>
<image name="ic_Secret_faceID" width="24" height="24.333333969116211"/>
</resources>
</document>
...@@ -9,7 +9,7 @@ import Foundation ...@@ -9,7 +9,7 @@ import Foundation
class SettingNormalCell : UITableViewCell { class SettingNormalCell : UITableViewCell {
override var frame: CGRect{ override var frame: CGRect {
didSet{ didSet{
var newFrame = frame var newFrame = frame
newFrame.origin.x += 15 newFrame.origin.x += 15
...@@ -65,8 +65,9 @@ class SettingNormalCell : UITableViewCell { ...@@ -65,8 +65,9 @@ class SettingNormalCell : UITableViewCell {
self.fLabel.snp.makeConstraints { make in self.fLabel.snp.makeConstraints { make in
make.left.equalTo(self.logoView.snp.right).offset(4) make.left.equalTo(self.logoView.snp.right).offset(4)
make.centerY.equalToSuperview(); make.top.equalToSuperview()
make.height.equalTo(20) make.height.equalTo(60)
make.bottom.equalToSuperview()
make.width.equalTo(206) make.width.equalTo(206)
} }
self.moreImageView.snp.makeConstraints { make in self.moreImageView.snp.makeConstraints { make in
......
...@@ -9,6 +9,27 @@ import Foundation ...@@ -9,6 +9,27 @@ import Foundation
class SettingSwitchCell : UITableViewCell { class SettingSwitchCell : UITableViewCell {
var data:RowInfoModel? {
didSet {
guard let dict = data else { return }
DispatchQueue.main.async {
self.fLabel.text = dict.title
self.logoView.image = UIImage(named: dict.imageName)
if dict.title == settingLabels.UsePIN.rawValue {
self.openImageView.isSelected = SettingConfiguration.share.config.secret?.count ?? 0 == 4
}else if dict.title == settingLabels.UseFaceID.rawValue {
self.openImageView.isSelected = SettingConfiguration.share.config.faceId ?? false
}else if dict.title == settingLabels.RemoveAfterImport.rawValue {
self.openImageView.isSelected = SettingConfiguration.share.config.removeImg
}else if dict.title == settingLabels.Vibration.rawValue {
self.openImageView.isSelected = SettingConfiguration.share.config.vibration ?? false
}else{
}
}
}
}
override var frame: CGRect{ override var frame: CGRect{
didSet{ didSet{
var newFrame = frame var newFrame = frame
...@@ -39,14 +60,16 @@ class SettingSwitchCell : UITableViewCell { ...@@ -39,14 +60,16 @@ class SettingSwitchCell : UITableViewCell {
label.textAlignment = .left label.textAlignment = .left
return label return label
}() }()
lazy var openImageView : UIImageView = {
let sview:UIImageView = UIImageView() lazy var openImageView : UIButton = {
let sview:UIButton = UIButton(type: .custom)
sview.backgroundColor = .clear sview.backgroundColor = .clear
sview.image = UIImage(named: "button_switch_off") sview.isUserInteractionEnabled = false
sview.setImage(UIImage(named: "icon_set_secret_Off"), for: .normal)
sview.setImage(UIImage(named: "icon_set_secret_On"), for: .selected)
return sview return sview
}() }()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier) super.init(style: style, reuseIdentifier: reuseIdentifier)
self.selectionStyle = .none self.selectionStyle = .none
...@@ -55,7 +78,6 @@ class SettingSwitchCell : UITableViewCell { ...@@ -55,7 +78,6 @@ class SettingSwitchCell : UITableViewCell {
self.contentView.addSubview(self.fLabel) self.contentView.addSubview(self.fLabel)
self.contentView.addSubview(self.openImageView) self.contentView.addSubview(self.openImageView)
self.contentView.addSubview(self.lineView) self.contentView.addSubview(self.lineView)
self.logoView.snp.makeConstraints { make in self.logoView.snp.makeConstraints { make in
make.width.height.equalTo(28) make.width.height.equalTo(28)
...@@ -65,9 +87,10 @@ class SettingSwitchCell : UITableViewCell { ...@@ -65,9 +87,10 @@ class SettingSwitchCell : UITableViewCell {
self.fLabel.snp.makeConstraints { make in self.fLabel.snp.makeConstraints { make in
make.left.equalTo(self.logoView.snp.right).offset(4) make.left.equalTo(self.logoView.snp.right).offset(4)
make.centerY.equalToSuperview(); make.top.equalToSuperview()
make.height.equalTo(20) make.height.equalTo(60)
make.width.equalTo(206) make.width.equalTo(206)
make.bottom.equalToSuperview()
} }
self.openImageView.snp.makeConstraints { make in self.openImageView.snp.makeConstraints { make in
make.height.equalTo(28) make.height.equalTo(28)
...@@ -81,7 +104,7 @@ class SettingSwitchCell : UITableViewCell { ...@@ -81,7 +104,7 @@ class SettingSwitchCell : UITableViewCell {
make.right.equalToSuperview().offset(-15) make.right.equalToSuperview().offset(-15)
make.bottom.equalToSuperview().offset(-1) make.bottom.equalToSuperview().offset(-1)
} }
self.clipsToBounds = true
} }
......
...@@ -46,7 +46,7 @@ class WidgetViewController: BaseViewController { ...@@ -46,7 +46,7 @@ class WidgetViewController: BaseViewController {
var widgetIdx = 0 var widgetIdx = 0
widgetIdx = widgets.rawValue * 10 + widgetMode widgetIdx = widgets.rawValue * 10 + widgetMode
widgetAppgourp.share.PushWidgetData(widgetIdx, battery: Int(battery), storage: Int(storage)) widgetAppgourp.share.PushWidgetData(widgetIdx, battery: Int(battery), storage: Int(storage))
PMAlert("Set Widget Successfully") PMAlert(messsage: "Set Widget Successfully")
} }
func setUI() -> Void { func setUI() -> Void {
......
...@@ -22,6 +22,9 @@ class EmailCleanListViewCell: UITableViewCell { ...@@ -22,6 +22,9 @@ class EmailCleanListViewCell: UITableViewCell {
@IBOutlet weak var descpText1: UILabel! @IBOutlet weak var descpText1: UILabel!
@IBOutlet weak var EmailTimeL: UILabel! @IBOutlet weak var EmailTimeL: UILabel!
@IBOutlet weak var startInfo: UIImageView!
override func awakeFromNib() { override func awakeFromNib() {
super.awakeFromNib() super.awakeFromNib()
} }
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
<rect key="frame" x="0.0" y="0.0" width="216" height="19.333333333333332"/> <rect key="frame" x="0.0" y="0.0" width="216" height="19.333333333333332"/>
<subviews> <subviews>
<stackView opaque="NO" contentMode="scaleToFill" alignment="center" spacing="2" translatesAutoresizingMaskIntoConstraints="NO" id="xWb-J8-Ui7"> <stackView opaque="NO" contentMode="scaleToFill" alignment="center" spacing="2" translatesAutoresizingMaskIntoConstraints="NO" id="xWb-J8-Ui7">
<rect key="frame" x="0.0" y="0.0" width="102.33333333333333" height="19.333333333333332"/> <rect key="frame" x="0.0" y="0.0" width="101" height="19.333333333333332"/>
<subviews> <subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Fi7-Jr-Qip"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Fi7-Jr-Qip">
<rect key="frame" x="0.0" y="6.6666666666666661" width="6" height="6"/> <rect key="frame" x="0.0" y="6.6666666666666661" width="6" height="6"/>
...@@ -72,15 +72,15 @@ ...@@ -72,15 +72,15 @@
</userDefinedRuntimeAttributes> </userDefinedRuntimeAttributes>
</view> </view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Social Media" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="49v-3u-EtJ"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Social Media" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="49v-3u-EtJ">
<rect key="frame" x="8" y="0.0" width="94.333333333333329" height="19.333333333333332"/> <rect key="frame" x="8" y="0.0" width="93" height="19.333333333333332"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="16"/> <fontDescription key="fontDescription" type="system" weight="medium" pointSize="16"/>
<nil key="textColor"/> <nil key="textColor"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
</subviews> </subviews>
</stackView> </stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" translatesAutoresizingMaskIntoConstraints="NO" id="5Cl-XH-rD8"> <stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" spacing="2" translatesAutoresizingMaskIntoConstraints="NO" id="5Cl-XH-rD8">
<rect key="frame" x="118" y="3.3333333333333339" width="98" height="13.000000000000002"/> <rect key="frame" x="101" y="3.3333333333333339" width="115" height="13.000000000000002"/>
<subviews> <subviews>
<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"> <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"/> <rect key="frame" x="0.0" y="0.0" width="85" height="13"/>
...@@ -91,8 +91,15 @@ ...@@ -91,8 +91,15 @@
<color key="textColor" red="0.70196078431372544" green="0.70196078431372544" blue="0.70196078431372544" alpha="1" colorSpace="calibratedRGB"/> <color key="textColor" red="0.70196078431372544" green="0.70196078431372544" blue="0.70196078431372544" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_emial_start" translatesAutoresizingMaskIntoConstraints="NO" id="8wT-va-Xgw">
<rect key="frame" x="87" y="0.0" width="13" height="13"/>
<constraints>
<constraint firstAttribute="height" constant="13" id="aHM-af-EzA"/>
<constraint firstAttribute="width" constant="13" id="jMa-Hx-jmm"/>
</constraints>
</imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_left_setting_grey" translatesAutoresizingMaskIntoConstraints="NO" id="ubl-ns-bXJ"> <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="85" y="0.0" width="13" height="13"/> <rect key="frame" x="102" y="0.0" width="13" height="13"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="13" id="YdB-iz-Nwc"/> <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"/> <constraint firstAttribute="width" secondItem="ubl-ns-bXJ" secondAttribute="height" multiplier="1:1" id="nFl-sn-e8h"/>
...@@ -152,11 +159,13 @@ ...@@ -152,11 +159,13 @@
<outlet property="descpText1" destination="S8d-tj-cjO" id="SJ7-ZV-MzU"/> <outlet property="descpText1" destination="S8d-tj-cjO" id="SJ7-ZV-MzU"/>
<outlet property="groupName" destination="49v-3u-EtJ" id="obF-nw-R09"/> <outlet property="groupName" destination="49v-3u-EtJ" id="obF-nw-R09"/>
<outlet property="selectBtn" destination="XwR-Ch-R1t" id="lCd-A7-DrQ"/> <outlet property="selectBtn" destination="XwR-Ch-R1t" id="lCd-A7-DrQ"/>
<outlet property="startInfo" destination="8wT-va-Xgw" id="Hhc-kh-A6U"/>
</connections> </connections>
<point key="canvasLocation" x="99.236641221374043" y="-11.619718309859156"/> <point key="canvasLocation" x="99.236641221374043" y="-11.619718309859156"/>
</tableViewCell> </tableViewCell>
</objects> </objects>
<resources> <resources>
<image name="ic_emial_start" width="13" height="13.333333015441895"/>
<image name="ic_sel_com" width="24" height="24"/> <image name="ic_sel_com" width="24" height="24"/>
<image name="ic_unsel_com_red" width="24" height="24"/> <image name="ic_unsel_com_red" width="24" height="24"/>
<image name="icon_left_setting_grey" width="20" height="20"/> <image name="icon_left_setting_grey" width="20" height="20"/>
......
...@@ -17,8 +17,12 @@ class EmailContentTabCell: UITableViewCell { ...@@ -17,8 +17,12 @@ class EmailContentTabCell: UITableViewCell {
@IBOutlet weak var groupName: UILabel! @IBOutlet weak var groupName: UILabel!
@IBOutlet weak var groupNumbers: UILabel! @IBOutlet weak var groupNumbers: UILabel!
@IBOutlet weak var info: UIImageView!
@IBOutlet weak var loaingView: UIActivityIndicatorView!
override func awakeFromNib() { override func awakeFromNib() {
super.awakeFromNib() super.awakeFromNib()
loaingView.startAnimating()
} }
@IBAction func selectActions(_ sender: Any) { @IBAction func selectActions(_ sender: Any) {
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<rect key="frame" x="15" y="0.0" width="290" height="74"/> <rect key="frame" x="15" y="0.0" width="290" height="74"/>
<subviews> <subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="SFC-9k-JL4"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="SFC-9k-JL4">
<rect key="frame" x="6" y="15.000000000000004" width="44" height="44.333333333333343"/> <rect key="frame" x="6" y="15" width="44" height="44"/>
<inset key="contentEdgeInsets" minX="10" minY="10" maxX="10" maxY="10"/> <inset key="contentEdgeInsets" minX="10" minY="10" maxX="10" maxY="10"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/> <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" image="ic_sel_com"/> <state key="normal" image="ic_sel_com"/>
...@@ -51,13 +51,18 @@ ...@@ -51,13 +51,18 @@
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_left_setting_grey" translatesAutoresizingMaskIntoConstraints="NO" id="JWZ-DO-70m"> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_left_setting_grey" translatesAutoresizingMaskIntoConstraints="NO" id="JWZ-DO-70m">
<rect key="frame" x="254" y="27" width="20" height="20"/> <rect key="frame" x="254" y="27" width="20" height="20"/>
</imageView> </imageView>
<activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" style="medium" translatesAutoresizingMaskIntoConstraints="NO" id="ojv-UW-pKp">
<rect key="frame" x="254" y="27" width="20" height="20"/>
</activityIndicatorView>
</subviews> </subviews>
<color key="backgroundColor" red="0.94901960784313721" green="0.96470588235294119" blue="0.9882352941176471" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/> <color key="backgroundColor" red="0.94901960784313721" green="0.96470588235294119" blue="0.9882352941176471" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
<constraints> <constraints>
<constraint firstAttribute="trailing" secondItem="JWZ-DO-70m" secondAttribute="trailing" constant="16" id="9Be-SQ-UxW"/> <constraint firstAttribute="trailing" secondItem="JWZ-DO-70m" secondAttribute="trailing" constant="16" id="9Be-SQ-UxW"/>
<constraint firstItem="JWZ-DO-70m" firstAttribute="centerX" secondItem="ojv-UW-pKp" secondAttribute="centerX" id="CRs-J2-hZT"/>
<constraint firstItem="SFC-9k-JL4" firstAttribute="centerY" secondItem="HGx-M7-LQS" secondAttribute="centerY" id="Gww-V3-ADp"/> <constraint firstItem="SFC-9k-JL4" firstAttribute="centerY" secondItem="HGx-M7-LQS" secondAttribute="centerY" id="Gww-V3-ADp"/>
<constraint firstItem="SFC-9k-JL4" firstAttribute="leading" secondItem="HGx-M7-LQS" secondAttribute="leading" constant="6" id="MuS-Bu-Wyb"/> <constraint firstItem="SFC-9k-JL4" firstAttribute="leading" secondItem="HGx-M7-LQS" secondAttribute="leading" constant="6" id="MuS-Bu-Wyb"/>
<constraint firstItem="a94-EP-nFu" firstAttribute="centerY" secondItem="HGx-M7-LQS" secondAttribute="centerY" id="b2x-dx-sEC"/> <constraint firstItem="a94-EP-nFu" firstAttribute="centerY" secondItem="HGx-M7-LQS" secondAttribute="centerY" id="b2x-dx-sEC"/>
<constraint firstItem="JWZ-DO-70m" firstAttribute="centerY" secondItem="ojv-UW-pKp" secondAttribute="centerY" id="gMb-dc-vT8"/>
<constraint firstItem="a94-EP-nFu" firstAttribute="leading" secondItem="SFC-9k-JL4" secondAttribute="trailing" id="kS8-jn-NTj"/> <constraint firstItem="a94-EP-nFu" firstAttribute="leading" secondItem="SFC-9k-JL4" secondAttribute="trailing" id="kS8-jn-NTj"/>
<constraint firstItem="JWZ-DO-70m" firstAttribute="centerY" secondItem="HGx-M7-LQS" secondAttribute="centerY" id="q4H-To-Ycj"/> <constraint firstItem="JWZ-DO-70m" firstAttribute="centerY" secondItem="HGx-M7-LQS" secondAttribute="centerY" id="q4H-To-Ycj"/>
</constraints> </constraints>
...@@ -80,13 +85,15 @@ ...@@ -80,13 +85,15 @@
<connections> <connections>
<outlet property="groupName" destination="eH5-kI-3vv" id="SJQ-eI-X4U"/> <outlet property="groupName" destination="eH5-kI-3vv" id="SJQ-eI-X4U"/>
<outlet property="groupNumbers" destination="dgz-WN-aKh" id="HJh-jw-nFW"/> <outlet property="groupNumbers" destination="dgz-WN-aKh" id="HJh-jw-nFW"/>
<outlet property="info" destination="JWZ-DO-70m" id="uOV-yU-gJR"/>
<outlet property="loaingView" destination="ojv-UW-pKp" id="7Q9-90-m8Q"/>
<outlet property="selectBtn" destination="SFC-9k-JL4" id="4V0-CJ-STJ"/> <outlet property="selectBtn" destination="SFC-9k-JL4" id="4V0-CJ-STJ"/>
</connections> </connections>
<point key="canvasLocation" x="131" y="-11"/> <point key="canvasLocation" x="131" y="-11"/>
</tableViewCell> </tableViewCell>
</objects> </objects>
<resources> <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="ic_unsel_com_red" width="24" height="24"/>
<image name="icon_left_setting_grey" width="20" height="20"/> <image name="icon_left_setting_grey" width="20" height="20"/>
</resources> </resources>
......
...@@ -13,6 +13,7 @@ class EmailFilterFAVORITECell: UITableViewCell { ...@@ -13,6 +13,7 @@ class EmailFilterFAVORITECell: UITableViewCell {
@IBOutlet weak var titleL: UILabel! @IBOutlet weak var titleL: UILabel!
@IBOutlet weak var LineW: UIView!
var callblock:((Bool)->Void) = { select in} var callblock:((Bool)->Void) = { select in}
@IBOutlet weak var emSwtich: UISwitch! @IBOutlet weak var emSwtich: UISwitch!
...@@ -22,11 +23,13 @@ class EmailFilterFAVORITECell: UITableViewCell { ...@@ -22,11 +23,13 @@ class EmailFilterFAVORITECell: UITableViewCell {
func reload() -> Void { func reload() -> Void {
DispatchQueue.main.async { DispatchQueue.main.async {
self.LineW.isHidden = false
if self.top && self.bot { if self.top && self.bot {
self.cornerCut(radius: 12, corner: [.allCorners]) self.cornerCut(radius: 12, corner: [.allCorners])
}else if self.top { }else if self.top {
self.cornerCut(radius: 12, corner: [.topLeft,.topRight]) self.cornerCut(radius: 12, corner: [.topLeft,.topRight])
}else if self.bot { }else if self.bot {
self.LineW.isHidden = true
self.cornerCut(radius: 12, corner: [.bottomLeft,.bottomRight]) self.cornerCut(radius: 12, corner: [.bottomLeft,.bottomRight])
}else{ }else{
self.cornerCut(radius: 0, corner: [.allCorners]) self.cornerCut(radius: 0, corner: [.allCorners])
......
...@@ -41,19 +41,30 @@ ...@@ -41,19 +41,30 @@
<action selector="selectActions:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="nvW-EK-ui8"/> <action selector="selectActions:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="nvW-EK-ui8"/>
</connections> </connections>
</switch> </switch>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dJG-Hb-NxX">
<rect key="frame" x="15" y="59.666666666666664" width="290" height="0.3333333333333357"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="0.5" id="hEZ-gi-iK3"/>
</constraints>
</view>
</subviews> </subviews>
<constraints> <constraints>
<constraint firstItem="Cz5-6m-Mah" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="0Mq-J4-Xeq"/> <constraint firstItem="Cz5-6m-Mah" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="0Mq-J4-Xeq"/>
<constraint firstItem="Z64-4z-Cnp" firstAttribute="leading" secondItem="Cz5-6m-Mah" secondAttribute="trailing" constant="5" id="4nT-3I-qbv"/> <constraint firstItem="Z64-4z-Cnp" firstAttribute="leading" secondItem="Cz5-6m-Mah" secondAttribute="trailing" constant="5" id="4nT-3I-qbv"/>
<constraint firstAttribute="bottom" secondItem="Cz5-6m-Mah" secondAttribute="bottom" id="M27-P5-Ro1"/> <constraint firstAttribute="bottom" secondItem="Cz5-6m-Mah" secondAttribute="bottom" id="M27-P5-Ro1"/>
<constraint firstItem="Cz5-6m-Mah" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="15" id="NKG-qu-La9"/> <constraint firstItem="Cz5-6m-Mah" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="15" id="NKG-qu-La9"/>
<constraint firstAttribute="trailing" secondItem="dJG-Hb-NxX" secondAttribute="trailing" constant="15" id="hU2-AF-5wJ"/>
<constraint firstAttribute="bottom" secondItem="dJG-Hb-NxX" secondAttribute="bottom" id="hsT-Gb-vul"/>
<constraint firstItem="Z64-4z-Cnp" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="tay-in-p1H"/> <constraint firstItem="Z64-4z-Cnp" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="tay-in-p1H"/>
<constraint firstAttribute="trailing" secondItem="Z64-4z-Cnp" secondAttribute="trailing" constant="15" id="ucO-vb-yyW"/> <constraint firstAttribute="trailing" secondItem="Z64-4z-Cnp" secondAttribute="trailing" constant="15" id="ucO-vb-yyW"/>
<constraint firstItem="dJG-Hb-NxX" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="15" id="y2B-mc-PNJ"/>
</constraints> </constraints>
</tableViewCellContentView> </tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/> <viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
<color key="backgroundColor" red="0.94901960784313721" green="0.96470588235294119" blue="0.9882352941176471" alpha="1" colorSpace="calibratedRGB"/> <color key="backgroundColor" red="0.94901960784313721" green="0.96470588235294119" blue="0.9882352941176471" alpha="1" colorSpace="calibratedRGB"/>
<connections> <connections>
<outlet property="LineW" destination="dJG-Hb-NxX" id="WO4-Wy-bh0"/>
<outlet property="emSwtich" destination="Z64-4z-Cnp" id="Tqg-qK-SLh"/> <outlet property="emSwtich" destination="Z64-4z-Cnp" id="Tqg-qK-SLh"/>
<outlet property="titleL" destination="Cz5-6m-Mah" id="tli-w9-h55"/> <outlet property="titleL" destination="Cz5-6m-Mah" id="tli-w9-h55"/>
</connections> </connections>
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<constraints> <constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="72" id="g5j-o3-20E"/> <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="72" id="g5j-o3-20E"/>
</constraints> </constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/> <fontDescription key="fontDescription" type="boldSystem" pointSize="14"/>
<nil key="textColor"/> <nil key="textColor"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
......
...@@ -14,6 +14,7 @@ class EmailFilterSelectCell: UITableViewCell { ...@@ -14,6 +14,7 @@ class EmailFilterSelectCell: UITableViewCell {
@IBOutlet weak var selectBtn: UIButton! @IBOutlet weak var selectBtn: UIButton!
@IBOutlet weak var titleL: UILabel! @IBOutlet weak var titleL: UILabel!
@IBOutlet weak var lineW: UIView!
var callblock:((Bool)->Void) = { select in} var callblock:((Bool)->Void) = { select in}
var top:Bool = false var top:Bool = false
...@@ -21,11 +22,13 @@ class EmailFilterSelectCell: UITableViewCell { ...@@ -21,11 +22,13 @@ class EmailFilterSelectCell: UITableViewCell {
func reload() -> Void { func reload() -> Void {
DispatchQueue.main.async { DispatchQueue.main.async {
self.lineW.isHidden = true
if self.top && self.bot { if self.top && self.bot {
self.cornerCut(radius: 12, corner: [.allCorners]) self.cornerCut(radius: 12, corner: [.allCorners])
}else if self.top { }else if self.top {
self.cornerCut(radius: 12, corner: [.topLeft,.topRight]) self.cornerCut(radius: 12, corner: [.topLeft,.topRight])
}else if self.bot { }else if self.bot {
self.lineW.isHidden = true
self.cornerCut(radius: 12, corner: [.bottomLeft,.bottomRight]) self.cornerCut(radius: 12, corner: [.bottomLeft,.bottomRight])
}else{ }else{
self.cornerCut(radius: 0, corner: [.allCorners]) self.cornerCut(radius: 0, corner: [.allCorners])
......
...@@ -45,6 +45,13 @@ ...@@ -45,6 +45,13 @@
<action selector="selectActions:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="ci2-Xj-AsH"/> <action selector="selectActions:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="ci2-Xj-AsH"/>
</connections> </connections>
</button> </button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="yml-hk-CZD">
<rect key="frame" x="15" y="49.666666666666664" width="290" height="0.3333333333333357"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="0.5" id="cVe-0i-0Lr"/>
</constraints>
</view>
</subviews> </subviews>
<color key="backgroundColor" red="0.9490196704864502" green="0.96470588445663452" blue="0.98823529481887817" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="0.9490196704864502" green="0.96470588445663452" blue="0.98823529481887817" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints> <constraints>
...@@ -52,20 +59,24 @@ ...@@ -52,20 +59,24 @@
<constraint firstAttribute="trailing" secondItem="cSn-hx-CjY" secondAttribute="trailing" constant="16" id="Kc3-R6-arj"/> <constraint firstAttribute="trailing" secondItem="cSn-hx-CjY" secondAttribute="trailing" constant="16" id="Kc3-R6-arj"/>
<constraint firstItem="cSn-hx-CjY" firstAttribute="leading" secondItem="DMV-nZ-gHm" secondAttribute="trailing" constant="5" id="Pc6-t5-ZZa"/> <constraint firstItem="cSn-hx-CjY" firstAttribute="leading" secondItem="DMV-nZ-gHm" secondAttribute="trailing" constant="5" id="Pc6-t5-ZZa"/>
<constraint firstItem="DMV-nZ-gHm" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="15" id="VMy-R0-sVH"/> <constraint firstItem="DMV-nZ-gHm" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="15" id="VMy-R0-sVH"/>
<constraint firstAttribute="bottom" secondItem="yml-hk-CZD" secondAttribute="bottom" id="WVb-O4-CvC"/>
<constraint firstAttribute="bottom" secondItem="DMV-nZ-gHm" secondAttribute="bottom" id="ZSi-7s-ZPI"/> <constraint firstAttribute="bottom" secondItem="DMV-nZ-gHm" secondAttribute="bottom" id="ZSi-7s-ZPI"/>
<constraint firstItem="cSn-hx-CjY" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="fVZ-m1-Dee"/> <constraint firstItem="cSn-hx-CjY" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="fVZ-m1-Dee"/>
<constraint firstAttribute="trailing" secondItem="yml-hk-CZD" secondAttribute="trailing" constant="15" id="kfY-T9-chf"/>
<constraint firstItem="yml-hk-CZD" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="15" id="vgm-Fb-xsU"/>
</constraints> </constraints>
</tableViewCellContentView> </tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/> <viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
<connections> <connections>
<outlet property="lineW" destination="yml-hk-CZD" id="Gzd-wt-SMP"/>
<outlet property="selectBtn" destination="cSn-hx-CjY" id="Q47-19-4Dl"/> <outlet property="selectBtn" destination="cSn-hx-CjY" id="Q47-19-4Dl"/>
<outlet property="titleL" destination="DMV-nZ-gHm" id="94o-jg-8bS"/> <outlet property="titleL" destination="DMV-nZ-gHm" id="94o-jg-8bS"/>
</connections> </connections>
<point key="canvasLocation" x="104" y="-11"/> <point key="canvasLocation" x="103.81679389312977" y="-11.267605633802818"/>
</tableViewCell> </tableViewCell>
</objects> </objects>
<resources> <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="ic_unsel_com_red" width="24" height="24"/>
</resources> </resources>
</document> </document>
...@@ -12,14 +12,22 @@ class EmailCleanController: BaseViewController { ...@@ -12,14 +12,22 @@ class EmailCleanController: BaseViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
setup() setup()
PMEmailManager.shareManager.fetchEmails { NotificationCenter.default.addObserver(self, selector: #selector(uupddate), name: messageUpdate, object: nil)
contentView.beginLoading()
}
@objc func uupddate() -> Void {
DispatchQueue.main.async {
self.contentView.endLoading()
self.contentView.datasource = PMEmailManager.shareManager.allMessage self.contentView.datasource = PMEmailManager.shareManager.allMessage
} }
} }
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
self.contentView.datasource = PMEmailManager.shareManager.allMessage DispatchQueue.main.async {
self.contentView.datasource = PMEmailManager.shareManager.allMessage
}
} }
private func setup() -> Void { private func setup() -> Void {
...@@ -43,4 +51,7 @@ class EmailCleanController: BaseViewController { ...@@ -43,4 +51,7 @@ class EmailCleanController: BaseViewController {
return content return content
}() }()
deinit {
NotificationCenter.default.removeObserver(self, name: messageUpdate, object: nil)
}
} }
...@@ -133,6 +133,8 @@ extension EmailFilterController : UITableViewDelegate,UITableViewDataSource { ...@@ -133,6 +133,8 @@ extension EmailFilterController : UITableViewDelegate,UITableViewDataSource {
self.view.hideBlur() self.view.hideBlur()
if idx == 1 { if idx == 1 {
EmailFilterManager.share.FilterSet = self.filter EmailFilterManager.share.FilterSet = self.filter
EmailFilterManager.share.SelectEmailSet = (0..<5).map { _ in NSMutableSet() }
emailSort()
let save = EmailSaveController() let save = EmailSaveController()
save.modalTransitionStyle = .crossDissolve save.modalTransitionStyle = .crossDissolve
save.modalPresentationStyle = .overFullScreen save.modalPresentationStyle = .overFullScreen
......
...@@ -11,11 +11,7 @@ class EmailFilterManager: NSObject { ...@@ -11,11 +11,7 @@ class EmailFilterManager: NSObject {
static let share = EmailFilterManager() static let share = EmailFilterManager()
var SelectEmailSet:[NSMutableSet] = [NSMutableSet(), var SelectEmailSet:[NSMutableSet] = (0..<5).map { _ in NSMutableSet() }
NSMutableSet(),
NSMutableSet(),
NSMutableSet(),
NSMutableSet()]
var FilterSet:EmailFilterData { var FilterSet:EmailFilterData {
get { get {
return self.getFilterSet() return self.getFilterSet()
......
...@@ -180,6 +180,14 @@ extension EmailCleanListView : UITableViewDataSource,UITableViewDelegate { ...@@ -180,6 +180,14 @@ extension EmailCleanListView : UITableViewDataSource,UITableViewDelegate {
cell.descpText1.text = data.payload?.body.plainText?.removeEscapeCharacters() cell.descpText1.text = data.payload?.body.plainText?.removeEscapeCharacters()
let set = EmailFilterManager.share.SelectEmailSet[self.indexPath?.row ?? 0] let set = EmailFilterManager.share.SelectEmailSet[self.indexPath?.row ?? 0]
cell.selectBtn.isSelected = set.contains(indexPath.row) cell.selectBtn.isSelected = set.contains(indexPath.row)
Print("startttt = \(data.labelids)")
if EmailFilterManager.share.FilterSet.start {
cell.startInfo.isHidden = !((data.labelids?.contains("STARRED")) ?? false)
}else{
cell.startInfo.isHidden = true
}
cell.ListDot.isHidden = !((data.labelids?.contains("UNREAD")) ?? false) cell.ListDot.isHidden = !((data.labelids?.contains("UNREAD")) ?? false)
cell.callblock = {[weak self] in cell.callblock = {[weak self] in
guard let self = self else { return } guard let self = self else { return }
......
...@@ -34,6 +34,14 @@ class EmailContentView: UIView { ...@@ -34,6 +34,14 @@ class EmailContentView: UIView {
} }
} }
func beginLoading() -> Void {
self.tableView.mj_header?.beginRefreshing()
}
func endLoading() -> Void {
self.tableView.mj_header?.endRefreshing()
}
convenience init( _ parent:UIViewController) { convenience init( _ parent:UIViewController) {
self.init(frame: CGRect()) self.init(frame: CGRect())
self.parent = parent self.parent = parent
...@@ -87,15 +95,11 @@ class EmailContentView: UIView { ...@@ -87,15 +95,11 @@ class EmailContentView: UIView {
}() }()
@objc func refresh() -> Void { @objc func refresh() -> Void {
EmailFilterManager.share.SelectEmailSet = [ self.tableView.reloadData()
NSMutableSet(), EmailFilterManager.share.SelectEmailSet = (0..<5).map { _ in NSMutableSet() }
NSMutableSet(), PMEmailManager.shareManager.fetchEmails { [weak self] in
NSMutableSet(), self?.endLoading()
NSMutableSet(), self?.datasource = PMEmailManager.shareManager.allMessage
NSMutableSet()
]
PMEmailManager.shareManager.fetchEmails {
self.datasource = PMEmailManager.shareManager.allMessage
} }
} }
...@@ -122,7 +126,6 @@ class EmailContentView: UIView { ...@@ -122,7 +126,6 @@ class EmailContentView: UIView {
var datasource:[EmailDetailModel] = PMEmailManager.shareManager.allMessage { var datasource:[EmailDetailModel] = PMEmailManager.shareManager.allMessage {
didSet { didSet {
DispatchQueue.main.async { DispatchQueue.main.async {
self.mj_header.endRefreshing()
self.tableView.reloadData() self.tableView.reloadData()
self.Total() self.Total()
} }
...@@ -232,7 +235,16 @@ extension EmailContentView :UITableViewDelegate,UITableViewDataSource{ ...@@ -232,7 +235,16 @@ extension EmailContentView :UITableViewDelegate,UITableViewDataSource{
let set = EmailFilterManager.share.SelectEmailSet[indexPath.row] let set = EmailFilterManager.share.SelectEmailSet[indexPath.row]
cell.selectBtn.isSelected = (set.count == data.child.count && set.count > 0) cell.selectBtn.isSelected = (set.count == data.child.count && set.count > 0)
cell.groupName.text = data.label cell.groupName.text = data.label
cell.groupNumbers.text = "\(data.child.count) Emails" + (set.count > 0 ? " · \(set.count) Selected" : "") if self.mj_header.isRefreshing {
cell.groupNumbers.text = "Scanning..."
cell.loaingView.isHidden = false
cell.loaingView.startAnimating()
cell.info.isHidden = true
}else{
cell.groupNumbers.text = "\(data.child.count) Emails" + (set.count > 0 ? " · \(set.count) Selected" : "")
cell.loaingView.isHidden = true
cell.info.isHidden = false
}
cell.callblock = {[weak self] in cell.callblock = {[weak self] in
guard let self = self else { return } guard let self = self else { return }
self.selectAll(indexPath) self.selectAll(indexPath)
...@@ -242,12 +254,14 @@ extension EmailContentView :UITableViewDelegate,UITableViewDataSource{ ...@@ -242,12 +254,14 @@ extension EmailContentView :UITableViewDelegate,UITableViewDataSource{
} }
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let vc = EmailCleanListController()
let data = datasource[indexPath.row].child let data = datasource[indexPath.row].child
vc.titleLabel.text = datasource[indexPath.row].label if data.count > 0 {
vc.datasoure = data let vc = EmailCleanListController()
vc.indexPath = indexPath vc.titleLabel.text = datasource[indexPath.row].label
parent?.navigationController?.pushViewController(vc, animated: true) vc.datasoure = data
vc.indexPath = indexPath
parent?.navigationController?.pushViewController(vc, animated: true)
}
} }
} }
...@@ -76,3 +76,10 @@ let kcWindow:UIWindow = { ...@@ -76,3 +76,10 @@ let kcWindow:UIWindow = {
return UIApplication.shared.keyWindow ?? UIWindow() return UIApplication.shared.keyWindow ?? UIWindow()
} }
}() }()
public func Alert( _ title:String? , _ message:String) -> Void {
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .cancel))
cWindow?.rootViewController?.present(alert, animated: true)
}
...@@ -55,8 +55,8 @@ func weekFormatter() -> String { ...@@ -55,8 +55,8 @@ func weekFormatter() -> String {
} }
func PMAlert(_ msg:String , _ action:[String] = [] , _ complate:@escaping(( UIAlertController ,Int)->Void) = { v , idx in} ) -> Void { func PMAlert(title:String? = nil, messsage:String , action:[String] = [] ,complate:@escaping(( UIAlertController ,Int)->Void) = { v , idx in} ) -> Void {
let alertview = UIAlertController(title: nil, message: msg, preferredStyle: .alert) let alertview = UIAlertController(title: title, message: messsage, preferredStyle: .alert)
guard let root = cWindow?.rootViewController else { return } guard let root = cWindow?.rootViewController else { return }
root.present(alertview, animated: true) root.present(alertview, animated: true)
if action.count > 0 { if action.count > 0 {
......
...@@ -8,10 +8,12 @@ ...@@ -8,10 +8,12 @@
import UIKit import UIKit
import GoogleSignIn import GoogleSignIn
import GoogleAPIClientForREST import GoogleAPIClientForREST
import SVProgressHUD
class PMEmailManager: NSObject { class PMEmailManager: NSObject {
static let cloud_id = "797378266354-no81qsffrlpj6p6i1umh981ne2mgtiua.apps.googleusercontent.com" static let cloud_id = "684306808588-cl093f79dogls1a608bh8oclk3ia0rig.apps.googleusercontent.com"
static let shareManager = PMEmailManager() static let shareManager = PMEmailManager()
...@@ -32,10 +34,13 @@ class PMEmailManager: NSObject { ...@@ -32,10 +34,13 @@ class PMEmailManager: NSObject {
} }
func signOut(_ complate:@escaping((Bool)->Void)) -> Void { func signOut(_ complate:@escaping((Bool)->Void)) -> Void {
GIDSignIn.sharedInstance.signOut()
GIDSignIn.sharedInstance.disconnect { error in GIDSignIn.sharedInstance.disconnect { error in
if error == nil { if error == nil {
self.loginUser = nil self.loginUser = nil
GIDSignIn.sharedInstance.signOut()
PMEmailManager.shareManager.messageFilter = PmEmailData()
PMEmailManager.shareManager.allMessage = PmEmailData()
EmailFilterManager.share.SelectEmailSet = (0..<5).map { _ in NSMutableSet() }
complate(true) complate(true)
}else{ }else{
complate(false) complate(false)
...@@ -76,16 +81,18 @@ class PMEmailManager: NSObject { ...@@ -76,16 +81,18 @@ class PMEmailManager: NSObject {
let query = GTLRGmailQuery_UsersMessagesList.query(withUserId: self.loginUser?.userID ?? "me") let query = GTLRGmailQuery_UsersMessagesList.query(withUserId: self.loginUser?.userID ?? "me")
query.includeSpamTrash = true query.includeSpamTrash = true
query.labelIds = ["INBOX"] query.labelIds = ["INBOX"]
service.executeQuery(query) { ticket, result, error in service.executeQuery(query) { ticket, result, error in
guard let list = result as? GTLRGmail_ListMessagesResponse else { guard let list = result as? GTLRGmail_ListMessagesResponse else {
self.loading = false self.loading = false
Alert("error","Request timed out, please try again")
complate() complate()
return return
} }
DispatchQueue.global().async { DispatchQueue.global().async {
var num = 0 var num = 0
list.messages?.forEach { message in list.messages?.forEach { Omsg in
self.fetchEmailDetails(message.identifier ?? "") { self.fetchEmailDetails(Omsg.identifier ?? "" ,message: Omsg) {
num += 1 num += 1
if list.messages?.count ?? 0 == num { if list.messages?.count ?? 0 == num {
emailSort() emailSort()
...@@ -100,7 +107,7 @@ class PMEmailManager: NSObject { ...@@ -100,7 +107,7 @@ class PMEmailManager: NSObject {
} }
} }
func fetchEmailDetails(_ messageID:String ,_ complate:@escaping(()->Void) ) { func fetchEmailDetails(_ messageID:String ,message:GTLRGmail_Message ,_ complate:@escaping(()->Void) ) {
let service = GTLRGmailService() let service = GTLRGmailService()
service.authorizer = self.loginUser?.fetcherAuthorizer service.authorizer = self.loginUser?.fetcherAuthorizer
let query = GTLRGmailQuery_UsersMessagesGet.query( let query = GTLRGmailQuery_UsersMessagesGet.query(
...@@ -113,37 +120,7 @@ class PMEmailManager: NSObject { ...@@ -113,37 +120,7 @@ class PMEmailManager: NSObject {
complate() complate()
return return
} }
var email = EmailMessageModel() _ = self.Analysis(message: message)
email.messageId = messageID
email.snippet = message.snippet
email.labelids = message.labelIds
var payload = EmailMessagepayLoadModel()
let headers = self.extractHeaders(from: message)
payload.headers = EmailMessageHeadersModel(from: headers.from,subject: headers.subject,date: headers.date, to: headers.to)
let plaint = self.parseMessageBody(message)
payload.body.plainText = plaint.plainText
payload.body.html = plaint.html
email.payload = payload
let labels = ["CATEGORY_SOCIAL","CATEGORY_PROMOTIONS","CATEGORY_UPDATES","CATEGORY_FORUMS","SPAM"]
let sets:NSMutableSet = NSMutableSet(array: message.labelIds ?? [])
for l in labels {
if sets.contains(l) {
if l == labels.first {
self.messageFilter[0].child.append(email)
}else if l == labels[1] {
self.messageFilter[1].child.append(email)
}else if l == labels[2] {
self.messageFilter[2].child.append(email)
}else if l == labels[3] {
self.messageFilter[3].child.append(email)
}else if l == labels[4] {
self.messageFilter[4].child.append(email)
}
}
}
complate() complate()
} }
} }
...@@ -245,7 +222,7 @@ class PMEmailManager: NSObject { ...@@ -245,7 +222,7 @@ class PMEmailManager: NSObject {
// MARK: - 批量删除邮件 // MARK: - 批量删除邮件
func deleteEmail(_ indexPath:Int = -1, _ complate:@escaping((Bool)->Void)) -> Void { func deleteEmail(_ indexPath:Int = -1, _ complate:@escaping((Bool)->Void)) -> Void {
var messageID = NSMutableSet() let messageID = NSMutableSet()
if indexPath < 0 { if indexPath < 0 {
for i in 0..<5 { for i in 0..<5 {
for row in EmailFilterManager.share.SelectEmailSet[i].allObjects { for row in EmailFilterManager.share.SelectEmailSet[i].allObjects {
...@@ -293,11 +270,7 @@ class PMEmailManager: NSObject { ...@@ -293,11 +270,7 @@ class PMEmailManager: NSObject {
return !deletes.contains(msg.messageId ?? "") return !deletes.contains(msg.messageId ?? "")
}) })
} }
EmailFilterManager.share.SelectEmailSet = [NSMutableSet(), EmailFilterManager.share.SelectEmailSet = (0..<5).map { _ in NSMutableSet() }
NSMutableSet(),
NSMutableSet(),
NSMutableSet(),
NSMutableSet()]
}else{ }else{
PMEmailManager.shareManager.messageFilter[all].child = PMEmailManager.shareManager.messageFilter[all].child.filter({ msg in PMEmailManager.shareManager.messageFilter[all].child = PMEmailManager.shareManager.messageFilter[all].child.filter({ msg in
return !deletes.contains(msg.messageId ?? "") return !deletes.contains(msg.messageId ?? "")
...@@ -307,6 +280,41 @@ class PMEmailManager: NSObject { ...@@ -307,6 +280,41 @@ class PMEmailManager: NSObject {
PMEmailManager.shareManager.allMessage = PMEmailManager.shareManager.messageFilter PMEmailManager.shareManager.allMessage = PMEmailManager.shareManager.messageFilter
} }
func Analysis(message:GTLRGmail_Message) -> EmailMessageModel {
var email = EmailMessageModel()
email.messageId = message.identifier
email.snippet = message.snippet
email.labelids = message.labelIds
var payload = EmailMessagepayLoadModel()
let headers = self.extractHeaders(from: message)
payload.headers = EmailMessageHeadersModel(from: headers.from,subject: headers.subject,date: headers.date, to: headers.to)
let plaint = self.parseMessageBody(message)
payload.body.plainText = plaint.plainText
payload.body.html = plaint.html
email.payload = payload
let labels = ["CATEGORY_SOCIAL","CATEGORY_PROMOTIONS","CATEGORY_UPDATES","CATEGORY_FORUMS","SPAM"]
let sets:NSMutableSet = NSMutableSet(array: message.labelIds ?? [])
for l in labels {
if sets.contains(l) {
if l == labels.first {
self.messageFilter[0].child.append(email)
}else if l == labels[1] {
self.messageFilter[1].child.append(email)
}else if l == labels[2] {
self.messageFilter[2].child.append(email)
}else if l == labels[3] {
self.messageFilter[3].child.append(email)
}else if l == labels[4] {
self.messageFilter[4].child.append(email)
}
}
}
return email
}
/** 解析base 64 */ /** 解析base 64 */
private func decodeBody(_ data: String?) -> String { private func decodeBody(_ data: String?) -> String {
...@@ -347,26 +355,24 @@ fileprivate func EMfilter() -> Void { ...@@ -347,26 +355,24 @@ fileprivate func EMfilter() -> Void {
default: default:
break break
} }
var filtrate = PMEmailManager.shareManager.messageFilter
for i in 0..<5 { for i in 0..<5 {
PMEmailManager.shareManager.messageFilter[i].child = PMEmailManager.shareManager.messageFilter[i].child.filter({ msg in filtrate[i].child = filtrate[i].child.filter({ msg in
var isTime = true var isTime = true
var isStart = true
var isRead = true var isRead = true
var keyword = true var keyword = true
if date != nil { // 时间 if date != nil { // 时间
let tm1 = msg.payload?.headers?.date?.EmailDateFromat().timeIntervalSince1970 ?? 0 let tm1 = msg.payload?.headers?.date?.EmailDateFromat().timeIntervalSince1970 ?? 0
let tm2 = date?.timeIntervalSince1970 ?? 0 let tm2 = date?.timeIntervalSince1970 ?? Date().timeIntervalSince1970
isTime = tm1 > tm2 isTime = tm1 < tm2
}
if EmailFilterManager.share.FilterSet.start { // 星标
isStart = msg.labelids?.contains("STARRED") ?? false
} }
let labels = msg.labelids ?? []
if EmailFilterManager.share.FilterSet.read && EmailFilterManager.share.FilterSet.unread { if EmailFilterManager.share.FilterSet.read && EmailFilterManager.share.FilterSet.unread {
isRead = true isRead = true
}else if EmailFilterManager.share.FilterSet.read { }else if EmailFilterManager.share.FilterSet.read {
isRead = !(msg.labelids?.contains("UNREAD") ?? false) isRead = !labels.contains("UNREAD")
}else{ }else{
isRead = (msg.labelids?.contains("UNREAD") ?? false) isRead = labels.contains("UNREAD")
} }
if EmailFilterManager.share.FilterSet.keyword { // 关键字 if EmailFilterManager.share.FilterSet.keyword { // 关键字
for key in EmailFilterManager.share.keyword { for key in EmailFilterManager.share.keyword {
...@@ -377,15 +383,17 @@ fileprivate func EMfilter() -> Void { ...@@ -377,15 +383,17 @@ fileprivate func EMfilter() -> Void {
} }
} }
} }
return isTime && isStart && isRead && keyword return isTime && isRead && keyword
}) })
} }
let bsp = PMEmailManager.shareManager.messageFilter PMEmailManager.shareManager.allMessage = filtrate
PMEmailManager.shareManager.allMessage = bsp NotificationCenter.default.post(name: messageUpdate, object: nil)
Print("邮件加载成功")
} }
let messageUpdate = NSNotification.Name("emailUpdate")
fileprivate func emailSort() -> Void { public func emailSort() -> Void {
for i in 0..<5 { // 时间排序 for i in 0..<5 { // 时间排序
PMEmailManager.shareManager.messageFilter[i].child = PMEmailManager.shareManager.messageFilter[i].child.sorted { email, email1 in PMEmailManager.shareManager.messageFilter[i].child = PMEmailManager.shareManager.messageFilter[i].child.sorted { email, email1 in
......
//
// PMFaceIDManger.swift
// PhoneManager
//
// Created by edy on 2025/5/15.
//
import UIKit
import LocalAuthentication
class PMFaceIDManger: NSObject {
class func isAvailable() -> Bool { // 有home键的全支持face id
return cWindow?.safeAreaInsets.bottom ?? 0 > 0
}
class func request() -> Bool {
let context = LAContext()
return context.biometricType == .faceID
}
class func authenticateWithFaceID(reason: String, completion: @escaping (Bool, Error?) -> Void) {
let context = LAContext()
context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { success, error in
DispatchQueue.main.async {
completion(success, error)
}
}
}
}
extension LAContext {
enum BiometricType {
case none, touchID, faceID
}
var biometricType: BiometricType {
var error: NSError?
guard canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) else {
self.handleLAError(error ?? NSError())
return .none
}
if #available(iOS 11.0, *) {
return biometryType == .faceID ? .faceID : .touchID
}
return .touchID
}
func handleLAError(_ error: Error) {
if let laError = error as? LAError {
switch laError.code {
case .biometryNotAvailable:
print("生物识别不可用:设备不支持或未启用")
PMAlert(title: "Error" ,messsage: "App needs to access your face ID.",action: ["Yes","Open in Settings"]) { alert, idx in
if idx == 1 {
UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!)
}
alert.dismiss(animated: true)
}
case .biometryNotEnrolled:
print("未录入生物特征")
PMAlert(title:"Error" ,messsage: "There is no registered Face ID on your iPhone. You should register your Face ID first before using it." , action: ["OK"])
case .biometryLockout:
print("功能锁定,需输入设备密码")
PMAlert(title:"Error" ,messsage: "FacelD cannot recognize your face. please try again later" , action: ["OK"])
case .userCancel:
print("用户取消验证")
default:
print("其他错误:\(laError.localizedDescription)")
}
}
}
}
...@@ -2,21 +2,21 @@ ...@@ -2,21 +2,21 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>GIDClientID</key> <key>CFBundleURLTypes</key>
<string>797378266354-no81qsffrlpj6p6i1umh981ne2mgtiua.apps.googleusercontent.com</string> <array>
<key>CFBundleURLTypes</key> <dict>
<array> <key>CFBundleTypeRole</key>
<dict> <string>Editor</string>
<key>CFBundleTypeRole</key> <key>CFBundleURLSchemes</key>
<string>Editor</string> <array>
<key>CFBundleURLSchemes</key> <string>com.googleusercontent.apps.684306808588-cl093f79dogls1a608bh8oclk3ia0rig</string>
<array> </array>
<string>com.googleusercontent.apps.797378266354-no81qsffrlpj6p6i1umh981ne2mgtiua</string> </dict>
</array> </array>
</dict>
</array>
<key>GADApplicationIdentifier</key> <key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string> <string>ca-app-pub-3940256099942544~1458002511</string>
<key>GIDClientID</key>
<string>684306808588-cl093f79dogls1a608bh8oclk3ia0rig.apps.googleusercontent.com</string>
<key>LSApplicationQueriesSchemes</key> <key>LSApplicationQueriesSchemes</key>
<array> <array>
<string>google</string> <string>google</string>
......
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