Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions ACON-iOS/ACON-iOS/Global/Service/GoogleAdsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,22 @@ final class GoogleAdsManager: NSObject {
$0.shouldRequestMultipleImages = false
}

let adLoader = AdLoader(
adUnitID: adUnitID,
rootViewController: rootViewController,
adTypes: [.native],
options: [options]
).then {
$0.delegate = self
DispatchQueue.main.async {
let adLoader = AdLoader(
adUnitID: adUnitID,
rootViewController: rootViewController,
adTypes: [.native],
options: [options]
)

adLoader.delegate = self

self.adLoaders[adType] = adLoader

DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
adLoader.load(request)
}
}

self.adLoaders[adType] = adLoader
adLoader.load(request)
}
}
}
Expand Down Expand Up @@ -149,6 +154,9 @@ private extension GoogleAdsManager {
}

func cleanAdType(_ adType: GoogleAdsType) {
if let adLoader = self.adLoaders[adType] {
adLoader.delegate = nil
}
loadingAds.remove(adType)
loadCompletions.removeValue(forKey: adType)
adLoaders.removeValue(forKey: adType)
Expand Down Expand Up @@ -192,7 +200,8 @@ extension GoogleAdsManager {
if isConnected && !previousState && self.needsAdReloadOnNetworkRecovery {
print("🥐 periodicNetworkCheck - 네트워크 복구 감지")

DispatchQueue.main.async {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
self.needsAdReloadOnNetworkRecovery = false

self.resetAdState()
Expand Down
2 changes: 1 addition & 1 deletion ACON-iOS/ACON-iOS/Global/Utils/Enums/GoogleAdsType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by 이수민 on 6/7/25.
//

enum GoogleAdsType: String {
enum GoogleAdsType: String, CaseIterable, Hashable {

case imageOnly

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ final class PhotoCollectionViewCell: BaseCollectionViewCell {

override var isSelected: Bool {
didSet {
whiteView.alpha = isSelected ? 0.3 : 0
dimView.alpha = isSelected ? 0.3 : 0
dimView.alpha = isSelected ? 1 : 0
}
}

Expand All @@ -32,16 +31,12 @@ final class PhotoCollectionViewCell: BaseCollectionViewCell {
override func setHierarchy() {
super.setHierarchy()

self.addSubviews(photoImageView, whiteView, dimView)
self.addSubviews(photoImageView, dimView)
}

override func setLayout() {
super.setLayout()

whiteView.snp.makeConstraints {
$0.edges.equalToSuperview()
}

dimView.snp.makeConstraints {
$0.edges.equalToSuperview()
}
Expand All @@ -57,12 +52,10 @@ final class PhotoCollectionViewCell: BaseCollectionViewCell {
self.backgroundColor = .clear
self.isSelected = false

whiteView.do {
$0.backgroundColor = .white
}

dimView.do {
$0.backgroundColor = .gray600
$0.backgroundColor = .labelAction.withAlphaComponent(0.2)
$0.layer.borderColor = UIColor.labelAction.cgColor
$0.layer.borderWidth = 1
}

photoImageView.do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PhotoCollectionViewController: BaseNavViewController {

private var isDataLoaded = false

var selectedIndexPath: IndexPath?
var selectedIndexPath: ObservablePattern<IndexPath> = ObservablePattern(nil)

private var isLoading = false

Expand All @@ -48,6 +48,7 @@ class PhotoCollectionViewController: BaseNavViewController {
addTarget()
registerCell()
bindViewModel()
bindSelectedIndexPath()
setDelegate()
}

Expand Down Expand Up @@ -100,7 +101,7 @@ private extension PhotoCollectionViewController {

@objc
func goToPhotoSelectionVC() {
albumViewModel.getHighQualityImage(index: selectedIndexPath?.item ?? 0) { [weak self] image in
albumViewModel.getHighQualityImage(index: selectedIndexPath.value?.item ?? 0) { [weak self] image in
let vc = PhotoSelectionViewController(image)
DispatchQueue.main.async {
self?.navigationController?.pushViewController(vc, animated: true)
Expand All @@ -124,6 +125,12 @@ private extension PhotoCollectionViewController {
}
}

func bindSelectedIndexPath() {
self.selectedIndexPath.bind { [weak self] selectedIndexPath in
self?.rightButton.isEnabled = (selectedIndexPath == nil) ? false : true
}
}

}


Expand Down Expand Up @@ -166,14 +173,15 @@ extension PhotoCollectionViewController: UICollectionViewDelegateFlowLayout {
}

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if let previousIndexPath = selectedIndexPath {
if let previousIndexPath = selectedIndexPath.value {
// NOTE: deselectItem 메소드 사용 시 가끔 오류
if let cell = collectionView.cellForItem(at: previousIndexPath) as? PhotoCollectionViewCell {
cell.isSelected = false
selectedIndexPath.value = nil
}
}

selectedIndexPath = indexPath
selectedIndexPath.value = indexPath
if let cell = collectionView.cellForItem(at: indexPath) as? PhotoCollectionViewCell {
cell.isSelected = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ class ProfileGoogleAdView: BaseView {
private let adButton = ACButton(style: GlassButton(glassmorphismType: .buttonGlassDefault, buttonType: .full_14_b1R), title: "광고")

private let headlineLabel = UILabel()

private let bodyLabel = UILabel()

private let iconImageView = UIImageView()


private let mediaView = MediaView()

private let callToActionButton = ACButton(style: GlassButton(glassmorphismType: .buttonGlassDefault, buttonType: .full_10_b1SB))
Expand Down Expand Up @@ -68,19 +64,22 @@ class ProfileGoogleAdView: BaseView {
}

adButton.snp.makeConstraints {
$0.top.trailing.equalToSuperview().inset(ScreenUtils.horizontalInset)
$0.top.leading.equalToSuperview().inset(10)
$0.width.equalTo(48)
$0.height.equalTo(28)
}

headlineLabel.snp.makeConstraints {
$0.top.leading.equalTo(ScreenUtils.horizontalInset)
$0.width.equalTo(210)
$0.height.equalTo(24)
$0.top.equalToSuperview().inset(46)
$0.leading.equalToSuperview().inset(10)
$0.width.equalTo(158)
$0.height.equalTo(48)
}

mediaView.snp.makeConstraints {
$0.edges.equalToSuperview()
$0.verticalEdges.trailing.equalToSuperview().inset(10)
$0.height.equalTo(120)
$0.width.equalTo(140*ScreenUtils.widthRatio)
}
}

Expand All @@ -96,7 +95,6 @@ class ProfileGoogleAdView: BaseView {
skeletonView.isHidden = true

mediaView.do {
$0.layer.cornerRadius = 8
$0.clipsToBounds = true
}

Expand Down Expand Up @@ -140,7 +138,7 @@ extension ProfileGoogleAdView {
skeletonView.isHidden = true

if let headline = nativeAd.headline {
headlineLabel.setLabel(text: headline, style: .t4SB)
headlineLabel.setLabel(text: headline, style: .t4SB, numberOfLines: 0)
headlineLabel.isHidden = false
} else {
headlineLabel.isHidden = true
Expand Down
6 changes: 3 additions & 3 deletions ACON-iOS/ACON-iOS/Presentation/Profile/View/ProfileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ final class ProfileView: BaseView {
}

googleAdView.snp.makeConstraints {
$0.top.equalToSuperview().offset(423*ScreenUtils.heightRatio)
$0.horizontalEdges.equalToSuperview().inset(20*ScreenUtils.widthRatio)
$0.height.equalTo(125*ScreenUtils.heightRatio)
$0.top.equalToSuperview().offset(431*ScreenUtils.heightRatio)
$0.horizontalEdges.equalToSuperview().inset(ScreenUtils.horizontalInset)
$0.height.equalTo(140*ScreenUtils.heightRatio)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,20 @@ class SpotListGoogleAdCollectionViewCell: BaseCollectionViewCell {

headlineLabel.snp.makeConstraints {
$0.top.leading.equalTo(edge)
$0.width.equalTo(210)
$0.width.equalTo(250)
$0.height.equalTo(24)
}

bodyLabel.snp.makeConstraints {
$0.bottom.equalToSuperview().inset(76*ScreenUtils.heightRatio)
$0.horizontalEdges.equalToSuperview().inset(edge)
$0.height.equalTo(40)
$0.height.equalTo(60)
}

mediaView.snp.makeConstraints {
$0.edges.equalToSuperview()
$0.top.equalToSuperview().inset(104*ScreenUtils.heightRatio)
$0.horizontalEdges.equalToSuperview()
$0.height.equalTo(212*ScreenUtils.heightRatio)
}

callToActionButton.snp.makeConstraints {
Expand Down