Files
汉秋 7469f92177 Replace CYLTabBarController with native UITabBarController for main tabs.
Use a system scan tab slot with MainScanTabItem interception so scanner presentation no longer depends on CYL PlusButton, and remove the CYLTabBarController pod dependency.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 19:17:38 +08:00

87 lines
2.2 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// AppTab.swift
// suixinkan
//
// Created by Codex on 2026/6/18.
//
import UIKit
/// Tab
enum AppTab: String, CaseIterable, Identifiable, Hashable {
case home
case orders
case statistics
case profile
var id: Self { self }
var title: String {
switch self {
case .home:
"首页"
case .orders:
"订单"
case .statistics:
"数据"
case .profile:
"我的"
}
}
/// TabBar
var selectedImageName: String {
switch self {
case .home:
"tab_home_selected"
case .orders:
"tab_order_selected"
case .statistics:
"tab_data_selected"
case .profile:
"tab_profile_selected"
}
}
/// TabBar
var unselectedImageName: String {
switch self {
case .home:
"tab_home_unselected"
case .orders:
"tab_order_unselected"
case .statistics:
"tab_data_unselected"
case .profile:
"tab_profile_unselected"
}
}
/// TabBarItem `UITabBarController` 使
func makeTabBarItem() -> UITabBarItem {
let unselectedImage = UIImage(named: unselectedImageName)?.withRenderingMode(.alwaysOriginal)
let selectedImage = UIImage(named: selectedImageName)?.withRenderingMode(.alwaysOriginal)
let item = UITabBarItem(
title: title,
image: unselectedImage,
selectedImage: selectedImage
)
item.accessibilityIdentifier = "main.tab.\(rawValue)"
return item
}
/// Tab ViewController
func makeRootViewController(services: AppServices) -> UIViewController {
switch self {
case .home:
return HomeViewController()
case .orders:
return OrdersViewController()
case .statistics:
return StatisticsViewController()
case .profile:
return ProfileViewController()
}
}
}