@@ -292,13 +292,11 @@ extension RootViewController: UICollectionViewDelegateFlowLayout {
292
292
let width = ( ( collectionView. bounds. width - 32 ) / count) - spacing * ( count - 1 )
293
293
return CGSize ( width: width, height: 32 )
294
294
case 1 :
295
- let spacing : CGFloat = 2
296
- let count : CGFloat = CGFloat ( selectionList. first ( where: { $0. isSelected} ) ? . providers. count ?? 0 )
297
- let width = ( ( collectionView. bounds. width - 32 ) / count) - spacing * ( count - 1 )
298
- return CGSize ( width: width, height: 32 )
295
+ let providerList = selectionList. first ( where: { $0. isSelected} ) ? . providers ?? [ ]
296
+ return getButtonButtonSize ( buttonValues: providerList. map { $0. name. rawValue } )
299
297
case 2 :
300
298
let creativesTypeList = selectionList. first ( where: { $0. isSelected} ) ? . creativeTypes ?? [ ]
301
- return getButtonButtonSize ( buttonValues: creativesTypeList)
299
+ return getButtonButtonSize ( buttonValues: creativesTypeList. map { $0 . name . rawValue } )
302
300
case 3 :
303
301
let spacing : CGFloat = 16
304
302
let width = ( ( collectionView. bounds. width - 32 ) / 2 ) - ( spacing / 2 )
@@ -325,18 +323,18 @@ extension RootViewController: UICollectionViewDelegateFlowLayout {
325
323
self . present ( alert, animated: true , completion: nil )
326
324
}
327
325
328
- func getButtonWidth( buttonValues: [ CreativeType ] ) -> Int {
326
+ func getButtonWidth( buttonValues: [ String ] ) -> Int {
329
327
330
328
var width = 0
331
329
buttonValues. forEach { ( item) in
332
- width = max ( width, Int ( item. name . rawValue . size ( withAttributes: [
330
+ width = max ( width, Int ( item. size ( withAttributes: [
333
331
NSAttributedString . Key. font : UIFont . systemFont ( ofSize: 18 )
334
332
] ) . width) )
335
333
}
336
334
return width + 16
337
335
}
338
336
339
- func getButtonButtonSize( buttonValues: [ CreativeType ] ) -> CGSize {
337
+ func getButtonButtonSize( buttonValues: [ String ] ) -> CGSize {
340
338
341
339
let spacing : CGFloat = 4
342
340
let availableWidth = Int ( collectionView. bounds. width - 32 )
0 commit comments