https://github.com/blowmindstyle/blowmindstyle
Framework that will help to orginize styles in your app
https://github.com/blowmindstyle/blowmindstyle
framework ios style swift swift5
Last synced: 5 months ago
JSON representation
Framework that will help to orginize styles in your app
- Host: GitHub
- URL: https://github.com/blowmindstyle/blowmindstyle
- Owner: BlowMindStyle
- License: mit
- Created: 2019-07-14T17:39:32.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-31T14:19:59.000Z (about 6 years ago)
- Last Synced: 2025-10-23T11:53:01.270Z (5 months ago)
- Topics: framework, ios, style, swift, swift5
- Language: Swift
- Homepage:
- Size: 933 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://cocoapods.org/pods/BlowMindStyle)
[](https://github.com/apple/swift-package-manager)
## Introduction
The purpose of the **BlowMindStyle** library is to provide the infrastructure for application styling.
**BlowMindStyle** allows:
- write reusable styles for views
- write reusable styles for text formatting (based on [SemanticString](https://github.com/BlowMindStyle/SemanticString))
- add application themes
- dynamically update views depending on trait collection and theme
- dynamically update views depending on a model state.
## Basic usage
1) Add resources, that will be used for stylization:
```swift
struct ButtonProperties {
var backgroundColor: UIColor?
var cornerRadius: CGFloat?
var titleColor: UIColor?
var font: UIFont?
var contentEdgeInsets: UIEdgeInsets?
}
```
2) Define style:
```swift
final class ButtonStyle: EnvironmentStyle { }
```
3) Apply resources to view:
```swift
extension EnvironmentContext where Element: UIButton {
var buttonStyle: StylableElement> {
stylableElement { button, style, resources in
button.setTitleColor(resources.titleColor, for: .normal)
let cornerRadius = resources.cornerRadius ?? 0
if let normalColor = resources.backgroundColor {
let normalBackground = UIImage.resizableImage(withSolidColor: normalColor, cornerRadius: cornerRadius)
button.setBackgroundImage(normalBackground, for: .normal)
} else {
button.setBackgroundImage(nil, for: .normal)
}
button.titleLabel?.font = resources.font ?? UIFont.systemFont(ofSize: UIFont.buttonFontSize)
button.contentEdgeInsets = resources.contentEdgeInsets ?? .zero
}
}
}
```
4) Use style:
```swift
button.setUpStyles {
$0.buttonStyle.apply(.primary)
}
```
For more info see [tutorial](#Tutorial)
## Dependencies
* [RxSwift 5](https://github.com/ReactiveX/RxSwift)
* [RxCocoa 5](https://github.com/ReactiveX/RxSwift)
* [SemanticString](https://github.com/BlowMindStyle/SemanticString)
## Installation
### [CocoaPods](https://guides.cocoapods.org/using/using-cocoapods.html)
```ruby
# Podfile
use_frameworks!
target 'YOUR_TARGET_NAME' do
pod 'BlowMindStyle'
end
```
### [Swift Package Manager](https://github.com/apple/swift-package-manager)
In XCode select File/Swift Packages/Add Package Dependency. Type 'BlowMindStyle', select `BlowMindStyle` project and click 'Next', 'Next'
## Tutorial
0. [Preparing the project](Tutorial/Docs/Part0_preparingTheProject.md)
1. [Creating your own style](Tutorial/Docs/Part1_createYourOwnStyle.md)
2. [Creating a theme](Tutorial/Docs/Part2_createATheme.md)
3. [Switching styles according to the state](Tutorial/Docs/Part3_switchStyles.md)
4. [Text stylization](Tutorial/Docs/Part4_textStylization.md)