Swiftpack.co -  miquido/Aegithalos as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
miquido/Aegithalos
Function composition for functional scared.
.package(url: "https://github.com/miquido/Aegithalos.git", from: "2.1.0")

Aegithalos is a library focused on composition of mutating functions. It is useful for preparing repeatable and composable setup for any types i.e views or network requests.

Instalation

Easiest way to use Aegithalos is to add it as you Swift package dependency:

.package(url: "https://github.com/miquido/aegithalos.git", from: "2.0.0")

You can also use Xcode add SPM dependency option using this URL: https://github.com/miquido/aegithalos.git

Common usage

Main component of this library is Mutation struct. It is used to encapsulate and compose mutating functions. You can use it to define any kind of mutating function that can be passed around and applied on multiple subjects. For example - to prepare common style for UILabel applied on different screens in your application.

let labelSetup = Mutation { (label: UILabel) in
  label.textAlignment = .center
  label.textColor = .gray
}

You can use it to apply same setup whenever it is needed...

labelSetup.apply(on: myLabel)

... or even instantiate new subjects (conforming to EmptyInstantiable) with mutations applied.

let newLabelAfterSetup = labelSetup.instantiate()

Moreover mutations can be composed to refine and apply large sets of mutations on complex subjects.

let baseLabelSetup = Mutation { (label: UILabel) in
    /* do some base setup */
  }
let errorLabelSetup = Mutation
  .combined(
    baseLabelSetup,
    Mutation { (label: UILabel) in
      /* add setup for errors */
    }
  )

AegithalosCocoa

Aegithalos comes with set of usefull extensions for UIKit already prepared in AegithalosCocoa package. You can easily prapare any kind of UI setup with it, even layout constraints. Lets have a Signin with Apple button:

import AegithalosCocoa

let signinWithAppleButtonSetup = Mutation<UIButton>
  .combined(
    .backgroundColor(.black),
    .cornerRadius(5),
    .heightAnchor(.equalTo, 50),
    .titleColor(.white),
    .titleAlignment(.center),
    .titleFont(.systemFont(ofSize: 14, weight: .medium)),
    .title(localized: "com.miquido.signin.apple.button.tittle"),
    .titleInsets(UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 0)),
    .tintColor(.white),
    .image(symbol: "applelogo")
  )

License

Copyright 2020-2021 Miquido

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

GitHub

link
Stars: 9
Last commit: 6 days ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

UI extensions
6 days ago

Adding more UIKit extensions including multipliers support for width and height constraints.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API