Skip to content

rollingglory/GloryKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anjay-With-Background

Cocoapods Support Carthage Support Swift: 4.2 XCode: 10.2 Release

Release Status
Release

GloryKit starts your project off with a great preparation and almost everything you need to start developing with ease 💖 and a peace of mind 😌.

Installation

Currently GloryKit can only be installed using Carthage or manual submoduling. Please refer to release status for release availability. Don't use incubation/beta version without knowing and accepting possible bugs or issues.

Carthage:

github "rollingglory/GloryKit"

New to Carthage? You can follow the instructions here to use Carthage and add frameworks to project.

Submodule:

Simply clone or download this project and add manually to your project directory.

Usage

Basic

For basic usage you can import GloryKit and other corresponding framework, as GloryKit doesn't automatically include specific framework in usage of its methods.

import GloryKit

class MyClass: GloryController {
  override func viewDidLoad() {
    super.viewDidLoad()

    Glory().initiate()
  }
}

You can directly use GloryKit features, extensions, public helper and many more.

Networking

GloryKit uses Moya as its networking layer. Moya itself covers Alamofire in exchange of URLSession. To use Moya, you need to create two basic class/struct. The first one is service, and the other is interactor/adapter.

Service

A service handles your list of endpoints in a server-way, you configure an endpoint's request method, base url, path, headers, url and body parameters.

import Moya

enum AuthenticationService {
  case login(email: String, password: String)
}

extension AuthenticationService: TargetType {
  var baseURL: URL { return "api.randomdude.com" }
  var path: String { return "/login" }
  var method: Moya.Method { return .post }
  var sampleData: Data { return Data() } // You can ignore this by setting `Data()` as default
  var task: Task {
    switch self {
      case .login(let email, let password):
        let params: [String: Any] = [
          "email": email, "password": password
        ]
        return .requestParameters(parameters: params, encoding: JSONEncoding.default)
    }
  }
  var headers: [String: String]? {
    return ["Content-Type": "application/json"
  }
}

Interactor/Adapter

Use any phrase you fancy to use. Interactor creates actual mediator between our service enum with the server.

struct AuthenticationInteractor {
  let provider = MoyaProvider<AuthenticationService>()

  func login(email: String, password: String) {
    provider.request(.login(email: email, password: password)) { result in
      // Handle result here
    }
  }
}

Once you're done with these two, your classes can call

AuthenticationInteractor().login(email: "something", password: "encrypted something")

from anywhere in the class and handles its result.

Database

As for database, GloryKit uses good ol' Realm. Realm gives an ease of use in writing, fetching and manipulating data. GloryKit ensures a more effective use of Realm with expanding its functions to better help developers.

GloryKit has `RealmHelper` class as-you guess it-Realm's helper functions. There, you can find Realm's default instance to be used from anywhere in your code. For example:

...
// Get default realm instance
let realm = RealmHelper.shared.realm

// Get list of realm object (and filter them as well)
RealmHelper.shared.get(Object.self, filter: "id != 12")

// You can also create a custom transaction within a closure
RealmHelper.shared.write(inRealm: realm) { (realm) in
  realm.add(object, update: .modified)
  realm.delete(anotherObject)
  // etc.
}
...

Keychain

Keychain is a secure storage. You can store all kind of sensitive data in it: user passwords, credit card numbers, secret tokens etc. Using KeychainSwift, your sensitive data is ensured to be secure all the time. KeychainSwift lets you get and set data in and out of device's keychain in an easy way.

let keychain = KeychainSwift()
keychain.set("hello world", forKey: "myKey")
keychain.get("myKey")

Image Loading

Kingfisher is a powerful, pure-Swift library for downloading and caching images from the web. With plenty of helpful functions already, Kingfisher is developers' favourite image library.

GloryKit extends a little bit of Kingfisher's method.

let soloImageView = UIImageView()
soloImageView.setImage(urlString: "https://img.url/anjaymabar")

Other than urlString parameter, there are placeholder, options, fade and completionHandler.

Other

You can read all advanced class reference here.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Information

For further information you can follow us on our website.

License

MIT License

Copyright (c) 2019 Rolling Glory

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published