Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement theme colors to UI Elements #62

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ public class FMImageEditorViewController: UIViewController {
}

private func openFiltersMenu() {
filterMenuButton.tintColor = kRedColor
filterMenuButton.setTitleColor(kRedColor, for: .normal)
filterMenuButton.tintColor = kThemeColor
filterMenuButton.setTitleColor(kThemeColor, for: .normal)
cropMenuButton.tintColor = kBlackColor
cropMenuButton.setTitleColor(kBlackColor, for: .normal)

Expand All @@ -369,8 +369,8 @@ public class FMImageEditorViewController: UIViewController {
}

private func openCropsMenu() {
cropMenuButton.tintColor = kRedColor
cropMenuButton.setTitleColor(kRedColor, for: .normal)
cropMenuButton.tintColor = kThemeColor
cropMenuButton.setTitleColor(kThemeColor, for: .normal)
filterMenuButton.tintColor = kBlackColor
filterMenuButton.setTitleColor(kBlackColor, for: .normal)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ class FMCropCropBoxCornersView: UIView {
borderView.layer.borderWidth = borderWidth
borderView.layer.borderColor = UIColor.white.cgColor

topLeftView.backgroundColor = kRedColor
topRightView.backgroundColor = kRedColor
topLeftView.backgroundColor = kThemeColor
topRightView.backgroundColor = kThemeColor

rightTopView.backgroundColor = kRedColor
rightBottomView.backgroundColor = kRedColor
rightTopView.backgroundColor = kThemeColor
rightBottomView.backgroundColor = kThemeColor

bottomRightView.backgroundColor = kRedColor
bottomLeftView.backgroundColor = kRedColor
bottomRightView.backgroundColor = kThemeColor
bottomLeftView.backgroundColor = kThemeColor

leftBottomView.backgroundColor = kRedColor
leftTopView.backgroundColor = kRedColor
leftBottomView.backgroundColor = kThemeColor
leftTopView.backgroundColor = kThemeColor

addSubview(borderView)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class FMCropCell: UICollectionViewCell {
public func setSelected() {
let tintedImage = imageView.image?.withRenderingMode(.alwaysTemplate)
imageView.image = tintedImage
imageView.tintColor = kRedColor
imageView.tintColor = kThemeColor

name.textColor = kRedColor
name.textColor = kThemeColor
}

public func setDeselected() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class FMFilterCell: UICollectionViewCell {
selectCircleView.frame = imageView.frame.insetBy(dx: -3, dy: -3)
selectCircleView.layer.cornerRadius = selectCircleView.frame.width / 2
selectCircleView.layer.borderWidth = 2
selectCircleView.layer.borderColor = kRedColor.cgColor
selectCircleView.layer.borderColor = kThemeColor.cgColor

// hide selectCircleView by default
selectCircleView.isHidden = true
Expand All @@ -54,7 +54,7 @@ class FMFilterCell: UICollectionViewCell {

public func setSelected() {
selectCircleView.isHidden = false
name.textColor = kRedColor
name.textColor = kThemeColor
}

public func setDeselected() {
Expand Down
2 changes: 2 additions & 0 deletions FMPhotoPicker/FMPhotoPicker/source/Utilities/Const.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ internal let kRedColor = UIColor(red: 1, green: 81/255, blue: 81/255, alpha: 1)
internal let kGrayColor = UIColor(red: 114/255, green: 114/255, blue: 114/255, alpha: 1)
internal let kBlackColor = UIColor(red: 0, green: 0, blue: 0, alpha: 1)
internal let kBackgroundColor = UIColor(red: 242/255, green: 242/255, blue: 242/255, alpha: 1)
public var kThemeColor: UIColor = kRedColor
internal let kTransparentBackgroundColor = UIColor(white: 1, alpha: 0.9)
internal let kBorderColor = UIColor(red: 221/255, green: 221/255, blue: 221/255, alpha: 1)

internal let kDefaultFilter = FMFilter.None
internal let kDefaultCrop = FMCrop.ratioCustom


internal let kEpsilon: CGFloat = 0.01

internal let kFilterPreviewImageSize = CGSize(width: 90, height: 90)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation
import Photos
import UIKit

public enum FMSelectMode {
case multiple
Expand Down Expand Up @@ -51,6 +52,11 @@ public struct FMPhotoPickerConfig {
public var availableCrops: [FMCroppable]? = kDefaultAvailableCrops
public var useCropFirst: Bool = false
public var alertController: FMAlertable = FMAlert()
public var themeColor: UIColor = kRedColor {
didSet {
kThemeColor = themeColor
}
}

/// Whether you want FMPhotoPicker returns PHAsset instead of UIImage.
public var shouldReturnAsset: Bool = false
Expand Down Expand Up @@ -91,6 +97,6 @@ public struct FMPhotoPickerConfig {
]

public init() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class ViewController: UIViewController, FMPhotoPickerViewControllerDelegate, FMI
config.maxVideo = self.maxVideo
config.forceCropEnabled = forceCropEnabled.isOn
config.eclipsePreviewEnabled = eclipsePreviewEnabled.isOn
config.themeColor = .purple

// in force crop mode, only the first crop option is available
config.availableCrops = [
Expand Down