This file contains hidden or 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
protocol BooksCollectionDataProvider { | |
var title: String { get } | |
var datasource: [ObjectId] { get } | |
func loadData(paginationDelegate: PaginationDelegate) | |
} | |
class BaseBooksCollectionDataProvider: BooksCollectionDataProvider { | |
var title: String { | |
return "No configuration" | |
} |
This file contains hidden or 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
// | |
// BooksCollectionProvider.swift | |
// Glose | |
// | |
// Created by Thomas Ricouard on 10/11/2017. | |
// Copyright © 2017 Thomas Ricouard. All rights reserved. | |
// | |
import Foundation | |
import UIKit |
This file contains hidden or 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
public string LongNameAndData | |
{ | |
get { | |
string[] description = new String[4]; | |
description[0] = LongName; | |
if (itemGroup == ItemGroups.Armor) { | |
description[1] = "Armor Rating: " + GetMaterialArmorValue(); | |
} else if (itemGroup == ItemGroups.Weapons) { | |
description[1] = "Damage: " + GetBaseDamageMin() + "-" + GetBaseDamageMax(); | |
} |
This file contains hidden or 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
class ReaderWebView: WKWebView { | |
init(frame: CGRect, asset: ObjectId) { | |
let conf = WKWebViewConfiguration() | |
conf.setURLSchemeHandler(GLAssetHandler(), forURLScheme: "glasset") | |
super.init(frame: frame, configuration: conf) | |
} | |
} |
This file contains hidden or 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 WebKit | |
class GLAssetHandler: NSObject, WKURLSchemeHandler { | |
func webView(_ webView: WKWebView, start urlSchemeTask: WKURLSchemeTask) { | |
//Check that the url path is of interest for you, etc... | |
//Create a NSURLResponse with the correct mimetype. | |
let urlResponse = URLResponse(url: url, mimeType: "image/jpeg", | |
expectedContentLength: -1, textEncodingName: nil) |
This file contains hidden or 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
class Author: Codable { | |
var name: String? | |
var slug: String? | |
} |
This file contains hidden or 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
private func decodeObject<T: Codable>(key: String) -> T? { | |
guard objectExist(key) else { return nil } | |
let path = URL(fileURLWithPath: fullPath(key)) | |
do { | |
let data = try Data(contentsOf: path) | |
let decoder = PropertyListDecoder() | |
let object = try decoder.decode(T.self, from: data) | |
return object | |
} catch { | |
print("Decoding error: \(error)") |
This file contains hidden or 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
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { | |
if section <= Sections.count() - Sections.feedOffset() { | |
let sectionSwitch = Sections(rawValue: section)! | |
return sectionSwitch.headerView(controller: self) | |
} | |
switch filter { | |
case .books: | |
return MyBooksTableProvider.Sections(rawValue: section - 2)!.headerView() | |
default: | |
return nil |
This file contains hidden or 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
public protocol Dequeueable { | |
static func id() -> String | |
static func hasNib() -> Bool | |
} | |
public extension UITableView { | |
func getCell<T: Dequeueable>(forType: T.Type) -> T? { | |
return dequeueReusableCell(withIdentifier: T.id()) as? T | |
} |
This file contains hidden or 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
class MyBooksTableProvider { | |
enum Sections: Int { | |
case reading, menu, booklists | |
static func count() -> Int { | |
return 3 | |
} | |
func headerView() -> UIView? { |