Refactor home to single collection view and add all-functions customization.
Replace scroll/stack layout with one UICollectionView, fix grid column math and Diffable item IDs so location report and quick actions render, and add the customizable all-functions page with persistence and tests. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -40,8 +40,18 @@ final class HomeCommonMenuStore {
|
||||
let saved = savedCommonURIs(accountScope: accountScope, roleCode: roleCode)
|
||||
let defaultURIs = Self.defaultCommonURIs(from: permissions)
|
||||
let commonURIs = saved.isEmpty ? defaultURIs : saved
|
||||
return Self.splitMenus(from: allMenus, commonURIs: commonURIs).common
|
||||
}
|
||||
|
||||
/// 按常用 URI 将菜单拆分为常用与更多两组。
|
||||
static func splitMenus(
|
||||
from allMenus: [HomeMenuItem],
|
||||
commonURIs: [String]
|
||||
) -> (common: [HomeMenuItem], more: [HomeMenuItem]) {
|
||||
let commonSet = Set(commonURIs)
|
||||
return allMenus.filter { commonSet.contains($0.uri) }
|
||||
let common = allMenus.filter { commonSet.contains($0.uri) }
|
||||
let more = allMenus.filter { !commonSet.contains($0.uri) }
|
||||
return (common, more)
|
||||
}
|
||||
|
||||
private func storageKey(accountScope: String, roleCode: String) -> String {
|
||||
|
||||
@ -13,9 +13,10 @@ enum HomeRouteHandler {
|
||||
static func open(
|
||||
uri: String,
|
||||
from viewController: UIViewController,
|
||||
storeItem: StoreItem?
|
||||
storeItem: StoreItem?,
|
||||
onCommonMenusChanged: (() -> Void)? = nil
|
||||
) {
|
||||
if uri == "pilot_controller" || uri == "more_functions" {
|
||||
if uri == "pilot_controller" {
|
||||
showDeveloping(from: viewController)
|
||||
return
|
||||
}
|
||||
@ -26,6 +27,10 @@ enum HomeRouteHandler {
|
||||
}
|
||||
|
||||
switch uri {
|
||||
case "more_functions":
|
||||
let controller = AllFunctionsViewController()
|
||||
controller.onDidCustomize = onCommonMenusChanged
|
||||
viewController.navigationController?.pushViewController(controller, animated: true)
|
||||
case "verification_order":
|
||||
selectTab(.orders, from: viewController)
|
||||
case "photographer_stats":
|
||||
|
||||
Reference in New Issue
Block a user