浏览代码

normalized

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 年之前
父节点
当前提交
ea3398d77c
共有 2 个文件被更改,包括 33 次插入6 次删除
  1. 32 5
      Widget/Dashboard/DashboardData.swift
  2. 1 1
      Widget/Dashboard/DashboardWidgetProvider.swift

+ 32 - 5
Widget/Dashboard/DashboardData.swift

@@ -52,7 +52,7 @@ let dashboardDatasTest: [DashboardData] = [
     .init(id: "6", image: UIImage(named: "nextcloud")!, title: "title6", subTitle: "subTitle-description6", url: URL(string: "https://nextcloud.com/")!)
 ]
 
-func getTitleDashboard(account: tableAccount?) -> String {
+func getTitleDashboard() -> String {
 
     let hour = Calendar.current.component(.hour, from: Date())
     var good = ""
@@ -65,7 +65,7 @@ func getTitleDashboard(account: tableAccount?) -> String {
     default: good = NSLocalizedString("_good_night_", value: "Good night", comment: "")
     }
 
-    if let account = account {
+    if let account = NCManageDatabase.shared.getActiveAccount() {
         return good + ", " + account.displayName
     } else {
         return good
@@ -77,15 +77,42 @@ func getDashboardDataEntry(isPreview: Bool, displaySize: CGSize, completion: @es
     let datasPlaceholder = Array(dashboardDatasTest[0...dashboaardItems - 1])
     
     if isPreview {
-        return completion(DashboardDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, title: "Dashboard", footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " dashboard"))
+        return completion(DashboardDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, title: getTitleDashboard(), footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " dashboard"))
     }
 
     guard let account = NCManageDatabase.shared.getActiveAccount() else {
-        return completion(DashboardDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, title: "Dashboard", footerImage: "xmark.icloud", footerText: NSLocalizedString("_no_active_account_", value: "No account found", comment: "")))
+        return completion(DashboardDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, title: getTitleDashboard(), footerImage: "xmark.icloud", footerText: NSLocalizedString("_no_active_account_", value: "No account found", comment: "")))
     }
+    
+    // NETWORKING
+    let password = CCUtility.getPassword(account.account)!
+    NKCommon.shared.setup(
+        account: account.account,
+        user: account.user,
+        userId: account.userId,
+        password: password,
+        urlBase: account.urlBase,
+        userAgent: CCUtility.getUserAgent(),
+        nextcloudVersion: 0,
+        delegate: NCNetworking.shared)
+
+    // LOG
+    let levelLog = CCUtility.getLogLevel()
+    let isSimulatorOrTestFlight = NCUtility.shared.isSimulatorOrTestFlight()
+    let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp())
 
+    NKCommon.shared.levelLog = levelLog
+    if let pathDirectoryGroup = CCUtility.getDirectoryGroup()?.path {
+        NKCommon.shared.pathLog = pathDirectoryGroup
+    }
+    if isSimulatorOrTestFlight {
+        NKCommon.shared.writeLog("Start \(NCBrandOptions.shared.brand) dashboard session with level \(levelLog) " + versionNextcloudiOS + " (Simulator / TestFlight)")
+    } else {
+        NKCommon.shared.writeLog("Start \(NCBrandOptions.shared.brand) dashboard session with level \(levelLog) " + versionNextcloudiOS)
+    }
+    
     let datas = [DashboardData]()
     
-    completion(DashboardDataEntry(date: Date(), datas: datas, isPlaceholder: false, title: getTitleDashboard(account: account), footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " dashboard"))
+    completion(DashboardDataEntry(date: Date(), datas: datas, isPlaceholder: false, title: getTitleDashboard(), footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " dashboard"))
     
 }

+ 1 - 1
Widget/Dashboard/DashboardWidgetProvider.swift

@@ -30,7 +30,7 @@ struct DashboardWidgetProvider: TimelineProvider {
 
     func placeholder(in context: Context) -> Entry {
         let datasPlaceholder = Array(dashboardDatasTest[0...nextcloudItems - 1])
-        return Entry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, title: "Dasboard", footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " widget")
+        return Entry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, title: getTitleDashboard(), footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " widget")
     }
 
     func getSnapshot(in context: Context, completion: @escaping (Entry) -> Void) {