Skip to content

Commit

Permalink
add UI Style and make AlbumManager public
Browse files Browse the repository at this point in the history
  • Loading branch information
gaoyuexit committed Sep 13, 2017
1 parent 356e601 commit b8ba7a1
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion LPAlbum/Controllers/LPAlbum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//
// Created by 郜宇 on 2017/9/8.
// Copyright © 2017年 Loopeer. All rights reserved.
//
// TODO: 1. add CompleteSelectAssetsBlock

import UIKit
import Photos
Expand Down
6 changes: 3 additions & 3 deletions LPAlbum/Controllers/LPNavigationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import UIKit
class LPNavigationController: UINavigationController {

override var preferredStatusBarStyle: UIStatusBarStyle {
return LPAlbum.Config.statusBarStyle
return LPAlbum.Style.statusBarStyle
}

override func viewDidLoad() {
Expand All @@ -22,8 +22,8 @@ class LPNavigationController: UINavigationController {

override init(rootViewController: UIViewController) {
super.init(rootViewController: rootViewController)
self.navigationBar.barTintColor = LPAlbum.Config.barTintColor
self.navigationBar.tintColor = LPAlbum.Config.tintColor
self.navigationBar.barTintColor = LPAlbum.Style.barTintColor
self.navigationBar.tintColor = LPAlbum.Style.tintColor
}

override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
Expand Down
6 changes: 3 additions & 3 deletions LPAlbum/Others/AlbumManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import Foundation
import Photos

class AlbumManager {
public class AlbumManager {

static let imageManager = PHCachingImageManager()

class func getAlbums() -> [AlbumModel] {
public class func getAlbums() -> [AlbumModel] {
//获取智能相册
let smartAlbums = PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .albumRegular, options: nil)
//获取用户创建的相册
Expand All @@ -25,7 +25,7 @@ class AlbumManager {
}

// 根据Asset获取photo
class func getPhoto(asset: PHAsset, targetSize: CGSize, option: PHImageRequestOptions? = nil, resultHandler: @escaping ((UIImage?, [AnyHashable: Any]?) -> Void)) {
public class func getPhoto(asset: PHAsset, targetSize: CGSize, option: PHImageRequestOptions? = nil, resultHandler: @escaping ((UIImage?, [AnyHashable: Any]?) -> Void)) {

let defalutOption = PHImageRequestOptions()
defalutOption.resizeMode = .fast
Expand Down
7 changes: 5 additions & 2 deletions LPAlbum/Others/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,25 @@ import Foundation

public extension LPAlbum {
public struct Config {

public var maxSelectCount: Int = 6
public var columnCount: Int = 4
public var photoPadding: CGFloat = 2.0
public var hasCamera: Bool = true
public var isSingleSelect: Bool = false
}

public struct Style {

public static var barTitleColor: UIColor = UIColor.white
public static var barTintColor: UIColor = UIColor.darkGray
public static var tintColor: UIColor = UIColor.white
public static var statusBarStyle: UIStatusBarStyle = .lightContent

public static var arrowImage: UIImage = Bundle.imageFromBundle("meun_down")!
public static var normalBox: UIImage = Bundle.imageFromBundle("circle_normal")!
public static var selectedBox: UIImage = Bundle.imageFromBundle("circle_selected")!
}

}


4 changes: 2 additions & 2 deletions LPAlbum/Others/Models.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import Foundation
import Photos

struct AssetModel {
public struct AssetModel {
var asset: PHAsset
var isSelect: Bool
}

struct AlbumModel {
public struct AlbumModel {
var name: String
var cover: PHAsset
var count: Int
Expand Down
4 changes: 2 additions & 2 deletions LPAlbum/Views/AlbumCollectionCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class AlbumCollectionCell: UICollectionViewCell {
let iconWH = 20.adapt

iconButton.frame = CGRect(x: frame.width - padding - iconWH, y: padding, width: iconWH, height: iconWH)
iconButton.setBackgroundImage(LPAlbum.Config.normalBox , for: .normal)
iconButton.setBackgroundImage(LPAlbum.Config.selectedBox, for: .selected)
iconButton.setBackgroundImage(LPAlbum.Style.normalBox , for: .normal)
iconButton.setBackgroundImage(LPAlbum.Style.selectedBox, for: .selected)
iconButton.lp_hitEdgeInsets = UIEdgeInsets(top: -5, left: -5, bottom: -5, right: -5)

addSubview(photoView)
Expand Down
4 changes: 2 additions & 2 deletions LPAlbum/Views/TitleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class TitleView: UIButton {

override init(frame: CGRect) {
super.init(frame: frame)
setImage(LPAlbum.Config.arrowImage, for: .normal)
setTitleColor(LPAlbum.Config.barTitleColor, for: .normal)
setImage(LPAlbum.Style.arrowImage, for: .normal)
setTitleColor(LPAlbum.Style.barTitleColor, for: .normal)
titleLabel?.font = UIFont.systemFont(ofSize: 17)
bounds = CGRect(origin: .zero, size: CGSize(width: 200, height: 40))
addTarget(self, action: #selector(click), for: .touchUpInside)
Expand Down

0 comments on commit b8ba7a1

Please sign in to comment.