Skip to content

Commit

Permalink
final pr fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
msadoon committed Jul 5, 2023
1 parent 9dc1cd1 commit a7a6279
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ internal final class DashboardViewController: UITableViewController {
self.viewModel.inputs.viewWillAppear(animated: animated)

self.showDeprecationWarning()
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

self.updateTableViewBottomContentInset()
}
Expand Down Expand Up @@ -212,11 +216,10 @@ internal final class DashboardViewController: UITableViewController {
}

private func updateTableViewBottomContentInset() {
if let tabController = self.tabBarController as? RootTabBarViewController,
let deprecationWarningHostingController = deprecationWarningHostingController {
if let deprecationWarningHostingController = deprecationWarningHostingController {
self.tableView.contentInset
.bottom = (tabController.tabBar.bounds.height + deprecationWarningHostingController.view.bounds
.height)
.bottom = deprecationWarningHostingController.view.bounds
.height

Check warning on line 222 in Kickstarter-iOS/Features/Dashboard/Controller/DashboardViewController.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/Dashboard/Controller/DashboardViewController.swift#L220-L222

Added lines #L220 - L222 were not covered by tests
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import SwiftUI
struct DashboardDeprecationView: View {
private let contentPadding = 12.0
private let imageSizeMultiplier = 1.5
private let deprecationDateText = formatted(dateString: "2023-08-14")
private var deprecationDateText: String {
self.formatted(dateString: "2023-08-14")

Check warning on line 8 in Kickstarter-iOS/Features/DashboardDeprecationBanner/DashboardDeprecationView.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/DashboardDeprecationBanner/DashboardDeprecationView.swift#L8

Added line #L8 was not covered by tests
}

var body: some View {
HStack {
Expand All @@ -25,26 +27,26 @@ struct DashboardDeprecationView: View {
.frame(maxWidth: .infinity, alignment: .center)
.background(Color(UIColor.ksr_alert))

Check warning on line 28 in Kickstarter-iOS/Features/DashboardDeprecationBanner/DashboardDeprecationView.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/DashboardDeprecationBanner/DashboardDeprecationView.swift#L27-L28

Added lines #L27 - L28 were not covered by tests
}
}

private func formatted(dateString: String) -> String {
let date = toDate(dateString: dateString)
return Format.date(
secondsInUTC: date.timeIntervalSince1970,
template: "MMMM d, yyyy",
timeZone: UTCTimeZone
)
}

private func toDate(dateString: String) -> Date {
// Always use UTC timezone here this date should be timezone agnostic
guard let date = Format.date(
from: dateString,
dateFormat: "yyyy-MM-dd",
timeZone: UTCTimeZone
) else {
fatalError("Unable to parse date format")
private func formatted(dateString: String) -> String {
let date = self.toDate(dateString: dateString)
return Format.date(
secondsInUTC: date.timeIntervalSince1970,
template: "MMMM d, yyyy",
timeZone: UTCTimeZone
)

Check warning on line 37 in Kickstarter-iOS/Features/DashboardDeprecationBanner/DashboardDeprecationView.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/DashboardDeprecationBanner/DashboardDeprecationView.swift#L32-L37

Added lines #L32 - L37 were not covered by tests
}

return date
private func toDate(dateString: String) -> Date {
// Always use UTC timezone here this date should be timezone agnostic
guard let date = Format.date(
from: dateString,
dateFormat: "yyyy-MM-dd",
timeZone: UTCTimeZone

Check warning on line 45 in Kickstarter-iOS/Features/DashboardDeprecationBanner/DashboardDeprecationView.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/DashboardDeprecationBanner/DashboardDeprecationView.swift#L41-L45

Added lines #L41 - L45 were not covered by tests
) else {
fatalError("Unable to parse date format")
}

return date
}
}
24 changes: 8 additions & 16 deletions Kickstarter-iOS/Features/RootTabBar/RootTabBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,11 @@ public final class RootTabBarViewController: UITabBarController, MessageBannerVi
case let .search(index):
_ = tabBarItem(atIndex: index) ?|> searchTabBarItemStyle
case let .dashboard(index):
let featureFlaggedTabBarItemStyle = self
.isDashboardViewControllerDisplayable() ? dashboardTabBarItemStyle :
profileTabBarItemStyle(isLoggedIn: data.isLoggedIn, isMember: data.isMember)
_ = tabBarItem(atIndex: index) ?|> featureFlaggedTabBarItemStyle
let style = self
.isTabBarItemLastItem(for: index) ?

Check warning on line 264 in Kickstarter-iOS/Features/RootTabBar/RootTabBarViewController.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/RootTabBar/RootTabBarViewController.swift#L263-L264

Added lines #L263 - L264 were not covered by tests
profileTabBarItemStyle(isLoggedIn: data.isLoggedIn, isMember: data.isMember) :
dashboardTabBarItemStyle
_ = tabBarItem(atIndex: index) ?|> style

Check warning on line 267 in Kickstarter-iOS/Features/RootTabBar/RootTabBarViewController.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/RootTabBar/RootTabBarViewController.swift#L267

Added line #L267 was not covered by tests
case let .profile(avatarUrl, index):
_ = tabBarItem(atIndex: index)
?|> profileTabBarItemStyle(isLoggedIn: data.isLoggedIn, isMember: data.isMember)
Expand Down Expand Up @@ -307,21 +308,12 @@ public final class RootTabBarViewController: UITabBarController, MessageBannerVi
}
}

fileprivate func isDashboardViewControllerDisplayable() -> Bool {
guard let navigationControllers = self.viewControllers as? [UINavigationController] else {
fileprivate func isTabBarItemLastItem(for index: Int) -> Bool {
guard let tabBarItemEndIndex = self.tabBar.items?.endIndex else {
return false
}

var foundDashboardViewController = false

for navController in navigationControllers {
if let dashboardVC = navController.viewControllers.first as? DashboardViewController {
foundDashboardViewController = true
break
}
}

return foundDashboardViewController
return tabBarItemEndIndex - 1 == index
}

fileprivate func tabBarItem(atIndex index: Int) -> UITabBarItem? {
Expand Down

0 comments on commit a7a6279

Please sign in to comment.