Skip to content

Commit

Permalink
Update AdView
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanov91 committed Jul 3, 2023
1 parent 449fd85 commit 1c984fe
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 53 deletions.
108 changes: 56 additions & 52 deletions Sources/OversizeAdsKit/AdView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? "")
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Sources/OversizeAdsKit/AdViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1c984fe

Please sign in to comment.