Browse Source

improved widget

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 năm trước cách đây
mục cha
commit
98a3325efe

+ 4 - 3
Widget/Nextcloud/NextcloudData.swift

@@ -48,18 +48,19 @@ let recentDatasTest: [RecentData] = [
     .init(id: "2", image: UIImage(named: "nextcloud")!, title: "title2", subTitle: "subTitle-description2", url: URL(string: "https://nextcloud.com/")!),
     .init(id: "3", image: UIImage(named: "nextcloud")!, title: "title3", subTitle: "subTitle-description3", url: URL(string: "https://nextcloud.com/")!),
     .init(id: "4", image: UIImage(named: "nextcloud")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!),
-    .init(id: "5", image: UIImage(named: "nextcloud")!, title: "title5", subTitle: "subTitle-description5", url: URL(string: "https://nextcloud.com/")!)
+    .init(id: "5", image: UIImage(named: "nextcloud")!, title: "title5", subTitle: "subTitle-description5", url: URL(string: "https://nextcloud.com/")!),
+    .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 - 150) / 40)
+    let num: Int = Int((height - 100) / 40)
     return num
 }
 
 func getDataEntry(isPreview: Bool, displaySize: CGSize, completion: @escaping (_ entry: NextcloudDataEntry) -> Void) {
 
-    let num: Int = Int((displaySize.height - 150) / 40) - 1
+    let num = getNumberItems(height: displaySize.height) - 1
     let recentDatasPlaceholder = Array(recentDatasTest[0...num])
     
     if isPreview {

+ 1 - 1
Widget/Nextcloud/NextcloudWidgetProvider.swift

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

+ 3 - 3
Widget/Nextcloud/NextcloudWidgetView.swift

@@ -31,7 +31,7 @@ struct NextcloudWidgetView: View {
             ZStack(alignment: .topLeading) {
                 HStack(spacing: 5) {
                     Text(NCBrandOptions.shared.brand)
-                        .font(.system(size: 12))
+                        .font(.system(size: 13))
                         .fontWeight(.bold)
                         .textCase(.uppercase)
                 }
@@ -66,7 +66,7 @@ struct NextcloudWidgetView: View {
                         }
                     }
                 }
-                .padding(.top, 40)
+                .padding(.top, 30)
                 .redacted(reason: entry.isPlaceholder ? .placeholder : [])
 
                 HStack(spacing: 0) {
@@ -119,7 +119,7 @@ struct NextcloudWidgetView: View {
                             .frame(width: geo.size.width/4, height: 50)
                     })
                 }
-                .frame(width: geo.size.width, height: geo.size.height-40, alignment: .bottomTrailing)
+                .frame(width: geo.size.width, height: geo.size.height-25, alignment: .bottomTrailing)
                 .redacted(reason: entry.isPlaceholder ? .placeholder : [])
 
                 HStack {