TemplateKit alternatives and similar libraries
Based on the "UI" category.
Alternatively, view TemplateKit alternatives based on common mentions on social networks and blogs.
-
Animated Tab Bar
:octocat: RAMAnimatedTabBarController is a Swift UI module library for adding animation to iOS tabbar items and icons. iOS library made by @Ramotion -
JTAppleCalendar
The Unofficial Apple iOS Swift Calendar View. Swift calendar Library. iOS calendar Control. 100% Customizable -
FSPagerView
FSPagerView is an elegant Screen Slide Library. It is extremely helpful for making Banner View、Product Show、Welcome/Guide Pages、Screen/ViewController Sliders. -
Pagemenu
A paging menu controller built from other view controllers placed inside a scroll view (like Spotify, Windows Phone, Instagram) -
SwiftEntryKit
SwiftEntryKit is a presentation library for iOS. It can be used to easily display overlays within your iOS apps. -
SwipeCellKit
Swipeable UITableViewCell/UICollectionViewCell based on the stock Mail.app, implemented in Swift. -
Alerts Pickers
Advanced usage of UIAlertController and pickers based on it: Telegram, Contacts, Location, PhotoLibrary, Country, Phone Code, Currency, Date... -
SideMenu
Simple side/slide menu control for iOS, no code necessary! Lots of customization. Add it to your project in 5 minutes or less. -
Scrollable-GraphView
An adaptive scrollable graph view for iOS to visualise simple discrete datasets. Written in Swift. -
ESTabBarController
:octocat: ESTabBarController is a Swift model for customize UI, badge and adding animation to tabbar items. Support lottie! -
Material Components for iOS
[In maintenance mode] Modular and customizable Material Design UI components for iOS -
NotificationBanner
The easiest way to display highly customizable in app notification banners in iOS -
ActiveLabel
UILabel drop-in replacement supporting Hashtags (#), Mentions (@) and URLs (http://) written in Swift -
SlideMenuControllerSwift
iOS Slide Menu View based on Google+, iQON, Feedly, Ameba iOS app. It is written in pure swift. -
PopupDialog
A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style. -
TLYShyNavBar
DISCONTINUED. Unlike all those arrogant UINavigationBar, this one is shy and humble! Easily create auto-scrolling navigation bars! -
StarWars.iOS
This component implements transition animation to crumble view-controller into tiny pieces. -
KMNavigationBarTransition
A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles while pushing or popping a view controller for all orientations. And you don't need to write any line of code for it, it all happens automatically. -
Whisper
:mega: Whisper is a component that will make the task of display messages and in-app notifications simple. It has three different views inside -
PaperOnboarding
:octocat: PaperOnboarding is a material design UI slider. Swift UI library by @Ramotion -
CircleMenu
:octocat: ⭕️ CircleMenu is a simple, elegant UI menu with a circular layout and material design animations. Swift UI library made by @Ramotion -
RazzleDazzle
A simple keyframe-based animation framework for iOS, written in Swift. Perfect for scrolling app intros.
CodeRabbit: AI Code Reviews for Developers
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of TemplateKit or a related project?
README
TemplateKit
React-inspired framework for building component-based user interfaces in Swift.
Features | |
---|---|
🐤 | Completely native - write your app in Swift |
📃 | Declarative - define your UI using markup |
📦 | Components - encapsulate functionality into reusable chunks |
📐 | Layout - Flexbox for layout, just like on the web |
🖋 | State - automatically flush state changes to UI |
⚖ | Diffing - the minimum set of updates are flushed to UI |
🚀 | Performance - diffing and layout are done on background threads |
⏲ | Animation - built-in support for animating any property |
Example
You define your UI using a simple markup language, which is inspired by HTML and CSS. This UI definition is rendered into a tree of native elements.
Component.xml
<template>
<style>
#container > .button {
color: #000;
}
#container > .button-selected {
color: #f00;
}
</style>
<box id="container">
<text text="$properties.title" />
<text text="Click me!" onTap="handleClick" classNames="$textClasses" />
</box>
</template>
Component.swift
Functionality and state is encapsulated into components, which do things like handle user events and flush state changes to the UI. Components have strongly typed State
and Properties
values, that are used to figure out what ends up getting pushed out to UIKit.
struct ComponentState: State {
var selected: Bool?
}
struct ComponentProperties: Properties {
var core = CoreProperties()
var title: String? = "This is a default title"
}
class MyComponent: CompositeComponent<ComponentState, ComponentProperties, UIView> {
// Stored properties on the component are made available to template.
var textClasses: String?
// As are functions, referenced by their selector name.
@objc func handleClick() {
updateComponentState { state in
state.selected = !state.selected
}
}
override func render() -> Element {
textClasses = state.selected ? "button" : "button-selected"
return render("http://localhost:8000/Component.xml")
}
}
ViewController.swift
Rendering components is as easy as calling a render
function, which asynchronously computes and flushes a component to the supplied container view.
override func viewDidLoad() {
super.viewDidLoad()
UIKitRenderer.render(component(MyComponent.self), container: self.view, context: self) { component in
self.component = component
}
}
See the included Example project for more examples of how to use TemplateKit.
Why?
Swift
Because you like writing your apps completely in Swift. TemplateKit is fully native and compiled.
Declarative Style
Writing user interfaces in a declarative style makes it easier to reason about how model data and user actions affect what gets rendered. Out-of-the-box support for XML. Extensible if you want to add your own template format (e.g., protocol buffers).
Components
Components make it easy to encapsulate application functionality into re-usable building blocks. These blocks can then be composed to create more complex interfaces.
Layout
Flexbox-based layout primitives allow developers to use the the same expressive layout system available in modern browsers.
Asynchronous Rendering & Performance
All layout computation, text sizing, tree diffing, image decoding is performed in the background. This keeps the main thread available for responding to user actions. Only the absolute minimum set of changes needed to update the view hierarchy are actually flushed to the rendered views.
CSS
Use stylesheets to style components, just like you do on the web.
Animations
Animate layout, style and arbitrary properties using an intuitive API.
Live Reloading
Automatically reload changes to user interfaces without having to re-build binaries or restart your application. Usable in both development and production environments.
Extensible
Add custom components, custom native views, custom template loading schemes and more.
Easy to try
Plug it in anywhere you want to render a view in your application. Plays nicely with the rest of your app.
Installation
Carthage
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
Add the following line to your Cartfile:
github "mcudich/TemplateKit"
Run carthage update
, then make sure to add TemplateKit.framework
, CSSLayout.framework
, and CSSParser.framework
to "Linked Frameworks and Libraries" and "copy-frameworks" Build Phases.
CocoaPods
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
To integrate TemplateKit into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target '<Your Target Name>' do
pod 'TemplateKit', '~> 0.1.0'
end
Then, run the following command:
$ pod install
Requirements
- iOS 9.3+
- Xcode 8.0+
- Swift 3.0+
Communication
- If you found a bug, open an issue.
- If you have a feature request, open an issue.
- If you want to contribute, submit a pull request.
How does it work?
At its core, TemplateKit is comprised of Element
and Node
instances. Elements are used to describe trees of nodes, which can be anything that implements the Node
interface. Nodes are used to vend out and manage view hierarchies.
Out of the box, there are several Node
implementations that make it easy to set up UI hierarchies: Component
, ViewNode
, and a set of native controls like buttons, text labels, text fields and so on.
Building a component is as simple as subclassing Component
, overriding its render()
function, and deciding the set of properties it might accept and use as part of rendering. render()
simply needs to return a Template
, which can be constructed programmatically, or via an XML document (or other custom payload). When it comes time to render your component into a view, you simply call UIKitRenderer.render
, and pass in the view that should contain your component's rendered output. This will in turn call render()
on your component instance, compute the layout and styles for the view tree, build this tree and then apply the layout and styles to it as appropriate.
When it comes time to update your component's state, you can call updateState
from within your component implementation. This function receives a function that is passed the current state value (each Component
can declare a State
type, in the same way it declares a Properties
type). This function in turn enqueues an update to the component, which will cause it to re-render, taking into account whatever changes were made to the state. This update is intelligent, and compares the current incarnation of the rendered view tree against the proposed element tree. Only the deltas between these two are flushed out to the view layer.
Opaque Views
If there are parts of your UI that are easier to deal with as plain UIViews
, TemplateKit provides a simple abstraction Node
called ViewNode
that allows you to include these "opaque" views as part of any TemplateKit-managed tree. TemplateKit stays out of the way, and simply sets the frame
of these views for you, so they sit nicely within in whatever UI tree you've composed.
Collections
TemplateKit provides UITableView
and UICollectionView
subclasses which are able to load, and asynchronously size and render Components
into cells with just a little bit of configuration. Tables and collections can be used via Table
and Collection
components, or simply wrapped as ViewNode
instances. The Table
and Collection
components have built-in support for diffing, so that data-source updates result in the minimum set of operations required to have the respective UIKit views reflect data changes. See Diff.swift for more information.
How's this different from React Native?
TemplateKit is implemented in Swift (and a bit of C). If you like writing entirely in Swift, then this framework might be for you.
React Native relies on a very well-tested library (React), and has been shipping in popular apps for some time now. This means it probably has way fewer rough edges, has sorted out many performance issues TemplateKit has yet to face, and so on.
What's Missing
A lot.
There's no AppKit support yet (though it would be straightforward to add). Lots of tests have yet to be written. Performance testing has yet to be done. The entirety of the applicable CSS spec is not supported. Animation features are rudimentary at best. Many gesture types need to be added. And much more.
If you'd like something added, please file a feature request or send a pull request!
Inspiration
See Also
If TemplateKit isn't exactly what you're looking for, check out these other great projects!
*Note that all licence references and agreements mentioned in the TemplateKit README section above
are relevant to that project's source code only.