This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/cupertino.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; | |
import 'package:platformaware/screens/aware_home_screen.dart'; | |
class AwareApp extends StatelessWidget { | |
const AwareApp({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"lastUpload":"2019-11-28T01:05:48.155Z","extensionVersion":"v3.4.3"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
enum PlanetsJSONClient: StarwarsJSONClient { | |
// MARK: - Public methods | |
static func fetchPlanets(page: Int = 1, _ completionHandler: @escaping StarWarsJSONCompletionHandler) { | |
AlamoFireJSONClient.makeAPICall(to: PlanetEndPoint.planets(page: page)) { (result) in | |
self.handle(result: result, completionHandler: completionHandler) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Alamofire | |
/// Models the Planets endpoint from the StarWars API. | |
enum PlanetEndPoint: AlamofireEndPoint { | |
case searchPlanets(forTerm: String, page: Int) | |
case planets(page: Int) | |
case planet(id: Int) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
/// All of the StarWars endpoints return a [String : Any] json object | |
typealias StarWarsJSONCompletionHandler = (Result<[String : Any]>)->() | |
/// The base URL for connecting to the StarWars json endpoint | |
let baseURL = "http://swapi.co/api" | |
/// Types that conform to this can return results from the StarWars JSON API | |
protocol StarwarsJSONClient { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Alamofire | |
/// The Reponse type from Alamofire is Any | |
typealias AlamofireJSONCompletionHandler = (Result<Any>)->() | |
/// Used to connect to any JSON API that is modeled by an AlamofireEndpoint | |
enum AlamoFireJSONClient { | |
static func makeAPICall(to endPoint: AlamofireEndPoint, completionHandler:@escaping AlamofireJSONCompletionHandler) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
/// The response from a method that can result in either a successful or failed state | |
public enum Result<T> { | |
case success(T) | |
case failure(Error) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Types that conform to this model an API endpoint that can be connected to via Alamofire | |
protocol AlamofireEndPoint { | |
/// Provides all the information required to make the API call from Alamofire | |
func provideValues()-> (url: String, httpMethod: HTTPMethod, parameters:[String:Any]?,encoding: ParameterEncoding) | |
var url: URLConvertible { get } | |
var httpMethod: HTTPMethod { get } | |
var parameters: [String: Any]? { get } | |
var encoding: ParameterEncoding { get } |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zipfile, os, shutil | |
# unzip the file | |
zip_ref = zipfile.ZipFile('data/train.zip', 'r') | |
zip_ref.extractall('data') | |
zip_ref.close() | |
os.remove('data/train.zip') | |
#rename train to dogscatsredux | |
os.rename('data/train', 'data/dogscatsredux') |
NewerOlder