Skip to content

Commit

Permalink
Merge pull request #424 from PermanentOrg/bugfix/VSP-1387-Profile-pho…
Browse files Browse the repository at this point in the history
…to-issue

VSP-1387[IOS]Archive profile photo and banner can't be changed
  • Loading branch information
luciancerbu-vsp authored Mar 14, 2024
2 parents 984ec62 + b1ccacc commit 3adb335
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions Permanent/Common/Files/ViewModel/MyFilesViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ protocol MyFilesViewModelPickerDelegate: AnyObject {
class MyFilesViewModel: FilesViewModel {
static let didSelectFilesNotifName = NSNotification.Name("MyFilesViewModel.didSelectFilesNotifName")
var isPickingImage: Bool = false
var isPickingProfilePicture: Bool = false
weak var pickerDelegate: MyFilesViewModelPickerDelegate?

override var currentFolderIsRoot: Bool { navigationStack.count == 1 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class FileCollectionViewHeaderCell: UICollectionReusableView {
rightButton.imageView?.contentMode = .scaleAspectFit
}

func configure(with viewModel: FilesViewModel?) {
func configure(with viewModel: FilesViewModel?, isPickingProfilePicture: Bool = false) {
guard let viewModel = viewModel else {
rightButtonTitle = nil
rightButton.setImage(nil, for: .normal)
Expand Down Expand Up @@ -78,6 +78,11 @@ class FileCollectionViewHeaderCell: UICollectionReusableView {

// Update clear button visibility
clearButton.isHidden = !viewModel.isSelecting

if isPickingProfilePicture {
rightButton.isHidden = true
clearButton.isHidden = true
}
}

@IBAction func leftButtonPressed(_ sender: Any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class MainViewController: BaseViewController<MyFilesViewModel> {
overlayView.backgroundColor = .overlay
overlayView.alpha = 0

fabView.isHidden = viewModel!.archivePermissions.contains(.create) == false || viewModel!.archivePermissions.contains(.upload) == false || viewModel!.isPickingImage
fabView.isHidden = viewModel!.archivePermissions.contains(.create) == false || viewModel!.archivePermissions.contains(.upload) == false || viewModel!.isPickingImage || viewModel!.isPickingProfilePicture
}

fileprivate func setupCollectionView() {
Expand Down Expand Up @@ -888,7 +888,7 @@ extension MainViewController: UICollectionViewDelegateFlowLayout, UICollectionVi

let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: FileCollectionViewHeaderCell.identifier, for: indexPath) as! FileCollectionViewHeaderCell
headerView.leftButtonTitle = viewModel?.title(forSection: section)
headerView.configure(with: viewModel)
headerView.configure(with: viewModel, isPickingProfilePicture: viewModel!.isPickingProfilePicture)
if viewModel?.shouldPerformAction(forSection: section) == true {
headerView.leftButtonAction = { [weak self] header in self?.headerButtonAction(UIButton()) }
} else {
Expand All @@ -905,7 +905,7 @@ extension MainViewController: UICollectionViewDelegateFlowLayout, UICollectionVi
headerView.rightButtonTitle = (viewModel?.isSelectingDestination ?? false) ? nil : "Select".localized()
}

headerView.rightButtonAction = { [weak self] header in self?.selectButtonWasPressed(UIButton()) }
headerView.rightButtonAction = { [weak self] header in self?.selectButtonWasPressed(UIButton())}
headerView.clearButtonAction = { [weak self] header in self?.clearButtonWasPressed(UIButton())}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class PublicArchiveViewController: BaseViewController<PublicProfilePicturesViewM

let myFilesVC = UIViewController.create(withIdentifier: .main, from: .main) as! MainViewController
let myFilesVM = MyFilesViewModel()
myFilesVM.isPickingImage = true
myFilesVM.isPickingProfilePicture = true
myFilesVM.pickerDelegate = self
myFilesVC.viewModel = myFilesVM

Expand All @@ -192,7 +192,7 @@ class PublicArchiveViewController: BaseViewController<PublicProfilePicturesViewM

let myFilesVC = UIViewController.create(withIdentifier: .main, from: .main) as! MainViewController
let myFilesVM = MyFilesViewModel()
myFilesVM.isPickingImage = true
myFilesVM.isPickingProfilePicture = true
myFilesVM.pickerDelegate = self
myFilesVC.viewModel = myFilesVM

Expand Down

0 comments on commit 3adb335

Please sign in to comment.