Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Marino Faggiana <[email protected]>
  • Loading branch information
marinofaggiana committed Jul 8, 2024
1 parent f3af759 commit 31131b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 45 deletions.
28 changes: 8 additions & 20 deletions iOSClient/Activity/NCActivity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,12 @@ import SwiftRichString
import NextcloudKit

class NCActivity: UIViewController, NCSharePagingContent {

@IBOutlet weak var viewContainerConstraint: NSLayoutConstraint!
@IBOutlet weak var tableView: UITableView!

var commentView: NCActivityCommentView?
var textField: UIView? { commentView?.newCommentField }

@IBOutlet weak var viewContainerConstraint: NSLayoutConstraint!
var height: CGFloat = 0

var metadata: tableMetadata?
var showComments: Bool = false

Expand Down Expand Up @@ -130,12 +127,8 @@ class NCActivity: UIViewController, NCSharePagingContent {
label.textColor = NCBrandColor.shared.textColor2
label.textAlignment = .center
label.text = NSLocalizedString("_no_activity_footer_", comment: "")
// label.frame = CGRect(x: 0, y: 10, width: tableView.frame.width, height: 60)

view.addSubview(label)

label.translatesAutoresizingMaskIntoConstraints = false

label.topAnchor.constraint(equalTo: view.topAnchor, constant: 20).isActive = true
label.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
label.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
Expand All @@ -151,6 +144,10 @@ extension NCActivity: UITableViewDelegate {
return 50
}

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 80
}

func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 50))
view.backgroundColor = .clear
Expand Down Expand Up @@ -187,7 +184,6 @@ extension NCActivity: UITableViewDelegate {
}

