Skip to content

Commit 0c1b711

Browse files
committed
refactor: start of settings controller
1 parent bf5c729 commit 0c1b711

3 files changed

Lines changed: 67 additions & 8 deletions

File tree

Feather/Entry.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import OSLog
1212

1313
@main enum Entry {
1414
static func main() {
15+
let _ = Storage.shared
16+
let _ = DownloadManager.shared
17+
let _ = HeartbeatManager.shared
18+
1519
let delegate = AppDelegate()
1620
UIApplication.shared.delegate = delegate
1721
_ = UIApplicationMain(CommandLine.argc, CommandLine.unsafeArgv, nil, NSStringFromClass(AppDelegate.self))
@@ -30,7 +34,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
3034
ResetView.clearWorkCache()
3135
_addDefaultCertificates()
3236

33-
let tc = TabController()
37+
let tc = TabBarController()
3438
window = UIWindow(frame: UIScreen.main.bounds)
3539
window?.rootViewController = tc
3640
window?.makeKeyAndVisible()
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//
2+
// SettingsViewController.swift
3+
// Feather
4+
//
5+
// Created by samsam on 5/10/26.
6+
//
7+
8+
import UIKit
9+
10+
class SettingsViewController: UITableViewController {
11+
init() {
12+
super.init(style: .insetGrouped)
13+
}
14+
15+
@available(*, unavailable)
16+
required init?(coder: NSCoder) {
17+
fatalError("init(coder:) has not been implemented")
18+
}
19+
20+
override func viewDidLoad() {
21+
super.viewDidLoad()
22+
self.title = .localized("Settings")
23+
self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "SettingsCell")
24+
}
25+
}
26+
27+
extension SettingsViewController {
28+
override func numberOfSections(in tableView: UITableView) -> Int {
29+
1
30+
}
31+
32+
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
33+
1
34+
}
35+
36+
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
37+
let cell = tableView.dequeueReusableCell(
38+
withIdentifier: "SettingsCell",
39+
for: indexPath
40+
)
41+
42+
cell.accessoryType = .disclosureIndicator
43+
44+
var content = cell.defaultContentConfiguration()
45+
content.text = "hai"
46+
cell.contentConfiguration = content
47+
48+
return cell
49+
}
50+
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
51+
tableView.deselectRow(at: indexPath, animated: true)
52+
}
53+
}
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@
88
import UIKit
99
import SwiftUI
1010

11-
final class TabController: UITabBarController {
11+
final class TabBarController: UITabBarController {
1212
override func viewDidLoad() {
1313
super.viewDidLoad()
14+
15+
if #available(iOS 18.0, *) {
16+
self.mode = .tabSidebar
17+
}
18+
1419
_setupTabs()
1520
}
1621

@@ -24,22 +29,21 @@ final class TabController: UITabBarController {
2429
let sources = _createNavigation(
2530
with: .localized("Sources"),
2631
using: UIImage(systemName: "globe.desk.fill"),
27-
controller: UIHostingController(rootView: SourcesView()),
32+
controller: UIHostingController(rootView: SourcesView().environment(\.managedObjectContext, Storage.shared.context)),
2833
withNavigation: false,
2934
)
3035

3136
let library = _createNavigation(
3237
with: .localized("Apps"),
3338
using: UIImage(systemName: "square.grid.2x2.fill"),
34-
controller: UIHostingController(rootView: LibraryView()),
39+
controller: UIHostingController(rootView: LibraryView().environment(\.managedObjectContext, Storage.shared.context)),
3540
withNavigation: false,
3641
)
3742

3843
let settings = _createNavigation(
3944
with: .localized("Settings"),
4045
using: UIImage(systemName: "gearshape.2.fill"),
41-
controller: UIHostingController(rootView: SettingsView()),
42-
withNavigation: false,
46+
controller: SettingsViewController(),
4347
)
4448

4549
self.setViewControllers([
@@ -61,12 +65,10 @@ final class TabController: UITabBarController {
6165
let nav = UINavigationController(rootViewController: controller)
6266
nav.tabBarItem.title = title
6367
nav.tabBarItem.image = image
64-
nav.viewControllers.first?.navigationItem.title = title
6568
return nav
6669
} else {
6770
controller.tabBarItem.title = title
6871
controller.tabBarItem.image = image
69-
controller.navigationItem.title = title
7072
return controller
7173
}
7274
}

0 commit comments

Comments
 (0)