Skip to content

Commit 6ce85c2

Browse files
committed
update root collection layout
1 parent 2159b8a commit 6ce85c2

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

TeadsSampleApp/Controllers/RootController/RootViewController.swift

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,11 @@ extension RootViewController: UICollectionViewDelegateFlowLayout {
292292
let width = ((collectionView.bounds.width - 32) / count) - spacing * (count - 1)
293293
return CGSize(width: width, height: 32)
294294
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 })
299297
case 2:
300298
let creativesTypeList = selectionList.first(where: {$0.isSelected})?.creativeTypes ?? []
301-
return getButtonButtonSize(buttonValues: creativesTypeList)
299+
return getButtonButtonSize(buttonValues: creativesTypeList.map { $0.name.rawValue })
302300
case 3:
303301
let spacing: CGFloat = 16
304302
let width = ((collectionView.bounds.width - 32) / 2) - (spacing / 2)
@@ -325,18 +323,18 @@ extension RootViewController: UICollectionViewDelegateFlowLayout {
325323
self.present(alert, animated: true, completion: nil)
326324
}
327325

328-
func getButtonWidth(buttonValues: [CreativeType]) -> Int {
326+
func getButtonWidth(buttonValues: [String]) -> Int {
329327

330328
var width = 0
331329
buttonValues.forEach { (item) in
332-
width = max(width, Int(item.name.rawValue.size(withAttributes: [
330+
width = max(width, Int(item.size(withAttributes: [
333331
NSAttributedString.Key.font : UIFont.systemFont(ofSize: 18)
334332
]).width))
335333
}
336334
return width + 16
337335
}
338336

339-
func getButtonButtonSize(buttonValues: [CreativeType]) -> CGSize {
337+
func getButtonButtonSize(buttonValues: [String]) -> CGSize {
340338

341339
let spacing: CGFloat = 4
342340
let availableWidth = Int(collectionView.bounds.width - 32)

TeadsSampleApp/Models/Format.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ enum ProviderName: String {
168168
case admob = "Admob"
169169
case mopub = "Mopub"
170170
case sas = "Smart"
171-
case appLovin = "MAX"
171+
case appLovin = "App Lovin"
172172
}
173173

174174
enum CreativeTypeName: String {

0 commit comments

Comments
 (0)