Skip to content
Open
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: 1 addition & 1 deletion iOSClient/Albums/API/Albums+WebDAV.swift
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ public extension NextcloudKit {
fileName: String,
options: NKRequestOptions = NKRequestOptions(),
taskHandler: @escaping (_ task: URLSessionTask) -> Void = { _ in },
completion: @escaping (Result<Void, Error>) -> Void
completion: @escaping (Result<Void, NKError>) -> Void
) {

let session = NCSession.shared.getSession(account: account)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,8 @@ struct AlbumDetailsScreen: View {
albumName: $viewModel.newAlbumName,
error: viewModel.newAlbumNameError,
isForRenamingAlbum: true,
onCreate: {
viewModel.onRenameAlbumPopupConfirm()
},
onCancel: {
viewModel.onRenameAlbumPopupCancel()
}
onCreate: viewModel.onRenameAlbumPopupConfirm,
onCancel: viewModel.onRenameAlbumPopupCancel
)
.alert(
NSLocalizedString("_albums_delete_album_popup_title_", comment: ""),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class AlbumDetailsViewModel: ObservableObject {
self.account = account
self.album = album
self.screenTitle = album.name
self.newAlbumName = album.name
registerPublishers()
loadAlbumPhotos()
}
Expand Down Expand Up @@ -90,7 +91,7 @@ class AlbumDetailsViewModel: ObservableObject {
}

func onRenameAlbumPopupCancel() {
newAlbumName = ""
newAlbumName = self.album.name
isRenameAlbumPopupVisible = false
}

Expand Down Expand Up @@ -185,7 +186,7 @@ class AlbumDetailsViewModel: ObservableObject {
self?.album = newAlbum
self?.loadAlbumPhotos {
self?.screenTitle = self?.album.name ?? ""
self?.newAlbumName = ""
self?.newAlbumName = self?.album.name ?? ""
}
}
}
Expand Down Expand Up @@ -224,7 +225,12 @@ class AlbumDetailsViewModel: ObservableObject {
AlbumsManager.shared.syncAlbums()

case .failure(let error):
NCContentPresenter().showError(error: NKError(error: error))
if error.errorCode == 409 {
// Item already present in album error handling
NCContentPresenter().showInfo(title: "Some items are already present in this album")
} else {
NCContentPresenter().showError(error: NKError(error: error))
}
}
}
}
Expand Down
29 changes: 20 additions & 9 deletions iOSClient/Albums/Presentation/Details/PhotosGridView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,29 @@ import SwiftUI

