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
bc466b51
Commit
bc466b51
authored
Jan 02, 2024
by
David黄金龙
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into davidhuang
parents
f1b24311
8ec0b5d9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
41 deletions
+87
-41
project.pbxproj
galaxy/galaxy.xcodeproj/project.pbxproj
+4
-4
YHSmsCodeInputView.swift
...alaxy/Modules/Login(登录)/V/验证码输入框/YHSmsCodeInputView.swift
+51
-13
YHSmsCodeView.swift
galaxy/galaxy/Modules/Login(登录)/V/验证码输入框/YHSmsCodeView.swift
+24
-23
YHMyViewController.swift
galaxy/galaxy/Modules/Mine(我的)/C/YHMyViewController.swift
+8
-1
No files found.
galaxy/galaxy.xcodeproj/project.pbxproj
View file @
bc466b51
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
04F526C72B3BB94200FC6CE6
/* YHSMSCodeInputView.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04F526C32B3BB94200FC6CE6
/* YHSMSCodeInputView.m */
;
};
04F526C72B3BB94200FC6CE6
/* YHSMSCodeInputView.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04F526C32B3BB94200FC6CE6
/* YHSMSCodeInputView.m */
;
};
04F526C82B3BB94200FC6CE6
/* YHSMSCodeView.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04F526C42B3BB94200FC6CE6
/* YHSMSCodeView.m */
;
};
04F526C82B3BB94200FC6CE6
/* YHSMSCodeView.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04F526C42B3BB94200FC6CE6
/* YHSMSCodeView.m */
;
};
04F526CA2B3E92E200FC6CE6
/* Algorithm.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04F526C92B3E92E200FC6CE6
/* Algorithm.swift */
;
};
04F526CA2B3E92E200FC6CE6
/* Algorithm.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04F526C92B3E92E200FC6CE6
/* Algorithm.swift */
;
};
04F526CC2B3E962400FC6CE6
/* Y
NSmsCodeView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04F526CB2B3E962400FC6CE6
/* YN
SmsCodeView.swift */
;
};
04F526CC2B3E962400FC6CE6
/* Y
HSmsCodeView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04F526CB2B3E962400FC6CE6
/* YH
SmsCodeView.swift */
;
};
04F526CE2B3EA80300FC6CE6
/* YHSmsCodeInputView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04F526CD2B3EA80300FC6CE6
/* YHSmsCodeInputView.swift */
;
};
04F526CE2B3EA80300FC6CE6
/* YHSmsCodeInputView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04F526CD2B3EA80300FC6CE6
/* YHSmsCodeInputView.swift */
;
};
04F526D02B3ECAE700FC6CE6
/* YHValidateCodeInputView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04F526CF2B3ECAE700FC6CE6
/* YHValidateCodeInputView.swift */
;
};
04F526D02B3ECAE700FC6CE6
/* YHValidateCodeInputView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04F526CF2B3ECAE700FC6CE6
/* YHValidateCodeInputView.swift */
;
};
04F526E52B3ECC6F00FC6CE6
/* UIApplication+Extension.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04F526D82B3ECC6F00FC6CE6
/* UIApplication+Extension.swift */
;
};
04F526E52B3ECC6F00FC6CE6
/* UIApplication+Extension.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04F526D82B3ECC6F00FC6CE6
/* UIApplication+Extension.swift */
;
};
...
@@ -91,7 +91,7 @@
...
@@ -91,7 +91,7 @@
04F526C52B3BB94200FC6CE6
/* YHSMSCodeInputView.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
YHSMSCodeInputView.h
;
sourceTree
=
"<group>"
;
};
04F526C52B3BB94200FC6CE6
/* YHSMSCodeInputView.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
YHSMSCodeInputView.h
;
sourceTree
=
"<group>"
;
};
04F526C62B3BB94200FC6CE6
/* YHSMSCodeView.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
YHSMSCodeView.h
;
sourceTree
=
"<group>"
;
};
04F526C62B3BB94200FC6CE6
/* YHSMSCodeView.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
YHSMSCodeView.h
;
sourceTree
=
"<group>"
;
};
04F526C92B3E92E200FC6CE6
/* Algorithm.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Algorithm.swift
;
sourceTree
=
"<group>"
;
};
04F526C92B3E92E200FC6CE6
/* Algorithm.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Algorithm.swift
;
sourceTree
=
"<group>"
;
};
04F526CB2B3E962400FC6CE6
/* Y
NSmsCodeView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YN
SmsCodeView.swift
;
sourceTree
=
"<group>"
;
};
04F526CB2B3E962400FC6CE6
/* Y
HSmsCodeView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YH
SmsCodeView.swift
;
sourceTree
=
"<group>"
;
};
04F526CD2B3EA80300FC6CE6
/* YHSmsCodeInputView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHSmsCodeInputView.swift
;
sourceTree
=
"<group>"
;
};
04F526CD2B3EA80300FC6CE6
/* YHSmsCodeInputView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHSmsCodeInputView.swift
;
sourceTree
=
"<group>"
;
};
04F526CF2B3ECAE700FC6CE6
/* YHValidateCodeInputView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHValidateCodeInputView.swift
;
sourceTree
=
"<group>"
;
};
04F526CF2B3ECAE700FC6CE6
/* YHValidateCodeInputView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHValidateCodeInputView.swift
;
sourceTree
=
"<group>"
;
};
04F526D82B3ECC6F00FC6CE6
/* UIApplication+Extension.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"UIApplication+Extension.swift"
;
sourceTree
=
"<group>"
;
};
04F526D82B3ECC6F00FC6CE6
/* UIApplication+Extension.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"UIApplication+Extension.swift"
;
sourceTree
=
"<group>"
;
};
...
@@ -202,7 +202,7 @@
...
@@ -202,7 +202,7 @@
04F526C42B3BB94200FC6CE6
/* YHSMSCodeView.m */
,
04F526C42B3BB94200FC6CE6
/* YHSMSCodeView.m */
,
04F526C52B3BB94200FC6CE6
/* YHSMSCodeInputView.h */
,
04F526C52B3BB94200FC6CE6
/* YHSMSCodeInputView.h */
,
04F526C62B3BB94200FC6CE6
/* YHSMSCodeView.h */
,
04F526C62B3BB94200FC6CE6
/* YHSMSCodeView.h */
,
04F526CB2B3E962400FC6CE6
/* Y
N
SmsCodeView.swift */
,
04F526CB2B3E962400FC6CE6
/* Y
H
SmsCodeView.swift */
,
04F526CD2B3EA80300FC6CE6
/* YHSmsCodeInputView.swift */
,
04F526CD2B3EA80300FC6CE6
/* YHSmsCodeInputView.swift */
,
);
);
path
=
"验证码输入框"
;
path
=
"验证码输入框"
;
...
@@ -713,7 +713,7 @@
...
@@ -713,7 +713,7 @@
A52DF24D2B33177F006618D6
/* BsHUDWariningView.swift in Sources */
,
A52DF24D2B33177F006618D6
/* BsHUDWariningView.swift in Sources */
,
A52DF0C32B330A20006618D6
/* YhCacheTool.swift in Sources */
,
A52DF0C32B330A20006618D6
/* YhCacheTool.swift in Sources */
,
A52DF24A2B33177F006618D6
/* BsHUDContainerView.swift in Sources */
,
A52DF24A2B33177F006618D6
/* BsHUDContainerView.swift in Sources */
,
04F526CC2B3E962400FC6CE6
/* Y
N
SmsCodeView.swift in Sources */
,
04F526CC2B3E962400FC6CE6
/* Y
H
SmsCodeView.swift in Sources */
,
04F526ED2B3ECC6F00FC6CE6
/* String+Extension.swift in Sources */
,
04F526ED2B3ECC6F00FC6CE6
/* String+Extension.swift in Sources */
,
A52DF0BD2B330A20006618D6
/* YHBaseUrlManager.swift in Sources */
,
A52DF0BD2B330A20006618D6
/* YHBaseUrlManager.swift in Sources */
,
A5009DD82B3D72FD00168BB1
/* NetBaseModel.swift in Sources */
,
A5009DD82B3D72FD00168BB1
/* NetBaseModel.swift in Sources */
,
...
...
galaxy/galaxy/Modules/Login(登录)/V/验证码输入框/YHSmsCodeInputView.swift
View file @
bc466b51
...
@@ -15,9 +15,9 @@ struct YHSmsCodeViewConfig {
...
@@ -15,9 +15,9 @@ struct YHSmsCodeViewConfig {
var
cursorColor
:
UIColor
?
=
.
black
var
cursorColor
:
UIColor
?
=
.
black
var
font
:
UIFont
?
=
.
systemFont
(
ofSize
:
20
)
var
font
:
UIFont
?
=
.
systemFont
(
ofSize
:
20
)
// 展示输入框个数
// 展示输入框个数
var
count
:
Int
=
3
var
count
:
Int
=
6
var
width
:
Double
=
6
0.0
var
width
:
Double
=
4
0.0
var
height
:
Double
=
6
0.0
var
height
:
Double
=
5
0.0
// 输入框之间间距
// 输入框之间间距
var
gap
:
Double
=
8
var
gap
:
Double
=
8
}
}
...
@@ -26,15 +26,15 @@ let codeViewBaseTag = 9527
...
@@ -26,15 +26,15 @@ let codeViewBaseTag = 9527
class
YHSmsCodeInputView
:
UIView
{
class
YHSmsCodeInputView
:
UIView
{
var
smsCode
:
String
?
var
complete
:
((
String
)
->
Void
)
?
var
config
:
YHSmsCodeViewConfig
=
YHSmsCodeViewConfig
()
var
config
:
YHSmsCodeViewConfig
=
YHSmsCodeViewConfig
()
// 此输入框并不显示,只是接收输入
// 此输入框并不显示,只是接收输入
lazy
var
textField
:
UITextField
=
{
lazy
var
textField
:
UITextField
=
{
let
textField
=
UITextField
()
let
textField
=
UITextField
()
textField
.
backgroundColor
=
.
clear
textField
.
backgroundColor
=
.
clear
textField
.
tintColor
=
.
clear
textField
.
tintColor
=
.
clear
textField
.
textColor
=
.
clear
textField
.
delegate
=
self
textField
.
delegate
=
self
textField
.
addTarget
(
self
,
action
:
#selector(
smsCodeInputChanged
)
,
for
:
.
editingChanged
)
textField
.
addTarget
(
self
,
action
:
#selector(
smsCodeInputChanged
)
,
for
:
.
editingChanged
)
return
textField
return
textField
...
@@ -62,6 +62,7 @@ class YHSmsCodeInputView: UIView {
...
@@ -62,6 +62,7 @@ class YHSmsCodeInputView: UIView {
textField
.
snp
.
makeConstraints
{
make
in
textField
.
snp
.
makeConstraints
{
make
in
make
.
edges
.
equalTo
(
self
)
make
.
edges
.
equalTo
(
self
)
}
}
textField
.
becomeFirstResponder
()
// 输入框数量
// 输入框数量
let
count
=
config
.
count
let
count
=
config
.
count
...
@@ -75,10 +76,20 @@ class YHSmsCodeInputView: UIView {
...
@@ -75,10 +76,20 @@ class YHSmsCodeInputView: UIView {
let
isEven
=
(
config
.
count
%
2
==
0
)
let
isEven
=
(
config
.
count
%
2
==
0
)
for
index
in
1
...
count
{
for
index
in
1
...
count
{
let
inputView
=
YNSmsCodeView
(
frame
:
CGRectZero
)
let
inputView
=
YHSmsCodeView
(
frame
:
CGRectZero
)
inputView
.
backgroundColor
=
config
.
bgColor
inputView
.
label
.
font
=
config
.
font
inputView
.
label
.
textColor
=
config
.
textColor
inputView
.
cursor
.
backgroundColor
=
config
.
cursorColor
if
(
index
==
1
)
{
inputView
.
showCursor
=
true
}
inputView
.
tag
=
codeViewBaseTag
+
index
inputView
.
tag
=
codeViewBaseTag
+
index
self
.
addSubview
(
inputView
)
self
.
addSubview
(
inputView
)
// 此处布局为轴对称布局
// 小组件右边距离父视图中轴线间距
// 小组件右边距离父视图中轴线间距
var
rightMargin
=
0.0
;
var
rightMargin
=
0.0
;
if
(
isEven
)
{
// 输入框个数为偶数
if
(
isEven
)
{
// 输入框个数为偶数
...
@@ -118,19 +129,33 @@ class YHSmsCodeInputView: UIView {
...
@@ -118,19 +129,33 @@ class YHSmsCodeInputView: UIView {
@objc
func
smsCodeInputChanged
(
input
:
UITextField
)
{
@objc
func
smsCodeInputChanged
(
input
:
UITextField
)
{
if
input
.
text
==
nil
{
return
}
guard
let
text
=
input
.
text
else
{
let
codeView
=
self
.
viewWithTag
(
codeViewBaseTag
+
1
)
as?
YHSmsCodeView
codeView
?
.
showCursor
=
true
return
}
if
(
text
.
count
>
config
.
count
)
{
return
}
for
index
in
0
..<
config
.
count
{
let
codeView
=
self
.
viewWithTag
(
codeViewBaseTag
+
index
+
1
)
as!
YHSmsCodeView
codeView
.
text
=
(
index
<
text
.
count
?
String
(
text
[
index
])
:
""
)
codeView
.
showCursor
=
(
index
==
text
.
count
)
}
for
(
index
,
char
)
in
input
.
text
!.
enumerated
()
{
for
(
index
,
char
)
in
input
.
text
!.
enumerated
()
{
if
(
index
<
config
.
count
)
{
if
(
index
<
config
.
count
)
{
var
codeView
=
self
.
viewWithTag
(
codeViewBaseTag
+
index
+
1
)
as?
YN
SmsCodeView
let
codeView
=
self
.
viewWithTag
(
codeViewBaseTag
+
index
+
1
)
as?
YH
SmsCodeView
codeView
?
.
text
=
String
(
char
)
codeView
?
.
text
=
String
(
char
)
}
}
}
}
for
index
in
(
0
..<
config
.
count
)
{
if
(
text
.
count
==
config
.
count
)
{
// if index < input.text?.count {
textField
.
resignFirstResponder
()
if
let
complete
=
self
.
complete
{
// }
complete
(
text
)
}
}
}
}
}
}
}
...
@@ -139,6 +164,19 @@ extension YHSmsCodeInputView: UITextFieldDelegate {
...
@@ -139,6 +164,19 @@ extension YHSmsCodeInputView: UITextFieldDelegate {
func
textField
(
_
textField
:
UITextField
,
shouldChangeCharactersIn
range
:
NSRange
,
replacementString
string
:
String
)
->
Bool
{
func
textField
(
_
textField
:
UITextField
,
shouldChangeCharactersIn
range
:
NSRange
,
replacementString
string
:
String
)
->
Bool
{
return
true
guard
let
text
=
textField
.
text
else
{
return
true
}
if
(
string
.
count
<=
0
)
{
// 删除字符操作
return
true
}
if
!
string
.
isDigits
{
// 必须是数字
return
false
}
// 限制字数
let
textLength
=
text
.
charactersArray
.
count
+
string
.
charactersArray
.
count
-
range
.
length
return
textLength
<=
config
.
count
}
}
}
}
galaxy/galaxy/Modules/Login(登录)/V/验证码输入框/Y
N
SmsCodeView.swift
→
galaxy/galaxy/Modules/Login(登录)/V/验证码输入框/Y
H
SmsCodeView.swift
View file @
bc466b51
...
@@ -7,27 +7,17 @@
...
@@ -7,27 +7,17 @@
import
UIKit
import
UIKit
class
Y
N
SmsCodeView
:
UIView
{
class
Y
H
SmsCodeView
:
UIView
{
// 是否显示光标
// 是否显示光标
var
showCursor
:
Bool
=
false
{
var
showCursor
:
Bool
=
false
{
didSet
{
didSet
{
if
(
showCursor
)
{
if
showCursor
{
UIView
.
animate
(
withDuration
:
0.5
,
animations
:
{
self
.
cursor
.
layer
.
removeAllAnimations
()
[
weak
self
]
in
self
.
animaitonShow
(
true
)
self
?
.
cursor
.
isHidden
=
false
},
completion
:
{
[
weak
self
]
finishd
in
UIView
.
animate
(
withDuration
:
0.5
,
animations
:
{
self
?
.
cursor
.
isHidden
=
true
})
})
}
else
{
}
else
{
cursor
.
layer
.
removeAllAnimations
()
self
.
cursor
.
layer
.
removeAllAnimations
()
cursor
.
isHidden
=
true
self
.
cursor
.
isHidden
=
true
}
}
}
}
}
}
...
@@ -47,10 +37,10 @@ class YNSmsCodeView: UIView {
...
@@ -47,10 +37,10 @@ class YNSmsCodeView: UIView {
var
cursor
:
UIView
=
{
var
cursor
:
UIView
=
{
let
cursor
=
UIView
()
let
cursor
=
UIView
()
cursor
.
backgroundColor
=
.
black
cursor
.
backgroundColor
=
.
black
cursor
.
alpha
=
0
cursor
.
isHidden
=
true
return
cursor
return
cursor
}()
}()
required
init
?(
coder
:
NSCoder
)
{
required
init
?(
coder
:
NSCoder
)
{
super
.
init
(
coder
:
coder
)
super
.
init
(
coder
:
coder
)
}
}
...
@@ -70,13 +60,24 @@ class YNSmsCodeView: UIView {
...
@@ -70,13 +60,24 @@ class YNSmsCodeView: UIView {
self
.
addSubview
(
cursor
)
self
.
addSubview
(
cursor
)
}
}
@objc
func
animaitonShow
(
_
show
:
Bool
)
{
override
func
layoutSubviews
()
{
// let x = (self.frame.size.width - self.label.frame.size.width) / 2.0;
if
!
self
.
showCursor
{
return
}
// let y = (self.frame.size.height - self.label.frame.size.height) / 2.0;
self
.
label
.
frame
=
self
.
bounds
UIView
.
animate
(
withDuration
:
0.8
,
animations
:
{
self
.
cursor
.
isHidden
=
!
show
},
completion
:
{
(
finishd
)
in
if
self
.
showCursor
{
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
0.8
)
{
self
.
animaitonShow
(
!
show
)
}
}
})
}
override
func
layoutSubviews
()
{
self
.
label
.
frame
=
self
.
bounds
self
.
cursor
.
bounds
=
CGRectMake
(
0
,
0
,
1.5
,
self
.
frame
.
size
.
height
-
20
);
self
.
cursor
.
bounds
=
CGRectMake
(
0
,
0
,
1.5
,
self
.
frame
.
size
.
height
-
20
);
self
.
cursor
.
center
=
CGPoint
(
x
:
CGRectGetMidX
(
self
.
bounds
)
,
y
:
CGRectGetMidY
(
self
.
bounds
))
self
.
cursor
.
center
=
CGPoint
(
x
:
CGRectGetMidX
(
self
.
bounds
)
,
y
:
CGRectGetMidY
(
self
.
bounds
))
}
}
...
...
galaxy/galaxy/Modules/Mine(我的)/C/YHMyViewController.swift
View file @
bc466b51
...
@@ -26,7 +26,14 @@ class YHMyViewController: YHBaseViewController, ConstraintRelatableTarget {
...
@@ -26,7 +26,14 @@ class YHMyViewController: YHBaseViewController, ConstraintRelatableTarget {
}()
}()
lazy
var
smsInputView
:
YHSmsCodeInputView
=
{
lazy
var
smsInputView
:
YHSmsCodeInputView
=
{
let
codeView
=
YHSmsCodeInputView
(
config
:
YHSmsCodeViewConfig
())
var
config
=
YHSmsCodeViewConfig
()
let
codeView
=
YHSmsCodeInputView
(
config
:
config
)
codeView
.
complete
=
{
(
text
)
in
print
(
text
)
}
return
codeView
return
codeView
}()
}()
...
...
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