Skip to content

Commit

Permalink
Merge pull request #446 from PermanentOrg/feature/VSP-1430-iPadOS-Wel…
Browse files Browse the repository at this point in the history
…come-Screen-With-Archives

VSP-1430[IOS][Tablet] Welcome screen with Archives
  • Loading branch information
luciancerbu-vsp authored Jul 25, 2024
2 parents 0078f58 + a6ec619 commit 4ce6b6c
Show file tree
Hide file tree
Showing 12 changed files with 492 additions and 86 deletions.
12 changes: 8 additions & 4 deletions Permanent.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
5EADF8092625BCCE00D14E9C /* TagsNamesCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5EADF8072625BCCD00D14E9C /* TagsNamesCollectionViewCell.xib */; };
5EADF80C262EDFCA00D14E9C /* TagsCollectionViewLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EADF80B262EDFC900D14E9C /* TagsCollectionViewLayout.swift */; };
5EB053D32BD120C400AFE66D /* TextField+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EB053D22BD120C400AFE66D /* TextField+Extension.swift */; };
5EB2D2362C245EEA0029D0DE /* OnboardingPendingArchives.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EB2D2352C245EEA0029D0DE /* OnboardingPendingArchives.swift */; };
5EB2D2362C245EEA0029D0DE /* OnboardingArchive.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EB2D2352C245EEA0029D0DE /* OnboardingArchive.swift */; };
5EB3EDBF2B04D18600D76B83 /* ResponseGiftingModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EB3EDBE2B04D18600D76B83 /* ResponseGiftingModel.swift */; };
5EB45A462943403600277800 /* UIDeviceExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EB45A452943403600277800 /* UIDeviceExtension.swift */; };
5EB4C6382BD2F00100561F0F /* CustomBorderTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EB4C6372BD2F00100561F0F /* CustomBorderTextField.swift */; };
Expand Down Expand Up @@ -451,6 +451,7 @@
5EE3E11125A72ED0009BACA8 /* AccountSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EE3E11025A72ED0009BACA8 /* AccountSettingsViewController.swift */; };
5EE3E9E02BCD447100A5EFE5 /* OnboardingArchiveName.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EE3E9DF2BCD447100A5EFE5 /* OnboardingArchiveName.swift */; };
5EE46D07260368B900FD756D /* LocationSetViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EE46D06260368B900FD756D /* LocationSetViewController.swift */; };
5EE5A8E22C470ECB0060301A /* OnboardingInvitedWelcomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EE5A8E12C470ECB0060301A /* OnboardingInvitedWelcomeView.swift */; };
5EE77BD92C3EADD4006D854C /* AccessRoleChipView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EE77BD82C3EADD4006D854C /* AccessRoleChipView.swift */; };
5EE9D8C127A0A02A00CE5F9C /* ProfilePageInformationCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EE9D8BF27A0A02A00CE5F9C /* ProfilePageInformationCollectionViewCell.swift */; };
5EE9D8C227A0A02A00CE5F9C /* ProfilePageInformationCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5EE9D8C027A0A02A00CE5F9C /* ProfilePageInformationCollectionViewCell.xib */; };
Expand Down Expand Up @@ -1186,7 +1187,7 @@
5EADF8072625BCCD00D14E9C /* TagsNamesCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TagsNamesCollectionViewCell.xib; sourceTree = "<group>"; };
5EADF80B262EDFC900D14E9C /* TagsCollectionViewLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagsCollectionViewLayout.swift; sourceTree = "<group>"; };
5EB053D22BD120C400AFE66D /* TextField+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TextField+Extension.swift"; sourceTree = "<group>"; };
5EB2D2352C245EEA0029D0DE /* OnboardingPendingArchives.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingPendingArchives.swift; sourceTree = "<group>"; };
5EB2D2352C245EEA0029D0DE /* OnboardingArchive.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingArchive.swift; sourceTree = "<group>"; };
5EB3EDBE2B04D18600D76B83 /* ResponseGiftingModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResponseGiftingModel.swift; sourceTree = "<group>"; };
5EB45A452943403600277800 /* UIDeviceExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIDeviceExtension.swift; sourceTree = "<group>"; };
5EB4C6372BD2F00100561F0F /* CustomBorderTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomBorderTextField.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1290,6 +1291,7 @@
5EE3E11025A72ED0009BACA8 /* AccountSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSettingsViewController.swift; sourceTree = "<group>"; };
5EE3E9DF2BCD447100A5EFE5 /* OnboardingArchiveName.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingArchiveName.swift; sourceTree = "<group>"; };
5EE46D06260368B900FD756D /* LocationSetViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationSetViewController.swift; sourceTree = "<group>"; };
5EE5A8E12C470ECB0060301A /* OnboardingInvitedWelcomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingInvitedWelcomeView.swift; sourceTree = "<group>"; };
5EE77BD82C3EADD4006D854C /* AccessRoleChipView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessRoleChipView.swift; sourceTree = "<group>"; };
5EE9D8BF27A0A02A00CE5F9C /* ProfilePageInformationCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfilePageInformationCollectionViewCell.swift; sourceTree = "<group>"; };
5EE9D8C027A0A02A00CE5F9C /* ProfilePageInformationCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ProfilePageInformationCollectionViewCell.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1877,6 +1879,7 @@
children = (
5E0B1BD32B961CE800B10BB5 /* OnboardingView.swift */,
5EE068932B9F23B4004055A4 /* OnboardingWelcomeView.swift */,
5EE5A8E12C470ECB0060301A /* OnboardingInvitedWelcomeView.swift */,
5EE068982B9F94A3004055A4 /* OnboardingCreateFirstArchiveView.swift */,
5ED9A7B52BBF3294009BDD70 /* OnboardingSelectArchiveTypeView.swift */,
5EE3E9DF2BCD447100A5EFE5 /* OnboardingArchiveName.swift */,
Expand Down Expand Up @@ -3467,7 +3470,7 @@
F5C8D246273204CA00707301 /* SearchVO.swift */,
5E62F7C827F79FF40046F6C8 /* PopularArchive.swift */,
5EB721122B35C9DC0036B28F /* RedeemVO.swift */,
5EB2D2352C245EEA0029D0DE /* OnboardingPendingArchives.swift */,
5EB2D2352C245EEA0029D0DE /* OnboardingArchive.swift */,
);
path = Data;
sourceTree = "<group>";
Expand Down Expand Up @@ -4453,6 +4456,7 @@
5E31B62C292FA7DE00934408 /* ShareManagementAccessRolesViewController.swift in Sources */,
BCC4066E25A6F8FA00E29CC4 /* MemberOperation.swift in Sources */,
BC4526E0251CAB7F00E24A51 /* VerifyCodeResponse.swift in Sources */,
5EE5A8E22C470ECB0060301A /* OnboardingInvitedWelcomeView.swift in Sources */,
9220ACCF2A20E6CE003797C9 /* RoundedImageView.swift in Sources */,
BCFFD293252B506B009485C1 /* UIViewControllerExtension.swift in Sources */,
BC42EDD325C014CC0031B965 /* InviteEndpoint.swift in Sources */,
Expand All @@ -4477,7 +4481,7 @@
BCF4E5DB255C3782003505BA /* AttachmentRecordVO.swift in Sources */,
06644A8B24EBF4CD003CD359 /* CustomView.swift in Sources */,
BC6D3B4D2514E57500390927 /* NetworkSessionProtocol.swift in Sources */,
5EB2D2362C245EEA0029D0DE /* OnboardingPendingArchives.swift in Sources */,
5EB2D2362C245EEA0029D0DE /* OnboardingArchive.swift in Sources */,
5E5AB60F2A6494170030BF61 /* AddTagsView.swift in Sources */,
F54596C325FF737200E0BC5F /* FilePreviewNavigationController.swift in Sources */,
927AE0CD2A2F290E00BDF26A /* BannerView.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions Permanent/Common/Models/Data/ArchiveVO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct ArchiveVOData: Model {
case pending = "status.generic.pending"
case orphaned = "status.generic.orphaned"
case genAvatar = "status.archive.gen_avatar"
case currentOwner = "status.generic.owner"

case unknown = "N/A"

Expand Down
24 changes: 24 additions & 0 deletions Permanent/Common/Models/Data/OnboardingArchive.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// OnboardingPendingArchives.swift
// Permanent
//
// Created by Lucian Cerbu on 20.06.2024.

import Foundation

class OnboardingArchive: Identifiable, Decodable {
var id = UUID()

var fullname: String
var accessType: String
var status: ArchiveVOData.Status
var archiveID: Int

init(id: UUID = UUID(), fullname: String, accessType: String, status: ArchiveVOData.Status, archiveID: Int) {
self.id = id
self.fullname = fullname
self.accessType = accessType
self.status = status
self.archiveID = archiveID
}
}
14 changes: 0 additions & 14 deletions Permanent/Common/Models/Data/OnboardingPendingArchives.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,54 @@ class OnboardingArchiveViewModel: ObservableObject {
@Published var archiveName: String = ""
@Published var selectedPath: [OnboardingPath] = []
@Published var selectedWhatsImportant: [OnboardingWhatsImportant] = []
@Published var pendingArchives: [OnboardingPendingArchives] = []
@Published var allArchives: [OnboardingArchive] = []
@Published var allArchivesVO: [ArchiveVO] = []
@Published var fullName: String
@Published var isLoading: Bool = false
@Published var initIsLoading: Bool = false
@Published var showAlert: Bool = false
@Published var isArchiveAccepted: Bool = false
var account: AccountVOData?


let welcomeMessage: String = "We’re so glad you’re here!\n\nAt Permanent, it is our mission to provide a safe and secure place to store, preserve, and share the digital legacy of all people, whether that's for you or for your friends, family, interests or organizations.\n\nWe know that starting this journey can sometimes be overwhelming, but don’t worry. We’re here to help you every step of the way."

init(username: String?, password: String?) {
isLoading = true
initIsLoading = true
self.username = username ?? ""
self.password = password ?? ""
self.fullName = AuthenticationManager.shared.session?.account.fullName ?? ""

self.getAccountArchives { error in
self.isLoading = false
self.initIsLoading = false
if error != nil {
self.showAlert = true
}
}
}

func getIndefiniteArticle() -> String {
if archiveType == .person || archiveType == .organization {
return "an"
}
return "a"
}

func togglePath(path: OnboardingPath) {
if let index = selectedPath.firstIndex(of: path) {
selectedPath.remove(at: index)
} else {
selectedPath.append(path)
}
}

func toggleWhatsImportant(whatsImportant: OnboardingWhatsImportant) {
if let index = selectedWhatsImportant.firstIndex(of: whatsImportant) {
selectedWhatsImportant.remove(at: index)
} else {
selectedWhatsImportant.append(whatsImportant)
}
}

func finishOnboard(_ completionBlock: @escaping ServerResponse) {
isLoading = true
createArchive(name: archiveName, type: archiveType.rawValue) { [weak self] archiveVO, error in
Expand Down Expand Up @@ -214,20 +224,91 @@ class OnboardingArchiveViewModel: ObservableObject {
guard let self = self else { return }
switch result {
case .json(let response, _):
guard let model: APIResults<ArchiveVO> = JSONHelper.decoding(from: response, with: APIResults<NoDataModel>.decoder), let archives = model.results.first?.data, model.isSuccessful else {
guard let model: APIResults<ArchiveVO> = JSONHelper.decoding(from: response, with: APIResults<NoDataModel>.decoder),
model.isSuccessful else {
completionBlock(APIError.invalidResponse)
return
}
for archive in archives {
if let fullName = archive.archiveVO?.fullName, archive.archiveVO?.status == ArchiveVOData.Status.pending {
pendingArchives.append(OnboardingPendingArchives(fullname: fullName, accessType: AccessRole.roleForValue(archive.archiveVO?.accessRole).groupName))

if let archives = model.results.first?.data {
allArchives = []
allArchivesVO = archives
for archive in archives {
if let fullName = archive.archiveVO?.fullName,
let status = archive.archiveVO?.status,
let archiveID = archive.archiveVO?.archiveID,
status == ArchiveVOData.Status.pending || status == ArchiveVOData.Status.ok {
allArchives.append(OnboardingArchive(fullname: fullName, accessType: AccessRole.roleForValue(archive.archiveVO?.accessRole).groupName, status: status, archiveID: archiveID))
}
}
} else {
allArchives = []
allArchivesVO = []
}

completionBlock(nil)

default:
completionBlock(APIError.invalidResponse)
}
}
}

func acceptPendingArchive(archive: OnboardingArchive) {
isLoading = true
guard let archiveVO = allArchivesVO.first(where: { $0.archiveVO?.archiveID == archive.archiveID}),
let archiveVOData = archiveVO.archiveVO else {
isLoading = false
showAlert = true
return
}

acceptArchiveOperation(archive: archiveVOData, { status, error in
self.isLoading = false
if status {
self.isArchiveAccepted = true
guard let _ = archiveVOData.archiveID else {
self.showAlert = true
return
}

archive.status = .ok
}
})
}

func acceptArchiveOperation(archive: ArchiveVOData, _ completionBlock: @escaping ((Bool, Error?) -> Void)) {
let acceptArchiveOperation = APIOperation(ArchivesEndpoint.accept(archiveVO: archive))

acceptArchiveOperation.execute(in: APIRequestDispatcher()) { result in
switch result {
case .json(let response, _):
guard
let model: APIResults<NoDataModel> = JSONHelper.decoding(from: response, with: APIResults<NoDataModel>.decoder),
model.isSuccessful
else {
completionBlock(false, APIError.invalidResponse)
return
}

self.changeArchive(archive) { success, error in
if success {
completionBlock(true, nil)
return
} else {
completionBlock(false, APIError.invalidResponse)
return
}
}

case .error:
completionBlock(false, APIError.invalidResponse)
return

default:
completionBlock(false, APIError.invalidResponse)
return
}
}
}
}
Loading

0 comments on commit 4ce6b6c

Please sign in to comment.