Browse Source

normalized

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 years ago
parent
commit
cb5a363a14

+ 1 - 1
Nextcloud.xcodeproj/project.pbxproj

@@ -1373,8 +1373,8 @@
 			isa = PBXGroup;
 			children = (
 				F72EA95728B7BC4F00C88F0C /* NextcloudData.swift */,
-				F72EA95928B7BD0D00C88F0C /* NextcloudWidgetView.swift */,
 				F72EA95328B7BABA00C88F0C /* NextcloudWidgetProvider.swift */,
+				F72EA95928B7BD0D00C88F0C /* NextcloudWidgetView.swift */,
 			);
 			path = Nextcloud;
 			sourceTree = "<group>";

+ 3 - 12
Widget/Nextcloud/NextcloudData.swift

@@ -24,8 +24,7 @@
 import WidgetKit
 import NextcloudKit
 
-let imageSize:CGFloat = 30
-let spacingImageUpload:CGFloat = 10
+let nextcloudItems = 4
 
 struct NextcloudDataEntry: TimelineEntry {
     let date: Date
@@ -52,16 +51,9 @@ let recentDatasTest: [RecentData] = [
     .init(id: "6", image: UIImage(named: "nextcloud")!, title: "title6", subTitle: "subTitle-description6", url: URL(string: "https://nextcloud.com/")!)
 ]
 
-func getNumberItems(height: CGFloat) -> Int {
-    
-    //let num: Int = Int((height - 120) / 40)
-    return 4
-}
-
 func getDataEntry(isPreview: Bool, displaySize: CGSize, completion: @escaping (_ entry: NextcloudDataEntry) -> Void) {
 
-    let num = getNumberItems(height: displaySize.height) - 1
-    let recentDatasPlaceholder = Array(recentDatasTest[0...num])
+    let recentDatasPlaceholder = Array(recentDatasTest[0...nextcloudItems - 1])
     
     if isPreview {
         return completion(NextcloudDataEntry(date: Date(), recentDatas: recentDatasPlaceholder, isPlaceholder: true, footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " widget"))
@@ -201,8 +193,7 @@ func getDataEntry(isPreview: Bool, displaySize: CGSize, completion: @escaping (_
             }
             let recentData = RecentData.init(id: file.ocId, image: imageRecent, title: file.fileName, subTitle: subTitle, url: url)
             recentDatas.append(recentData)
-            let numItems = getNumberItems(height: displaySize.height)
-            if recentDatas.count == numItems { break}
+            if recentDatas.count == nextcloudItems { break}
         }
 
         // Completion

+ 1 - 2
Widget/Nextcloud/NextcloudWidgetProvider.swift

@@ -29,8 +29,7 @@ struct NextcloudWidgetProvider: TimelineProvider {
     typealias Entry = NextcloudDataEntry
 
     func placeholder(in context: Context) -> Entry {
-        let num = getNumberItems(height: context.displaySize.height) - 1
-        let recentDatasPlaceholder = Array(recentDatasTest[0...num])
+        let recentDatasPlaceholder = Array(recentDatasTest[0...nextcloudItems - 1])
         return Entry(date: Date(), recentDatas: recentDatasPlaceholder, isPlaceholder: true, footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " widget")
     }
 

+ 1 - 0
Widget/Nextcloud/NextcloudWidgetView.swift

@@ -62,6 +62,7 @@ struct NextcloudWidgetView: View {
                                 HStack {
                                     
                                     let subTitleColor = Color(white: 0.5)
+                                    let imageSize:CGFloat = 30
                                     
                                     Image(uiImage: element.image)
                                         .resizable()