Skip to content

Commit f1ed7bd

Browse files
Mid commit for AppTheme changes
1 parent b8c64cc commit f1ed7bd

File tree

57 files changed

+557
-495
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+557
-495
lines changed

Sources/PassioNutritionUIModule/NutritionUIModule/Nutrition.xcassets/Images/Tabs/plus.imageset/Contents.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@
55
"scale" : "1x"
66
},
77
{
8-
"filename" : "Shape=Circle, Color=primary, Size=Large@2x.png",
8+
"filename" : "plus@2x.png",
99
"idiom" : "universal",
1010
"scale" : "2x"
1111
},
1212
{
13-
"filename" : "Shape=Circle, Color=primary, Size=Large@3x.png",
13+
"filename" : "plus@3x.png",
1414
"idiom" : "universal",
1515
"scale" : "3x"
1616
}
1717
],
1818
"info" : {
1919
"author" : "xcode",
2020
"version" : 1
21+
},
22+
"properties" : {
23+
"template-rendering-intent" : "original"
2124
}
2225
}
6.51 KB
Loading
11.8 KB
Loading

Sources/PassioNutritionUIModule/NutritionUIModule/NutritionUI/Extensions/UINavigationController+Extension.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@ extension UINavigationController: UIGestureRecognizerDelegate {
1717
interactivePopGestureRecognizer?.delegate = self
1818
}
1919

