Skip to content

Commit

Permalink
IOS-2560 Migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
mgolovko committed Mar 27, 2024
1 parent a793a7f commit e6be24b
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 119 deletions.
8 changes: 0 additions & 8 deletions Anytype.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -688,10 +688,8 @@
2AC429A629B784280002AD05 /* BaseDocumentProtocol+Home.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AC429A529B784280002AD05 /* BaseDocumentProtocol+Home.swift */; };
2AC434972B7A0683006166BF /* SpaceShareView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AC434962B7A0683006166BF /* SpaceShareView.swift */; };
2AC434992B7A068B006166BF /* SpaceShareViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AC434982B7A068B006166BF /* SpaceShareViewModel.swift */; };
2AC4349B2B7A0697006166BF /* SpaceShareModuleAssembly.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AC4349A2B7A0697006166BF /* SpaceShareModuleAssembly.swift */; };
2AC4349E2B7A074B006166BF /* SpaceShareCoordinatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AC4349D2B7A074B006166BF /* SpaceShareCoordinatorView.swift */; };
2AC434A02B7A0759006166BF /* SpaceShareCoordinatorViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AC4349F2B7A0759006166BF /* SpaceShareCoordinatorViewModel.swift */; };
2AC434A22B7A0763006166BF /* SpaceShareCoordinatorAssembly.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AC434A12B7A0763006166BF /* SpaceShareCoordinatorAssembly.swift */; };
2AC434AA2B7A15B9006166BF /* SpaceShareParticipantView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AC434A92B7A15B9006166BF /* SpaceShareParticipantView.swift */; };
2AC434AC2B7A1D17006166BF /* CommonError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AC434AB2B7A1D17006166BF /* CommonError.swift */; };
2AC434B02B7A20EF006166BF /* Participant+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AC434AF2B7A20EF006166BF /* Participant+Extensions.swift */; };
Expand Down Expand Up @@ -2484,10 +2482,8 @@
2AC434942B7A0100006166BF /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = nl; path = nl.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
2AC434962B7A0683006166BF /* SpaceShareView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpaceShareView.swift; sourceTree = "<group>"; };
2AC434982B7A068B006166BF /* SpaceShareViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpaceShareViewModel.swift; sourceTree = "<group>"; };
2AC4349A2B7A0697006166BF /* SpaceShareModuleAssembly.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpaceShareModuleAssembly.swift; sourceTree = "<group>"; };
2AC4349D2B7A074B006166BF /* SpaceShareCoordinatorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpaceShareCoordinatorView.swift; sourceTree = "<group>"; };
2AC4349F2B7A0759006166BF /* SpaceShareCoordinatorViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpaceShareCoordinatorViewModel.swift; sourceTree = "<group>"; };
2AC434A12B7A0763006166BF /* SpaceShareCoordinatorAssembly.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpaceShareCoordinatorAssembly.swift; sourceTree = "<group>"; };
2AC434A92B7A15B9006166BF /* SpaceShareParticipantView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpaceShareParticipantView.swift; sourceTree = "<group>"; };
2AC434AB2B7A1D17006166BF /* CommonError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonError.swift; sourceTree = "<group>"; };
2AC434AF2B7A20EF006166BF /* Participant+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Participant+Extensions.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6546,7 +6542,6 @@
2AC434A82B7A15AD006166BF /* Subviews */,
2AC434962B7A0683006166BF /* SpaceShareView.swift */,
2AC434982B7A068B006166BF /* SpaceShareViewModel.swift */,
2AC4349A2B7A0697006166BF /* SpaceShareModuleAssembly.swift */,
);
path = SpaceShare;
sourceTree = "<group>";
Expand All @@ -6556,7 +6551,6 @@
children = (
2AC4349D2B7A074B006166BF /* SpaceShareCoordinatorView.swift */,
2AC4349F2B7A0759006166BF /* SpaceShareCoordinatorViewModel.swift */,
2AC434A12B7A0763006166BF /* SpaceShareCoordinatorAssembly.swift */,
);
path = SpaceShareCoordinator;
sourceTree = "<group>";
Expand Down Expand Up @@ -11508,7 +11502,6 @@
2E2D256028880C8D00E3DFD1 /* SetFiltersContentViewBuilder.swift in Sources */,
C93B2D32274E4FA70008544D /* TwoStandardButtonsView.swift in Sources */,
120E818E26A05946006FE84E /* ObjectIconPickerViewModel.swift in Sources */,
2AC434A22B7A0763006166BF /* SpaceShareCoordinatorAssembly.swift in Sources */,
2AFD7E182B626C2D003B16EB /* KeyboardDismiss.swift in Sources */,
3DB692B12697645C00149864 /* MiddlewareColorConverter.swift in Sources */,
2A5BC4BE2A78F9D9004FAABF /* SquircleIconPainter.swift in Sources */,
Expand Down Expand Up @@ -12139,7 +12132,6 @@
3D471E1F26C3B60200457DE5 /* BlockLinkState+Icon.swift in Sources */,
3DA6263D2657AB8000942249 /* AnimationExtension.swift in Sources */,
53728D00273596C40092A8CF /* MarkupAccessoryViewModel.swift in Sources */,
2AC4349B2B7A0697006166BF /* SpaceShareModuleAssembly.swift in Sources */,
1289F5A42733C50500656EC2 /* TextRelationFactory.swift in Sources */,
2AF2C6B928BD104B00F8612B /* UIAnytypeActivityIndicator.swift in Sources */,
120EB4DC26E8E94C003A0C2B /* ObjectHeaderView.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,6 @@ final class CoordinatorsDI: CoordinatorsDIProtocol {
)
}

func spaceShare() -> SpaceShareCoordinatorAssemblyProtocol {
SpaceShareCoordinatorAssembly(modulesDI: modulesDI)
}

func typeSearchForNewObject() -> TypeSearchForNewObjectCoordinatorAssemblyProtocol {
TypeSearchForNewObjectCoordinatorAssembly(
serviceLocator: serviceLocator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ protocol CoordinatorsDIProtocol: AnyObject {
func setObjectCreation() -> SetObjectCreationCoordinatorAssemblyProtocol
func serverConfiguration() -> ServerConfigurationCoordinatorAssemblyProtocol
func sharingTip() -> SharingTipCoordinatorProtocol
func spaceShare() -> SpaceShareCoordinatorAssemblyProtocol
func typeSearchForNewObject() -> TypeSearchForNewObjectCoordinatorAssemblyProtocol

// Now like a coordinator. Migrate to isolated modules
Expand Down
4 changes: 0 additions & 4 deletions Anytype/Sources/PresentationLayer/Assemblies/ModulesDI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,4 @@ final class ModulesDI: ModulesDIProtocol {
func shareOptions() -> ShareOptionsModuleAssemblyProtocol {
ShareOptionsModuleAssembly(serviceLocator: serviceLocator)
}

func spareShare() -> SpaceShareModuleAssemblyProtocol {
SpaceShareModuleAssembly(serviceLocator: serviceLocator)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,4 @@ protocol ModulesDIProtocol: AnyObject {
func serverDocumentPicker() -> ServerDocumentPickerModuleAssemblyProtocol
func sharingTip() -> SharingTipModuleAssemblyProtocol
func shareOptions() -> ShareOptionsModuleAssemblyProtocol
func spareShare() -> SpaceShareModuleAssemblyProtocol
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ final class SpaceSettingsCoordinatorAssembly: SpaceSettingsCoordinatorAssemblyPr
newSearchModuleAssembly: self.modulesDI.newSearch(),
objectTypeSearchModuleAssembly: self.modulesDI.objectTypeSearch(),
wallpaperPickerModuleAssembly: self.modulesDI.wallpaperPicker(),
spaceShareCoordinatorAssembly: self.coordinatorsDI.spaceShare(),
objectTypeProvider: self.serviceLocator.objectTypeProvider(),
urlOpener: self.uiHelpersDI.urlOpener(),
documentService: self.serviceLocator.documentService()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct SpaceSettingsCoordinatorView: View {
}
}
.sheet(isPresented: $model.showSpaceShare) {
model.spaceShareModule()
SpaceShareCoordinatorView()
}
.sheet(isPresented: $model.showSpaceMembers) {
SpaceMembersView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ final class SpaceSettingsCoordinatorViewModel: ObservableObject, SpaceSettingsMo
private let newSearchModuleAssembly: NewSearchModuleAssemblyProtocol
private let objectTypeSearchModuleAssembly: ObjectTypeSearchModuleAssemblyProtocol
private let wallpaperPickerModuleAssembly: WallpaperPickerModuleAssemblyProtocol
private let spaceShareCoordinatorAssembly: SpaceShareCoordinatorAssemblyProtocol
private let objectTypeProvider: ObjectTypeProviderProtocol
private let urlOpener: URLOpenerProtocol
private let documentService: OpenedDocumentsProviderProtocol
Expand All @@ -38,7 +37,6 @@ final class SpaceSettingsCoordinatorViewModel: ObservableObject, SpaceSettingsMo
newSearchModuleAssembly: NewSearchModuleAssemblyProtocol,
objectTypeSearchModuleAssembly: ObjectTypeSearchModuleAssemblyProtocol,
wallpaperPickerModuleAssembly: WallpaperPickerModuleAssemblyProtocol,
spaceShareCoordinatorAssembly: SpaceShareCoordinatorAssemblyProtocol,
objectTypeProvider: ObjectTypeProviderProtocol,
urlOpener: URLOpenerProtocol,
documentService: OpenedDocumentsProviderProtocol
Expand All @@ -51,7 +49,6 @@ final class SpaceSettingsCoordinatorViewModel: ObservableObject, SpaceSettingsMo
self.newSearchModuleAssembly = newSearchModuleAssembly
self.objectTypeSearchModuleAssembly = objectTypeSearchModuleAssembly
self.wallpaperPickerModuleAssembly = wallpaperPickerModuleAssembly
self.spaceShareCoordinatorAssembly = spaceShareCoordinatorAssembly
self.objectTypeProvider = objectTypeProvider
self.urlOpener = urlOpener
self.documentService = documentService
Expand All @@ -67,10 +64,6 @@ final class SpaceSettingsCoordinatorViewModel: ObservableObject, SpaceSettingsMo
return wallpaperPickerModuleAssembly.make(spaceId: accountSpaceId)
}

func spaceShareModule() -> AnyView {
return spaceShareCoordinatorAssembly.make()
}

// MARK: - SpaceSettingsModuleOutput

func onChangeIconSelected(objectId: String) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import SwiftUI

struct SpaceShareCoordinatorView: View {

@StateObject var model: SpaceShareCoordinatorViewModel
@StateObject private var model = SpaceShareCoordinatorViewModel()

var body: some View {
model.shareModule()
SpaceShareView()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ import SwiftUI
@MainActor
final class SpaceShareCoordinatorViewModel: ObservableObject {

private let spaceShareModule: SpaceShareModuleAssemblyProtocol

init(spaceShareModule: SpaceShareModuleAssemblyProtocol) {
self.spaceShareModule = spaceShareModule
}

func shareModule() -> AnyView {
return spaceShareModule.make()
init() {
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SwiftUI

struct SpaceShareView: View {

@StateObject var model: SpaceShareViewModel
@StateObject private var model = SpaceShareViewModel()

var body: some View {
VStack(spacing: 0) {
Expand All @@ -27,6 +27,12 @@ struct SpaceShareView: View {
}
}
}
.task {
await model.startParticipantsTask()
}
.task {
await model.onAppear()
}
.anytypeShareView(item: $model.shareInviteLink)
.snackbar(toastBarData: $model.toastBarData)
.anytypeSheet(item: $model.requestAlertModel) { model in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ final class SpaceShareViewModel: ObservableObject {
static let participantLimit = 11 // 10 participants and 1 owner
}

private let activeSpaceParticipantStorage: ActiveSpaceParticipantStorageProtocol
private let workspaceService: WorkspaceServiceProtocol
private let activeWorkspaceStorage: ActiveWorkpaceStorageProtocol
private let deppLinkParser: DeepLinkParserProtocol
@Injected(\.activeSpaceParticipantStorage)
private var activeSpaceParticipantStorage: ActiveSpaceParticipantStorageProtocol
@Injected(\.workspaceService)
private var workspaceService: WorkspaceServiceProtocol
@Injected(\.activeWorkspaceStorage)
private var activeWorkspaceStorage: ActiveWorkpaceStorageProtocol
@Injected(\.deepLinkParser)
private var deppLinkParser: DeepLinkParserProtocol

private var participants: [Participant] = []
private var subscriptions: [AnyCancellable] = []

@Published var accountSpaceId: String
var accountSpaceId: String { activeWorkspaceStorage.workspaceInfo.accountSpaceId }
@Published var rows: [SpaceShareParticipantViewModel] = []
@Published var inviteLink: URL?
@Published var shareInviteLink: URL?
Expand All @@ -31,22 +34,19 @@ final class SpaceShareViewModel: ObservableObject {
@Published var showDeleteLinkAlert = false
@Published var showStopSharingAlert = false

init(
activeSpaceParticipantStorage: ActiveSpaceParticipantStorageProtocol,
workspaceService: WorkspaceServiceProtocol,
activeWorkspaceStorage: ActiveWorkpaceStorageProtocol,
deppLinkParser: DeepLinkParserProtocol
) {
self.activeSpaceParticipantStorage = activeSpaceParticipantStorage
self.workspaceService = workspaceService
self.activeWorkspaceStorage = activeWorkspaceStorage
self.deppLinkParser = deppLinkParser
self.accountSpaceId = activeWorkspaceStorage.workspaceInfo.accountSpaceId
startSubscriptions()
Task {
nonisolated init() {}

func startParticipantsTask() async {
for await items in activeSpaceParticipantStorage.participantsPublisher.values {
updateParticipant(items: items)
}
}

func onAppear() async {
do {
let invite = try await workspaceService.getCurrentInvite(spaceId: accountSpaceId)
inviteLink = deppLinkParser.createUrl(deepLink: .invite(cid: invite.cid, key: invite.fileKey), scheme: .main)
}
} catch {}
}

func onShareInvite() {
Expand Down Expand Up @@ -81,13 +81,6 @@ final class SpaceShareViewModel: ObservableObject {

// MARK: - Private

private func startSubscriptions() {
activeSpaceParticipantStorage.participantsPublisher.sink { [weak self] items in
self?.updateParticipant(items: items)
}
.store(in: &subscriptions)
}

private func updateParticipant(items: [Participant]) {
participants = items.sorted { $0.sortingWeight > $1.sortingWeight }
rows = participants.map { participant in
Expand Down

0 comments on commit e6be24b

Please sign in to comment.