struct PhotosGridView: View {

@Environment(\.horizontalSizeClass) var horizontalSizeClass

let photos: [AlbumPhoto : tableMetadata?]
let onAddPhotosIntent: () -> Void

private let columns = [
GridItem(
.adaptive(
minimum: 100,
maximum: 300
),
spacing: 1
)
]
private var columns: [GridItem] {
let min: CGFloat
let max: CGFloat

if horizontalSizeClass == .compact {
// iPhone
min = 120
max = 160
} else {
// iPad
min = 200
max = 300
}

return [
GridItem(.adaptive(minimum: min, maximum: max), spacing: 1)
]
}

var body: some View {

Expand Down
6 changes: 5 additions & 1 deletion iOSClient/Albums/Presentation/List/AlbumsGridView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ struct AlbumsGridView: View {
private func makeSubtitle(for album: Album) -> String? {
guard let count = album.itemCount else { return nil }

var parts: [String] = ["\(count) \(NSLocalizedString("_albums_list_entities_", comment: ""))"]
let quantifyingString = (count == 1)
? NSLocalizedString("_albums_list_entity_", comment: "")
: NSLocalizedString("_albums_list_entities_", comment: "")

var parts: [String] = ["\(count) \(quantifyingString)"]

if count > 0, let end = album.endDate {
let formatter = DateFormatter()
Expand Down
8 changes: 2 additions & 6 deletions iOSClient/Albums/Presentation/List/AlbumsListScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,8 @@ struct AlbumsListScreen: View {
isPresented: $viewModel.isNewAlbumCreationPopupVisible,
albumName: $viewModel.newAlbumName,
error: viewModel.newAlbumNameError,
onCreate: {
viewModel.onNewAlbumPopupCreate()
},
onCancel: {
viewModel.onNewAlbumPopupCancel()
}
onCreate: viewModel.onNewAlbumPopupCreate,
onCancel: viewModel.onNewAlbumPopupCancel
)
}

Expand Down
3 changes: 0 additions & 3 deletions iOSClient/Albums/Presentation/List/AlbumsListViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ class AlbumsListViewModel: ObservableObject {
@Published private(set) var isLoading: Bool = false
@Published private(set) var errorMessage: String? = nil

private var thumbnailsTask: Task<Void, Never>?
@Published private(set) var albumThumbnails: [String: UIImage] = [:]

@Published var isLoadingPopupVisible: Bool = false

@Published var isNewAlbumCreationPopupVisible: Bool = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ struct NCMediaViewRepresentable: UIViewControllerRepresentable {

@Binding var ncMedia: NCMedia?

let itemSelectionCountCallback: (Int) -> Void

func makeUIViewController(context: Context) -> UIViewController {

let sb = UIStoryboard(name: "NCMedia", bundle: nil)
let media = sb.instantiateInitialViewController() as! NCMedia
media.isInGeneralPhotosSelectionContext = true
media.generalPhotosSelectionCountCallback = itemSelectionCountCallback

DispatchQueue.main.async {
self.ncMedia = media
Expand All @@ -26,12 +29,7 @@ struct NCMediaViewRepresentable: UIViewControllerRepresentable {
let nav = UINavigationController(rootViewController: media)
nav.navigationBar.isHidden = true

let tab = UITabBarController()
tab.setViewControllers([nav], animated: false)
tab.tabBar.isHidden = true
tab.additionalSafeAreaInsets.bottom = 0

return tab
return nav
}

func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ struct PhotoSelectionSheet: View {

let onPhotosSelected: ([String]) -> Void

@State private var selectedPhotosCount: Int = 0 // TODO: Figure out how to get this count from NCMedia
@State private var selectedPhotosCount: Int = 0

@State private var mediaVC: NCMedia?

var body: some View {
NavigationView {
VStack {
NCMediaViewRepresentable(ncMedia: $mediaVC)
.frame(maxHeight: .infinity)
NCMediaViewRepresentable(
ncMedia: $mediaVC,
itemSelectionCountCallback: { count in
selectedPhotosCount = count
}
).frame(maxHeight: .infinity)
}
.navigationTitle(NSLocalizedString("_albums_photo_selection_sheet_title_", comment: ""))
.navigationBarTitleDisplayMode(.inline)
Expand All @@ -38,11 +42,16 @@ struct PhotoSelectionSheet: View {
.foregroundColor(Color(NCBrandColor.shared.customer))
}

// ToolbarItemGroup(placement: .bottomBar) {
// Text("\(selectedPhotosCount) items selected")
// .font(.subheadline)
// .foregroundColor(.secondary)
// }
ToolbarItemGroup(placement: .bottomBar) {

let quantifyingString = (selectedPhotosCount == 1)
? NSLocalizedString("_albums_photo_selection_sheet_item_selected_", comment: "")
: NSLocalizedString("_albums_photo_selection_sheet_items_selected_", comment: "")

Text("\(selectedPhotosCount) \(quantifyingString)")
.font(.subheadline)
.foregroundColor(.secondary)
}
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion iOSClient/Media/NCMedia.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate {
let refreshControl = UIRefreshControl()
var isTop: Bool = true
var isEditMode = false
var fileSelect: [String] = []
var fileSelect: [String] = [] {
didSet {
generalPhotosSelectionCountCallback?(fileSelect.count)
}
}
var filesExists: ThreadSafeArray<String> = ThreadSafeArray()
var ocIdDoNotExists: ThreadSafeArray<String> = ThreadSafeArray()
var searchMediaInProgress: Bool = false
Expand Down Expand Up @@ -94,6 +98,7 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate {
var hiddenCellMetadats: ThreadSafeArray<String> = ThreadSafeArray()

var isInGeneralPhotosSelectionContext: Bool = false
var generalPhotosSelectionCountCallback: ((Int) -> Void)?

var session: NCSession.Session {
NCSession.shared.getSession(controller: tabBarController)
Expand Down
Binary file modified iOSClient/Supporting Files/de.lproj/Localizable.strings
Binary file not shown.
3 changes: 3 additions & 0 deletions iOSClient/Supporting Files/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,7 @@
"_albums_list_empty_subheading_" = "You can organize all your photos in as many albums as you like. You haven't created an album yet.";
"_albums_list_empty_new_album_btn_" = "Create album";
"_albums_list_own_albums_heading_" = "My albums";
"_albums_list_entity_" = "Item";
"_albums_list_entities_" = "Items";
"_albums_list_new_album_popup_title_" = "Create new Album";
"_albums_list_new_album_popup_desc_" = "Please enter an album name between 3 and 30 characters.";
Expand All @@ -1369,6 +1370,8 @@
"_albums_photo_selection_sheet_title_" = "Select items";
"_albums_photo_selection_sheet_back_btn_" = "Back";
"_albums_photo_selection_sheet_done_btn_" = "Done";
"_albums_photo_selection_sheet_item_selected_" = "item selected";
"_albums_photo_selection_sheet_items_selected_" = "items selected";
"_albums_photos_loading_msg_" = "Loading photos...";
"_albums_photos_error_msg_" = "Unable to load photos. Please try again later!";
"_albums_photos_empty_heading_" = "All that's\nmissing are\nyour photos";
Expand Down