feat: update app workflows and permissions
This commit is contained in:
@ -28,8 +28,7 @@ enum HomeCollectionItem: Hashable {
|
||||
enum HomeCollectionLayoutBuilder {
|
||||
|
||||
private static let menuColumns = 3
|
||||
private static let menuSpacing: CGFloat = 15
|
||||
private static let menuAspectRatio: CGFloat = 1.3
|
||||
private static let menuSpacing = AppSpacing.sm
|
||||
private static let sectionSpacing = AppSpacing.sm
|
||||
|
||||
/// 构建 Compositional Layout,按当前分区类型返回 section 布局。
|
||||
@ -42,7 +41,7 @@ enum HomeCollectionLayoutBuilder {
|
||||
case .locationReport:
|
||||
return fullWidthSection(height: 132)
|
||||
case .quickActions:
|
||||
return fullWidthSection(height: 72)
|
||||
return quickActionsSection(environment: environment)
|
||||
case .store:
|
||||
return fullWidthSection(height: 96)
|
||||
case .commonApps:
|
||||
@ -120,19 +119,16 @@ enum HomeCollectionLayoutBuilder {
|
||||
}
|
||||
|
||||
private static func menuGridSection(environment: NSCollectionLayoutEnvironment) -> NSCollectionLayoutSection {
|
||||
let availableWidth = environment.container.effectiveContentSize.width - horizontalInset * 2
|
||||
let totalSpacing = menuSpacing * CGFloat(menuColumns - 1)
|
||||
let itemWidth = max(0, (availableWidth - totalSpacing) / CGFloat(menuColumns))
|
||||
let itemHeight = itemWidth / menuAspectRatio
|
||||
let itemWidth = menuItemWidth(environment: environment)
|
||||
|
||||
let itemSize = NSCollectionLayoutSize(
|
||||
widthDimension: .absolute(itemWidth),
|
||||
heightDimension: .absolute(itemHeight)
|
||||
heightDimension: .absolute(itemWidth)
|
||||
)
|
||||
let item = NSCollectionLayoutItem(layoutSize: itemSize)
|
||||
let groupSize = NSCollectionLayoutSize(
|
||||
widthDimension: .fractionalWidth(1),
|
||||
heightDimension: .absolute(itemHeight)
|
||||
heightDimension: .absolute(itemWidth)
|
||||
)
|
||||
let group = NSCollectionLayoutGroup.horizontal(
|
||||
layoutSize: groupSize,
|
||||
@ -162,4 +158,14 @@ enum HomeCollectionLayoutBuilder {
|
||||
section.boundarySupplementaryItems = [header]
|
||||
return section
|
||||
}
|
||||
|
||||
private static func quickActionsSection(environment: NSCollectionLayoutEnvironment) -> NSCollectionLayoutSection {
|
||||
fullWidthSection(height: menuItemWidth(environment: environment))
|
||||
}
|
||||
|
||||
private static func menuItemWidth(environment: NSCollectionLayoutEnvironment) -> CGFloat {
|
||||
let availableWidth = environment.container.effectiveContentSize.width - horizontalInset * 2
|
||||
let totalSpacing = menuSpacing * CGFloat(menuColumns - 1)
|
||||
return max(0, (availableWidth - totalSpacing) / CGFloat(menuColumns))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user