Commit 7a599916 authored by lmj_521aiau@163.com's avatar lmj_521aiau@163.com

cloud

parent d6dbfaf5
...@@ -490,9 +490,6 @@ ...@@ -490,9 +490,6 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
A95CE03724E17BAF0066DAE6 /* SHTimer.swift */, A95CE03724E17BAF0066DAE6 /* SHTimer.swift */,
A94D935D24F7AF2300A886C0 /* SHLocationManager.swift */,
A94DD57124FDF9D200B1B5A2 /* SHMp3RecordManager.h */,
A94DD57224FDF9D200B1B5A2 /* SHMp3RecordManager.m */,
A94DD57B24FE377100B1B5A2 /* AlertControllerTool.h */, A94DD57B24FE377100B1B5A2 /* AlertControllerTool.h */,
A94DD57A24FE377100B1B5A2 /* AlertControllerTool.m */, A94DD57A24FE377100B1B5A2 /* AlertControllerTool.m */,
A9A16C782519DDC300DE0FEE /* PopView */, A9A16C782519DDC300DE0FEE /* PopView */,
...@@ -651,6 +648,9 @@ ...@@ -651,6 +648,9 @@
A95CDFED24E0F42E0066DAE6 /* Managers */ = { A95CDFED24E0F42E0066DAE6 /* Managers */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
A94D935D24F7AF2300A886C0 /* SHLocationManager.swift */,
A94DD57124FDF9D200B1B5A2 /* SHMp3RecordManager.h */,
A94DD57224FDF9D200B1B5A2 /* SHMp3RecordManager.m */,
A94D935624F7958500A886C0 /* SHStoreManager.swift */, A94D935624F7958500A886C0 /* SHStoreManager.swift */,
A95CDFEE24E0F42E0066DAE6 /* SHUserAccountManager.swift */, A95CDFEE24E0F42E0066DAE6 /* SHUserAccountManager.swift */,
A95CDFF024E0F42F0066DAE6 /* CRContactTools.swift */, A95CDFF024E0F42F0066DAE6 /* CRContactTools.swift */,
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "完成@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "完成@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
...@@ -89,7 +89,7 @@ struct CRUserDefaults { ...@@ -89,7 +89,7 @@ struct CRUserDefaults {
} }
} }
// recordList //
static var sortType: NSInteger? { static var sortType: NSInteger? {
set { set {
UserDefaults.standard.set(newValue, forKey: "com.app.sortType") UserDefaults.standard.set(newValue, forKey: "com.app.sortType")
......
...@@ -29,13 +29,13 @@ class SHDeleteDetailsViewController: SHBaseViewController { ...@@ -29,13 +29,13 @@ class SHDeleteDetailsViewController: SHBaseViewController {
for (index, dic) in (list ?? []).enumerated(){ for (index, dic) in (list ?? []).enumerated(){
let model = SHRecordModel() let model = SHRecordModel()
model.setValuesForKeys(dic) model.setValuesForKeys(dic)
if model.delete == true{ // if model.delete == true{
if model.deleteDate.daysBetweenDate(toDate: Date.init()) > 30 { // if model.deleteDate.daysBetweenDate(toDate: Date.init()) > 30 {
list?.remove(at: index) // list?.remove(at: index)
}else{ // }else{
dataSource.append(model) // dataSource.append(model)
} // }
} // }
} }
CRUserDefaults.recordList = list CRUserDefaults.recordList = list
} }
......
...@@ -22,34 +22,4 @@ class SHRecordFolderModel: NSObject{ ...@@ -22,34 +22,4 @@ class SHRecordFolderModel: NSObject{
override func setValue(_ value: Any?, forUndefinedKey key: String) { override func setValue(_ value: Any?, forUndefinedKey key: String) {
} }
// //构造方法
// required init(createDate:Date=Date(), modifyDate:Date=Date(), name:String="", id:String="", top:Bool=false, dataSources:Array<SHRecordModel> = []) {
// self.name = name
// self.id = name
// self.createDate = createDate
// self.modifyDate = modifyDate
// self.top = top
// self.dataSources = dataSources
// }
//
// //从object解析回来
// required init(coder decoder: NSCoder) {
// self.createDate = (decoder.decodeObject(forKey: "createDate") as? Date)!
// self.modifyDate = (decoder.decodeObject(forKey: "modifyDate") as? Date)!
// self.id = decoder.decodeObject(forKey: "id") as? String ?? ""
// self.name = decoder.decodeObject(forKey: "name") as? String ?? ""
// self.top = decoder.decodeObject(forKey: "top") as? Bool ?? false
// self.dataSources = decoder.decodeObject(forKey: "dataSources") as! Array<SHRecordModel>
// }
//
// //编码成object
// func encode(with coder: NSCoder) {
// coder.encode(createDate, forKey:"createDate")
// coder.encode(modifyDate, forKey:"modifyDate")
// coder.encode(top, forKey:"top")
// coder.encode(name, forKey:"name")
// coder.encode(id, forKey:"id")
// coder.encode(dataSources, forKey:"dataSources")
// }
} }
...@@ -10,75 +10,25 @@ import UIKit ...@@ -10,75 +10,25 @@ import UIKit
class SHRecordModel: NSObject{ class SHRecordModel: NSObject{
@objc var recordType: NSInteger = 0
@objc var createDate: Date = Date() @objc var createDate: Date = Date()
@objc var modifyDate: Date = Date() @objc var modifyDate: Date = Date()
@objc var deleteDate: Date = Date()
@objc var during: NSInteger = 0
@objc var address: String = "" @objc var address: String = ""
@objc var rename: String = "" @objc var rename: String = ""
@objc var txt: String = ""
@objc var pathFile: String = "" @objc var pathFile: String = ""
@objc var pcmPathFile: String = "" @objc var pcmPathFile: String = ""
@objc var txt: String = "" @objc var during: NSInteger = 0
@objc var delete: Bool = false
@objc var top: Bool = false
@objc var selected: Bool = false @objc var selected: Bool = false
@objc var icloud: Bool = false
@objc var fileData: Data = Data() @objc var fileData: Data = Data()
override func setValue(_ value: Any?, forUndefinedKey key: String) { override func setValue(_ value: Any?, forUndefinedKey key: String) {
} }
// //构造方法
// required init(createDate:Date=Date(), modifyDate:Date=Date(), deleteDate:Date=Date(), during:NSInteger=0, address:String="", rename:String="", pathFile:String="", pcmPathFile:String="", txt:String="", delete:Bool=false, top:Bool=false, fileData:Data=Data()) {
// self.createDate = createDate
// self.modifyDate = modifyDate
// self.deleteDate = deleteDate
//
// self.during = during
// self.address = address
// self.pathFile = pathFile
// self.pcmPathFile = pcmPathFile
// self.txt = txt
//
// self.delete = delete
// self.top = top
//
// self.fileData = fileData
// self.rename = rename
// }
//
// //从object解析回来
// required init(coder decoder: NSCoder) {
// self.createDate = (decoder.decodeObject(forKey: "createDate") as? Date)!
// self.modifyDate = (decoder.decodeObject(forKey: "modifyDate") as? Date)!
// self.deleteDate = (decoder.decodeObject(forKey: "deleteDate") as? Date)!
// self.during = (decoder.decodeObject(forKey: "during") as? NSInteger)!
// self.address = decoder.decodeObject(forKey: "address") as? String ?? ""
// self.pathFile = decoder.decodeObject(forKey: "pathFile") as? String ?? ""
// self.pcmPathFile = decoder.decodeObject(forKey: "pcmPathFile") as? String ?? ""
// self.txt = decoder.decodeObject(forKey: "txt") as? String ?? ""
// self.delete = decoder.decodeObject(forKey: "delete") as? Bool ?? false
// self.top = decoder.decodeObject(forKey: "top") as? Bool ?? false
// self.fileData = (decoder.decodeObject(forKey: "fileData") as? Data)!
// self.rename = decoder.decodeObject(forKey: "rename") as? String ?? ""
// }
//
// //编码成object
// func encode(with coder: NSCoder) {
// coder.encode(createDate, forKey:"createDate")
// coder.encode(modifyDate, forKey:"modifyDate")
// coder.encode(deleteDate, forKey:"deleteDate")
// coder.encode(during, forKey:"during")
// coder.encode(address, forKey:"address")
// coder.encode(pathFile, forKey:"pathFile")
// coder.encode(pcmPathFile, forKey:"pcmPathFile")
// coder.encode(txt, forKey:"txt")
// coder.encode(delete, forKey:"delete")
// coder.encode(top, forKey:"top")
// coder.encode(fileData, forKey:"fileData")
// coder.encode(rename, forKey:"rename")
// }
} }
...@@ -380,9 +380,6 @@ ...@@ -380,9 +380,6 @@
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="recordDetails_voice" translatesAutoresizingMaskIntoConstraints="NO" id="6je-jR-opG"> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="recordDetails_voice" translatesAutoresizingMaskIntoConstraints="NO" id="6je-jR-opG">
<rect key="frame" x="18" y="107" width="16" height="16"/> <rect key="frame" x="18" y="107" width="16" height="16"/>
</imageView> </imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="recordDetails_icloud" translatesAutoresizingMaskIntoConstraints="NO" id="urE-AE-afS">
<rect key="frame" x="310" y="107" width="16" height="16"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XAw-V9-smq"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XAw-V9-smq">
<rect key="frame" x="39" y="106.5" width="36" height="17"/> <rect key="frame" x="39" y="106.5" width="36" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/> <fontDescription key="fontDescription" type="system" pointSize="14"/>
...@@ -395,6 +392,15 @@ ...@@ -395,6 +392,15 @@
<color key="textColor" red="0.58431372549019611" green="0.62745098039215685" blue="0.72156862745098038" alpha="1" colorSpace="calibratedRGB"/> <color key="textColor" red="0.58431372549019611" green="0.62745098039215685" blue="0.72156862745098038" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="SzJ-Gk-Tag">
<rect key="frame" x="296" y="100" width="30" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="30" id="oaj-sd-4Uh"/>
<constraint firstAttribute="height" constant="30" id="wkj-jD-iI1"/>
</constraints>
<state key="normal" image="recordDetails_icloud"/>
<state key="selected" image="recordDetails_icloud_selected"/>
</button>
</subviews> </subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/> <color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints> <constraints>
...@@ -402,12 +408,12 @@ ...@@ -402,12 +408,12 @@
<constraint firstItem="6je-jR-opG" firstAttribute="leading" secondItem="6bV-3V-R81" secondAttribute="leading" id="3MN-xi-qGf"/> <constraint firstItem="6je-jR-opG" firstAttribute="leading" secondItem="6bV-3V-R81" secondAttribute="leading" id="3MN-xi-qGf"/>
<constraint firstItem="6je-jR-opG" firstAttribute="top" secondItem="FVv-OG-DwV" secondAttribute="bottom" constant="10" id="4KH-Iy-ZhP"/> <constraint firstItem="6je-jR-opG" firstAttribute="top" secondItem="FVv-OG-DwV" secondAttribute="bottom" constant="10" id="4KH-Iy-ZhP"/>
<constraint firstItem="XAw-V9-smq" firstAttribute="centerY" secondItem="6je-jR-opG" secondAttribute="centerY" id="50B-aE-1WZ"/> <constraint firstItem="XAw-V9-smq" firstAttribute="centerY" secondItem="6je-jR-opG" secondAttribute="centerY" id="50B-aE-1WZ"/>
<constraint firstAttribute="trailing" secondItem="urE-AE-afS" secondAttribute="trailing" constant="18" id="8HT-0k-imP"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="FVv-OG-DwV" secondAttribute="trailing" constant="17" id="8HX-P1-g1a"/> <constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="FVv-OG-DwV" secondAttribute="trailing" constant="17" id="8HX-P1-g1a"/>
<constraint firstItem="urE-AE-afS" firstAttribute="centerY" secondItem="6je-jR-opG" secondAttribute="centerY" id="Gn4-lu-046"/>
<constraint firstItem="6bV-3V-R81" firstAttribute="leading" secondItem="Ace-iU-keq" secondAttribute="leading" constant="18" id="IIf-qf-lrN"/> <constraint firstItem="6bV-3V-R81" firstAttribute="leading" secondItem="Ace-iU-keq" secondAttribute="leading" constant="18" id="IIf-qf-lrN"/>
<constraint firstItem="FVv-OG-DwV" firstAttribute="top" secondItem="cAa-wI-k0B" secondAttribute="bottom" constant="14" id="Lpt-nL-sQY"/> <constraint firstItem="FVv-OG-DwV" firstAttribute="top" secondItem="cAa-wI-k0B" secondAttribute="bottom" constant="14" id="Lpt-nL-sQY"/>
<constraint firstAttribute="trailing" secondItem="SzJ-Gk-Tag" secondAttribute="trailing" constant="18" id="NMg-Q5-D9g"/>
<constraint firstItem="XAw-V9-smq" firstAttribute="leading" secondItem="6je-jR-opG" secondAttribute="trailing" constant="5" id="PC3-oS-13D"/> <constraint firstItem="XAw-V9-smq" firstAttribute="leading" secondItem="6je-jR-opG" secondAttribute="trailing" constant="5" id="PC3-oS-13D"/>
<constraint firstItem="SzJ-Gk-Tag" firstAttribute="centerY" secondItem="XAw-V9-smq" secondAttribute="centerY" id="QtN-zj-NGy"/>
<constraint firstItem="cAa-wI-k0B" firstAttribute="leading" secondItem="6bV-3V-R81" secondAttribute="leading" id="RCB-kP-xS4"/> <constraint firstItem="cAa-wI-k0B" firstAttribute="leading" secondItem="6bV-3V-R81" secondAttribute="leading" id="RCB-kP-xS4"/>
<constraint firstItem="6bV-3V-R81" firstAttribute="top" secondItem="Ace-iU-keq" secondAttribute="top" constant="18" id="Sj5-yA-Hdn"/> <constraint firstItem="6bV-3V-R81" firstAttribute="top" secondItem="Ace-iU-keq" secondAttribute="top" constant="18" id="Sj5-yA-Hdn"/>
<constraint firstItem="FVv-OG-DwV" firstAttribute="leading" secondItem="6bV-3V-R81" secondAttribute="leading" id="k4e-UV-52H"/> <constraint firstItem="FVv-OG-DwV" firstAttribute="leading" secondItem="6bV-3V-R81" secondAttribute="leading" id="k4e-UV-52H"/>
...@@ -436,6 +442,7 @@ ...@@ -436,6 +442,7 @@
<connections> <connections>
<outlet property="bgView" destination="Ace-iU-keq" id="31n-sq-R8Z"/> <outlet property="bgView" destination="Ace-iU-keq" id="31n-sq-R8Z"/>
<outlet property="duringLab" destination="XAw-V9-smq" id="VcG-2T-mDb"/> <outlet property="duringLab" destination="XAw-V9-smq" id="VcG-2T-mDb"/>
<outlet property="icloudBtn" destination="SzJ-Gk-Tag" id="6yW-x7-QEA"/>
<outlet property="intervalConstraint" destination="Vl1-fz-hLo" id="7j9-uM-4A6"/> <outlet property="intervalConstraint" destination="Vl1-fz-hLo" id="7j9-uM-4A6"/>
<outlet property="leftConstraint" destination="ZZS-Bg-AaH" id="ddK-2Q-gnL"/> <outlet property="leftConstraint" destination="ZZS-Bg-AaH" id="ddK-2Q-gnL"/>
<outlet property="selectedBtn" destination="adA-MF-vWU" id="4V6-5L-aw2"/> <outlet property="selectedBtn" destination="adA-MF-vWU" id="4V6-5L-aw2"/>
...@@ -682,6 +689,7 @@ ...@@ -682,6 +689,7 @@
</scenes> </scenes>
<resources> <resources>
<image name="recordDetails_icloud" width="16" height="16"/> <image name="recordDetails_icloud" width="16" height="16"/>
<image name="recordDetails_icloud_selected" width="16" height="16"/>
<image name="recordDetails_select" width="20" height="20"/> <image name="recordDetails_select" width="20" height="20"/>
<image name="recordDetails_selected" width="20" height="20"/> <image name="recordDetails_selected" width="20" height="20"/>
<image name="recordDetails_voice" width="16" height="16"/> <image name="recordDetails_voice" width="16" height="16"/>
......
...@@ -26,6 +26,7 @@ class SHRecordDetailsVC: SHBaseViewController { ...@@ -26,6 +26,7 @@ class SHRecordDetailsVC: SHBaseViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
setupUI() setupUI()
updateocloudUI()
} }
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
...@@ -85,6 +86,29 @@ class SHRecordDetailsVC: SHBaseViewController { ...@@ -85,6 +86,29 @@ class SHRecordDetailsVC: SHBaseViewController {
} }
} }
} }
//MARK:XXXXXXXXX
func updateocloudUI(_ update: Bool = true){
for recordModel in self.currentModel.dataSources {
recordModel.icloud = false
}
for folderModel in SHCloudManager.shared.icloudFolderModels{
if self.currentModel.id == folderModel.id {
for recordModel in self.currentModel.dataSources {
for icloudRecordModel in folderModel.dataSources {
if recordModel.pathFile == icloudRecordModel.pathFile {
recordModel.icloud = icloudRecordModel.icloud
}
}
}
}
}
if update {
DispatchQueue.main.async {
self.tableView?.reloadData()
}
}
}
@objc func editClick(){ @objc func editClick(){
if currentModel.dataSources.count == 0 { if currentModel.dataSources.count == 0 {
...@@ -104,6 +128,11 @@ class SHRecordDetailsVC: SHBaseViewController { ...@@ -104,6 +128,11 @@ class SHRecordDetailsVC: SHBaseViewController {
UIView.animate(withDuration: 0.25) { UIView.animate(withDuration: 0.25) {
self.bottomView?.frame = CGRect.init(x: -self.tableFooterView!.frame.width, y: 0, width: self.tableFooterView!.frame.width*2, height: self.tableFooterView!.frame.height) self.bottomView?.frame = CGRect.init(x: -self.tableFooterView!.frame.width, y: 0, width: self.tableFooterView!.frame.width*2, height: self.tableFooterView!.frame.height)
} }
for model in currentModel.dataSources{
model.selected = false
}
} }
self.navigationItem.rightBarButtonItem?.tintColor = UIColor.init(hexStr: "4183F4") self.navigationItem.rightBarButtonItem?.tintColor = UIColor.init(hexStr: "4183F4")
self.tableView?.reloadData() self.tableView?.reloadData()
...@@ -144,7 +173,63 @@ extension SHRecordDetailsVC { ...@@ -144,7 +173,63 @@ extension SHRecordDetailsVC {
self.navigationController?.present(nav, animated: true, completion: nil) self.navigationController?.present(nav, animated: true, completion: nil)
move.saveSuccessCallBack = { model in move.saveSuccessCallBack = { model in
self.currentModel = model self.currentModel = model
self.tableView?.reloadData() for model in self.currentModel.dataSources {
model.selected = false
}
self.edit = false
self.updateocloudUI()
// self.tableView?.reloadData()
}
}
//MARK:icloud上传Models
func icloundUpload(_ index:NSInteger){
let model = currentModel.dataSources[index]
var contains = false
for folderModel in SHCloudManager.shared.icloudFolderModels {
if currentModel.id == folderModel.id {
contains = true
break
}
}
if contains {
SHCloudManager.shared.addNewRecord(model) { (result, models) in
if result {
model.icloud = true
SHCloudManager.shared.modifyFolder(self.currentModel) { (result, models) in
if result {
self.updateocloudUI()
}
}
}
}
} else {
SHCloudManager.shared.addNewRecord(model) { (result, models) in
if result {
model.icloud = true
SHCloudManager.shared.addNewFolder(self.currentModel) { (result, models) in
if result {
self.updateocloudUI()
}
}
}
}
}
}
//MARK:icloud 移除 Models
func icloundRemove(_ index:NSInteger){
let model = currentModel.dataSources[index]
SHCloudManager.shared.deleteRecord(model) { (result, models) in
if result {
model.icloud = false
SHCloudManager.shared.modifyFolder(self.currentModel) { (result, models) in
if result {
self.updateocloudUI()
}
}
}
} }
} }
//MARK:删除Models //MARK:删除Models
...@@ -162,7 +247,7 @@ extension SHRecordDetailsVC { ...@@ -162,7 +247,7 @@ extension SHRecordDetailsVC {
} }
} }
var list = CRUserDefaults.recordList let list = CRUserDefaults.recordList
if var recordList = list{ if var recordList = list{
for (index, subDict) in recordList.enumerated(){ for (index, subDict) in recordList.enumerated(){
let subFolderModel:SHRecordFolderModel = getDataDictWith(dict: subDict) let subFolderModel:SHRecordFolderModel = getDataDictWith(dict: subDict)
...@@ -177,21 +262,34 @@ extension SHRecordDetailsVC { ...@@ -177,21 +262,34 @@ extension SHRecordDetailsVC {
CRUserDefaults.recordList = recordList CRUserDefaults.recordList = recordList
} }
list = keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>] for model in selectRecordModels {
if var recordList = list{ SHCloudManager.shared.deleteRecord(model) { (result, models) in
for (index, subDict) in recordList.enumerated(){ if result {
let subFolderModel:SHRecordFolderModel = getDataDictWith(dict: subDict)
if subFolderModel.id == currentModel.id {
subFolderModel.modifyDate = nowDate
subFolderModel.dataSources = currentModel.dataSources
let dic = getDictWith(obj: subFolderModel)
recordList[index] = dic
break
} }
} }
keyValueStore.set(recordList, forKey: "Folderlist")
keyValueStore.synchronize()
} }
SHCloudManager.shared.modifyFolder(self.currentModel) { (result, models) in
if result {
self.updateocloudUI()
}
}
// list = keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>]
// if var recordList = list{
// for (index, subDict) in recordList.enumerated(){
// let subFolderModel:SHRecordFolderModel = getDataDictWith(dict: subDict)
// if subFolderModel.id == currentModel.id {
// subFolderModel.modifyDate = nowDate
// subFolderModel.dataSources = currentModel.dataSources
// let dic = getDictWith(obj: subFolderModel)
// recordList[index] = dic
// break
// }
// }
// keyValueStore.set(recordList, forKey: "Folderlist")
// keyValueStore.synchronize()
// }
if currentModel.dataSources.count == 0 { if currentModel.dataSources.count == 0 {
self.navigationItem.rightBarButtonItem = UIBarButtonItem.init(title: "编辑", style: .done, target: self, action: #selector(editClick)) self.navigationItem.rightBarButtonItem = UIBarButtonItem.init(title: "编辑", style: .done, target: self, action: #selector(editClick))
...@@ -203,7 +301,7 @@ extension SHRecordDetailsVC { ...@@ -203,7 +301,7 @@ extension SHRecordDetailsVC {
bottomView?.cancel = true bottomView?.cancel = true
} }
selectRecordModels = [] selectRecordModels = []
edit = false // edit = false
tableView?.reloadData() tableView?.reloadData()
} }
//MARK:笔记弹框 //MARK:笔记弹框
...@@ -236,7 +334,8 @@ extension SHRecordDetailsVC { ...@@ -236,7 +334,8 @@ extension SHRecordDetailsVC {
record.saveSuccessCallBack = { model in record.saveSuccessCallBack = { model in
self.currentModel = model self.currentModel = model
self.tableView?.reloadData() self.updateocloudUI()
// self.tableView?.reloadData()
} }
break break
} }
...@@ -262,11 +361,19 @@ extension SHRecordDetailsVC: UITableViewDelegate, UITableViewDataSource{ ...@@ -262,11 +361,19 @@ extension SHRecordDetailsVC: UITableViewDelegate, UITableViewDataSource{
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "SHRecordDetailsCell", for: indexPath) as! SHRecordDetailsCell let cell = tableView.dequeueReusableCell(withIdentifier: "SHRecordDetailsCell", for: indexPath) as! SHRecordDetailsCell
let model = currentModel.dataSources[indexPath.row]
cell.model = currentModel.dataSources[indexPath.row] cell.model = model
cell.edit = edit cell.edit = edit
cell.selectCallBack = { selected in cell.selectCallBack = { (type, selected) in
self.selectModel(indexPath.row, selected: selected) if type == 0 {
self.selectModel(indexPath.row, selected: selected)
}else{
if model.icloud == false{
self.icloundUpload(indexPath.row)
}else{
self.icloundRemove(indexPath.row)
}
}
} }
cell.selectionStyle = .none cell.selectionStyle = .none
......
...@@ -62,6 +62,13 @@ class SHRecordListViewController: SHBaseViewController { ...@@ -62,6 +62,13 @@ class SHRecordListViewController: SHBaseViewController {
NotificationCenter.default.addObserver(self, selector: #selector(hehe), name: NSUbiquitousKeyValueStore.didChangeExternallyNotification, object: keyValueStore) NotificationCenter.default.addObserver(self, selector: #selector(hehe), name: NSUbiquitousKeyValueStore.didChangeExternallyNotification, object: keyValueStore)
let url = FileManager.default.url(forUbiquityContainerIdentifier: nil)
print(url as Any)
SHCloudManager.shared.getAllFolderDataSource { (result, sss) in
}
setupUI() setupUI()
preposeMember() preposeMember()
MobClick.event("tab_imp") MobClick.event("tab_imp")
...@@ -136,7 +143,7 @@ class SHRecordListViewController: SHBaseViewController { ...@@ -136,7 +143,7 @@ class SHRecordListViewController: SHBaseViewController {
if list == nil { if list == nil {
list = keyValueStore.object(forKey: "list") as? [Dictionary<String, Any>] list = keyValueStore.object(forKey: "list") as? [Dictionary<String, Any>]
} }
list = nil
if let list = list { if let list = list {
var folderModel = SHRecordFolderModel() var folderModel = SHRecordFolderModel()
if let sub = list.first{ if let sub = list.first{
...@@ -166,18 +173,18 @@ class SHRecordListViewController: SHBaseViewController { ...@@ -166,18 +173,18 @@ class SHRecordListViewController: SHBaseViewController {
} }
} }
let modityList = keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>] // let modityList = keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>]
if let list = modityList { // if let list = modityList {
for dict in list.reversed(){ // for dict in list.reversed(){
var model = SHRecordFolderModel() // var model = SHRecordFolderModel()
model = getDataDictWith(dict: dict) // model = getDataDictWith(dict: dict)
if model.top == true { // if model.top == true {
topDataSources.append(model) // topDataSources.append(model)
}else{ // }else{
dataSources.append(model) // dataSources.append(model)
} // }
} // }
} // }
dataSources = dataSources.filterDuplicates({$0.id}) dataSources = dataSources.filterDuplicates({$0.id})
topDataSources = topDataSources.filterDuplicates({$0.id}) topDataSources = topDataSources.filterDuplicates({$0.id})
...@@ -294,18 +301,18 @@ extension SHRecordListViewController { ...@@ -294,18 +301,18 @@ extension SHRecordListViewController {
CRUserDefaults.recordList = list CRUserDefaults.recordList = list
} }
let list = self.keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>] // let list = self.keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>]
//
if var list = list { // if var list = list {
for (index, dic) in list.enumerated(){ // for (index, dic) in list.enumerated(){
if dic["id"] as! String == deleteModel.id{ // if dic["id"] as! String == deleteModel.id{
list.remove(at: index) // list.remove(at: index)
break // break
} // }
} // }
self.keyValueStore.set(list, forKey: "Folderlist") // self.keyValueStore.set(list, forKey: "Folderlist")
self.keyValueStore.synchronize() // self.keyValueStore.synchronize()
} // }
self.dataSources.remove(at: indexPath.row) self.dataSources.remove(at: indexPath.row)
self.tableView?.beginUpdates() self.tableView?.beginUpdates()
...@@ -346,20 +353,20 @@ extension SHRecordListViewController { ...@@ -346,20 +353,20 @@ extension SHRecordListViewController {
CRUserDefaults.recordList = list CRUserDefaults.recordList = list
} }
let list = self.keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>] // let list = self.keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>]
//
if var list = list { // if var list = list {
for (index, dic) in list.enumerated(){ // for (index, dic) in list.enumerated(){
if dic["id"] as! String == selectModel.id{ // if dic["id"] as! String == selectModel.id{
var subDic = dic // var subDic = dic
subDic["name"] = renameStr // subDic["name"] = renameStr
list[index] = subDic // list[index] = subDic
break // break
} // }
} // }
self.keyValueStore.set(list, forKey: "Folderlist") // self.keyValueStore.set(list, forKey: "Folderlist")
self.keyValueStore.synchronize() // self.keyValueStore.synchronize()
} // }
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(333)) { DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(333)) {
self.prepareDateSource() self.prepareDateSource()
...@@ -385,20 +392,20 @@ extension SHRecordListViewController { ...@@ -385,20 +392,20 @@ extension SHRecordListViewController {
CRUserDefaults.recordList = list CRUserDefaults.recordList = list
} }
let list = keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>] // let list = keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>]
//
if var list = list { // if var list = list {
for (index, dic) in list.enumerated(){ // for (index, dic) in list.enumerated(){
if dic["id"] as! String == deleteModel.id{ // if dic["id"] as! String == deleteModel.id{
var subDic = dic // var subDic = dic
subDic["top"] = !deleteModel.top // subDic["top"] = !deleteModel.top
list[index] = subDic // list[index] = subDic
break // break
} // }
} // }
keyValueStore.set(list, forKey: "Folderlist") // keyValueStore.set(list, forKey: "Folderlist")
keyValueStore.synchronize() // keyValueStore.synchronize()
} // }
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(333)) { DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(333)) {
self.prepareDateSource() self.prepareDateSource()
...@@ -432,17 +439,17 @@ extension SHRecordListViewController { ...@@ -432,17 +439,17 @@ extension SHRecordListViewController {
CRUserDefaults.recordList = list CRUserDefaults.recordList = list
} }
let list = self.keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>] // let list = self.keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>]
//
if var list = list { // if var list = list {
list.append(modelDict) // list.append(modelDict)
self.keyValueStore.set(list, forKey: "Folderlist") // self.keyValueStore.set(list, forKey: "Folderlist")
self.keyValueStore.synchronize() // self.keyValueStore.synchronize()
}else{ // }else{
let list = [modelDict] // let list = [modelDict]
self.keyValueStore.set(list, forKey: "Folderlist") // self.keyValueStore.set(list, forKey: "Folderlist")
self.keyValueStore.synchronize() // self.keyValueStore.synchronize()
} // }
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(333)) { DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(333)) {
self.prepareDateSource() self.prepareDateSource()
......
...@@ -88,7 +88,8 @@ class SHRecordMoveFileVC: SHBaseViewController { ...@@ -88,7 +88,8 @@ class SHRecordMoveFileVC: SHBaseViewController {
if list == nil { if list == nil {
list = keyValueStore.object(forKey: "list") as? [Dictionary<String, Any>] list = keyValueStore.object(forKey: "list") as? [Dictionary<String, Any>]
} }
list = nil
if list != nil { if list != nil {
for dict in list!.reversed(){ for dict in list!.reversed(){
var model = SHRecordFolderModel() var model = SHRecordFolderModel()
...@@ -157,66 +158,32 @@ class SHRecordMoveFileVC: SHBaseViewController { ...@@ -157,66 +158,32 @@ class SHRecordMoveFileVC: SHBaseViewController {
CRUserDefaults.recordList = list CRUserDefaults.recordList = list
} }
let list = self.keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>] // let list = self.keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>]
//
if var list = list { // if var list = list {
list.append(modelDict) // list.append(modelDict)
self.keyValueStore.set(list, forKey: "Folderlist") // self.keyValueStore.set(list, forKey: "Folderlist")
self.keyValueStore.synchronize() // self.keyValueStore.synchronize()
}else{ // }else{
let list = [modelDict] // let list = [modelDict]
self.keyValueStore.set(list, forKey: "Folderlist") // self.keyValueStore.set(list, forKey: "Folderlist")
self.keyValueStore.synchronize() // self.keyValueStore.synchronize()
} // }
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(333)) { DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(333)) {
self.prepareDataSource() self.prepareDataSource()
} }
} }
} }
}
//MARK: tableView delegate
extension SHRecordMoveFileVC: UITableViewDelegate, UITableViewDataSource{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if self.searchBarVC.isActive {
return searchDataSource.count
}
return dataSources.count
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 44
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let identifier = "UITableViewCell"
var cell = tableView.dequeueReusableCell(withIdentifier: identifier)
if cell == nil{
cell = UITableViewCell.init(style: .default, reuseIdentifier: identifier)
}
let model: SHRecordFolderModel
if self.searchBarVC.isActive {
model = searchDataSource[indexPath.row]
}else{
model = dataSources[indexPath.row]
}
cell?.textLabel?.text = model.name
cell?.selectionStyle = .none
return cell!
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func moveFile(_ index:NSInteger) {
//TODO:转移 //TODO:转移
let targetModel: SHRecordFolderModel var targetModel: SHRecordFolderModel
if self.searchBarVC.isActive { if self.searchBarVC.isActive {
targetModel = searchDataSource[indexPath.row] targetModel = searchDataSource[index]
}else{ }else{
targetModel = dataSources[indexPath.row] targetModel = dataSources[index]
} }
let nowDate = Date() let nowDate = Date()
for model in moveFiles { for model in moveFiles {
...@@ -226,37 +193,7 @@ extension SHRecordMoveFileVC: UITableViewDelegate, UITableViewDataSource{ ...@@ -226,37 +193,7 @@ extension SHRecordMoveFileVC: UITableViewDelegate, UITableViewDataSource{
} }
} }
} }
let list = CRUserDefaults.recordList
var list = CRUserDefaults.recordList
if var recordList = list{
//增
for (index, subDict) in recordList.enumerated(){
let subFolderModel:SHRecordFolderModel = getDataDictWith(dict: subDict)
if subFolderModel.id == targetModel.id {
subFolderModel.modifyDate = nowDate
subFolderModel.dataSources = subFolderModel.dataSources+moveFiles
let dic = getDictWith(obj: subFolderModel)
recordList[index] = dic
break
}
}
//删
if var recordList = list{
for (index, subDict) in recordList.enumerated(){
let subFolderModel:SHRecordFolderModel = getDataDictWith(dict: subDict)
if subFolderModel.id == currentModel.id {
subFolderModel.modifyDate = nowDate
subFolderModel.dataSources = currentModel.dataSources
let dic = getDictWith(obj: subFolderModel)
recordList[index] = dic
break
}
}
}
CRUserDefaults.recordList = recordList
}
list = keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>]
if var recordList = list{ if var recordList = list{
//增 //增
for (index, subDict) in recordList.enumerated(){ for (index, subDict) in recordList.enumerated(){
...@@ -266,6 +203,8 @@ extension SHRecordMoveFileVC: UITableViewDelegate, UITableViewDataSource{ ...@@ -266,6 +203,8 @@ extension SHRecordMoveFileVC: UITableViewDelegate, UITableViewDataSource{
subFolderModel.dataSources = subFolderModel.dataSources+moveFiles subFolderModel.dataSources = subFolderModel.dataSources+moveFiles
let dic = getDictWith(obj: subFolderModel) let dic = getDictWith(obj: subFolderModel)
recordList[index] = dic recordList[index] = dic
targetModel = subFolderModel
break break
} }
} }
...@@ -280,11 +219,105 @@ extension SHRecordMoveFileVC: UITableViewDelegate, UITableViewDataSource{ ...@@ -280,11 +219,105 @@ extension SHRecordMoveFileVC: UITableViewDelegate, UITableViewDataSource{
break break
} }
} }
keyValueStore.set(recordList, forKey: "Folderlist")
keyValueStore.synchronize() CRUserDefaults.recordList = recordList
}
SHCloudManager.shared.modifyFolder(self.currentModel) { (result, models) in
if result {
var contains = false
for folderModel in SHCloudManager.shared.icloudFolderModels {
if targetModel.id == folderModel.id {
contains = true
break
}
}
if contains {
SHCloudManager.shared.modifyFolder(targetModel) { (result, models) in
if result {
self.saveSuccessCallBack?(self.currentModel)
DispatchQueue.main.async {
self.navigationController?.dismiss(animated: true, completion: nil)
}
}
}
} else {
SHCloudManager.shared.addNewFolder(targetModel) { (result, models) in
if result {
self.saveSuccessCallBack?(self.currentModel)
DispatchQueue.main.async {
self.navigationController?.dismiss(animated: true, completion: nil)
}
}
}
}
}
}
// list = keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>]
// if var recordList = list{
// //增
// for (index, subDict) in recordList.enumerated(){
// let subFolderModel:SHRecordFolderModel = getDataDictWith(dict: subDict)
// if subFolderModel.id == targetModel.id {
// subFolderModel.modifyDate = nowDate
// subFolderModel.dataSources = subFolderModel.dataSources+moveFiles
// let dic = getDictWith(obj: subFolderModel)
// recordList[index] = dic
// break
// }
// }
// //删
// for (index, subDict) in recordList.enumerated(){
// let subFolderModel:SHRecordFolderModel = getDataDictWith(dict: subDict)
// if subFolderModel.id == currentModel.id {
// subFolderModel.modifyDate = nowDate
// subFolderModel.dataSources = currentModel.dataSources
// let dic = getDictWith(obj: subFolderModel)
// recordList[index] = dic
// break
// }
// }
// keyValueStore.set(recordList, forKey: "Folderlist")
// keyValueStore.synchronize()
// }
}
}
//MARK: tableView delegate
extension SHRecordMoveFileVC: UITableViewDelegate, UITableViewDataSource{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if self.searchBarVC.isActive {
return searchDataSource.count
}
return dataSources.count
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 44
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let identifier = "UITableViewCell"
var cell = tableView.dequeueReusableCell(withIdentifier: identifier)
if cell == nil{
cell = UITableViewCell.init(style: .default, reuseIdentifier: identifier)
}
let model: SHRecordFolderModel
if self.searchBarVC.isActive {
model = searchDataSource[indexPath.row]
}else{
model = dataSources[indexPath.row]
} }
saveSuccessCallBack?(currentModel) cell?.textLabel?.text = model.name
self.navigationController?.dismiss(animated: true, completion: nil)
cell?.selectionStyle = .none
return cell!
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.moveFile(indexPath.row)
} }
} }
......
...@@ -542,26 +542,26 @@ class SHRecordViewController: SHBaseViewController{ ...@@ -542,26 +542,26 @@ class SHRecordViewController: SHBaseViewController{
folderModel.dataSources.append(model) folderModel.dataSources.append(model)
} }
let keyValueStore = NSUbiquitousKeyValueStore.default // let keyValueStore = NSUbiquitousKeyValueStore.default
let list = keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>] // let list = keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>]
//
if var recordList = list{ // if var recordList = list{
for (index, subDict) in recordList.enumerated(){ // for (index, subDict) in recordList.enumerated(){
let subFolderModel:SHRecordFolderModel = getDataDictWith(dict: subDict) // let subFolderModel:SHRecordFolderModel = getDataDictWith(dict: subDict)
if subFolderModel.id == folderModel.id { // if subFolderModel.id == folderModel.id {
contains = true // contains = true
subFolderModel.modifyDate = nowDate // subFolderModel.modifyDate = nowDate
subFolderModel.dataSources = folderModel.dataSources // subFolderModel.dataSources = folderModel.dataSources
let dic = getDictWith(obj: subFolderModel) // let dic = getDictWith(obj: subFolderModel)
recordList[index] = dic // recordList[index] = dic
break // break
} // }
} // }
if contains == true { // if contains == true {
keyValueStore.set(recordList, forKey: "Folderlist") // keyValueStore.set(recordList, forKey: "Folderlist")
keyValueStore.synchronize() // keyValueStore.synchronize()
} // }
} // }
currentModel = model currentModel = model
} catch { } catch {
......
...@@ -14,13 +14,14 @@ class SHRecordDetailsCell: UITableViewCell { ...@@ -14,13 +14,14 @@ class SHRecordDetailsCell: UITableViewCell {
@IBOutlet weak var intervalConstraint: NSLayoutConstraint? @IBOutlet weak var intervalConstraint: NSLayoutConstraint?
@IBOutlet weak var bgView: UIView? @IBOutlet weak var bgView: UIView?
@IBOutlet weak var selectedBtn: UIButton? @IBOutlet weak var selectedBtn: UIButton?
@IBOutlet weak var icloudBtn: UIButton?
@IBOutlet weak var titleName: UILabel? @IBOutlet weak var titleName: UILabel?
@IBOutlet weak var timeLab: UILabel? @IBOutlet weak var timeLab: UILabel?
@IBOutlet weak var txtLab: UILabel? @IBOutlet weak var txtLab: UILabel?
@IBOutlet weak var duringLab: UILabel? @IBOutlet weak var duringLab: UILabel?
var selectCallBack: ((Bool)->Void)? var selectCallBack: ((NSInteger, Bool)->Void)?
private var _model: SHRecordModel? private var _model: SHRecordModel?
var model: SHRecordModel { var model: SHRecordModel {
...@@ -32,6 +33,7 @@ class SHRecordDetailsCell: UITableViewCell { ...@@ -32,6 +33,7 @@ class SHRecordDetailsCell: UITableViewCell {
txtLab?.text = newValue.txt txtLab?.text = newValue.txt
duringLab?.text = countSecond(newValue.during) duringLab?.text = countSecond(newValue.during)
selectedBtn?.isSelected = model.selected selectedBtn?.isSelected = model.selected
icloudBtn?.isSelected = model.icloud
} }
get{ get{
return _model! return _model!
...@@ -69,11 +71,16 @@ class SHRecordDetailsCell: UITableViewCell { ...@@ -69,11 +71,16 @@ class SHRecordDetailsCell: UITableViewCell {
bgView?.layer.borderColor = UIColor.init(hexStr: "EEEEEE").cgColor bgView?.layer.borderColor = UIColor.init(hexStr: "EEEEEE").cgColor
selectedBtn?.addTarget(self, action: #selector(selectBtnClick(_:)), for: .touchUpInside) selectedBtn?.addTarget(self, action: #selector(selectBtnClick(_:)), for: .touchUpInside)
icloudBtn?.addTarget(self, action: #selector(selectBtnClick(_:)), for: .touchUpInside)
} }
@objc func selectBtnClick(_ sender:UIButton){ @objc func selectBtnClick(_ sender:UIButton){
sender.isSelected = !sender.isSelected if sender == selectedBtn {
selectCallBack?(sender.isSelected) sender.isSelected = !sender.isSelected
selectCallBack?(0, sender.isSelected)
}else{
selectCallBack?(1, sender.isSelected)
}
} }
@objc private func countSecond(_ during:NSInteger) -> String { @objc private func countSecond(_ during:NSInteger) -> 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