Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions iBox/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@
// Created by 김찬희 on 2023/12/21.
//

import UIKit
import CoreData
import UIKit
import WebKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
let versioningHandler: VersioningHandler = VersioningHandler()

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

if UserDefaultsManager.isPreload {
Task { [weak self] in
self?.preloadFavoriteWeb()
}
}
workaroundInitialWebViewDelay()

versioningHandler.checkAppVersion { result in
AppStateManager.shared.isVersionCheckCompleted = result
Expand All @@ -27,16 +23,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return true
}

private func preloadFavoriteWeb() {
let favoriteId = UserDefaultsManager.favoriteId
var favoriteUrl: URL? = nil
if let favoriteId {
favoriteUrl = CoreDataManager.shared.getBookmarkUrl(favoriteId)
if favoriteUrl == nil {
UserDefaultsManager.favoriteId = nil
}
}
WebViewPreloader.shared.preloadFavoriteView(url: favoriteUrl)
func workaroundInitialWebViewDelay() {
let webView = WKWebView()
webView.loadHTMLString("", baseURL: nil)
Comment on lines +26 to +28
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

빈 HTML을 로드함으로써 WKWebView의 초기 설정을 미리 처리
-> 실제로 웹 뷰를 필요로 할 때는 이 초기화로 인한 지연 없이 더 빠르게 컨텐츠를 표시

굳입니다 !

}

// MARK: UISceneSession Lifecycle
Expand Down
10 changes: 4 additions & 6 deletions iBox/Sources/Favorite/FavoriteView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ import SnapKit

class FavoriteView: UIView {

lazy var webView = {
if WebViewPreloader.shared.getFavoriteView() == nil {
loadFavoriteWeb()
}
return WebViewPreloader.shared.getFavoriteView()
}()
var webView: WebView?

// MARK: - Initializer

Expand All @@ -41,6 +36,9 @@ class FavoriteView: UIView {

private func setupProperty() {
backgroundColor = .backgroundColor

loadFavoriteWeb()
webView = WebViewPreloader.shared.getFavoriteView()
}

private func setupHierarchy() {
Expand Down
8 changes: 1 addition & 7 deletions iBox/Sources/Favorite/FavoriteViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ class FavoriteViewController: BaseViewController<FavoriteView>, BaseViewControll
guard let contentView = contentView as? FavoriteView else { return }
contentView.webView?.delegate = self
}

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
guard let contentView = contentView as? FavoriteView else { return }
contentView.webView?.setupRefreshControl()
}


// MARK: - BaseViewControllerProtocol

func setupNavigationBar() {
Expand Down
2 changes: 0 additions & 2 deletions iBox/Sources/Model/SettingsItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ enum SettingsType {
case theme
case homeTab
case haptics
case preload
case reset
case guide
case feedback
Expand All @@ -21,7 +20,6 @@ enum SettingsType {
case .theme: "테마"
case .homeTab: "홈화면"
case .haptics: "진동"
case .preload: "즐겨찾기 미리 로드"
case .reset: "데이터 초기화"
case .guide: "앱 소개"
case .feedback: "앱 피드백"
Expand Down
10 changes: 1 addition & 9 deletions iBox/Sources/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ final class SettingsView: UIView {
viewModel.input.send(.setHaptics(controlSwitch.isOn))
}

@objc private func handlePreloadSwitchTap(_ controlSwitch: UISwitch) {
guard let viewModel = viewModel else { return }
viewModel.input.send(.setPreload(controlSwitch.isOn))
}

}

extension SettingsView: UITableViewDelegate {
Expand All @@ -105,7 +100,7 @@ extension SettingsView: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
guard let viewModel = viewModel else { return }
let settingsItem = viewModel.sectionViewModels[indexPath.section].cellViewModels[indexPath.row].settingsItem
if (settingsItem.type != SettingsType.haptics && settingsItem.type != SettingsType.preload) {
if (settingsItem.type != SettingsType.haptics) {
delegate?.pushViewController(settingsItem.type)
}
}
Expand All @@ -129,9 +124,6 @@ extension SettingsView: UITableViewDataSource {
if settingsType == .haptics {
cell.switchControl.removeTarget(nil, action: nil, for: .valueChanged)
cell.switchControl.addTarget(self, action: #selector(handleHapticsSwitchTap), for: .valueChanged)
} else if settingsType == .preload {
cell.switchControl.removeTarget(nil, action: nil, for: .valueChanged)
cell.switchControl.addTarget(self, action: #selector(handlePreloadSwitchTap), for: .valueChanged)
}
return cell
}
Expand Down
6 changes: 1 addition & 5 deletions iBox/Sources/Settings/SettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class SettingsViewModel {
enum Input {
case viewWillAppear
case setHaptics(_ isOn: Bool)
case setPreload(_ isOn: Bool)
}

enum Output {
Expand All @@ -36,8 +35,6 @@ class SettingsViewModel {
self?.output.send(.updateSectionViewModels)
case let .setHaptics(isOn):
UserDefaultsManager.isHaptics = isOn
case let .setPreload(isOn):
UserDefaultsManager.isPreload = isOn
}
}.store(in: &cancellables)
return output.eraseToAnyPublisher()
Expand All @@ -47,8 +44,7 @@ class SettingsViewModel {
sectionViewModels.append(SettingsSectionViewModel(cellViewModels: [
SettingsCellViewModel(SettingsItem(type: .theme, description: UserDefaultsManager.theme.toString())),
SettingsCellViewModel(SettingsItem(type: .homeTab, description: HomeTabType.allCases[UserDefaultsManager.homeTabIndex].toString())),
SettingsCellViewModel(SettingsItem(type: .haptics, flag: UserDefaultsManager.isHaptics)),
SettingsCellViewModel(SettingsItem(type: .preload, flag: UserDefaultsManager.isPreload))
SettingsCellViewModel(SettingsItem(type: .haptics, flag: UserDefaultsManager.isHaptics))
]))
sectionViewModels.append(SettingsSectionViewModel(cellViewModels: [
SettingsCellViewModel(SettingsItem(type: .reset)),
Expand Down
3 changes: 0 additions & 3 deletions iBox/Sources/Shared/UserDefaultsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ final class UserDefaultsManager {
@UserDefaultsData(key: "isHaptics", defaultValue: true)
static var isHaptics: Bool

@UserDefaultsData(key: "isPreload", defaultValue: false)
static var isPreload: Bool

@UserDefaultsData(key: "selectedFolderId", defaultValue: nil)
static var selectedFolderId: UUID?

Expand Down