Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
ppraveentr committed Sep 24, 2023
1 parent 5a7b991 commit 2c6c249
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 21 deletions.
4 changes: 4 additions & 0 deletions Example/MobileCoreExample/Classes/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
// Copyright © 2017 Praveen Prabhakar. All rights reserved.
//

#if canImport(AppTheming)
import AppTheming
import CoreComponents
#endif
import UIKit
import WebKit

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class SegmentCollectionView: UIView {
ftLog("Segment Selected: \(segment)", self.segmentedControl?.titleForSegment(at: segment) ?? "")
}

self.theme = ThemeStyle.defaultStyle
segmentedControl?.theme = ThemeStyle.defaultStyle
// self.theme = ThemeStyle.defaultStyle
// segmentedControl?.theme = ThemeStyle.defaultStyle

if let segment = segmentedControl {
self.pin(view: segment, edgeOffsets: UIEdgeInsets(10))
Expand Down
4 changes: 3 additions & 1 deletion Sources/AppTheming/ThemeComponents/UIView+Themes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#if canImport(CoreUtility)
import CoreComponents
import CoreUtility
#endif
import Foundation
Expand All @@ -17,7 +18,7 @@ private extension AssociatedKey {
static var gradientLayer = "gradientLayer"
}

extension UIView {
extension UIView: ShadowPathProtocol {
// Theme style-name for the view
@IBInspectable
public var theme: String? {
Expand All @@ -33,6 +34,7 @@ extension UIView {
self.needsThemesUpdate = true
}

@objc
public func updateShadowPathIfNeeded() {
if self.layer.shadowPath != nil {
let rect = CGRect(x: 0, y: 0, width: self.bounds.width, height: self.bounds.height)
Expand Down
8 changes: 6 additions & 2 deletions Sources/AppTheming/ThemesManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ open class ThemesManager {
// MARK: UIImage
public static func getImage(_ imageName: Any?) -> UIImage? {
guard let imageName = imageName as? String else { return nil }
if imageName == "@empty" { return UIImage() }
if imageName == "@empty" {
return UIImage()
}
if imageName.hasPrefix("@") {
// Search for image in all available bundles
for bundleName in ThemesManager.imageSourceBundle {
Expand Down Expand Up @@ -284,7 +286,9 @@ extension ThemeModel {
}

extension ThemesManager {
static subscript(key: ThemeType) -> ThemeModel? { return ThemesManager.themesJSON[key] as? ThemeModel }
static subscript(key: ThemeType) -> ThemeModel? {
ThemesManager.themesJSON[key] as? ThemeModel
}

// MARK: Component
fileprivate class var themeComponent: ThemeModel? { ThemesManager[ThemeType.components] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public protocol ViewControllerProtocol where Self: UIViewController {
func topSafeAreaLayoutGuide() -> Bool
func horizontalSafeAreaLayoutGuide() -> Bool
func shouldDissmissKeyboardOnTap() -> Bool
func shouldHideNavigationOnScroll() -> Bool
}

private extension AssociatedKey {
Expand Down Expand Up @@ -109,12 +108,10 @@ extension UIViewController: ViewControllerProtocol {
@objc
open func shouldDissmissKeyboardOnTap() -> Bool { true }

// Will hide Navigation bar on scroll
@objc
open func shouldHideNavigationOnScroll() -> Bool { true }

public func setupCoreView() {
if self.view == self.baseView { return }
if self.view == self.baseView {
return
}
guard let rootView = self.view else { return }
var isValidBaseView = false

Expand Down
10 changes: 8 additions & 2 deletions Sources/CoreComponents/CustomComponents/FTView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import CoreUtility
import Foundation
import UIKit

@objc
public protocol ShadowPathProtocol where Self: UIView {
func updateShadowPathIfNeeded()
}

open class FTView: UIView {

// Set as BaseView, so that "pin'ning" subViews wont alter the base position
Expand Down Expand Up @@ -107,8 +112,9 @@ open class FTView: UIView {
rootView.pin(view: self.mainPinnedView, edgeInsets: .horizontal )
}

open override func layoutSubviews() {
updateShadowPathIfNeeded()
override open func layoutSubviews() {
// Send action to superView to update view
UIApplication.shared.sendAction(#selector(ShadowPathProtocol.updateShadowPathIfNeeded), to: nil, from: self, for: nil)
super.layoutSubviews()
}
}
Expand Down
8 changes: 7 additions & 1 deletion Sources/CoreUtility/Extensions/ScrollingNavBarProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,24 @@
//

import Foundation
import UIKit

public protocol ScrollingNavBarProtocol where Self: UIViewController {
func hideNavigationOnScroll(for scrollableView: UIView, delay: Double)
func navBarAnimation(velocity: CGPoint, animateDuration: TimeInterval, delay: TimeInterval)
func setBarStatus(hidden: Bool)
func shouldHideNavigationOnScroll() -> Bool
}

private extension AssociatedKey {
static var navBarScrollableView = "navBar.scrollableView"
}

extension UIViewController: ScrollingNavBarProtocol {
// Will hide Navigation bar on scroll
@objc
open func shouldHideNavigationOnScroll() -> Bool { true }

private var scrollableView: UIView? {
get { AssociatedObject<ScrollingNavBar>.getAssociated(self, key: &AssociatedKey.navBarScrollableView)?.scrollableView }
set {
Expand Down Expand Up @@ -48,7 +54,7 @@ extension UIViewController: ScrollingNavBarProtocol {
}
}

fileprivate class ScrollingNavBar: NSObject, UIGestureRecognizerDelegate {
private class ScrollingNavBar: NSObject, UIGestureRecognizerDelegate {
weak var scrollableView: UIView?
weak var delegate: ScrollingNavBarProtocol?
private lazy var gestureRecognizer: UIPanGestureRecognizer = {
Expand Down
8 changes: 5 additions & 3 deletions Sources/CoreUtility/Extensions/String+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ public extension String {
paragraphStyle.lineBreakMode = lineBreakMode
let attributes: AttributedDictionary = [ .font: font, .paragraphStyle: paragraphStyle ]
let attributedString = NSAttributedString(string: self, attributes: attributes)
let rect = attributedString.boundingRect(with: constrainedSize,
options: [.usesDeviceMetrics, .usesLineFragmentOrigin, .usesFontLeading],
context: nil)
let rect = attributedString.boundingRect(
with: constrainedSize,
options: [.usesDeviceMetrics, .usesLineFragmentOrigin, .usesFontLeading],
context: nil
)
return ceil(size: rect.size)
}

Expand Down
4 changes: 0 additions & 4 deletions fastlane/Package.swift

This file was deleted.

0 comments on commit 2c6c249

Please sign in to comment.