Skip to content

Commit

Permalink
Merge pull request #37 from THT-Team/Fix/bottom_tabbar
Browse files Browse the repository at this point in the history
[#34]Fix: 노치 없는 폰에서 하단 네비 바 짤림 수정
  • Loading branch information
Minny27 authored Sep 28, 2023
2 parents 590054c + 7cf5bad commit 67d2b10
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 44 deletions.
9 changes: 4 additions & 5 deletions .github/ISSUE_TEMPLATE/🔴-bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ assignees: ''
## Detail
-

## Cause
-

## Solution
-
## Environment
- Mac:
- Xcode:
- Device:
34 changes: 17 additions & 17 deletions Falling/Sources/Base/TFBaseViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ import UIKit
import RxSwift

class TFBaseViewController: UIViewController {
var disposeBag = DisposeBag()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = FallingAsset.Color.neutral700.color
navigationSetting()
makeUI()
bindViewModel()
}
var disposeBag = DisposeBag()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = FallingAsset.Color.neutral700.color
navigationSetting()
makeUI()
bindViewModel()
}
/// Set up Navigation Bar
func navigationSetting() {
navigationController?.navigationBar.topItem?.title = ""
navigationController?.navigationBar.backIndicatorImage = FallingAsset.Image.chevron.image
navigationController?.navigationBar.backIndicatorTransitionMaskImage = FallingAsset.Image.chevron.image
navigationController?.navigationBar.tintColor = FallingAsset.Color.neutral50.color
func navigationSetting() {
navigationController?.navigationBar.topItem?.title = ""
navigationController?.navigationBar.backIndicatorImage = FallingAsset.Image.chevron.image
navigationController?.navigationBar.backIndicatorTransitionMaskImage = FallingAsset.Image.chevron.image
navigationController?.navigationBar.tintColor = FallingAsset.Color.neutral50.color

let navBarAppearance = UINavigationBarAppearance()
navBarAppearance.titlePositionAdjustment.horizontal = -CGFloat.greatestFiniteMagnitude
Expand All @@ -35,7 +35,7 @@ class TFBaseViewController: UIViewController {
navBarAppearance.shadowColor = nil
navigationItem.standardAppearance = navBarAppearance
navigationItem.scrollEdgeAppearance = navBarAppearance
}
}

/// call in super viewDidLoad
func makeUI() { }
Expand Down
3 changes: 1 addition & 2 deletions Falling/Sources/Common/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class Application {

private func makeTabBarController() -> UIViewController {
let heartService = HeartAPI(isStub: true, sampleStatusCode: 200, customEndpointClosure: nil)

let mainNavigationController = UINavigationController()
let heartNavigationController = UINavigationController()
let chatNavigationController = UINavigationController()
Expand Down Expand Up @@ -81,7 +81,6 @@ final class Application {
image: image,
selectedImage: selectedImage
)
navigationController.tabBarItem.imageInsets = .init(top: 5, left: 0, bottom: -5, right: 0)
return navigationController
}
}
10 changes: 5 additions & 5 deletions Falling/Sources/Feature/Main/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ final class MainViewController: TFBaseViewController {
super.init(nibName: nil, bundle: nil)
}

override func loadView() {
self.view = mainView
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
Expand All @@ -35,13 +39,9 @@ final class MainViewController: TFBaseViewController {
navigationItem.rightBarButtonItem = notificationButtonItem
}

override func loadView() {
self.view = mainView
}

override func bindViewModel() {
let output = viewModel.transform(input: MainViewModel.Input())

output.state
.drive(mainView.rx.timeState)
.disposed(by: disposeBag)
Expand Down
32 changes: 17 additions & 15 deletions Falling/Sources/Foundation/TabBar/TFTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import UIKit
import RxSwift

protocol TabBarDependnecy: AnyObject {

var tabBarHeight: CGFloat { get }
}

final class TabBarComponent: TabBarDependnecy {

var tabBarHeight: CGFloat = 56
}

final class TFTabBarController: UITabBarController {
Expand All @@ -30,33 +30,35 @@ final class TFTabBarController: UITabBarController {

override func viewDidLoad() {
super.viewDidLoad()

setAppearance()
}

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
tabBar.frame.size.height = dependnecy.tabBarHeight + UIWindow.safeAreaInsetBottom
tabBar.frame.origin.y = self.view.frame.height - tabBar.frame.size.height
}

// https://emptytheory.com/2019/12/31/using-uitabbarappearance-for-tab-bar-changes-in-ios-13/
private func setAppearance() {
let appearence = UITabBarAppearance()

appearence.backgroundColor = FallingAsset.Color.neutral700.color
appearence.shadowColor = FallingAsset.Color.neutral600.color
let tabBarAppearance = UITabBarAppearance()
tabBarAppearance.backgroundColor = FallingAsset.Color.neutral700.color
tabBarAppearance.shadowColor = FallingAsset.Color.neutral600.color
self.tabBar.isTranslucent = false

setTabItemAppearence(appearence.stackedLayoutAppearance)
self.tabBar.scrollEdgeAppearance = appearence
self.tabBar.standardAppearance = appearence
setTabItemAppearence(tabBarAppearance.stackedLayoutAppearance)
self.tabBar.standardAppearance = tabBarAppearance
self.tabBar.scrollEdgeAppearance = tabBarAppearance
}

private func setTabItemAppearence(_ itemAppearence: UITabBarItemAppearance) {
itemAppearence.normal.titleTextAttributes = [
private func setTabItemAppearence(_ itemAppearance: UITabBarItemAppearance) {
itemAppearance.normal.titleTextAttributes = [
.foregroundColor: FallingAsset.Color.unSelected.color,
.font: UIFont.thtCaption1M
]
itemAppearence.normal.titlePositionAdjustment.vertical = 10
itemAppearence.selected.titleTextAttributes = [
itemAppearance.selected.titleTextAttributes = [
.foregroundColor: FallingAsset.Color.neutral50.color,
.font: UIFont.thtCaption1M
]

}
}
23 changes: 23 additions & 0 deletions Falling/Sources/Util/UIWindow+Utils.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// UIWindow+Utils.swift
// Falling
//
// Created by SeungMin on 2023/09/27.
//

import UIKit

extension UIWindow {

static var keyWindow: UIWindow? {
return UIApplication
.shared
.connectedScenes
.compactMap { ($0 as? UIWindowScene)?.keyWindow }
.last
}

static var safeAreaInsetBottom: CGFloat {
return (UIWindow.keyWindow?.safeAreaInsets.bottom ?? 0)
}
}

0 comments on commit 67d2b10

Please sign in to comment.