diff --git a/ios/Podfile b/ios/Podfile index 2109233..4eeff12 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -36,6 +36,9 @@ target 'Runner' do use_frameworks! use_modular_headers! + pod 'Alamofire', '~> 5.0' + pod 'AlamofireImage', '~> 4.0' + # Flutter Pod copied_flutter_dir = File.join(__dir__, 'Flutter') diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 5d22012..4950cc3 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1,4 +1,7 @@ PODS: + - Alamofire (5.0.2) + - AlamofireImage (4.0.2): + - Alamofire (< 6.0.0, >= 5.0.2) - Flutter (1.0.0) - flutter_plugin_android_lifecycle (0.0.1): - Flutter @@ -32,6 +35,8 @@ PODS: - Flutter DEPENDENCIES: + - Alamofire (~> 5.0) + - AlamofireImage (~> 4.0) - Flutter (from `Flutter`) - flutter_plugin_android_lifecycle (from `.symlinks/plugins/flutter_plugin_android_lifecycle/ios`) - image_picker (from `.symlinks/plugins/image_picker/ios`) @@ -49,6 +54,8 @@ DEPENDENCIES: SPEC REPOS: trunk: + - Alamofire + - AlamofireImage - FMDB EXTERNAL SOURCES: @@ -82,6 +89,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/url_launcher_web/ios" SPEC CHECKSUMS: + Alamofire: 3ba7a4db18b4f62c4a1c0e1cb39d7f3d52e10ada + AlamofireImage: ca7325440303d041a80b7caa55066ba945522378 Flutter: 0e3d915762c693b495b44d77113d4970485de6ec flutter_plugin_android_lifecycle: 47de533a02850f070f5696a623995e93eddcdb9b FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a @@ -98,6 +107,6 @@ SPEC CHECKSUMS: url_launcher_macos: fd7894421cd39320dce5f292fc99ea9270b2a313 url_launcher_web: e5527357f037c87560776e36436bf2b0288b965c -PODFILE CHECKSUM: a2b0bf7fe93e4e6b732ab20a6fda201dc8a23f90 +PODFILE CHECKSUM: de92ffc9c4fb086e3bef042f78de79dfec856d10 COCOAPODS: 1.8.4 diff --git a/ios/TodayExtension/TodayViewController.swift b/ios/TodayExtension/TodayViewController.swift index 470b3c3..e733b43 100644 --- a/ios/TodayExtension/TodayViewController.swift +++ b/ios/TodayExtension/TodayViewController.swift @@ -14,6 +14,8 @@ // limitations under the License. // +import Alamofire +import AlamofireImage import UIKit import NotificationCenter @@ -28,15 +30,24 @@ class TodayViewController: UIViewController, NCWidgetProviding { } func widgetPerformUpdate(completionHandler: (@escaping (NCUpdateResult) -> Void)) { - Picture.today(completion: { data in - self.current = data[Int.random(in: 0.. { + let random = data[Int.random(in: 0.. Void) { - var result: [Picture] = [] - - let url = URL.init(string: "https://v2.api.dailypics.cn/today") - URLSession.shared.dataTask(with: url!) { data, response, error in - if let data = data, - let decoded = try? JSONSerialization.jsonObject(with: data, options: []) as? Array { - for case let item in decoded { - if let obj = Picture.init(source: item as! [String : Any]) { - result.append(obj) - } - } - completion(result) - } - }.resume() - } } diff --git a/pubspec.yaml b/pubspec.yaml index 4b5f6e6..82aed31 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: dailypics description: A new Flutter application. -version: 2.1.2+200305 +version: 2.1.2+200307 environment: sdk: ">=2.3.0 <3.0.0"