Commit bef972ba authored by lmj_521aiau@163.com's avatar lmj_521aiau@163.com

Merge branch 'branch_1.0.1' of gitlab.huolea.com:lmi/shorthandmaster into branch_1.0.1

parents ba635e83 3079cf96
......@@ -47,6 +47,10 @@ class SHInputController: SHBaseViewController
/// 是否是编辑
var isEdited = false
/// 是否编辑过
var didEdited = false
/// 是否有音频
var haveAudio = false
......@@ -186,6 +190,54 @@ class SHInputController: SHBaseViewController
self.shInputView.textView.attributedText = self.viewModel.getAttributedStringWithSHRecordModel(recordModel: self.dataModel)
self.initPlayer()
// 修改音频时间, 保存一次
// 获取本地数据
// 笔记本列表
var recordList = CRUserDefaults.recordList
// 当前笔记本下标
var folderIndex = 0
// 遍历笔记本列表找到当前笔记本下标
for dict in recordList!
{
var folderModel = SHRecordFolderModel()
folderModel = getDataDictWith(dict: dict)
if folderModel.id.isEqualTo(self.folderModel.id)
{
break
}
folderIndex += 1
}
// 当前笔记下标
var recordIndex = 0
// 遍历当前笔记本的笔记列表找到当前笔记下标
for recordModel in self.folderModel.dataSources
{
if recordModel.pathFile.isEqualTo(self.dataModel.pathFile)
{
break
}
recordIndex += 1
}
// 保存数据
self.folderModel.dataSources[recordIndex] = self.dataModel
// 把添加数据后的文件夹保存到数组中
recordList![folderIndex] = getDictWith(obj: self.folderModel!)
CRUserDefaults.recordList = recordList
self.saveSuccessCallBack?(self.folderModel)
}
else
{
......@@ -208,6 +260,17 @@ class SHInputController: SHBaseViewController
// MARK: 点击navigationBar左侧按钮
override func goback()
{
if !didEdited
{
self.navigationController?.popViewController(animated: true)
}
else
{
if !isEdited
{
self.didSelectedPauseAudioButton(sender: self.shInputView.bottomView.pauseAudioButton)
}
let alert = UIAlertController(title: "确认退出编辑?", message: nil, preferredStyle: .alert)
let leftAction = UIAlertAction(title: "直接退出", style: .destructive) { (action) in
......@@ -226,9 +289,18 @@ class SHInputController: SHBaseViewController
self.present(alert, animated: true, completion: nil)
}
}
// MARK: 点击navigationBar右侧按钮
@objc func didSelectedNavRightButton()
{
self.saveData()
self.navigationController?.popViewController(animated: true)
}
// MARK: 保存数据
func saveData()
{
// 获取本地数据
// 笔记本列表
......@@ -349,8 +421,6 @@ class SHInputController: SHBaseViewController
CRUserDefaults.recordList = recordList
self.saveSuccessCallBack?(self.folderModel)
self.navigationController?.popViewController(animated: true)
}
// MARK: 点击键盘按钮
......@@ -388,7 +458,7 @@ class SHInputController: SHBaseViewController
}
do {
let documentsFile = DocumentPath+self.viewModel.documentFilePath+"/\(self.dataModel.rename).pdf"
let documentsFile = DocumentPath + self.viewModel.documentFilePath + "/\(self.dataModel.rename).pdf"
try PDFGenerator.generate(self.shInputView.textView!, to: documentsFile)
//此三方会把传入控件约束移除 需重新添加
......@@ -440,12 +510,19 @@ extension SHInputController: UITextViewDelegate, SHInputTextViewDelegate
// MARK: 文字发生了变化
func textViewDidChange(_ textView: UITextView)
{
self.didEdited = true
self.shInputView.placeholder.isHidden = textView.text.length > 0
}
// MARK: 文字将要变化
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool
{
if self.hasEmoji(text: text)
{
return false
}
// 获取标题文字位置
let titleRange = NSRange(location: 0, length: self.dataModel.rename.length)
......@@ -487,6 +564,20 @@ extension SHInputController: UITextViewDelegate, SHInputTextViewDelegate
}
// MARK: 是否是emoji
func hasEmoji(text: String)->Bool {
let stringUtf8Length = text.lengthOfBytes(using: .utf8)
if stringUtf8Length >= 4 && stringUtf8Length / text.length != 3
{
return true
}
else
{
return false
}
}
// MARK: - SHInputTextView代理
// MARK: 点击删除按钮
func textViewDidDelete(textView: SHInputTextView)
......@@ -506,7 +597,9 @@ extension SHInputController: UIImagePickerControllerDelegate, UINavigationContro
{
// MARK: - 代理方法
// MARK: 选中了一张照片/拍了一张照片
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any])
{
self.didEdited = true
if (info[UIImagePickerController.InfoKey.originalImage] != nil)
{
......@@ -847,10 +940,7 @@ extension SHInputController
break
// MARK: 用户允许当前应用访问麦克风
case AVAuthorizationStatus.authorized:
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerController.SourceType.camera)
{
self.beginAddAudio()
}
break
// MARK: 用户还没有做出选择
case AVAuthorizationStatus.notDetermined:
......@@ -940,6 +1030,8 @@ extension SHInputController
// MARK: 点击结束录制按钮
@objc func didSelectedStopAudioButton(sender : SHInputAudioButton)
{
self.didEdited = true
recorder_mp3.pause()
self.timer.suspend()
......
......@@ -102,6 +102,8 @@ class SHInputViewModel: NSObject {
// 找到图片
if imageAttachment.image != nil
{
if (imageAttachment.image?.size.width)! > 0 && (imageAttachment.image?.size.height)! > 0
{
// 将图片保存在本地
......@@ -136,6 +138,7 @@ class SHInputViewModel: NSObject {
}
}
}
}
})
......
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