20-
func updateStatusBarColor(color: UIColor) {
20+
func updateStatusBarColor(color: UIColor = .white) {
2121
if let statusBar = self.view.viewWithTag(-1) {
2222
statusBar.backgroundColor = color
2323
} else {
24-
let statusBar = UIView(frame: (UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.windowScene?.statusBarManager?.statusBarFrame)!)
24+
let frame = (UIApplication.shared.windows.filter {
25+
$0.isKeyWindow
26+
}.first?.windowScene?.statusBarManager?.statusBarFrame)!
27+
let statusBar = UIView(frame: frame)
2528
statusBar.tag = -1
2629
statusBar.backgroundColor = color
2730
view.addSubview(statusBar)

Sources/PassioNutritionUIModule/NutritionUIModule/NutritionUI/Extensions/UIView+Extension.swift

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -164,74 +164,28 @@ public extension UIView {
164164
}
165165

166166
func applyBorder(width: CGFloat, color: UIColor) {
167-
168167
layer.borderColor = color.cgColor
169168
layer.borderWidth = width
170169
}
171170

172-
func dropShadow() {
173-
174-
layer.shadowRadius = 2
175-
layer.shadowOpacity = 0.125
176-
layer.shadowColor = UIColor.black.cgColor
177-
layer.shadowOffset = .init(width: 1, height: 1)
178-
layer.shouldRasterize = true
179-
layer.rasterizationScale = UIScreen.main.scale
180-
layer.masksToBounds = false
181-
}
182-
183-
func dropShadow(radius: CGFloat) {
184-
185-
layer.cornerRadius = radius
186-
layer.shadowRadius = 2
187-
layer.shadowOpacity = 0.125
188-
layer.shadowColor = UIColor.black.cgColor
189-
layer.shadowOffset = .init(width: 1, height: 1)
190-
layer.shouldRasterize = true
191-
layer.rasterizationScale = UIScreen.main.scale
192-
}
193-
194-
/// Use this function to draw shadow. Using this function you can avoid shadow performance issue and related warnings in view debugger.
171+
/// Use this function to draw shadow
195172
/// - Parameters:
196173
/// - radius: View's cornerRadius
197174
/// - offset: Shadow's offset
198175
/// - color: Shadow's color
199176
/// - shadowRadius: Shadow's radius (blur)
200177
/// - shadowOpacity: Shadow's opacity
201-
/// - useShadowPath: Set to true to avoid performance issue
202-
/// - shadowPath: Shadow's path
203178
func dropShadow(radius: CGFloat,
204179
offset: CGSize,
205180
color: UIColor,
206181
shadowRadius: CGFloat,
207-
shadowOpacity: Float,
208-
useShadowPath: Bool = false,
209-
shadowPath: CGPath? = nil) {
182+
shadowOpacity: Float) {
210183

211184
layer.cornerRadius = radius
212185
layer.shadowRadius = shadowRadius
213186
layer.shadowOpacity = shadowOpacity
214187
layer.shadowColor = color.cgColor
215188
layer.shadowOffset = offset
216-
if useShadowPath {
217-
layer.shadowPath = shadowPath ?? UIBezierPath(roundedRect: bounds,
218-
cornerRadius: layer.cornerRadius).cgPath
219-
}
220-
layer.masksToBounds = false
221-
layer.shouldRasterize = true
222-
layer.rasterizationScale = UIScreen.main.scale
223-
}
224-
225-
func addShadowAndCornerRadius(shadowColor: UIColor = .black,
226-
shadowOffset: CGSize = CGSize(width: 1, height: 1),
227-
shadowOpacity: Float = 0.125,
228-
shadowRadius: CGFloat = 2,
229-
cornerRadius: CGFloat = 8) {
230-
layer.shadowColor = shadowColor.cgColor
231-
layer.shadowOffset = shadowOffset
232-
layer.shadowOpacity = shadowOpacity
233-
layer.shadowRadius = shadowRadius
234-
layer.cornerRadius = cornerRadius
235189
layer.masksToBounds = false
236190
layer.shouldRasterize = true
237191
layer.rasterizationScale = UIScreen.main.scale

Sources/PassioNutritionUIModule/NutritionUIModule/NutritionUI/Extensions/UIViewController+Extension.swift

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -34,34 +34,6 @@ public extension UIViewController {
3434
self.navigationController?.popViewController(animated: true)
3535
}
3636

37-
// open override func awakeAfter(using coder: NSCoder) -> Any? {
38-
// navigationItem.backButtonDisplayMode = .minimal // This will help us to remove text from back button
39-
// return super.awakeAfter(using: coder)
40-
// }
41-
42-
/// Customize Navigation bar
43-
// func customizeNavigationBar(tintColor: UIColor = .gray400,
44-
// titleColor: UIColor = .gray900,
45-
// withBackButton: Bool = true) {
46-
//
47-
// guard let navBar = self.navigationController?.navigationBar else { return }
48-
// navBar.setBackgroundImage(nil, for: .default)
49-
// navBar.shadowImage = UIImage()
50-
// navBar.tintColor = tintColor
51-
//
52-
// let appearance = UINavigationBarAppearance()
53-
// appearance.configureWithTransparentBackground()
54-
// appearance.titleTextAttributes = [.font: UIFont.inter(type: .bold, size: 23),
55-
// .foregroundColor: titleColor]
56-
// navBar.standardAppearance = appearance
57-
// navBar.scrollEdgeAppearance = appearance
58-
// navBar.tintColor = tintColor
59-
// addEmptyleftButon()
60-
// if !withBackButton {
61-
// navigationItem.hidesBackButton = true
62-
// }
63-
// }
64-
6537
var topBarHeight: CGFloat {
6638
return (view.window?.windowScene?.statusBarManager?.statusBarFrame.height ?? 0.0) +
6739
(self.navigationController?.navigationBar.frame.height ?? 0.0)
@@ -309,20 +281,3 @@ public extension UIViewController {
309281
]
310282
}
311283
}
312-
313-
//public protocol InteractivePopGestureRecognizerDelegate: UIGestureRecognizerDelegate {
314-
// func setupInteractivePopGestureRecognizer()
315-
//}
316-
//
317-
//extension InteractivePopGestureRecognizerDelegate where Self: UIViewController {
318-
// public func setupInteractivePopGestureRecognizer() {
319-
// navigationController?.interactivePopGestureRecognizer?.delegate = self
320-
// }
321-
//}
322-
//
323-
//extension UIViewController: InteractivePopGestureRecognizerDelegate {
324-
// // Ensure the gesture recognizer works alongside the custom back button
325-
// public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
326-
// return navigationController?.viewControllers.count ?? 0 > 1
327-
// }
328-
//}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
//
2+
// PassioThemeManager.swift
3+
//
4+
//
5+
// Created by Nikunj Prajapati on 02/07/24.
6+
//
7+
8+
import UIKit
9+
10+
/// PassioTheme struct to modify PassioNutrition UI's theme
11+
/// - Parameters:
12+
/// - primaryColor: Main tint color
13+
/// - secondaryTabColor: secondary tab color for unselected Tab
14+
/// - navigationColor: Navigation bar color
15+
public struct PassioTheme {
16+
17+
public var primaryColor: String
18+
public var secondaryTabColor: String
19+
public var navigationColor: String
20+
public var statusBarColor: String
21+
22+
public init(primaryColor: String,
23+
secondaryTabColor: String,
24+
navigationColor: String,
25+
statusBarColor: String) {
26+
self.primaryColor = primaryColor
27+
self.secondaryTabColor = secondaryTabColor
28+
self.navigationColor = navigationColor
29+
self.statusBarColor = statusBarColor
30+
}
31+
}
32+
33+
public protocol PassioThemeable: AnyObject {
34+
func setAppTheme(theme: PassioTheme)
35+
}
36+
37+
public class PassioThemeManager: PassioThemeable {
38+
39+
private struct Static {
40+
fileprivate static var instance: PassioThemeManager?
41+
}
42+
43+
// MARK: Shared Object
44+
public class var shared: PassioThemeManager {
45+
if Static.instance == nil {
46+
Static.instance = PassioThemeManager()
47+
}
48+
return Static.instance!
49+
}
50+
private init() {}
51+
52+
public var passioAppTheme: PassioTheme = PassioTheme(primaryColor: "#4F46E5",
53+
secondaryTabColor: "#D1D5DB",
54+
navigationColor: "#FFFFFF",
55+
statusBarColor: "#FFFFFF")
56+
57+
public func setAppTheme(theme: PassioTheme) {
58+
passioAppTheme = theme
59+
}
60+
}

Sources/PassioNutritionUIModule/NutritionUIModule/NutritionUI/THEME.swift

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,30 @@ import UIKit
1111
public struct Custom {
1212
public static let insetBackgroundRadius: CGFloat = 16.0
1313
public static let buttonCornerRadius: CGFloat = 8.0
14-
public static let engineeringViews = false
15-
public static let useFirebase = false
16-
public static let useNutritionBrowser = false
17-
public static let oneLineAlternative = false
18-
public static let oneSizeAlternative = true
14+
// public static let useFirebase = false
1915
}
2016

2117
// MARK: - UIColor
2218
public extension UIColor { // customized colors
2319

20+
static let passioAppTheme = PassioThemeManager.shared.passioAppTheme
21+
22+
static var primaryColor: UIColor {
23+
UIColor(hex: passioAppTheme.primaryColor) ?? .indigo600
24+
}
25+
26+
static var secondaryTabColor: UIColor {
27+
UIColor(hex: passioAppTheme.secondaryTabColor) ?? .gray300
28+
}
29+
30+
static var navigationColor: UIColor {
31+
UIColor(hex: passioAppTheme.navigationColor) ?? .white
32+
}
33+
34+
static var statusBarColor: UIColor {
35+
UIColor(hex: passioAppTheme.statusBarColor) ?? .white
36+
}
37+
2438
static var gray50: UIColor {
2539
colorFromBundle(named: "gray-50") ?? .blue
2640
}

0 commit comments

Comments
 (0)