Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
galaxy-iOS
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile-group
galaxy-iOS
Commits
74fe5f06
Commit
74fe5f06
authored
Dec 17, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// AI
parent
8f1d6f19
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
3 deletions
+78
-3
YHAutoTextView.swift
galaxy/galaxy/Classes/Base/V/YHAutoTextView.swift
+41
-3
YHAITextInputView.swift
...es/Modules/AI/AI-Dialogue(AI对话)/V/YHAITextInputView.swift
+37
-0
No files found.
galaxy/galaxy/Classes/Base/V/YHAutoTextView.swift
View file @
74fe5f06
...
...
@@ -10,6 +10,40 @@ import UIKit
class
YHAutoTextView
:
UITextView
,
UITextViewDelegate
{
private
var
calculateHeight
:
CGFloat
=
0.0
var
isShowKeyboard
:
Bool
=
false
{
didSet
{
if
!
isShowKeyboard
{
self
.
snp
.
updateConstraints
{
make
in
make
.
top
.
equalTo
(
5
)
make
.
height
.
equalTo
(
36
)
make
.
bottom
.
equalTo
(
-
5
)
}
}
else
{
var
realHeight
=
self
.
calculateHeight
if
self
.
calculateHeight
>
maxHeight
{
height
=
maxHeight
self
.
snp
.
updateConstraints
{
make
in
make
.
top
.
equalTo
(
11
)
make
.
height
.
equalTo
(
realHeight
)
make
.
bottom
.
equalTo
(
-
11
)
}
}
else
{
self
.
snp
.
updateConstraints
{
make
in
make
.
top
.
equalTo
(
11
-
Self
.
verticalGap
)
make
.
height
.
equalTo
(
realHeight
)
make
.
bottom
.
equalTo
(
-
(
11
-
Self
.
verticalGap
))
}
}
}
self
.
setNeedsLayout
()
self
.
layoutIfNeeded
()
}
}
var
textChange
:((
String
)
->
())?
override
open
var
text
:
String
!
{
...
...
@@ -28,25 +62,27 @@ class YHAutoTextView: UITextView, UITextViewDelegate {
}
}
l
et
placeholderLabel
:
UILabel
=
{
l
azy
var
placeholderLabel
:
UILabel
=
{
let
label
=
UILabel
()
label
.
translatesAutoresizingMaskIntoConstraints
=
false
label
.
textColor
=
UIColor
.
init
(
hex
:
0xB3C8E9
)
label
.
font
=
UIFont
.
PFSC_R
(
ofSize
:
14
)
return
label
}()
override
init
(
frame
:
CGRect
,
textContainer
:
NSTextContainer
?)
{
super
.
init
(
frame
:
frame
,
textContainer
:
textContainer
)
self
.
font
=
.
PFSC_R
(
ofSize
:
14
)
delegate
=
self
isScrollEnabled
=
false
// 禁止滚动
self
.
addSubview
(
placeholderLabel
)
placeholderLabel
.
snp
.
makeConstraints
{
make
in
make
.
center
.
equalToSuperview
()
make
.
left
.
equalTo
(
5
)
make
.
right
.
equalTo
(
-
5
)
}
}
required
init
?(
coder
:
NSCoder
)
{
...
...
@@ -72,8 +108,10 @@ class YHAutoTextView: UITextView, UITextViewDelegate {
let
size
=
sizeThatFits
(
CGSize
(
width
:
frame
.
width
,
height
:
.
greatestFiniteMagnitude
))
var
height
=
size
.
height
self
.
calculateHeight
=
height
isScrollEnabled
=
height
>
maxHeight
if
height
>
maxHeight
{
height
=
maxHeight
self
.
snp
.
updateConstraints
{
make
in
...
...
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/V/YHAITextInputView.swift
View file @
74fe5f06
...
...
@@ -93,6 +93,8 @@ class YHAITextInputView: UIView {
textView
.
text
=
""
textView
.
isScrollEnabled
=
false
self
.
endEditing
(
true
)
textLabel
.
isHidden
=
true
textView
.
isHidden
=
false
}
@objc
func
didStopSendBtnClicked
()
{
...
...
@@ -103,10 +105,12 @@ class YHAITextInputView: UIView {
let
v
=
YHAutoTextView
()
v
.
backgroundColor
=
.
clear
v
.
font
=
.
PFSC_R
(
ofSize
:
14
)
v
.
textColor
=
.
mainTextColor
v
.
placeHolder
=
"有什么问题尽管问我"
v
.
textChange
=
{
[
weak
self
]
text
in
guard
let
self
=
self
else
{
return
}
self
.
textLabel
.
text
=
text
if
status
!=
.
loading
{
status
=
text
.
count
>
0
?
.
enableSend
:
.
disableSend
}
...
...
@@ -114,6 +118,22 @@ class YHAITextInputView: UIView {
return
v
}()
lazy
var
textLabel
:
UILabel
=
{
let
label
=
UILabel
()
label
.
translatesAutoresizingMaskIntoConstraints
=
false
label
.
textColor
=
.
mainTextColor
label
.
font
=
.
PFSC_R
(
ofSize
:
14
)
label
.
isHidden
=
true
label
.
isUserInteractionEnabled
=
true
let
tap
=
UITapGestureRecognizer
(
target
:
self
,
action
:
#selector(
tapText
)
)
label
.
addGestureRecognizer
(
tap
)
return
label
}()
@objc
func
tapText
()
{
textView
.
becomeFirstResponder
()
}
required
init
?(
coder
:
NSCoder
)
{
fatalError
(
"init(coder:) has not been implemented"
)
}
...
...
@@ -154,6 +174,7 @@ class YHAITextInputView: UIView {
contentView
.
addSubview
(
sendBtn
)
contentView
.
addSubview
(
loadingImgView
)
contentView
.
addSubview
(
textView
)
contentView
.
addSubview
(
textLabel
)
status
=
.
disableSend
whiteView
.
snp
.
makeConstraints
{
make
in
...
...
@@ -189,6 +210,12 @@ class YHAITextInputView: UIView {
make
.
bottom
.
equalTo
(
-
(
11
-
YHAutoTextView
.
verticalGap
))
make
.
right
.
equalTo
(
sendBtn
.
snp
.
left
)
.
offset
(
-
5
)
}
textLabel
.
snp
.
makeConstraints
{
make
in
make
.
center
.
equalToSuperview
()
make
.
left
.
equalTo
(
textView
)
.
offset
(
5
)
make
.
right
.
equalTo
(
textView
)
.
offset
(
-
5
)
}
addKeyBoardNotify
()
}
...
...
@@ -203,7 +230,17 @@ class YHAITextInputView: UIView {
let
isKeyboardShow
=
notification
.
name
==
UIResponder
.
keyboardWillShowNotification
let
bottomMargin
=
(
isKeyboardShow
?
-
keyboardFrame
.
height
:
0
)
if
isKeyboardShow
{
textLabel
.
isHidden
=
true
textView
.
isHidden
=
false
}
else
{
textLabel
.
isHidden
=
textView
.
text
.
isEmpty
textView
.
isHidden
=
!
textView
.
text
.
isEmpty
}
textLabel
.
text
=
textView
.
text
textView
.
isShowKeyboard
=
isKeyboardShow
contentView
.
snp
.
updateConstraints
{
make
in
make
.
bottom
.
equalTo
(
-
10
-
(
isKeyboardShow
?
0.0
:
k_Height_safeAreaInsetsBottom
()))
}
...
...
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