Skip to content

Commit

Permalink
refactor(iosApp): use koin for dependency injection of shared classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
GerardPaligot committed Jan 8, 2024
1 parent 6dcc707 commit f62d030
Show file tree
Hide file tree
Showing 57 changed files with 165 additions and 209 deletions.
20 changes: 5 additions & 15 deletions iosApp/iosApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
D5AE1BE727D18B7E005849B4 /* UserItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5AE1BE627D18B7E005849B4 /* UserItemView.swift */; };
D5AEA3A928341C630023245B /* FirebaseAnalytics in Frameworks */ = {isa = PBXBuildFile; productRef = D5AEA3A828341C630023245B /* FirebaseAnalytics */; };
D5AEA3AB28341C630023245B /* FirebaseCrashlytics in Frameworks */ = {isa = PBXBuildFile; productRef = D5AEA3AA28341C630023245B /* FirebaseCrashlytics */; };
D5B6D47D29983D4C0056EA02 /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B6D47C29983D4C0056EA02 /* Configuration.swift */; };
D5BC483229B0CC98002CC517 /* ViewModelFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5BC483129B0CC98002CC517 /* ViewModelFactory.swift */; };
D5C1B3BB29F26D9E00D94391 /* BundleExt.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5C1B3BA29F26D9E00D94391 /* BundleExt.swift */; };
D5C753292975E7BC00E2FD0B /* EventListVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5C753282975E7BC00E2FD0B /* EventListVM.swift */; };
Expand All @@ -92,7 +91,6 @@
D5CAA6512821BCC7005BB242 /* RemoteImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5CAA6502821BCC7005BB242 /* RemoteImage.swift */; };
D5D5ABF5282071D2004E2F78 /* ShareSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5D5ABF4282071D2004E2F78 /* ShareSheetView.swift */; };
D5D6166C27B15C7400C59EC9 /* AgendaViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5D6166B27B15C7400C59EC9 /* AgendaViewModel.swift */; };
D5F324A327C6E2DE007CA4C1 /* QrCodeGeneratoriOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5F324A227C6E2DE007CA4C1 /* QrCodeGeneratoriOS.swift */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -169,7 +167,6 @@
D59EFCB927B5AE25000AADCF /* EventVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventVM.swift; sourceTree = "<group>"; };
D5AA380929B2206C00E1A5D4 /* TalkItemNavigation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TalkItemNavigation.swift; sourceTree = "<group>"; };
D5AE1BE627D18B7E005849B4 /* UserItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserItemView.swift; sourceTree = "<group>"; };
D5B6D47C29983D4C0056EA02 /* Configuration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Configuration.swift; sourceTree = "<group>"; };
D5BC483129B0CC98002CC517 /* ViewModelFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewModelFactory.swift; sourceTree = "<group>"; };
D5C1B3BA29F26D9E00D94391 /* BundleExt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BundleExt.swift; sourceTree = "<group>"; };
D5C753282975E7BC00E2FD0B /* EventListVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventListVM.swift; sourceTree = "<group>"; };
Expand All @@ -188,7 +185,6 @@
D5D5ABF328207025004E2F78 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };
D5D5ABF4282071D2004E2F78 /* ShareSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareSheetView.swift; sourceTree = "<group>"; };
D5D6166B27B15C7400C59EC9 /* AgendaViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgendaViewModel.swift; sourceTree = "<group>"; };
D5F324A227C6E2DE007CA4C1 /* QrCodeGeneratoriOS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QrCodeGeneratoriOS.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -248,7 +244,6 @@
D58F1D5227B0054E00FB59C7 /* theming */,
2152FB032600AC8F00CF470E /* iOSApp.swift */,
D5BC483129B0CC98002CC517 /* ViewModelFactory.swift */,
D5B6D47C29983D4C0056EA02 /* Configuration.swift */,
7555FF8C242A565B00829871 /* Info.plist */,
058557BA273AAA24004C7B11 /* Assets.xcassets */,
D58F1D5027B001CE00FB59C7 /* Colors.xcassets */,
Expand Down Expand Up @@ -546,7 +541,6 @@
D5F324A127C6E2C6007CA4C1 /* data */ = {
isa = PBXGroup;
children = (
D5F324A227C6E2DE007CA4C1 /* QrCodeGeneratoriOS.swift */,
D538BED62954F6B700F25CBE /* AlarmScheduler.swift */,
);
path = data;
Expand Down Expand Up @@ -661,7 +655,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "cd \"$SRCROOT/..\"\n./gradlew :shared:core:embedAndSignAppleFrameworkForXcode\n";
shellScript = "cd \"$SRCROOT/..\"\n./gradlew :shared:core-di:embedAndSignAppleFrameworkForXcode\n";
};
D50BB94829BCAD5C00AB9C56 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -734,7 +728,6 @@
D5D5ABF5282071D2004E2F78 /* ShareSheetView.swift in Sources */,
D524D73C27BBFC530078DF0D /* ScheduleDetail.swift in Sources */,
D567C00B29B4D6B700D427D6 /* ProfileItemView.swift in Sources */,
D5F324A327C6E2DE007CA4C1 /* QrCodeGeneratoriOS.swift in Sources */,
D52F3B9A2961CDCC00535233 /* ViewExt.swift in Sources */,
D5C92ECF283ACE6000D5CF2D /* MenusViewModel.swift in Sources */,
D563E2EA29755B2700B5FCA0 /* EventListView.swift in Sources */,
Expand All @@ -758,7 +751,6 @@
D5AA380A29B2206C00E1A5D4 /* TalkItemNavigation.swift in Sources */,
D5C753302975F73700E2FD0B /* AppView.swift in Sources */,
D55D7A75295F83D9008EA04B /* PartnerDetailView.swift in Sources */,
D5B6D47D29983D4C0056EA02 /* Configuration.swift in Sources */,
7555FF83242A565900829871 /* HomeView.swift in Sources */,
D57028AD27B5535F008EF4AD /* Event.swift in Sources */,
);
Expand Down Expand Up @@ -901,13 +893,12 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
BASE_URL = "https://cms4partners-ce427.nw.r.appspot.com";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2001;
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
DEVELOPMENT_TEAM = DU6582MPLT;
ENABLE_PREVIEWS = YES;
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../shared/core/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)";
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../shared/core-di/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)";
INFOPLIST_FILE = iosApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -919,7 +910,7 @@
"$(inherited)",
"-lsqlite3",
"-framework",
shared,
SharedDi,
);
PRODUCT_BUNDLE_IDENTIFIER = org.gdglille.devfest.ios.debug;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -935,13 +926,12 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
BASE_URL = "https://cms4partners-ce427.nw.r.appspot.com";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2001;
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
DEVELOPMENT_TEAM = DU6582MPLT;
ENABLE_PREVIEWS = YES;
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../shared/core/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)";
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../shared/core-di/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)";
INFOPLIST_FILE = iosApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -953,7 +943,7 @@
"$(inherited)",
"-lsqlite3",
"-framework",
shared,
SharedDi,
);
PRODUCT_BUNDLE_IDENTIFIER = org.gdglille.devfest.ios;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Binary file not shown.
77 changes: 21 additions & 56 deletions iosApp/iosApp/ViewModelFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,86 +7,51 @@
//

