Skip to content

Commit

Permalink
added Rambafiles + Classes
Browse files Browse the repository at this point in the history
  • Loading branch information
sidorov-panda committed Apr 2, 2018
1 parent 5a12311 commit a0fb2f8
Show file tree
Hide file tree
Showing 26 changed files with 1,370 additions and 0 deletions.
7 changes: 7 additions & 0 deletions MinterWallet/Classes/Coins/Coins.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
</dependencies>
<scenes/>
</document>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// CoinsCoinsViewController.swift
// MinterWallet
//
// Created by Alexey Sidorov on 02/04/2018.
// Copyright © 2018 Minter. All rights reserved.
//

import UIKit

class CoinsViewController: UIViewController {

var viewModel = CoinsViewModel()

// MARK: Life cycle
override func viewDidLoad() {
super.viewDidLoad()
}

}
23 changes: 23 additions & 0 deletions MinterWallet/Classes/Coins/ViewModel/CoinsViewModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// CoinsCoinsViewModel.swift
// MinterWallet
//
// Created by Alexey Sidorov on 02/04/2018.
// Copyright © 2018 Minter. All rights reserved.
//

import RxSwift

class CoinsViewModel: BaseViewModel {

var title: String {
get {
return "Coins".localized()
}
}

override init() {
super.init()

}
}
256 changes: 256 additions & 0 deletions MinterWallet/Classes/Common/Helper/Storyboards.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
//
// Autogenerated by Natalie - Storyboard Generator
// by Marcin Krzyzanowski http://krzyzanowskim.com
//
import UIKit

// MARK: - Storyboards

extension UIStoryboard {
func instantiateViewController<T: UIViewController>(ofType type: T.Type) -> T? where T: IdentifiableProtocol {
let instance = type.init()
if let identifier = instance.storyboardIdentifier {
return self.instantiateViewController(withIdentifier: identifier) as? T
}
return nil
}

}

protocol Storyboard {
static var storyboard: UIStoryboard { get }
static var identifier: String { get }
}

struct Storyboards {

struct Login: Storyboard {

static let identifier = "Login"

static var storyboard: UIStoryboard {
return UIStoryboard(name: self.identifier, bundle: nil)
}

static func instantiateViewController(withIdentifier identifier: String) -> UIViewController {
return self.storyboard.instantiateViewController(withIdentifier: identifier)
}

static func instantiateViewController<T: UIViewController>(ofType type: T.Type) -> T? where T: IdentifiableProtocol {
return self.storyboard.instantiateViewController(ofType: type)
}

static func instantiateLoginViewController() -> LoginViewController {
return self.storyboard.instantiateViewController(withIdentifier: "LoginViewController") as! LoginViewController
}
}

struct LaunchScreen: Storyboard {

static let identifier = "LaunchScreen"

static var storyboard: UIStoryboard {
return UIStoryboard(name: self.identifier, bundle: nil)
}

static func instantiateInitialViewController() -> UIViewController {
return self.storyboard.instantiateInitialViewController()!
}

static func instantiateViewController(withIdentifier identifier: String) -> UIViewController {
return self.storyboard.instantiateViewController(withIdentifier: identifier)
}

static func instantiateViewController<T: UIViewController>(ofType type: T.Type) -> T? where T: IdentifiableProtocol {
return self.storyboard.instantiateViewController(ofType: type)
}
}

struct Main: Storyboard {

static let identifier = "Main"

static var storyboard: UIStoryboard {
return UIStoryboard(name: self.identifier, bundle: nil)
}

static func instantiateInitialViewController() -> UITabBarController {
return self.storyboard.instantiateInitialViewController() as! UITabBarController
}

static func instantiateViewController(withIdentifier identifier: String) -> UIViewController {
return self.storyboard.instantiateViewController(withIdentifier: identifier)
}

static func instantiateViewController<T: UIViewController>(ofType type: T.Type) -> T? where T: IdentifiableProtocol {
return self.storyboard.instantiateViewController(ofType: type)
}
}
}

