Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
ShorthandMaster
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lmj
ShorthandMaster
Commits
6a07d516
Commit
6a07d516
authored
Sep 28, 2020
by
lmj_521aiau@163.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'branch_1.0.1' of gitlab.huolea.com:lmi/shorthandmaster into branch_1.0.1
parents
5b87fdb9
dae5e19a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
80 deletions
+92
-80
project.pbxproj
ShorthandMaster.xcodeproj/project.pbxproj
+4
-4
SHInputController.swift
ShorthandMaster/Input/Controller/SHInputController.swift
+58
-64
SHInputAudioButton.swift
ShorthandMaster/Input/View/SHInputAudioButton.swift
+2
-2
SHInputBottomView.swift
ShorthandMaster/Input/View/SHInputBottomView.swift
+26
-8
SHInputViewModel.swift
ShorthandMaster/Input/ViewModel/SHInputViewModel.swift
+2
-2
No files found.
ShorthandMaster.xcodeproj/project.pbxproj
View file @
6a07d516
...
...
@@ -134,7 +134,7 @@
CC13DB6A251C83E600835654
/* SHInputViewModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CC13DB69251C83E600835654
/* SHInputViewModel.swift */
;
};
CC13DB6F251C972600835654
/* SHInputModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CC13DB6E251C972600835654
/* SHInputModel.swift */
;
};
CC13DB74251C9A2F00835654
/* SHInputTextView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CC13DB73251C9A2F00835654
/* SHInputTextView.swift */
;
};
CC13DB79251CA62800835654
/* SHI
mputAudioButton.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CC13DB78251CA62800835654
/* SHIm
putAudioButton.swift */
;
};
CC13DB79251CA62800835654
/* SHI
nputAudioButton.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CC13DB78251CA62800835654
/* SHIn
putAudioButton.swift */
;
};
CC29A704251C50520059BD5C
/* SHInputController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CC29A703251C50520059BD5C
/* SHInputController.swift */
;
};
CC29A709251C71AC0059BD5C
/* SHSwift.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CC29A708251C71AC0059BD5C
/* SHSwift.swift */
;
};
CC29A716251C75210059BD5C
/* SHInputView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CC29A715251C75210059BD5C
/* SHInputView.swift */
;
};
...
...
@@ -337,7 +337,7 @@
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>"
;
};
CC13DB73251C9A2F00835654
/* SHInputTextView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
SHInputTextView.swift
;
sourceTree
=
"<group>"
;
};
CC13DB78251CA62800835654
/* SHI
mputAudioButton.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
SHIm
putAudioButton.swift
;
sourceTree
=
"<group>"
;
};
CC13DB78251CA62800835654
/* SHI
nputAudioButton.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
SHIn
putAudioButton.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>"
;
};
CC29A715251C75210059BD5C
/* SHInputView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
SHInputView.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -845,7 +845,7 @@
CC29A715251C75210059BD5C
/* SHInputView.swift */
,
CC13DB73251C9A2F00835654
/* SHInputTextView.swift */
,
CC29A71A251C790D0059BD5C
/* SHInputBottomView.swift */
,
CC13DB78251CA62800835654
/* SHI
m
putAudioButton.swift */
,
CC13DB78251CA62800835654
/* SHI
n
putAudioButton.swift */
,
);
path
=
View
;
sourceTree
=
"<group>"
;
...
...
@@ -1157,7 +1157,7 @@
A950F5AA24F3727A007AB63E
/* SHRecordListCell.swift in Sources */
,
A95A76882521D70F003B4E1C
/* DDSoundWaveView.m in Sources */
,
A9A16C812519DDC400DE0FEE
/* PopContainerView.swift in Sources */
,
CC13DB79251CA62800835654
/* SHI
m
putAudioButton.swift in Sources */
,
CC13DB79251CA62800835654
/* SHI
n
putAudioButton.swift in Sources */
,
A94DD56B24FDF29700B1B5A2
/* XBAudioConverterPlayer.m in Sources */
,
A94EE11D251B7E510066B490
/* SHRecordDetailsVC.swift in Sources */
,
A9A16C6E2519DD6900DE0FEE
/* PinyinFormatter.m in Sources */
,
...
...
ShorthandMaster/Input/Controller/SHInputController.swift
View file @
6a07d516
...
...
@@ -63,66 +63,60 @@ class SHInputController: SHBaseViewController
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
)
// TODO: 先做新增, 查看和编辑稍后再做
// // 有记录显示记录
// if UserDefaults.standard.value(forKey: "InputRecord") != nil
// {
// self.shInputView.placeholder.isHidden = true
//
// let historyDic : [String : Any] = UserDefaults.standard.value(forKey: "InputRecord") as! [String : Any]
//
// let attributeString : NSMutableAttributedString = NSMutableAttributedString()
//
// let titleString = NSAttributedString(string: historyDic["title"] as! String, attributes: (SHInputViewModel.titleAttributes() as! [NSAttributedString.Key : Any]))
// attributeString.append(titleString)
//// self.viewModel.title = titleString.string
// self.dataModel.rename = titleString.string
//
// let contentString = NSAttributedString(string: historyDic["content"] as! String, attributes: SHInputViewModel.contentAttributes() as? [NSAttributedString.Key : Any])
// attributeString.append(contentString)
//
// let imageArray : Array = historyDic["imageArray"] as! Array<[String : Any]>
//
// for imageDictionary : [String : Any] in imageArray
// {
// let imageDataString : String = imageDictionary["imageData"] as! String
//
// let imageData : Data = NSData(base64Encoded: imageDataString, options: NSData.Base64DecodingOptions.ignoreUnknownCharacters)! as Data
// let image : UIImage = UIImage(data: imageData)!
//
// // 调整图片大小, 宽相同, 高随比例变化
// 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]
// }
// 默认文字样式
self
.
shInputView
.
textView
.
typingAttributes
=
SHInputViewModel
.
titleAttributes
()
as!
[
NSAttributedString
.
Key
:
Any
]
// 有记录显示记录
if
dataModel
.
rename
.
length
>
0
{
self
.
shInputView
.
placeholder
.
isHidden
=
true
let
attributeString
:
NSMutableAttributedString
=
NSMutableAttributedString
()
let
titleString
=
NSAttributedString
(
string
:
self
.
dataModel
.
rename
,
attributes
:
(
SHInputViewModel
.
titleAttributes
()
as!
[
NSAttributedString
.
Key
:
Any
]))
attributeString
.
append
(
titleString
)
let
contentString
=
NSAttributedString
(
string
:
self
.
dataModel
.
txt
,
attributes
:
SHInputViewModel
.
contentAttributes
()
as?
[
NSAttributedString
.
Key
:
Any
])
attributeString
.
append
(
contentString
)
let
imagesPath
:
Array
=
self
.
dataModel
.
imagesPath
let
imagesIndex
:
Array
=
self
.
dataModel
.
imagesIndex
var
i
=
0
for
imagePath
:
String
in
imagesPath
{
let
image
:
UIImage
=
UIImage
(
contentsOfFile
:
DocumentPath
+
imagePath
)
??
UIImage
()
// 调整图片大小, 宽相同, 高随比例变化
let
newWidth
=
kScreenWidth
-
20
*
2
let
newHeight
=
newWidth
*
image
.
size
.
height
/
image
.
size
.
width
let
newSize
=
CGSize
(
width
:
newWidth
,
height
:
newHeight
)
let
imageLocation
:
Int
=
imagesIndex
[
i
]
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
]
}
}
// MARK: 设置控件位置
...
...
@@ -590,7 +584,7 @@ extension SHInputController: UIImagePickerControllerDelegate, UINavigationContro
extension
SHInputController
{
// MARK: 点击添加录音按钮
@objc
func
didSelectedAddAudioButton
(
sender
:
SHI
m
putAudioButton
)
@objc
func
didSelectedAddAudioButton
(
sender
:
SHI
n
putAudioButton
)
{
self
.
shInputView
.
bottomView
.
addAudioButton
.
isHidden
=
true
self
.
shInputView
.
bottomView
.
pauseAudioButton
.
isHidden
=
false
...
...
@@ -610,7 +604,7 @@ extension SHInputController
}
// MARK: 点击暂停录音按钮
@objc
func
didSelectedPauseAudioButton
(
sender
:
SHI
m
putAudioButton
)
@objc
func
didSelectedPauseAudioButton
(
sender
:
SHI
n
putAudioButton
)
{
self
.
shInputView
.
bottomView
.
addAudioButton
.
isHidden
=
true
self
.
shInputView
.
bottomView
.
pauseAudioButton
.
isHidden
=
true
...
...
@@ -627,7 +621,7 @@ extension SHInputController
}
// MARK: 点击继续录音按钮
@objc
func
didSelectedGoOnAudioButton
(
sender
:
SHI
m
putAudioButton
)
@objc
func
didSelectedGoOnAudioButton
(
sender
:
SHI
n
putAudioButton
)
{
self
.
shInputView
.
bottomView
.
addAudioButton
.
isHidden
=
true
self
.
shInputView
.
bottomView
.
pauseAudioButton
.
isHidden
=
false
...
...
@@ -644,7 +638,7 @@ extension SHInputController
}
// MARK: 点击结束录制按钮
@objc
func
didSelectedStopAudioButton
(
sender
:
SHI
m
putAudioButton
)
@objc
func
didSelectedStopAudioButton
(
sender
:
SHI
n
putAudioButton
)
{
self
.
shInputView
.
bottomView
.
addAudioButton
.
isHidden
=
false
self
.
shInputView
.
bottomView
.
pauseAudioButton
.
isHidden
=
true
...
...
ShorthandMaster/Input/View/SHI
m
putAudioButton.swift
→
ShorthandMaster/Input/View/SHI
n
putAudioButton.swift
View file @
6a07d516
//
// SHI
m
putAudioButton.swift
// SHI
n
putAudioButton.swift
// ShorthandMaster
//
// Created by 张哲 on 2020/9/24.
...
...
@@ -8,7 +8,7 @@
import
UIKit
class
SHI
m
putAudioButton
:
UIButton
{
class
SHI
n
putAudioButton
:
UIButton
{
// MARK: - property
/// 背景
...
...
ShorthandMaster/Input/View/SHInputBottomView.swift
View file @
6a07d516
...
...
@@ -16,17 +16,26 @@ class SHInputBottomView: UIView {
/// 选择图片按钮
var
imageButton
:
UIButton
!
/// 录音按钮背景
var
audioBgView
:
UIView
!
/// 录制时间背景
var
audioTimeBgView
:
UIView
!
/// 录制时间小红点
var
audioTimePointView
:
UIView
!
/// 录制时间
var
audioTimeLabel
:
UIView
!
/// 添加录音按钮
var
addAudioButton
:
SHI
m
putAudioButton
!
var
addAudioButton
:
SHI
n
putAudioButton
!
/// 暂停录音按钮
var
pauseAudioButton
:
SHI
m
putAudioButton
!
var
pauseAudioButton
:
SHI
n
putAudioButton
!
/// 继续录音按钮
var
goOnAudioButton
:
SHI
m
putAudioButton
!
var
goOnAudioButton
:
SHI
n
putAudioButton
!
/// 结束录音按钮
var
stopAudioButton
:
SHImputAudioButton
!
var
stopAudioButton
:
SHInputAudioButton
!
/// 键盘按钮
var
keyboardButton
:
UIButton
!
...
...
@@ -68,8 +77,17 @@ class SHInputBottomView: UIView {
self
.
audioBgView
=
UIView
()
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
=
SHI
m
putAudioButton
(
type
:
UIButton
.
ButtonType
.
custom
)
self
.
addAudioButton
=
SHI
n
putAudioButton
(
type
:
UIButton
.
ButtonType
.
custom
)
self
.
addAudioButton
.
layer
.
cornerRadius
=
15
self
.
addAudioButton
.
backgroundColor
=
UIColor
(
r
:
250
,
g
:
219
,
b
:
219
)
self
.
addAudioButton
.
leftImageView
.
image
=
UIImage
(
named
:
"input_addAudio"
)
...
...
@@ -78,7 +96,7 @@ class SHInputBottomView: UIView {
self
.
audioBgView
.
addSubview
(
self
.
addAudioButton
)
// 暂停录音按钮
self
.
pauseAudioButton
=
SHI
m
putAudioButton
(
type
:
UIButton
.
ButtonType
.
custom
)
self
.
pauseAudioButton
=
SHI
n
putAudioButton
(
type
:
UIButton
.
ButtonType
.
custom
)
self
.
pauseAudioButton
.
layer
.
cornerRadius
=
15
self
.
pauseAudioButton
.
backgroundColor
=
UIColor
(
r
:
219
,
g
:
231
,
b
:
250
)
self
.
pauseAudioButton
.
leftImageView
.
image
=
UIImage
(
named
:
"input_pause"
)
...
...
@@ -88,7 +106,7 @@ class SHInputBottomView: UIView {
self
.
pauseAudioButton
.
isHidden
=
true
// 继续录音按钮
self
.
goOnAudioButton
=
SHI
m
putAudioButton
(
type
:
UIButton
.
ButtonType
.
custom
)
self
.
goOnAudioButton
=
SHI
n
putAudioButton
(
type
:
UIButton
.
ButtonType
.
custom
)
self
.
goOnAudioButton
.
layer
.
cornerRadius
=
15
self
.
goOnAudioButton
.
backgroundColor
=
UIColor
(
r
:
250
,
g
:
234
,
b
:
219
)
self
.
goOnAudioButton
.
leftImageView
.
image
=
UIImage
(
named
:
"input_goOn"
)
...
...
@@ -98,7 +116,7 @@ class SHInputBottomView: UIView {
self
.
goOnAudioButton
.
isHidden
=
true
// 结束录音按钮
self
.
stopAudioButton
=
SHI
m
putAudioButton
(
type
:
UIButton
.
ButtonType
.
custom
)
self
.
stopAudioButton
=
SHI
n
putAudioButton
(
type
:
UIButton
.
ButtonType
.
custom
)
self
.
stopAudioButton
.
layer
.
cornerRadius
=
15
self
.
stopAudioButton
.
backgroundColor
=
UIColor
(
r
:
250
,
g
:
219
,
b
:
219
)
self
.
stopAudioButton
.
leftImageView
.
image
=
UIImage
(
named
:
"input_stop"
)
...
...
ShorthandMaster/Input/ViewModel/SHInputViewModel.swift
View file @
6a07d516
...
...
@@ -96,9 +96,9 @@ class SHInputViewModel: NSObject {
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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment