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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ GoogleService-Info.plist
### Sensitive Data ###
DevelopmentEndpoint.swift
ProductionEndpoint.swift
DevelopmentAdsService.swift
ProductionAdsService.swift

### Projects ###
*.xcodeproj
Expand Down
29 changes: 28 additions & 1 deletion .package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "34724f4ec037b9f40a821de88ecf11d541e22e538ad65946bfc2556846216f32",
"originHash" : "979c4fb83e47a264cb81aaa5fc13729f0ec12b28107f097b15efbd708794e5f4",
"pins" : [
{
"identity" : "abseil-cpp-binary",
Expand Down Expand Up @@ -109,6 +109,15 @@
"version" : "1.22.5"
}
},
{
"identity" : "lottie-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/airbnb/lottie-ios",
"state" : {
"revision" : "047aa81b77adcbf583a966dfef620d17650cc656",
"version" : "4.5.1"
}
},
{
"identity" : "nanopb",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -145,6 +154,24 @@
"version" : "1.5.0"
}
},
{
"identity" : "swift-package-manager-google-mobile-ads",
"kind" : "remoteSourceControl",
"location" : "https://github.com/googleads/swift-package-manager-google-mobile-ads",
"state" : {
"revision" : "7778cc1ab037c10dbbe026959e51e616bd961be9",
"version" : "11.13.0"
}
},
{
"identity" : "swift-package-manager-google-user-messaging-platform",
"kind" : "remoteSourceControl",
"location" : "https://github.com/googleads/swift-package-manager-google-user-messaging-platform.git",
"state" : {
"revision" : "708a282840c2171ee63bd93b87afa49fe507d70e",
"version" : "2.7.0"
}
},
{
"identity" : "swift-protobuf",
"kind" : "remoteSourceControl",
Expand Down
28 changes: 20 additions & 8 deletions ModularPlugin/ProjectDescriptionHelpers/ExternalPackages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,34 @@ public struct ExternalPackages {
return .package(product: "ConfettiSwiftUI", type: .runtime)
}

public static var Lottie: TargetDependency {
return .package(product: "Lottie", type: .runtime)
}

public static var ToastUI: TargetDependency {
return .package(product: "ToastUI", type: .runtime)
}
}

public struct Firebase {
public static var Core: TargetDependency {
return .package(product: "FirebaseCore", type: .runtime)
}
public struct Google {

public static var Analytics: TargetDependency {
return .package(product: "FirebaseAnalytics", type: .runtime)
public struct Firebase {
public static var Core: TargetDependency {
return .package(product: "FirebaseCore", type: .runtime)
}

public static var Analytics: TargetDependency {
return .package(product: "FirebaseAnalytics", type: .runtime)
}

public static var Crashlytics: TargetDependency {
return .package(product: "FirebaseCrashlytics", type: .runtime)
}
}

public static var Crashlytics: TargetDependency {
return .package(product: "FirebaseCrashlytics", type: .runtime)
public static var MobileAds: TargetDependency {
return .package(product: "GoogleMobileAds", type: .runtime)
}

}
}
1 change: 1 addition & 0 deletions ModularPlugin/ProjectDescriptionHelpers/Presentation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ extension PresentationLayer {
case UIExtensions
case Resources
case Toast
case MobileAds
case Main
case PlaceDetail
case ReportSurcharge
Expand Down
25 changes: 25 additions & 0 deletions ModularPlugin/ProjectDescriptionHelpers/Shared.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ extension Shared {
case AppStatusServiceProtocol
case ViewUpdateService
case ViewUpdateServiceProtocol
case ProductionAdsService
case DevelopmentAdsService
case AdsServiceProtocol
}
}

Expand All @@ -42,10 +45,32 @@ public extension Shared.Services {
return "\(parent.path)/Shared/Services/AppStatus/\(name)"
case .ViewUpdateService, .ViewUpdateServiceProtocol:
return "\(parent.path)/Shared/Services/ViewUpdate/\(name)"
case .ProductionAdsService, .DevelopmentAdsService, .AdsServiceProtocol:
return "\(parent.path)/Shared/Services/Ads/\(name)"
}
}

var parent: Workspace {
return Surcharges.Surcharges
}
}

extension Shared {
public enum Google: Project {
case FirebaseSDKs
}
}

public extension Shared.Google {
var name: String {
return String(describing: self)
}

var path: String {
return "\(parent.path)/Shared/Google/\(name)"
}

var parent: Workspace {
return Surcharges.Surcharges
}
}
31 changes: 21 additions & 10 deletions Surcharges/Applications/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ func getDependencies(_ config: Configuration) -> [TargetDependency] {
PresentationLayer.UIs.ReportSurcharge,
PresentationLayer.UIs.SurchargeStatusHelp,
PresentationLayer.UIs.Toast,
Shared.Google.FirebaseSDKs,
]

switch config {
case .dev:
projects.append(DataSource.DevelopmentEndpoint)
projects.append(Shared.Services.DevelopmentAdsService)
case .prod:
projects.append(DataSource.ProductionEndpoint)
projects.append(Shared.Services.ProductionAdsService)
}

return projects.map {
Expand All @@ -41,9 +44,7 @@ let developmentDependencies: [TargetDependency] = getDependencies(.dev)

// MARK: External Dependencies
let externalDependencies: [TargetDependency] = [
ExternalPackages.Firebase.Core,
ExternalPackages.Firebase.Analytics,
ExternalPackages.Firebase.Crashlytics,

]

// MARK: Target - Infomation
Expand All @@ -54,16 +55,16 @@ let baseSetting = SettingsDictionary()
.swiftVersion("6.0")
.bitcodeEnabled(false)
.marketingVersion(appVersion)
.otherLinkerFlags(["-ObjC"])
.automaticCodeSigning(devTeam: developmentTeam)

let debugSetting = SettingsDictionary()

let releaseSetting = SettingsDictionary()

// MARK: Plist
let infoPlist: InfoPlist = .extendingDefault(
with: [
func getInfoPlist(_ config: Configuration, appVersion: String) -> InfoPlist {

var infoPlist: [String: Plist.Value] = [
"UILaunchScreen": [
"UIColorName": "",
"UIImageName": "",
Expand All @@ -73,9 +74,19 @@ let infoPlist: InfoPlist = .extendingDefault(
"NSLocationWhenInUseUsageDescription": .string("Surcharges uses your location to provide nearest places to you."),
"NSCameraUsageDescription": .string("Surcharges uses your camera to take your receipt."),
"ITSAppUsesNonExemptEncryption": .boolean(false),
"UISupportedInterfaceOrientations": .array([.string("UIInterfaceOrientationPortrait")])
"UISupportedInterfaceOrientations": .array([.string("UIInterfaceOrientationPortrait")]),
]
)

switch config {
case .dev:
infoPlist.updateValue(.string("ca-app-pub-2719055739020811~8730306210"), forKey: "GADApplicationIdentifier")
case .prod:
infoPlist.updateValue(.string("ca-app-pub-2719055739020811~5366340920"), forKey: "GADApplicationIdentifier")
}

return .extendingDefault(with: infoPlist)

}

// MARK: Target - Prod
let surcharges = Target.target(
Expand All @@ -84,7 +95,7 @@ let surcharges = Target.target(
product: .app,
bundleId: "nz.surcharges",
deploymentTargets: .iOS("17.0"),
infoPlist: infoPlist,
infoPlist: getInfoPlist(.prod, appVersion: appVersion),
sources: ["Sources/Commons/**", "Sources/Prod/**"],
resources: .resources(
[
Expand Down Expand Up @@ -112,7 +123,7 @@ let surchargesDev = Target.target(
product: .app,
bundleId: "nz.surcharges.development",
deploymentTargets: .iOS("17.0"),
infoPlist: infoPlist,
infoPlist: getInfoPlist(.dev, appVersion: appVersion),
sources: ["Sources/Commons/**", "Sources/Dev/**"],
resources: .resources(
[
Expand Down
3 changes: 3 additions & 0 deletions Surcharges/Applications/Sources/Commons/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
//

import UIKit

import FirebaseCore
import GoogleMobileAds

final class AppDelegate: NSObject, UIApplicationDelegate {
func application(
_ application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil
) -> Bool {
FirebaseApp.configure()
GADMobileAds.sharedInstance().start(completionHandler: nil)
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ import Factories
import AppStatusService
import LocationService
import ViewUpdateService
import AdsServiceProtocol

// Endpoint
import EndpointProtocol

public struct SurchargeAppView<Endpoint: EndpointProtocol>: View {
public struct SurchargeAppView<Endpoint: EndpointProtocol, AdsService: AdsServiceProtocol>: View {

@StateObject private var _mainRouter = MainRouter()
@StateObject private var _placeDetailRouter = PlaceDetailRouter()
Expand All @@ -55,7 +56,7 @@ public struct SurchargeAppView<Endpoint: EndpointProtocol>: View {

NavigationStack {

MainView(
MainView<MainFactory<Endpoint>.ViewModel, MainRouter, AdsService>(
viewModel: _mainFactory.resolve(appStatusService: _appStatusService),
router: _mainRouter
)
Expand Down
3 changes: 2 additions & 1 deletion Surcharges/Applications/Sources/Dev/SurchargesApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import SwiftUI

import DevelopmentEndpoint
import DevelopmentAdsService

@main
struct SurchargesApp: App {
Expand All @@ -20,7 +21,7 @@ struct SurchargesApp: App {
var body: some Scene {
WindowGroup {

SurchargeAppView<DevelopmentEndpoint>()
SurchargeAppView<DevelopmentEndpoint, DevelopmentAdsService>()

}
}
Expand Down
3 changes: 2 additions & 1 deletion Surcharges/Applications/Sources/Prod/SurchargesApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import SwiftUI

import ProductionEndpoint
import ProductionAdsService

@main
struct SurchargesApp: App {
Expand All @@ -20,7 +21,7 @@ struct SurchargesApp: App {
var body: some Scene {
WindowGroup {

SurchargeAppView<ProductionEndpoint>()
SurchargeAppView<ProductionEndpoint, ProductionAdsService>()

}
}
Expand Down
7 changes: 5 additions & 2 deletions Surcharges/PresentationLayer/UIs/Main/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@ let target = surcharges.target(
PresentationLayer.ViewModelProtocols,
PresentationLayer.UIs.CommonUI,
PresentationLayer.Routers.RouterProtocols,
PresentationLayer.UIs.MobileAds,
Shared.Services.AdsServiceProtocol,
],
externalPackages:
externalPackages:
[

]
]
)

let demo = surcharges.demo(
projects: [
Builder.Factories,
DataSource.DevelopmentEndpoint,
Shared.Services.DevelopmentAdsService,
PresentationLayer.Routers.MainRouter,
PresentationLayer.UIs.Main,
PresentationLayer.UIs.SurchargeStatusHelp,
Expand Down
20 changes: 17 additions & 3 deletions Surcharges/PresentationLayer/UIs/Main/Sources/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ import TipKit

import Resources
import CommonUI
import MobileAds

import ViewModelProtocols
import RouterProtocols
import AdsServiceProtocol

public struct MainView<VM: MainViewModelProtocol, Router: MainRouterProtocol>: View {
public struct MainView<VM: MainViewModelProtocol, Router: MainRouterProtocol, AdsService: AdsServiceProtocol>: View {

@StateObject private var _viewModel: VM
@StateObject private var _router: Router
@StateObject private var _adsService: AdsService = AdsService()

private let _surchargeStatusTip = SurchargeStatusTip()
private let _useLocationTip = UseLocationTip()
Expand Down Expand Up @@ -71,6 +74,10 @@ public struct MainView<VM: MainViewModelProtocol, Router: MainRouterProtocol>: V

if _viewModel.noResults {

if _adsService.isShowingAds {
ListAdsView(unitId: _adsService.listBannerUnitId)
}

NoResultView(searchedText: _viewModel.searchedText)
.padding(.top, 40)
.padding([.leading, .trailing], 20)
Expand All @@ -79,6 +86,10 @@ public struct MainView<VM: MainViewModelProtocol, Router: MainRouterProtocol>: V

if !_viewModel.mainModel.places.isEmpty {

if _adsService.isShowingAds {
ListAdsView(unitId: _adsService.listBannerUnitId)
}

Section {
PlacesView(
mainModel: $_viewModel.mainModel,
Expand All @@ -93,8 +104,7 @@ public struct MainView<VM: MainViewModelProtocol, Router: MainRouterProtocol>: V
)

} header: {
Text(R.string.localizable.searchFor(_viewModel.searchedText))
.font(.title3)
Text("🔎\(R.string.localizable.searchFor(_viewModel.searchedText))")
.blurBackground()
}

Expand All @@ -104,6 +114,10 @@ public struct MainView<VM: MainViewModelProtocol, Router: MainRouterProtocol>: V
.padding(.top, 40)
.padding([.leading, .trailing], 20)

FixedAdsView(isAdShowing: $_adsService.isShowingAds, unitId: _adsService.fixedBannerUnitId)
.padding(.top, 20)
.padding([.leading, .trailing], 20)

}
}
}
Expand Down
Loading
Loading