diff --git a/Sources/OversizeAdsKit/AdView.swift b/Sources/OversizeAdsKit/AdView.swift index 9a6f650..2cff439 100644 --- a/Sources/OversizeAdsKit/AdView.swift +++ b/Sources/OversizeAdsKit/AdView.swift @@ -24,58 +24,7 @@ public struct AdView: View { Surface { isShowProduct.toggle() } label: { - HStack(spacing: .zero) { - AsyncImage(url: URL(string: "\(Info.links?.company.cdnString ?? "")/assets/apps/\(viewModel.appAd?.path ?? "")/icon.png"), content: { - $0 - .resizable() - .frame(width: 64, height: 64) - .mask(RoundedRectangle(cornerRadius: .large, - style: .continuous)) - .overlay( - RoundedRectangle(cornerRadius: 16, - style: .continuous) - .stroke(lineWidth: 1) - .opacity(0.15) - ) - .onTapGesture { - isShowProduct.toggle() - } - - }, placeholder: { - RoundedRectangle(cornerRadius: .large, style: .continuous) - .fillSurfaceSecondary() - .frame(width: 64, height: 64) - }) - - VStack(alignment: .leading, spacing: .xxxSmall) { - HStack { - Text(viewModel.appAd?.name ?? "") - .subheadline(.bold) - .onSurfaceHighEmphasisForegroundColor() - - Bage(color: .warning) { - Text("Our app") - .bold() - } - } - - Text(viewModel.appAd?.title ?? "") - .subheadline() - .onSurfaceMediumEmphasisForegroundColor() - } - .padding(.leading, .xSmall) - - Spacer() - - Button("Get") { - isShowProduct.toggle() - } - .buttonStyle(.tertiary) - .controlBorderShape(.capsule) - .controlSize(.small) - .padding(.trailing, .xxxSmall) - .loading(isShowProduct) - } + premiumBanner } .surfaceContentInsets(.xSmall) .appStoreOverlay(isPresent: $isShowProduct, appId: viewModel.appAd?.id ?? "") @@ -84,6 +33,61 @@ public struct AdView: View { #endif } } + + var premiumBanner: some View { + HStack(spacing: .zero) { + AsyncImage(url: URL(string: "\(Info.links?.company.cdnString ?? "")/assets/apps/\(viewModel.appAd?.path ?? "")/icon.png"), content: { + $0 + .resizable() + .frame(width: 64, height: 64) + .mask(RoundedRectangle(cornerRadius: .large, + style: .continuous)) + .overlay( + RoundedRectangle(cornerRadius: 16, + style: .continuous) + .stroke(lineWidth: 1) + .opacity(0.15) + ) + .onTapGesture { + isShowProduct.toggle() + } + + }, placeholder: { + RoundedRectangle(cornerRadius: .large, style: .continuous) + .fillSurfaceSecondary() + .frame(width: 64, height: 64) + }) + + VStack(alignment: .leading, spacing: .xxxSmall) { + HStack { + Text(viewModel.appAd?.name ?? "") + .subheadline(.bold) + .onSurfaceHighEmphasisForegroundColor() + + Bage(color: .warning) { + Text("Our app") + .bold() + } + } + + Text(viewModel.appAd?.title ?? "") + .subheadline() + .onSurfaceMediumEmphasisForegroundColor() + } + .padding(.leading, .xSmall) + + Spacer() + + Button("Get") { + isShowProduct.toggle() + } + .buttonStyle(.tertiary) + .controlBorderShape(.capsule) + .controlSize(.small) + .padding(.trailing, .xxxSmall) + .loading(isShowProduct) + } + } } struct AdView_Previews: PreviewProvider { diff --git a/Sources/OversizeAdsKit/AdViewModel.swift b/Sources/OversizeAdsKit/AdViewModel.swift index 7e42b35..ad0ee09 100644 --- a/Sources/OversizeAdsKit/AdViewModel.swift +++ b/Sources/OversizeAdsKit/AdViewModel.swift @@ -10,7 +10,7 @@ import SwiftUI @MainActor public class AdViewModel: ObservableObject { - @Published var appAd = Info.all?.apps.filter { $0.id != Info.app.appStoreID }.randomElement() + let appAd = Info.all?.apps.filter { $0.id != Info.app.appStoreID }.randomElement() /* @Injected(\.networkService) var networkService