// MARK: - ReusableKind
enum ReusableKind: String, CustomStringConvertible {
case tableViewCell = "tableViewCell"
case collectionViewCell = "collectionViewCell"

var description: String { return self.rawValue }
}

// MARK: - SegueKind
enum SegueKind: String, CustomStringConvertible {
case relationship = "relationship"
case show = "show"
case presentation = "presentation"
case embed = "embed"
case unwind = "unwind"
case push = "push"
case modal = "modal"
case popover = "popover"
case replace = "replace"
case custom = "custom"

var description: String { return self.rawValue }
}

// MARK: - IdentifiableProtocol

public protocol IdentifiableProtocol: Equatable {
var storyboardIdentifier: String? { get }
}

// MARK: - SegueProtocol

public protocol SegueProtocol {
var identifier: String? { get }
}

public func ==<T: SegueProtocol, U: SegueProtocol>(lhs: T, rhs: U) -> Bool {
return lhs.identifier == rhs.identifier
}

public func ~=<T: SegueProtocol, U: SegueProtocol>(lhs: T, rhs: U) -> Bool {
return lhs.identifier == rhs.identifier
}

public func ==<T: SegueProtocol>(lhs: T, rhs: String) -> Bool {
return lhs.identifier == rhs
}

public func ~=<T: SegueProtocol>(lhs: T, rhs: String) -> Bool {
return lhs.identifier == rhs
}

public func ==<T: SegueProtocol>(lhs: String, rhs: T) -> Bool {
return lhs == rhs.identifier
}

public func ~=<T: SegueProtocol>(lhs: String, rhs: T) -> Bool {
return lhs == rhs.identifier
}

// MARK: - ReusableViewProtocol
public protocol ReusableViewProtocol: IdentifiableProtocol {
var viewType: UIView.Type? { get }
}

public func ==<T: ReusableViewProtocol, U: ReusableViewProtocol>(lhs: T, rhs: U) -> Bool {
return lhs.storyboardIdentifier == rhs.storyboardIdentifier
}

// MARK: - Protocol Implementation
extension UIStoryboardSegue: SegueProtocol {
}

extension UICollectionReusableView: ReusableViewProtocol {
public var viewType: UIView.Type? { return type(of: self) }
public var storyboardIdentifier: String? { return self.reuseIdentifier }
}

extension UITableViewCell: ReusableViewProtocol {
public var viewType: UIView.Type? { return type(of: self) }
public var storyboardIdentifier: String? { return self.reuseIdentifier }
}

// MARK: - UIViewController extension
extension UIViewController {
func perform<T: SegueProtocol>(segue: T, sender: Any?) {
if let identifier = segue.identifier {
performSegue(withIdentifier: identifier, sender: sender)
}
}

func perform<T: SegueProtocol>(segue: T) {
perform(segue: segue, sender: nil)
}
}
// MARK: - UICollectionView

extension UICollectionView {

func dequeue<T: ReusableViewProtocol>(reusable: T, for: IndexPath) -> UICollectionViewCell? {
if let identifier = reusable.storyboardIdentifier {
return dequeueReusableCell(withReuseIdentifier: identifier, for: `for`)
}
return nil
}

func register<T: ReusableViewProtocol>(reusable: T) {
if let type = reusable.viewType, let identifier = reusable.storyboardIdentifier {
register(type, forCellWithReuseIdentifier: identifier)
}
}

func dequeueReusableSupplementaryViewOfKind<T: ReusableViewProtocol>(elementKind: String, withReusable reusable: T, for: IndexPath) -> UICollectionReusableView? {
if let identifier = reusable.storyboardIdentifier {
return dequeueReusableSupplementaryView(ofKind: elementKind, withReuseIdentifier: identifier, for: `for`)
}
return nil
}

func register<T: ReusableViewProtocol>(reusable: T, forSupplementaryViewOfKind elementKind: String) {
if let type = reusable.viewType, let identifier = reusable.storyboardIdentifier {
register(type, forSupplementaryViewOfKind: elementKind, withReuseIdentifier: identifier)
}
}
}
// MARK: - UITableView