import Foundation
import shared
import SharedDi

@MainActor
class ViewModelFactory: ObservableObject {
private var agendaRepository: AgendaRepository
private var userRepository: UserRepository
private var eventRepository: EventRepository

init(isDebug: Bool = false) {
let platform = Platform(context: IOSContext())
let db = DatabaseWrapper().createDb()
let api = ConferenceApi.companion.create(
platform: platform,
baseUrl: Configuration.baseURL.absoluteString,
acceptLanguage: Locale.preferredLanguages[0],
enableNetworkLogs: isDebug
)
let settings = AppleSettings(delegate: UserDefaults.standard)
self.agendaRepository = AgendaRepositoryImpl(
api: api,
scheduleDao: ScheduleDao(db: db, settings: settings, platform: platform),
speakerDao: SpeakerDao(db: db, platform: platform),
talkDao: TalkDao(db: db, platform: platform),
eventDao: EventDao(db: db, settings: settings),
partnerDao: PartnerDao(db: db, platform: platform),
featuresDao: FeaturesActivatedDao(db: db, settings: settings),
qrCodeGenerator: QrCodeGeneratoriOS()
)
self.userRepository = UserRepositoryImpl(
userDao: UserDao(db: db, platform: platform),
eventDao: EventDao(db: db, settings: settings),
qrCodeGenerator: QrCodeGeneratoriOS()
)
self.eventRepository = EventRepositoryImpl(
api: api,
eventDao: EventDao(db: db, settings: settings)
)
}

func makeAppViewModel() -> AppViewModel {
return AppViewModel(repository: self.eventRepository)
return AppViewModel()
}

func makeEventListViewModel() -> EventListViewModel {
return EventListViewModel(repository: self.eventRepository)
return EventListViewModel()
}

func makeHomeViewModel() -> HomeViewModel {
return HomeViewModel(repository: self.agendaRepository)
return HomeViewModel()
}

func makeAgendaViewModel() -> AgendaViewModel {
return AgendaViewModel(repository: self.agendaRepository)
return AgendaViewModel()
}

func makeScheduleItemViewModel(scheduleId: String) -> ScheduleItemViewModel {
return ScheduleItemViewModel(repository: self.agendaRepository, scheduleId: scheduleId)
return ScheduleItemViewModel(scheduleId: scheduleId)
}

func makeSpeakerViewModel(speakerId: String) -> SpeakerViewModel {
return SpeakerViewModel(repository: self.agendaRepository, speakerId: speakerId)
return SpeakerViewModel(speakerId: speakerId)
}

func makeNetworkingViewModel() -> NetworkingViewModel {
return NetworkingViewModel(repository: self.userRepository)
return NetworkingViewModel()
}

func makePartnersViewModel() -> PartnersViewModel {
return PartnersViewModel(repository: self.agendaRepository)
return PartnersViewModel()
}

func makePartnerDetailViewModel(partnerId: String) -> PartnerDetailViewModel {
return PartnerDetailViewModel(repository: self.agendaRepository, partnerId: partnerId)
return PartnerDetailViewModel(partnerId: partnerId)
}

func makeEventViewModel() -> EventViewModel {
return EventViewModel(agendaRepository: self.agendaRepository)
return EventViewModel()
}

func makeMenusViewModel() -> MenusViewModel {
return MenusViewModel(repository: self.agendaRepository)
return MenusViewModel()
}
}
2 changes: 1 addition & 1 deletion iosApp/iosApp/components/cards/AddressCardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import SwiftUI
import shared
import SharedDi

