dianqk / flix Goto Github PK
View Code? Open in Web Editor NEWiOS reusable form library in Swift.
License: MIT License
iOS reusable form library in Swift.
License: MIT License
Often times in real app, there are async requests return after viewDidLoad, and we want to update UI upon that return. In this particular context of Flix, main README does not document how to dynamically add in new cellProvider, but it seems there are ways to achieve that with Flix. So it would be nice to add a new section for that.
@DianQK Wdyt ?
UIViewController
as Provider?I write the code in viewDidLoad
function at my viewController:
let provider = WNFlixAddButtonProvider()
provider.tap.subscribe(onNext: { _ in
print("Ooops")
}).disposed(by: self.disposeBag)
tableView.flix.build([provider])
And WNFlixAddButtonProvider
is just based on UniqueCustomTableViewProvider
:
class WNFlixAddButtonProvider: UniqueCustomTableViewProvider {
let addButton = UIButton().then {
$0.backgroundColor = .red
$0.setTitle("+ Work Experience", for: .normal)
$0.setTitleColor(UIColor.blue, for: .normal)
$0.titleLabel?.font = Specs.font.regular
}
override init() {
super.init()
contentView.addSubview(addButton)
addButton.snp.makeConstraints { (make) in
make.edges.equalToSuperview()
}
}
}
When I run the project, the UI look's perfect, but when I tap the addButton
, it's not working.
I find some code at: Flix/Example/Example/LoginViewController.swift, the tap action works:
loginProvider.tap
.withLatestFrom(isVerified).filter { $0 }
.subscribe(onNext: { [weak self] _ in
let alert = UIAlertController(title: "Success", message: nil, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { (_) in
self?.navigationController?.popViewController(animated: true)
}))
self?.present(alert, animated: true, completion: nil)
})
.disposed(by: disposeBag)
Some code I miss?
First, Great work!!
New to this, and have a quick question regarding the example provided:
In Do Not Disturb
VC, there is this UniqueCommentTextProvider
, how can that be used in SettingsViewController
? (it does not allow now as the former is a collection view cell, while the latter is mainly on a tableview) - so the question could also be: how to write a similar UniqueCommentTextProvider
for collectionviewcell ?
Thanks ahead!!
说实话,依赖一个库的框架都不敢用,哈哈,亲是北京的~~
I always use the following code
provider.sectionHeight = { _ in return 180 }
Why not define provider.sectionHeight is CGFloat? so I could write like this:
provider.sectionHeight = 180
TableViewGroupProvider
AnimatableTableViewGroupProvider
CollectionViewGroupProvider
AnimatableCollectionViewGroupProvider
HEy Dian,
Is there is built-in support that can align collectionview cells(providers) from bottom ?
(By default, when you add a new provider/cell, it will be added from top of the screen and following last provider/cell. My quest here is if there is a built-in support or easy way to achieve align from bottom: first cell go to bottom of the screen and second following that on top of it ? )
SingleCollectionViewProvider<Cell: UICollectionViewCell> Does not conform protocol "UniqueAnimatableCollectionViewProvider" in UniqueCustomCollectionViewProvider.swift
- it used compile with no problem, any idea on why this is happening lately on 2.0.0 release ? @DianQK
Maybe you will find Segmentation fault: 11 While emitting IR SIL function ... error info when use AnimatableCollectionViewProvider
. This look like Swift bug.
This issue will closed when this error go away.
This code will cause Segmentation fault: 11:
class TestRadioProvider<Option: Equatable & StringIdentifiableType>: AnimatableCollectionViewProvider {
func configureCell(_ collectionView: UICollectionView, cell: RadioCollectionViewCell, indexPath: IndexPath, value: Value) {
}
func createValues() -> Observable<[Value]> {
return Observable.empty()
}
typealias Cell = RadioCollectionViewCell
typealias Value = Option
}
There are some workaround methods:
add createAnimatableNodes
:
class TestRadioProvider<Option: Equatable & StringIdentifiableType>: AnimatableCollectionViewProvider {
func configureCell(_ collectionView: UICollectionView, cell: RadioCollectionViewCell, indexPath: IndexPath, value: Value) {
}
func createValues() -> Observable<[Value]> {
return Observable.empty()
}
typealias Cell = RadioCollectionViewCell
typealias Value = Option
func createAnimatableNodes() -> Observable<[IdentifiableNode]> {
let providerIdentity = self._flix_identity
return createValues()
.map { $0.map { IdentifiableNode(providerIdentity: providerIdentity, valueNode: $0) } }
}
}
or add a model to warp this Option
:
struct SegmentationFault11Warp<Value: Equatable & StringIdentifiableType>: Equatable & StringIdentifiableType {
var identity: String {
return value.identity
}
let value: Value
}
class TestRadioProvider<Option: Equatable & StringIdentifiableType>: AnimatableCollectionViewProvider {
func configureCell(_ collectionView: UICollectionView, cell: RadioCollectionViewCell, indexPath: IndexPath, value: Value) {
}
func createValues() -> Observable<[Value]> {
return Observable.empty()
}
typealias Cell = RadioCollectionViewCell
typealias Value = SegmentationFault11Warp<Option>
}
not support cocoapods?
Not a issue, but since I really like and use Flix heavily, want to point out a typo in the file and contribute a tiny :), cheers 👍
line 19
let delegeteProxy = CollectionViewDelegateProxy()
guess you meant delegateProxy
After network request in viewDidLoad
function, I want to build the providers according to the network data.
// <NSThread: 0x170076e40>{number = 1, name = main}
let provider = WNFlixTitleTextFieldProvider(title: "Title", placeholder: "Placeholder")
self.tableView.flix.build([provider])
But if I just write this code in viewDidLoad
function rather than after network request, it's good:
It would be nice to support RxSwift 5.
*** Building scheme "Flix" in Flix.xcworkspace
Build Failed
Task failed with exit code 65:
/usr/bin/xcrun xcodebuild -workspace ... -scheme Flix -configuration Release -derivedDataPath ../org.carthage.CarthageKit/DerivedData/9.1_9B55/Flix/1.0.0 -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive -archivePath ./ SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO (launched in /Users/..)
i use xcode 9.1 with carthage update --platform iOS --no-use-binaries
what i'm missing?
Thank you for your open source library, I have benefited a lot.
I've been using Objective-C for years, but I recently started using Swift in my work, so I do not know deep about it.
When I integrated a library (FSPagerView) I found that I needed to implement the ' NSObjectProtocol ' protocol, which I believe is the problem with this library interacting with Objective-C, and I want to ask if there is any suggestion? Thanks.
TL;DR
How does Flix handle scroll activity ? or does it provide sth like didScroll, didEndScroll, etc. ?
More:
When I was trying to figure the above out, more things came to me:
I found that if I set collectionView to current viewcontroller where all cells are built for, then all cells are messed up, so guessing the delegate for either tableview/collectionview is set somewhere, but cant seem to find it.
The actual delegate be set to is: RxCocoa.RxCollectionViewDelegateProxy
, any idea to port that to current view controller where we need to build nodes/cells ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.