Commit 6a07d516 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 5b87fdb9 dae5e19a
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
CC13DB6A251C83E600835654 /* SHInputViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC13DB69251C83E600835654 /* SHInputViewModel.swift */; }; CC13DB6A251C83E600835654 /* SHInputViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC13DB69251C83E600835654 /* SHInputViewModel.swift */; };
CC13DB6F251C972600835654 /* SHInputModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC13DB6E251C972600835654 /* SHInputModel.swift */; }; CC13DB6F251C972600835654 /* SHInputModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC13DB6E251C972600835654 /* SHInputModel.swift */; };
CC13DB74251C9A2F00835654 /* SHInputTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC13DB73251C9A2F00835654 /* SHInputTextView.swift */; }; CC13DB74251C9A2F00835654 /* SHInputTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC13DB73251C9A2F00835654 /* SHInputTextView.swift */; };
CC13DB79251CA62800835654 /* SHImputAudioButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC13DB78251CA62800835654 /* SHImputAudioButton.swift */; }; CC13DB79251CA62800835654 /* SHInputAudioButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC13DB78251CA62800835654 /* SHInputAudioButton.swift */; };
CC29A704251C50520059BD5C /* SHInputController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC29A703251C50520059BD5C /* SHInputController.swift */; }; CC29A704251C50520059BD5C /* SHInputController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC29A703251C50520059BD5C /* SHInputController.swift */; };
CC29A709251C71AC0059BD5C /* SHSwift.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC29A708251C71AC0059BD5C /* SHSwift.swift */; }; CC29A709251C71AC0059BD5C /* SHSwift.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC29A708251C71AC0059BD5C /* SHSwift.swift */; };
CC29A716251C75210059BD5C /* SHInputView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC29A715251C75210059BD5C /* SHInputView.swift */; }; CC29A716251C75210059BD5C /* SHInputView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC29A715251C75210059BD5C /* SHInputView.swift */; };
...@@ -337,7 +337,7 @@ ...@@ -337,7 +337,7 @@
CC13DB69251C83E600835654 /* SHInputViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHInputViewModel.swift; sourceTree = "<group>"; }; CC13DB69251C83E600835654 /* SHInputViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHInputViewModel.swift; sourceTree = "<group>"; };
CC13DB6E251C972600835654 /* SHInputModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHInputModel.swift; sourceTree = "<group>"; }; CC13DB6E251C972600835654 /* SHInputModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHInputModel.swift; sourceTree = "<group>"; };
CC13DB73251C9A2F00835654 /* SHInputTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHInputTextView.swift; sourceTree = "<group>"; }; CC13DB73251C9A2F00835654 /* SHInputTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHInputTextView.swift; sourceTree = "<group>"; };
CC13DB78251CA62800835654 /* SHImputAudioButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHImputAudioButton.swift; sourceTree = "<group>"; }; CC13DB78251CA62800835654 /* SHInputAudioButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHInputAudioButton.swift; sourceTree = "<group>"; };
CC29A703251C50520059BD5C /* SHInputController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHInputController.swift; sourceTree = "<group>"; }; CC29A703251C50520059BD5C /* SHInputController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHInputController.swift; sourceTree = "<group>"; };
CC29A708251C71AC0059BD5C /* SHSwift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHSwift.swift; sourceTree = "<group>"; }; CC29A708251C71AC0059BD5C /* SHSwift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHSwift.swift; sourceTree = "<group>"; };
CC29A715251C75210059BD5C /* SHInputView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHInputView.swift; sourceTree = "<group>"; }; CC29A715251C75210059BD5C /* SHInputView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHInputView.swift; sourceTree = "<group>"; };
...@@ -845,7 +845,7 @@ ...@@ -845,7 +845,7 @@
CC29A715251C75210059BD5C /* SHInputView.swift */, CC29A715251C75210059BD5C /* SHInputView.swift */,
CC13DB73251C9A2F00835654 /* SHInputTextView.swift */, CC13DB73251C9A2F00835654 /* SHInputTextView.swift */,
CC29A71A251C790D0059BD5C /* SHInputBottomView.swift */, CC29A71A251C790D0059BD5C /* SHInputBottomView.swift */,
CC13DB78251CA62800835654 /* SHImputAudioButton.swift */, CC13DB78251CA62800835654 /* SHInputAudioButton.swift */,
); );
path = View; path = View;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -1157,7 +1157,7 @@ ...@@ -1157,7 +1157,7 @@
A950F5AA24F3727A007AB63E /* SHRecordListCell.swift in Sources */, A950F5AA24F3727A007AB63E /* SHRecordListCell.swift in Sources */,
A95A76882521D70F003B4E1C /* DDSoundWaveView.m in Sources */, A95A76882521D70F003B4E1C /* DDSoundWaveView.m in Sources */,
A9A16C812519DDC400DE0FEE /* PopContainerView.swift in Sources */, A9A16C812519DDC400DE0FEE /* PopContainerView.swift in Sources */,
CC13DB79251CA62800835654 /* SHImputAudioButton.swift in Sources */, CC13DB79251CA62800835654 /* SHInputAudioButton.swift in Sources */,
A94DD56B24FDF29700B1B5A2 /* XBAudioConverterPlayer.m in Sources */, A94DD56B24FDF29700B1B5A2 /* XBAudioConverterPlayer.m in Sources */,
A94EE11D251B7E510066B490 /* SHRecordDetailsVC.swift in Sources */, A94EE11D251B7E510066B490 /* SHRecordDetailsVC.swift in Sources */,
A9A16C6E2519DD6900DE0FEE /* PinyinFormatter.m in Sources */, A9A16C6E2519DD6900DE0FEE /* PinyinFormatter.m in Sources */,
......
...@@ -63,67 +63,61 @@ class SHInputController: SHBaseViewController ...@@ -63,67 +63,61 @@ class SHInputController: SHBaseViewController
self.shInputView.bottomView.stopAudioButton.addTarget(self, action: #selector(didSelectedStopAudioButton(sender:)), for: UIControl.Event.touchUpInside) self.shInputView.bottomView.stopAudioButton.addTarget(self, action: #selector(didSelectedStopAudioButton(sender:)), for: UIControl.Event.touchUpInside)
self.shInputView.bottomView.keyboardButton.addTarget(self, action: #selector(didSelectedKeyboardButton(sender:)), for: UIControl.Event.touchUpInside) self.shInputView.bottomView.keyboardButton.addTarget(self, action: #selector(didSelectedKeyboardButton(sender:)), for: UIControl.Event.touchUpInside)
// TODO: 先做新增, 查看和编辑稍后再做 // 有记录显示记录
// // 有记录显示记录 if dataModel.rename.length > 0
// if UserDefaults.standard.value(forKey: "InputRecord") != nil {
// { self.shInputView.placeholder.isHidden = true
// self.shInputView.placeholder.isHidden = true
// let attributeString : NSMutableAttributedString = NSMutableAttributedString()
// let historyDic : [String : Any] = UserDefaults.standard.value(forKey: "InputRecord") as! [String : Any]
// let titleString = NSAttributedString(string: self.dataModel.rename, attributes: (SHInputViewModel.titleAttributes() as! [NSAttributedString.Key : Any]))
// let attributeString : NSMutableAttributedString = NSMutableAttributedString() attributeString.append(titleString)
//
// let titleString = NSAttributedString(string: historyDic["title"] as! String, attributes: (SHInputViewModel.titleAttributes() as! [NSAttributedString.Key : Any])) let contentString = NSAttributedString(string: self.dataModel.txt, attributes: SHInputViewModel.contentAttributes() as? [NSAttributedString.Key : Any])
// attributeString.append(titleString) attributeString.append(contentString)
//// self.viewModel.title = titleString.string
// self.dataModel.rename = titleString.string let imagesPath : Array = self.dataModel.imagesPath
// let imagesIndex : Array = self.dataModel.imagesIndex
// let contentString = NSAttributedString(string: historyDic["content"] as! String, attributes: SHInputViewModel.contentAttributes() as? [NSAttributedString.Key : Any])
// attributeString.append(contentString) var i = 0
//
// let imageArray : Array = historyDic["imageArray"] as! Array<[String : Any]> for imagePath : String in imagesPath
// {
// for imageDictionary : [String : Any] in imageArray let image : UIImage = UIImage(contentsOfFile: DocumentPath + imagePath) ?? UIImage()
// {
// let imageDataString : String = imageDictionary["imageData"] as! String // 调整图片大小, 宽相同, 高随比例变化
// let newWidth = kScreenWidth - 20 * 2
// let imageData : Data = NSData(base64Encoded: imageDataString, options: NSData.Base64DecodingOptions.ignoreUnknownCharacters)! as Data let newHeight = newWidth * image.size.height / image.size.width
// let image : UIImage = UIImage(data: imageData)! let newSize = CGSize(width: newWidth, height: newHeight)
//
// // 调整图片大小, 宽相同, 高随比例变化 let imageLocation : Int = imagesIndex[i]
// let newWidth = kScreenWidth - 20 * 2
// let newHeight = newWidth * image.size.height / image.size.width
// let newSize = CGSize(width: newWidth, height: newHeight)
//
// let imageLocation : Int = imageDictionary["imageLocation"] as! Int
//
//
// let attachment = NSTextAttachment.init()
// attachment.image = image
// attachment.bounds = CGRect(origin: CGPoint.zero, size: newSize)
// let imageString = NSMutableAttributedString(attachment: attachment)
//
// // 设置图片文字属性
// imageString.addAttributes((SHInputViewModel.contentAttributes() as? [NSAttributedString.Key : Any])!, range: NSRange(location: 0, length: imageString.length))
// // 设置图片间距
// let paragraphStyle = NSMutableParagraphStyle()
// paragraphStyle.lineSpacing = 18
// imageString.addAttribute(NSAttributedString.Key.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: imageString.length))
//
// attributeString.insert(imageString, at: imageLocation)
// }
//
// self.shInputView.textView.attributedText = attributeString
// }
// else
// {
// // 默认文字样式
// self.shInputView.textView.typingAttributes = SHInputViewModel.titleAttributes() as! [NSAttributedString.Key : Any]
// }
let attachment = NSTextAttachment.init()
attachment.image = image
attachment.bounds = CGRect(origin: CGPoint.zero, size: newSize)
let imageString = NSMutableAttributedString(attachment: attachment)
// 设置图片文字属性
imageString.addAttributes((SHInputViewModel.contentAttributes() as? [NSAttributedString.Key : Any])!, range: NSRange(location: 0, length: imageString.length))
// 设置图片间距
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 18
imageString.addAttribute(NSAttributedString.Key.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: imageString.length))
attributeString.insert(imageString, at: imageLocation)
i += 1
}
self.shInputView.textView.attributedText = attributeString
}
else
{
// 默认文字样式 // 默认文字样式
self.shInputView.textView.typingAttributes = SHInputViewModel.titleAttributes() as! [NSAttributedString.Key : Any] self.shInputView.textView.typingAttributes = SHInputViewModel.titleAttributes() as! [NSAttributedString.Key : Any]
} }
}
// MARK: 设置控件位置 // MARK: 设置控件位置
func setUpSubviewsLocation() func setUpSubviewsLocation()
...@@ -590,7 +584,7 @@ extension SHInputController: UIImagePickerControllerDelegate, UINavigationContro ...@@ -590,7 +584,7 @@ extension SHInputController: UIImagePickerControllerDelegate, UINavigationContro
extension SHInputController extension SHInputController
{ {
// MARK: 点击添加录音按钮 // MARK: 点击添加录音按钮
@objc func didSelectedAddAudioButton(sender : SHImputAudioButton) @objc func didSelectedAddAudioButton(sender : SHInputAudioButton)
{ {
self.shInputView.bottomView.addAudioButton.isHidden = true self.shInputView.bottomView.addAudioButton.isHidden = true
self.shInputView.bottomView.pauseAudioButton.isHidden = false self.shInputView.bottomView.pauseAudioButton.isHidden = false
...@@ -610,7 +604,7 @@ extension SHInputController ...@@ -610,7 +604,7 @@ extension SHInputController
} }
// MARK: 点击暂停录音按钮 // MARK: 点击暂停录音按钮
@objc func didSelectedPauseAudioButton(sender : SHImputAudioButton) @objc func didSelectedPauseAudioButton(sender : SHInputAudioButton)
{ {
self.shInputView.bottomView.addAudioButton.isHidden = true self.shInputView.bottomView.addAudioButton.isHidden = true
self.shInputView.bottomView.pauseAudioButton.isHidden = true self.shInputView.bottomView.pauseAudioButton.isHidden = true
...@@ -627,7 +621,7 @@ extension SHInputController ...@@ -627,7 +621,7 @@ extension SHInputController
} }
// MARK: 点击继续录音按钮 // MARK: 点击继续录音按钮
@objc func didSelectedGoOnAudioButton(sender : SHImputAudioButton) @objc func didSelectedGoOnAudioButton(sender : SHInputAudioButton)
{ {
self.shInputView.bottomView.addAudioButton.isHidden = true self.shInputView.bottomView.addAudioButton.isHidden = true
self.shInputView.bottomView.pauseAudioButton.isHidden = false self.shInputView.bottomView.pauseAudioButton.isHidden = false
...@@ -644,7 +638,7 @@ extension SHInputController ...@@ -644,7 +638,7 @@ extension SHInputController
} }
// MARK: 点击结束录制按钮 // MARK: 点击结束录制按钮
@objc func didSelectedStopAudioButton(sender : SHImputAudioButton) @objc func didSelectedStopAudioButton(sender : SHInputAudioButton)
{ {
self.shInputView.bottomView.addAudioButton.isHidden = false self.shInputView.bottomView.addAudioButton.isHidden = false
self.shInputView.bottomView.pauseAudioButton.isHidden = true self.shInputView.bottomView.pauseAudioButton.isHidden = true
......
// //
// SHImputAudioButton.swift // SHInputAudioButton.swift
// ShorthandMaster // ShorthandMaster
// //
// Created by 张哲 on 2020/9/24. // Created by 张哲 on 2020/9/24.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import UIKit import UIKit
class SHImputAudioButton: UIButton { class SHInputAudioButton: UIButton {
// MARK: - property // MARK: - property
/// 背景 /// 背景
......
...@@ -16,17 +16,26 @@ class SHInputBottomView: UIView { ...@@ -16,17 +16,26 @@ class SHInputBottomView: UIView {
/// 选择图片按钮 /// 选择图片按钮
var imageButton : UIButton! var imageButton : UIButton!
/// 录音按钮背景 /// 录音按钮背景
var audioBgView : UIView! var audioBgView : UIView!
/// 录制时间背景
var audioTimeBgView : UIView!
/// 录制时间小红点
var audioTimePointView : UIView!
/// 录制时间
var audioTimeLabel : UIView!
/// 添加录音按钮 /// 添加录音按钮
var addAudioButton : SHImputAudioButton! var addAudioButton : SHInputAudioButton!
/// 暂停录音按钮 /// 暂停录音按钮
var pauseAudioButton : SHImputAudioButton! var pauseAudioButton : SHInputAudioButton!
/// 继续录音按钮 /// 继续录音按钮
var goOnAudioButton : SHImputAudioButton! var goOnAudioButton : SHInputAudioButton!
/// 结束录音按钮 /// 结束录音按钮
var stopAudioButton : SHImputAudioButton! var stopAudioButton : SHInputAudioButton!
/// 键盘按钮 /// 键盘按钮
var keyboardButton : UIButton! var keyboardButton : UIButton!
...@@ -68,8 +77,17 @@ class SHInputBottomView: UIView { ...@@ -68,8 +77,17 @@ class SHInputBottomView: UIView {
self.audioBgView = UIView() self.audioBgView = UIView()
self.bgView.addSubview(self.audioBgView) self.bgView.addSubview(self.audioBgView)
// 录制时间背景
self.audioTimeBgView = UIView()
self.audioTimeBgView.backgroundColor = UIColor(r: 241, g: 241, b: 241)
self.audioTimeBgView.layer.masksToBounds = true
self.bgView.addSubview(self.audioTimeBgView)
// 录制时间小红点
// 录制时间
// 添加录音按钮 // 添加录音按钮
self.addAudioButton = SHImputAudioButton(type: UIButton.ButtonType.custom) self.addAudioButton = SHInputAudioButton(type: UIButton.ButtonType.custom)
self.addAudioButton.layer.cornerRadius = 15 self.addAudioButton.layer.cornerRadius = 15
self.addAudioButton.backgroundColor = UIColor(r: 250, g: 219, b: 219) self.addAudioButton.backgroundColor = UIColor(r: 250, g: 219, b: 219)
self.addAudioButton.leftImageView.image = UIImage(named: "input_addAudio") self.addAudioButton.leftImageView.image = UIImage(named: "input_addAudio")
...@@ -78,7 +96,7 @@ class SHInputBottomView: UIView { ...@@ -78,7 +96,7 @@ class SHInputBottomView: UIView {
self.audioBgView.addSubview(self.addAudioButton) self.audioBgView.addSubview(self.addAudioButton)
// 暂停录音按钮 // 暂停录音按钮
self.pauseAudioButton = SHImputAudioButton(type: UIButton.ButtonType.custom) self.pauseAudioButton = SHInputAudioButton(type: UIButton.ButtonType.custom)
self.pauseAudioButton.layer.cornerRadius = 15 self.pauseAudioButton.layer.cornerRadius = 15
self.pauseAudioButton.backgroundColor = UIColor(r: 219, g: 231, b: 250) self.pauseAudioButton.backgroundColor = UIColor(r: 219, g: 231, b: 250)
self.pauseAudioButton.leftImageView.image = UIImage(named: "input_pause") self.pauseAudioButton.leftImageView.image = UIImage(named: "input_pause")
...@@ -88,7 +106,7 @@ class SHInputBottomView: UIView { ...@@ -88,7 +106,7 @@ class SHInputBottomView: UIView {
self.pauseAudioButton.isHidden = true self.pauseAudioButton.isHidden = true
// 继续录音按钮 // 继续录音按钮
self.goOnAudioButton = SHImputAudioButton(type: UIButton.ButtonType.custom) self.goOnAudioButton = SHInputAudioButton(type: UIButton.ButtonType.custom)
self.goOnAudioButton.layer.cornerRadius = 15 self.goOnAudioButton.layer.cornerRadius = 15
self.goOnAudioButton.backgroundColor = UIColor(r: 250, g: 234, b: 219) self.goOnAudioButton.backgroundColor = UIColor(r: 250, g: 234, b: 219)
self.goOnAudioButton.leftImageView.image = UIImage(named: "input_goOn") self.goOnAudioButton.leftImageView.image = UIImage(named: "input_goOn")
...@@ -98,7 +116,7 @@ class SHInputBottomView: UIView { ...@@ -98,7 +116,7 @@ class SHInputBottomView: UIView {
self.goOnAudioButton.isHidden = true self.goOnAudioButton.isHidden = true
// 结束录音按钮 // 结束录音按钮
self.stopAudioButton = SHImputAudioButton(type: UIButton.ButtonType.custom) self.stopAudioButton = SHInputAudioButton(type: UIButton.ButtonType.custom)
self.stopAudioButton.layer.cornerRadius = 15 self.stopAudioButton.layer.cornerRadius = 15
self.stopAudioButton.backgroundColor = UIColor(r: 250, g: 219, b: 219) self.stopAudioButton.backgroundColor = UIColor(r: 250, g: 219, b: 219)
self.stopAudioButton.leftImageView.image = UIImage(named: "input_stop") self.stopAudioButton.leftImageView.image = UIImage(named: "input_stop")
......
...@@ -96,9 +96,9 @@ class SHInputViewModel: NSObject { ...@@ -96,9 +96,9 @@ class SHInputViewModel: NSObject {
let imageData : Data = (imageAttachment.image?.jpegData(compressionQuality: 1.0))! let imageData : Data = (imageAttachment.image?.jpegData(compressionQuality: 1.0))!
// 保存的本地路径 // 保存的本地路径
let imagePath = filePath + "/" + "image.jpeg" + imagesPathArray.count.string let imagePath = "/" + subFile + time + "/" + "image.jpeg" + imagesPathArray.count.string
let imageUrl : URL = URL(fileURLWithPath: imagePath) let imageUrl : URL = URL(fileURLWithPath: DocumentPath + imagePath)
var saveSucceed : Bool = Bool(true) var saveSucceed : Bool = Bool(true)
......
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