struct AddressCardView: View {
var formattedAddress: Array<String>
Expand Down
2 changes: 1 addition & 1 deletion iosApp/iosApp/components/cards/JobItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import SwiftUI
import shared
import SharedDi

struct JobItemView: View {
let jobUi: JobUi
Expand Down
2 changes: 1 addition & 1 deletion iosApp/iosApp/components/events/EventItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import SwiftUI
import shared
import SharedDi

struct EventItemView: View {
var item: EventItemUi
Expand Down
2 changes: 1 addition & 1 deletion iosApp/iosApp/components/menus/MenuItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import SwiftUI
import shared
import SharedDi
import MapKit

struct MenuItemView: View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import SwiftUI
import shared
import SharedDi

struct SpeakerAvatarBorderedView: View {
var url: String
Expand Down
2 changes: 1 addition & 1 deletion iosApp/iosApp/components/speakers/SpeakerAvatarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import SwiftUI
import shared
import SharedDi

extension CGFloat {
public static let small: CGFloat = 30
Expand Down
2 changes: 1 addition & 1 deletion iosApp/iosApp/components/speakers/SpeakerItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import SwiftUI
import shared
import SharedDi

struct SpeakerItemView: View {
var speakerUi: SpeakerItemUi
Expand Down
2 changes: 1 addition & 1 deletion iosApp/iosApp/components/speakers/SpeakersAvatarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import SwiftUI
import shared
import SharedDi

struct SpeakersAvatarView: View {
var speakers: Array<String>
Expand Down
2 changes: 1 addition & 1 deletion iosApp/iosApp/components/structures/RemoteImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import SwiftUI
import shared
import SharedDi
import SDWebImageSwiftUI

struct RemoteImage: View {
Expand Down
2 changes: 1 addition & 1 deletion iosApp/iosApp/components/structures/SocialHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import SwiftUI
import WrappingHStack
import shared
import SharedDi

struct SocialHeaderView: View {
var title: String
Expand Down
2 changes: 1 addition & 1 deletion iosApp/iosApp/components/tags/DecorativeTagView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import SwiftUI
import shared
import SharedDi

struct DecorativeTagView: View {
var category: CategoryUi
Expand Down
2 changes: 1 addition & 1 deletion iosApp/iosApp/components/talks/TalkItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import SwiftUI
import shared
import SharedDi

struct TalkItemView: View {
var talk: TalkItemUi
Expand Down
2 changes: 1 addition & 1 deletion iosApp/iosApp/components/talks/TalkSectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import SwiftUI
import shared
import SharedDi

struct TalkSectionView: View {
var talkUi: TalkUi
Expand Down
2 changes: 1 addition & 1 deletion iosApp/iosApp/components/tickets/TicketDetailedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import SwiftUI
import shared
import SharedDi

struct TicketDetailedView: View {
var ticket: TicketInfoUi
Expand Down
2 changes: 1 addition & 1 deletion iosApp/iosApp/components/users/ProfileInputView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import SwiftUI
import shared
import SharedDi

struct ProfileInputView: View {
@State var email: String = ""
Expand Down
2 changes: 1 addition & 1 deletion iosApp/iosApp/components/users/ProfileItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import SwiftUI
import shared
import SharedDi

struct ProfileItemView: View {
let profileUi: UserProfileUi
Expand Down
2 changes: 1 addition & 1 deletion iosApp/iosApp/components/users/UserItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import SwiftUI
import shared
import SharedDi

struct UserItemView: View {
@State private var showingAlert = false
Expand Down
8 changes: 2 additions & 6 deletions iosApp/iosApp/data/AlarmScheduler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@
//

import SwiftUI
import shared
import SharedDi

class AlarmScheduler {
let repository: AgendaRepository

init(repository: AgendaRepository) {
self.repository = repository
}
private let repository: AgendaRepository = RepositoryHelper().agendaRepository

func schedule(talkItem: TalkItemUi) async {
let scheduleId = talkItem.id
Expand Down
Loading

0 comments on commit f62d030

Please sign in to comment.