Skip to content

Commit f1dd910

Browse files
committed
Made show/hide green dot funcs static
1 parent 805ebb3 commit f1dd910

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

WooCommerce/Classes/AppDelegate.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
8585
}
8686

8787
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
88-
89-
tabBarController?.showDotOn(.notifications)
90-
9188
return true
9289
}
9390

WooCommerce/Classes/ViewRelated/MainTabBarController.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ extension MainTabBarController {
132132
//
133133
extension MainTabBarController {
134134

135-
func showDotOn(_ tab: WooTab) {
135+
static func showDotOn(_ tab: WooTab) {
136+
guard let tabBar = AppDelegate.shared.tabBarController?.tabBar else {
137+
return
138+
}
139+
136140
hideDotOn(tab)
137141
let dot = GreenDotView(frame: CGRect(x: DotConstants.xOffset,
138142
y: DotConstants.yOffset,
@@ -142,7 +146,11 @@ extension MainTabBarController {
142146
tabBar.subviews[tab.rawValue].subviews.first?.insertSubview(dot, at: 1)
143147
}
144148

145-
func hideDotOn(_ tab: WooTab) {
149+
static func hideDotOn(_ tab: WooTab) {
150+
guard let tabBar = AppDelegate.shared.tabBarController?.tabBar else {
151+
return
152+
}
153+
146154
let tag = dotTag(for: tab)
147155
if let subviews = tabBar.subviews[tab.rawValue].subviews.first?.subviews {
148156
for subview in subviews where subview.tag == tag {
@@ -151,7 +159,7 @@ extension MainTabBarController {
151159
}
152160
}
153161

154-
private func dotTag(for tab: WooTab) -> Int {
162+
private static func dotTag(for tab: WooTab) -> Int {
155163
return tab.rawValue + DotConstants.tagOffset
156164
}
157165
}
@@ -193,7 +201,7 @@ private class GreenDotView: UIView {
193201
}
194202

195203
private func setupSubviews() {
196-
self.backgroundColor = .clear
204+
backgroundColor = .clear
197205
}
198206

199207
override func draw(_ rect: CGRect) {

0 commit comments

Comments
 (0)