extension UITableView {

func dequeue<T: ReusableViewProtocol>(reusable: T, for: IndexPath) -> UITableViewCell? {
if let identifier = reusable.storyboardIdentifier {
return dequeueReusableCell(withIdentifier: identifier, for: `for`)
}
return nil
}

func register<T: ReusableViewProtocol>(reusable: T) {
if let type = reusable.viewType, let identifier = reusable.storyboardIdentifier {
register(type, forCellReuseIdentifier: identifier)
}
}

func dequeueReusableHeaderFooter<T: ReusableViewProtocol>(_ reusable: T) -> UITableViewHeaderFooterView? {
if let identifier = reusable.storyboardIdentifier {
return dequeueReusableHeaderFooterView(withIdentifier: identifier)
}
return nil
}

func registerReusableHeaderFooter<T: ReusableViewProtocol>(_ reusable: T) {
if let type = reusable.viewType, let identifier = reusable.storyboardIdentifier {
register(type, forHeaderFooterViewReuseIdentifier: identifier)
}
}
}

// MARK: - LoginViewController
protocol LoginViewControllerIdentifiableProtocol: IdentifiableProtocol { }

extension LoginViewController: LoginViewControllerIdentifiableProtocol { }

extension IdentifiableProtocol where Self: LoginViewController {
var storyboardIdentifier: String? { return "LoginViewController" }
static var storyboardIdentifier: String? { return "LoginViewController" }
}

15 changes: 15 additions & 0 deletions MinterWallet/Classes/Common/Helper/String+Localized.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// String+Localized.swift
// MinterWallet
//
// Created by Alexey Sidorov on 02/04/2018.
// Copyright © 2018 Minter. All rights reserved.
//

import Foundation

extension String {
func localized(_ comment: String = "") -> String {
return NSLocalizedString(self, comment: comment)
}
}
29 changes: 29 additions & 0 deletions MinterWallet/Classes/Common/Helper/UIColor+HEX.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// UIColor+HEX.swift
// MinterWallet
//
// Created by Alexey Sidorov on 02/04/2018.
// Copyright © 2018 Minter. All rights reserved.
//

import UIKit

extension UIColor {

convenience init?(hex: UInt) {
let red = CGFloat((hex & 0xFF0000) >> 16) / 255.0
let green = CGFloat((hex & 0x00FF00) >> 8) / 255.0
let blue = CGFloat(hex & 0x0000FF) / 255.0

self.init(red: red, green: green, blue: blue, alpha: 1)
}

convenience init?(hex: UInt, alpha: CGFloat) {
let red = CGFloat((hex & 0xFF0000) >> 16) / 255.0
let green = CGFloat((hex & 0x00FF00) >> 8) / 255.0
let blue = CGFloat(hex & 0x0000FF) / 255.0

self.init(red: red, green: green, blue: blue, alpha: alpha)
}

}
41 changes: 41 additions & 0 deletions MinterWallet/Classes/Common/Helper/UIFont+Default.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// UIFont+Default.swift
// MinterWallet
//
// Created by Alexey Sidorov on 02/04/2018.
// Copyright © 2018 Minter. All rights reserved.
//

import UIKit


let defaultFontNameRegular = "Ubuntu-R"
let defaultFontNameMedium = "Ubuntu-M"
let defaultFontNameBold = "Ubuntu-B"
let defaultFontNameCoursive = "Ubuntu-C"
let defaultFontNameLight = "Ubuntu-L"


extension UIFont {

static func defaultFont(of size: CGFloat) -> UIFont {
return UIFont(name: defaultFontNameRegular, size: size)!
}

static func boldFont(of size: CGFloat) -> UIFont {
return UIFont(name: defaultFontNameBold, size: size)!
}

static func mediumFont(of size: CGFloat) -> UIFont {
return UIFont(name: defaultFontNameMedium, size: size)!
}

static func lightFont(of size: CGFloat) -> UIFont {
return UIFont(name: defaultFontNameLight, size: size)!
}

static func coursiveFont(of size: CGFloat) -> UIFont {
return UIFont(name: defaultFontNameCoursive, size: size)!
}

}
Loading

0 comments on commit a0fb2f8

Please sign in to comment.