Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
zhangyongji
/
MRFramework
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c65bd2ec
authored
Sep 12, 2019
by
Sarkizz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
相册添加自定义设置
parent
4626d40f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
23 deletions
+66
-23
MRFramework/MRFramework/UIControls/Album/Interface/MRAlbumCell.swift
+36
-6
MRFramework/MRFramework/UIControls/Album/Interface/MRCheckBoxImage.swift
+19
-15
MRFramework/MRFramework/UIControls/Album/MRAlbumListViewController.swift
+4
-0
MRFramework/MRFramework/UIControls/PhotoPicker/SAPhotoPicker.swift
+7
-2
No files found.
MRFramework/MRFramework/UIControls/Album/Interface/MRAlbumCell.swift
View file @
c65bd2ec
...
@@ -9,15 +9,30 @@
...
@@ -9,15 +9,30 @@
import
UIKit
import
UIKit
import
SnapKit
import
SnapKit
private
let
checkboxSize
=
CGSize
(
width
:
30
,
height
:
30
)
private
let
checkboxEmptyImage
=
MRCheckBoxImage
.
image
(
with
:
MRCheckBoxOptions
.
defaultEmpty
(
checkboxSize
))
private
let
checkboxCheckImage
=
MRCheckBoxImage
.
image
(
with
:
MRCheckBoxOptions
.
defaultCheck
(
checkboxSize
))
public
final
class
MRAlbumCell
:
UICollectionViewCell
{
public
final
class
MRAlbumCell
:
UICollectionViewCell
{
static
let
defaultCheckboxSize
=
CGSize
(
width
:
30
,
height
:
30
)
public
let
imageView
=
UIImageView
()
public
let
imageView
=
UIImageView
()
public
let
selectedMask
=
UIView
()
public
let
selectedMask
=
UIView
()
public
let
checkbox
=
UIButton
()
public
let
checkbox
=
UIButton
()
public
var
checkboxSize
=
MRAlbumCell
.
defaultCheckboxSize
{
didSet
{
resetCheckboxOptions
()
}
}
public
var
deselectedCheckboxOptions
:
MRCheckBoxOptions
?
{
didSet
{
resetCheckboxInterface
()
}
}
public
var
selectedCheckboxOptions
:
MRCheckBoxOptions
=
.
defaultCheck
(
MRAlbumCell
.
defaultCheckboxSize
)
{
didSet
{
resetCheckboxInterface
()
}
}
public
var
check
:
((
_
cell
:
MRAlbumCell
)
->
Void
)?
public
var
check
:
((
_
cell
:
MRAlbumCell
)
->
Void
)?
public
override
init
(
frame
:
CGRect
)
{
public
override
init
(
frame
:
CGRect
)
{
...
@@ -53,8 +68,7 @@ extension MRAlbumCell {
...
@@ -53,8 +68,7 @@ extension MRAlbumCell {
selectedMask
.
isUserInteractionEnabled
=
false
selectedMask
.
isUserInteractionEnabled
=
false
selectedMask
.
isHidden
=
true
selectedMask
.
isHidden
=
true
checkbox
.
setImage
(
nil
,
for
:
.
normal
)
resetCheckboxInterface
()
checkbox
.
setImage
(
checkboxCheckImage
,
for
:
.
selected
)
checkbox
.
addTarget
(
self
,
action
:
#selector(
checkButtonPressed(_:)
)
,
for
:
.
touchUpInside
)
checkbox
.
addTarget
(
self
,
action
:
#selector(
checkButtonPressed(_:)
)
,
for
:
.
touchUpInside
)
contentView
.
addSubview
(
imageView
)
contentView
.
addSubview
(
imageView
)
...
@@ -62,6 +76,22 @@ extension MRAlbumCell {
...
@@ -62,6 +76,22 @@ extension MRAlbumCell {
contentView
.
addSubview
(
checkbox
)
contentView
.
addSubview
(
checkbox
)
}
}
private
func
resetCheckboxInterface
()
{
if
let
options
=
deselectedCheckboxOptions
{
checkbox
.
setImage
(
MRCheckBoxImage
.
image
(
with
:
options
),
for
:
.
normal
)
}
checkbox
.
setImage
(
MRCheckBoxImage
.
image
(
with
:
selectedCheckboxOptions
),
for
:
.
selected
)
}
private
func
resetCheckboxOptions
()
{
deselectedCheckboxOptions
?
.
size
=
checkboxSize
selectedCheckboxOptions
.
size
=
checkboxSize
checkbox
.
snp
.
updateConstraints
{
(
make
)
in
make
.
size
.
equalTo
(
checkboxSize
)
}
}
private
func
layoutViews
()
{
private
func
layoutViews
()
{
imageView
.
snp
.
makeConstraints
{
(
make
)
in
imageView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
edges
.
equalToSuperview
()
make
.
edges
.
equalToSuperview
()
...
...
MRFramework/MRFramework/UIControls/Album/Interface/MRCheckBoxImage.swift
View file @
c65bd2ec
...
@@ -18,24 +18,28 @@ public struct MRCheckBoxOptions {
...
@@ -18,24 +18,28 @@ public struct MRCheckBoxOptions {
var
curveLineColor
:
UIColor
var
curveLineColor
:
UIColor
var
backgroundColor
:
UIColor
var
backgroundColor
:
UIColor
static
func
defaultEmpty
(
_
size
:
CGSize
)
->
MRCheckBoxOptions
{
public
static
func
defaultEmpty
(
_
size
:
CGSize
)
->
MRCheckBoxOptions
{
return
.
init
(
size
:
size
,
return
custom
(
size
:
size
,
type
:
.
empty
,
backgroundColor
:
.
clear
)
type
:
.
empty
,
}
checkLineWidth
:
3
,
curveLineWidth
:
2
,
public
static
func
defaultCheck
(
_
size
:
CGSize
)
->
MRCheckBoxOptions
{
checkLineColor
:
.
white
,
return
custom
(
size
:
size
)
curveLineColor
:
.
white
,
backgroundColor
:
.
clear
)
}
}
static
func
defaultCheck
(
_
size
:
CGSize
)
->
MRCheckBoxOptions
{
public
static
func
custom
(
size
:
CGSize
,
type
:
MRCheckBoxType
=
.
check
,
checkLineWidth
:
CGFloat
=
3
,
curveLineWidth
:
CGFloat
=
2
,
checkLineColor
:
UIColor
=
.
white
,
curveLineColor
:
UIColor
=
.
white
,
backgroundColor
:
UIColor
=
.
green
)
->
MRCheckBoxOptions
{
return
.
init
(
size
:
size
,
return
.
init
(
size
:
size
,
type
:
.
check
,
type
:
type
,
checkLineWidth
:
3
,
checkLineWidth
:
checkLineWidth
,
curveLineWidth
:
2
,
curveLineWidth
:
curveLineWidth
,
checkLineColor
:
.
white
,
checkLineColor
:
checkLineColor
,
curveLineColor
:
.
white
,
curveLineColor
:
curveLineColor
,
backgroundColor
:
.
green
)
backgroundColor
:
backgroundColor
)
}
}
}
}
...
...
MRFramework/MRFramework/UIControls/Album/MRAlbumListViewController.swift
View file @
c65bd2ec
...
@@ -17,6 +17,7 @@ public enum MRAlbumListStatus {
...
@@ -17,6 +17,7 @@ public enum MRAlbumListStatus {
case
finish
case
finish
}
}
public
typealias
MRAlbumCustomCellSetting
=
(
_
cell
:
MRAlbumCell
)
->
Void
public
typealias
MRAlbumDidSelect
=
(
_
vc
:
MRAlbumListViewController
,
_
assests
:
[
PHAsset
])
->
Void
public
typealias
MRAlbumDidSelect
=
(
_
vc
:
MRAlbumListViewController
,
_
assests
:
[
PHAsset
])
->
Void
open
class
MRAlbumListViewController
:
UIViewController
{
open
class
MRAlbumListViewController
:
UIViewController
{
...
@@ -45,6 +46,8 @@ open class MRAlbumListViewController: UIViewController {
...
@@ -45,6 +46,8 @@ open class MRAlbumListViewController: UIViewController {
statusDidChange
()
statusDidChange
()
}
}
}
}
public
var
customCellSetting
:
MRAlbumCustomCellSetting
?
public
var
assests
:
PHFetchResult
<
PHAsset
>
?
public
var
assests
:
PHFetchResult
<
PHAsset
>
?
public
var
selectedAssests
=
[
PHAsset
]()
public
var
selectedAssests
=
[
PHAsset
]()
...
@@ -94,6 +97,7 @@ open class MRAlbumListViewController: UIViewController {
...
@@ -94,6 +97,7 @@ open class MRAlbumListViewController: UIViewController {
open
func
cellSetting
(
_
cell
:
UICollectionViewCell
,
at
indexPath
:
IndexPath
)
{
open
func
cellSetting
(
_
cell
:
UICollectionViewCell
,
at
indexPath
:
IndexPath
)
{
if
let
cell
=
cell
as?
MRAlbumCell
,
let
assest
=
assests
?[
indexPath
.
row
]
{
if
let
cell
=
cell
as?
MRAlbumCell
,
let
assest
=
assests
?[
indexPath
.
row
]
{
customCellSetting
?(
cell
)
requestImage
(
with
:
assest
,
size
:
thumbImageSize
*
UIScreen
.
main
.
scale
)
{
image
,
info
in
requestImage
(
with
:
assest
,
size
:
thumbImageSize
*
UIScreen
.
main
.
scale
)
{
image
,
info
in
cell
.
setImage
(
image
)
cell
.
setImage
(
image
)
}
}
...
...
MRFramework/MRFramework/UIControls/PhotoPicker/SAPhotoPicker.swift
View file @
c65bd2ec
...
@@ -18,6 +18,7 @@ public enum SAPhotoPickerType {
...
@@ -18,6 +18,7 @@ public enum SAPhotoPickerType {
}
}
public
typealias
SAPhotoPickerComplateBlock
=
(
_
images
:
[
UIImage
]?,
_
imageURLs
:
[
URL
]?,
_
error
:
Error
?)
->
Void
public
typealias
SAPhotoPickerComplateBlock
=
(
_
images
:
[
UIImage
]?,
_
imageURLs
:
[
URL
]?,
_
error
:
Error
?)
->
Void
public
typealias
SAPhotoPickerMutableSelectionAlbumSetting
=
(
_
picker
:
SAPhotoPicker
,
_
vc
:
SAMutableSelectionAlbum
)
->
Void
extension
SAPhotoPicker
{
extension
SAPhotoPicker
{
//config keys
//config keys
...
@@ -40,7 +41,7 @@ extension SAPhotoPicker.ConfigKey {
...
@@ -40,7 +41,7 @@ extension SAPhotoPicker.ConfigKey {
public
class
SAPhotoPicker
:
NSObject
{
public
class
SAPhotoPicker
:
NSObject
{
public
static
let
shared
=
SAPhotoPicker
()
public
static
let
shared
=
SAPhotoPicker
()
var
config
:
[
SAPhotoPicker
.
ConfigKey
:
Any
]
=
[
public
var
config
:
[
SAPhotoPicker
.
ConfigKey
:
Any
]
=
[
.
cameraTitle
:
"拍照"
,
.
cameraTitle
:
"拍照"
,
.
libraryTitle
:
"相册"
,
.
libraryTitle
:
"相册"
,
.
albumTitle
:
"相册"
,
.
albumTitle
:
"相册"
,
...
@@ -48,6 +49,8 @@ public class SAPhotoPicker: NSObject {
...
@@ -48,6 +49,8 @@ public class SAPhotoPicker: NSObject {
.
editable
:
false
.
editable
:
false
]
]
public
var
mutableSelectionAlbumSetting
:
SAPhotoPickerMutableSelectionAlbumSetting
?
private
var
imageMaxSize
:
CGSize
?
private
var
imageMaxSize
:
CGSize
?
private
var
complateBlock
:
SAPhotoPickerComplateBlock
?
private
var
complateBlock
:
SAPhotoPickerComplateBlock
?
...
@@ -112,7 +115,9 @@ extension SAPhotoPicker {
...
@@ -112,7 +115,9 @@ extension SAPhotoPicker {
self
.
complateBlock
?(
nil
,
nil
,
nil
)
self
.
complateBlock
?(
nil
,
nil
,
nil
)
vc
.
dismiss
(
animated
:
true
)
vc
.
dismiss
(
animated
:
true
)
}
}
UIApplication
.
shared
.
keyWindow
?
.
rootViewController
?
.
present
(
vc
,
animated
:
true
,
completion
:
nil
)
mutableSelectionAlbumSetting
?(
self
,
vc
)
let
nav
=
UINavigationController
(
rootViewController
:
vc
)
UIApplication
.
shared
.
keyWindow
?
.
rootViewController
?
.
present
(
nav
,
animated
:
true
,
completion
:
nil
)
}
}
private
func
navTitle
(
with
sourceType
:
UIImagePickerController
.
SourceType
)
->
String
?
{
private
func
navTitle
(
with
sourceType
:
UIImagePickerController
.
SourceType
)
->
String
?
{
...
...
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