extension NCActivity: UITableViewDataSource {

func numberOfSections(in tableView: UITableView) -> Int {
return sectionDates.count
}
Expand Down Expand Up @@ -248,7 +244,6 @@ extension NCActivity: UITableViewDataSource {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "tableCell", for: indexPath) as? NCActivityTableViewCell else {
return UITableViewCell()
}

var orderKeysId: [String] = []

cell.idActivity = activity.idActivity
Expand All @@ -261,7 +256,6 @@ extension NCActivity: UITableViewDataSource {

// icon
if !activity.icon.isEmpty {

let fileNameIcon = (activity.icon as NSString).lastPathComponent
let fileNameLocalPath = utilityFileSystem.directoryUserData + "/" + fileNameIcon

Expand All @@ -283,12 +277,9 @@ extension NCActivity: UITableViewDataSource {

// avatar
if !activity.user.isEmpty && activity.user != appDelegate.userId {

cell.avatar.isHidden = false
cell.fileUser = activity.user

let fileName = appDelegate.userBaseUrl + "-" + activity.user + ".png"

NCNetworking.shared.downloadAvatar(user: activity.user, dispalyName: nil, fileName: fileName, cell: cell, view: tableView)
cell.subjectLeadingConstraint.constant = 15
} else {
Expand All @@ -298,7 +289,6 @@ extension NCActivity: UITableViewDataSource {
// subject
cell.subject.text = activity.subject
if !activity.subjectRich.isEmpty {

var subject = activity.subjectRich
var keys: [String] = []

Expand Down Expand Up @@ -348,12 +338,11 @@ extension NCActivity: UIScrollViewDelegate {
// MARK: - NC API & Algorithm

extension NCActivity {

func fetchAll(isInitial: Bool) {
guard !isFetchingActivity else { return }
self.isFetchingActivity = true

var bottom: CGFloat = 0

if let mainTabBar = self.tabBarController?.tabBar as? NCMainTabBar {
bottom = -mainTabBar.getHeight()
}
Expand All @@ -380,8 +369,8 @@ extension NCActivity {
}

func loadDataSource() {

var newItems = [DateCompareable]()

if showComments, let metadata = metadata, let account = NCManageDatabase.shared.getActiveAccount() {
let comments = NCManageDatabase.shared.getComments(account: account.account, objectId: metadata.fileId)
newItems += comments
Expand Down Expand Up @@ -453,10 +442,9 @@ extension NCActivity {

func loadActivity(idActivity: Int, limit: Int = 200, disptachGroup: DispatchGroup) {
guard hasActivityToLoad else { return }

var resultActivityId = 0
disptachGroup.enter()

disptachGroup.enter()
NextcloudKit.shared.getActivity(
since: idActivity,
limit: min(limit, 200),
Expand Down
6 changes: 2 additions & 4 deletions iOSClient/Activity/NCActivityCommentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class NCActivityCommentView: UIView, UITextFieldDelegate {
imageItem.image = NCUtility().loadImage(named: "person.crop.circle", colors: [NCBrandColor.shared.iconImageColor])
}
}
//

func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
completionHandler?(textField.text)
Expand All @@ -55,8 +55,6 @@ extension NCActivityCommentView: UISearchBarDelegate {
searchBar.resignFirstResponder()
completionHandler?(searchBar.text)
}
func searchBarTextDidEndEditing(_ searchBar: UISearchBar) {

// return true
}
func searchBarTextDidEndEditing(_ searchBar: UISearchBar) { }
}
22 changes: 1 addition & 21 deletions iOSClient/Activity/NCActivityTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import JGProgressHUD
import Queuer

class NCActivityCollectionViewCell: UICollectionViewCell {

@IBOutlet weak var imageView: UIImageView!

var fileId = ""
Expand Down Expand Up @@ -83,19 +82,16 @@ class NCActivityTableViewCell: UITableViewCell, NCCellProtocol {
// MARK: - Collection View

extension NCActivityTableViewCell: UICollectionViewDelegate {

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {

// Select not permitted
if !didSelectItemEnable {
return
}

let activityPreview = activityPreviews[indexPath.row]

if activityPreview.view == "trashbin" {

var responder: UIResponder? = collectionView

while !(responder is UIViewController) {
responder = responder?.next
if responder == nil {
Expand All @@ -114,23 +110,19 @@ extension NCActivityTableViewCell: UICollectionViewDelegate {
}
}
}

return
}

if activityPreview.view == NCGlobal.shared.appName && activityPreview.mimeType != "dir" {

guard let activitySubjectRich = NCManageDatabase.shared.getActivitySubjectRich(account: activityPreview.account, idActivity: activityPreview.idActivity, id: String(activityPreview.fileId)) else {
return
}

NCActionCenter.shared.viewerFile(account: appDelegate.account, fileId: activitySubjectRich.id, viewController: viewController)
}
}
}

extension NCActivityTableViewCell: UICollectionViewDataSource {

func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
Expand All @@ -141,7 +133,6 @@ extension NCActivityTableViewCell: UICollectionViewDataSource {
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

guard let cell: NCActivityCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionCell", for: indexPath) as? NCActivityCollectionViewCell else {
return UICollectionViewCell()
}
Expand All @@ -154,7 +145,6 @@ extension NCActivityTableViewCell: UICollectionViewDataSource {

// Trashbin
if activityPreview.view == "trashbin" {

let source = activityPreview.source

utility.convertSVGtoPNGWriteToUserData(svgUrlString: source, width: 100, rewrite: false, account: appDelegate.account, id: idActivity) { imageNamePath, id in
Expand All @@ -164,11 +154,8 @@ extension NCActivityTableViewCell: UICollectionViewDataSource {
cell.imageView.image = NCImageCache.images.file
}
}

} else {

if activityPreview.isMimeTypeIcon {

let source = activityPreview.source

utility.convertSVGtoPNGWriteToUserData(svgUrlString: source, width: 150, rewrite: false, account: appDelegate.account, id: idActivity) { imageNamePath, id in
Expand All @@ -178,11 +165,8 @@ extension NCActivityTableViewCell: UICollectionViewDataSource {
cell.imageView.image = NCImageCache.images.file
}
}

} else {

if let activitySubjectRich = NCManageDatabase.shared.getActivitySubjectRich(account: activityPreview.account, idActivity: idActivity, id: fileId) {

let fileNamePath = NCUtilityFileSystem().directoryUserData + "/" + activitySubjectRich.name

if FileManager.default.fileExists(atPath: fileNamePath), let image = UIImage(contentsOfFile: fileNamePath) {
Expand All @@ -201,14 +185,11 @@ extension NCActivityTableViewCell: UICollectionViewDataSource {
}
}
}

return cell
}

}

extension NCActivityTableViewCell: UICollectionViewDelegateFlowLayout {

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: 50, height: 30)
}
Expand All @@ -223,7 +204,6 @@ extension NCActivityTableViewCell: UICollectionViewDelegateFlowLayout {
}

class NCOperationDownloadThumbnailActivity: ConcurrentOperation {

var cell: NCActivityCollectionViewCell?
var collectionView: UICollectionView?
var fileNamePreviewLocalPath: String
Expand Down

0 comments on commit 31131b7

Please sign in to comment.