Browse Source

activity view

Marino Faggiana 6 năm trước cách đây
mục cha
commit
35116e6532
2 tập tin đã thay đổi với 20 bổ sung14 xóa
  1. 1 1
      iOSClient/Activity/NCActivity.storyboard
  2. 19 13
      iOSClient/Activity/NCActivity.swift

+ 1 - 1
iOSClient/Activity/NCActivity.storyboard

@@ -63,7 +63,7 @@
                                                     <constraints>
                                                         <constraint firstAttribute="height" constant="50" id="deQ-wc-jNT"/>
                                                     </constraints>
-                                                    <collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="10" minimumInteritemSpacing="20" id="nnU-ds-wda">
+                                                    <collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="10" minimumInteritemSpacing="61" id="nnU-ds-wda">
                                                         <size key="itemSize" width="50" height="50"/>
                                                         <size key="headerReferenceSize" width="0.0" height="0.0"/>
                                                         <size key="footerReferenceSize" width="0.0" height="0.0"/>

+ 19 - 13
iOSClient/Activity/NCActivity.swift

@@ -148,16 +148,23 @@ class NCActivity: UIViewController, UITableViewDataSource, UITableViewDelegate,
 
             // icon
             if activity.icon.count > 0 {
+                
                 let fileNameIcon = (activity.icon as NSString).lastPathComponent
                 let fileNameLocalPath = CCUtility.getDirectoryUserData() + "/" + fileNameIcon
+                
                 if FileManager.default.fileExists(atPath: fileNameLocalPath) {
+                    
                     if let image = UIImage(contentsOfFile: fileNameLocalPath) {
                         cell.icon.image = image
                     }
+                    
                 } else {
+                    
                     DispatchQueue.global().async {
+                        
                         let encodedString = activity.icon.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
                         if let data = try? Data(contentsOf: URL(string: encodedString!)!) {
+                            
                             DispatchQueue.main.async {
                                 do {
                                     try data.write(to: fileNameLocalPath.url, options: .atomic)
@@ -207,7 +214,14 @@ class NCActivity: UIViewController, UITableViewDataSource, UITableViewDelegate,
             if activity.subjectRich.count > 0 {
                 
                 var subject = activity.subjectRich
-                let keys = keyTags(text: subject)
+                var keys = [String]()
+                
+                if let regex = try? NSRegularExpression(pattern: "\\{[a-z0-9]+\\}", options: .caseInsensitive) {
+                    let string = subject as NSString
+                    keys = regex.matches(in: subject, options: [], range: NSRange(location: 0, length: string.length)).map {
+                        string.substring(with: $0.range).replacingOccurrences(of: "[\\{\\}]", with: "", options: .regularExpression)
+                    }
+                }
                 
                 for key in keys {
                     if let result = NCManageDatabase.sharedInstance.getActivitySubjectRich(account: appDelegate.activeAccount, idActivity: activity.idActivity, key: key) {
@@ -235,18 +249,6 @@ class NCActivity: UIViewController, UITableViewDataSource, UITableViewDelegate,
         
         return UITableViewCell()
     }
-    
-    // MARK: Utility
-    
-    func keyTags(text: String) -> [String] {
-        if let regex = try? NSRegularExpression(pattern: "\\{[a-z0-9]+\\}", options: .caseInsensitive) {
-            let string = text as NSString
-            return regex.matches(in: text, options: [], range: NSRange(location: 0, length: string.length)).map {
-                string.substring(with: $0.range).replacingOccurrences(of: "[\\{\\}]", with: "", options: .regularExpression)
-            }
-        }
-        return []
-    }
 }
 
 class activityTableViewCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
@@ -276,6 +278,10 @@ class activityTableViewCell: UITableViewCell, UICollectionViewDelegate, UICollec
         return size
     }
     
+    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
+        return 20
+    }
+    
     func numberOfSections(in collectionView: UICollectionView) -> Int {
         return 1
     }