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:
2026-07-07 09:57:41 +08:00
parent d8329d19fd
commit 715393e78c
14 changed files with 1222 additions and 209 deletions

View File

@ -0,0 +1,53 @@
//
// HomeCollectionModelsTests.swift
// suixinkanTests
//
import XCTest
@testable import suixinkan
/// Collection snapshot
final class HomeCollectionModelsTests: XCTestCase {
func testMakeSnapshotIncludesDistinctWorkBlockItems() {
let snapshot = HomeCollectionLayoutBuilder.makeSnapshot(
showWorkBlock: true,
showStore: false,
storeItem: nil,
commonMenus: []
)
XCTAssertEqual(snapshot.numberOfSections, 4)
XCTAssertEqual(snapshot.numberOfItems(inSection: .workStatus), 1)
XCTAssertEqual(snapshot.numberOfItems(inSection: .locationReport), 1)
XCTAssertEqual(snapshot.numberOfItems(inSection: .quickActions), 1)
XCTAssertEqual(snapshot.itemIdentifiers(inSection: .workStatus), [.workStatus])
XCTAssertEqual(snapshot.itemIdentifiers(inSection: .locationReport), [.locationReport])
XCTAssertEqual(snapshot.itemIdentifiers(inSection: .quickActions), [.quickActions])
}
func testMakeSnapshotOmitsWorkBlockForMinimalTopRole() {
let snapshot = HomeCollectionLayoutBuilder.makeSnapshot(
showWorkBlock: false,
showStore: false,
storeItem: nil,
commonMenus: []
)
XCTAssertEqual(snapshot.sectionIdentifiers, [.commonApps])
XCTAssertEqual(snapshot.itemIdentifiers(inSection: .commonApps).count, 1)
}
func testMakeSnapshotIncludesStoreSectionWhenAvailable() {
let store = StoreItem(id: 1, name: "测试门店", address: "测试地址")
let snapshot = HomeCollectionLayoutBuilder.makeSnapshot(
showWorkBlock: true,
showStore: true,
storeItem: store,
commonMenus: []
)
XCTAssertTrue(snapshot.sectionIdentifiers.contains(.store))
XCTAssertEqual(snapshot.itemIdentifiers(inSection: .store), [.store])
}
}