Giter Club home page Giter Club logo

lbtacomponents's People

Contributors

bhlvoong avatar sckelemen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lbtacomponents's Issues

Conversion to Swift 4.2

The Code needs some updating:

- 'NSAttributedStringKey' has been renamed to 'NSAttributedString.Key'
- 'NSLayoutFormatOptions' has been renamed to 'NSLayoutConstraint.FormatOptions'
- 'init(activityIndicatorStyle:)' has been renamed to 'init(style:)'
- 'UICollectionElementKindSectionHeader' has been renamed to 'UICollectionView.elementKindSectionHeader'

The issues are easy to fix, even by the user. But it would be more convenient if these issues didn't have to be fixed by the user in the first place.

DatasourceControllerDelegate?

Any future plans on implementing some delegate for DatasourceController and removing "controller" property from DatasourceCell?

Thanks for the pod btw!

Cast data to dataSourceItem return null entity Core Data

Hello sir,
I set up a DataSourceController, HomeDataSource and DatasourceCell.

class CategoryCell: DatasourceCell {
    
    override var datasourceItem: Any? {
        didSet {
            print(datasourceItem as! IVNCategory)
            self.configure(dataSourceItem: datasourceItem)
        }
    }
    
    let wordlabel = UILabel()
    
    let dividerLineView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor(white: 0, alpha: 0.5)
        return view
    }()
    
    override func setupViews() {
        super.setupViews()
        
        addSubview(wordlabel)
        addSubview(dividerLineView)
        
        wordlabel.anchor(topAnchor, left: leftAnchor, bottom: bottomAnchor, right: rightAnchor, topConstant: 0, leftConstant: 8, bottomConstant: 0, rightConstant: 8, widthConstant: 0, heightConstant: 0)
        
        dividerLineView.anchor(nil, left: leftAnchor, bottom: bottomAnchor, right: rightAnchor, topConstant: 0, leftConstant: 8, bottomConstant: 0, rightConstant: 0, widthConstant: 0, heightConstant: 0.5)
    }
    func configure(dataSourceItem: Any?) {
        
        if let category = dataSourceItem as? IVNCategory {
            print(category)
            if let name = Reachability.stringFromDictionary(data: category.name) {
                self.wordlabel.text = name
            }
        }
    }

}

class HomeDataSource: Datasource {
   
    override init() {
        super.init()
    }
    func fetchData(helper: IVNBaseDataHelper) {
        if let categories = helper.findAll() as? [IVNCategory] {
            objects = categories
        }
    }
    override func cellClass(_ indexPath: IndexPath) -> DatasourceCell.Type? {
        return CategoryCell.self
    }
    override func cellClasses() -> [DatasourceCell.Type] {
        return [CategoryCell.self]
    }
}

And in DataSourceController and have to fetch data from Core Data :

     let homeDataSource = HomeDataSource()
        if let helper = initDataHelper() {
            homeDataSource.fetchData(helper: helper)
            self.datasource = homeDataSource
        }

So my problem is: When I cast data from IVNCategory to Any and get back to dataSourceCell, in first load collection view ( do not scroll ) it's ok but it's return null entity when scrolled.

<inVietNam.IVNCategory: 0x600000282940> (entity: ; id: 0xd000000000400000 x-coredata://04A839A5-B2D4-4357-A1A0-A919E1C71EE4/IVNCategory/p16 ; data: )

I think problem in Reusable Cells. I tested my data, it just got error when I scroll to the first new line.
Thank you very much,

iOS 8.0

Would it be possible to make it work on iOS 8.0 and above?

UIView not showing up

I'm using LBTA components in my application, but i'm hitting a wall while trying to add a UIView to the screen with a background.
let greenView: UIView = { let v = UIView() v.backgroundColor = UIColor.rgb(red: 183, green: 202, blue: 45) v.layer.borderWidth = 1 return v }()
or
let greenView: UIView = { let v = UIView(frame: CGRect.zero) v.translatesAutoresizingMaskIntoConstraints = false v.backgroundColor = UIColor.rgb(red: 183, green: 202, blue: 45) v.layer.borderWidth = 1 return v }()

I'm adding it tho the main view and applying the constrains as recommended:
view.addSubview(greenView) greenView.anchor(top: joined.bottomAnchor, left: view.leftAnchor, bottom: nil, right: view.rightAnchor, paddingTop: 20, paddingLeft: 0, paddingBottom: 0, paddingRight: 0, width: view.frame.width - 20, height: 200)

As far as I notice this should work fine, but somehow does not appear on screen.
When debugging it I can see the view in the debugger but with a warning saying "ambiguous height".
Didn't I just defined the height on the constrains?
Am I doing something wrong here or is this some type of bug?

Dynamiclally change Datasource items number

so i have successfully loaded data from rest api into collection view but i want to add new data from server into existing arrayData after scrolling to bottom which means the collectionview number of items should get bigger... However i can not manage this

Swift Problem?

Here's the error.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSLayoutConstraint for <NSLayoutXAxisAnchor:0x604000a7e5c0 "UIImageView:0x7fccbb65e150.left">: A constraint cannot be made between <NSLayoutXAxisAnchor:0x604000a7e5c0 "UIImageView:0x7fccbb65e150.left"> and <NSLayoutXAxisAnchor:0x600000a78900 "UIView:0x7fccbb469700.leading"> because their units are not compatible.'

VFL with Safe Area

Hi, been using your VFL functions a lot and they are very helpful. Having to adapt most of my apps to the iPhone X, I realized that your functions do not take the newly introduced Safe Area into account. Any plans on updating?

Add UITextfield delegate to the textfield within my cells ?

The coolest thing about LBTAcomponents is that you don't have to dequeue cells. However, using this method does not allow me to set the delegate while dequeing the cells.

Usually I do something like this:


let cell = tableView.dequeueReusableCellWithIdentifier(settingIndexPath.cellName, forIndexPath: indexPath) as! HAIConfigurationTableViewCell
            let cellInput   = cell.viewWithTag(1) as! UITextField
            
            cellInput.delegate = self

Any advice ?

Optional constraints

how to assign optional constraints like height as greaterthan or equal some constant
height anchor >= 40 like this

Allow branch creation and pull requests?

I updated the pod and example to Swift 4.2 and wanted to push my changes into a new branch and then create a pull request but you don't allow that. Have you considered open sourcing this pod. I had to fork and create a PR but that can be annoying

How to access datasource object property from didSelectItemAt ?

from my method

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)

I can print the object like so

let object =  self.datasource?.objects?[indexPath.item]
print(object)

but if I want to access a property from my object, I can't. For instance,

print(object.imageUrl)

does not work.

How to go about this?

I've used the demo project to play with the library and the class I am trying to access is very similar to the Intermediate Example

struct MenuItem {
    let name: String
    let imageUrl: String
    let destination: String
```
    
```
    init(name: String, imageUrl: String, destination: String = "none"){
        self.name = name
        self.imageUrl = imageUrl
        self.destination = destination.uppercased()
    }
}`
```

Division on two Pods

Hello, Brian!
I finally decided to install your LBTAComponents and immediately found one issue: almost 400mb. And 95% of it is examples. So a little piece of advice: maybe two pods?

Update to Swift 5

Hi! I love this library, will it be updated for Swift 5? Can we, its users, help in any way? Thank you.

Can't reload DataSourceCell from DataSourceContoller

I Can't reload DataSourceCell with new data. I can load data API call In ViewDidLoad in HomeDataSourceController. But When i tap a button then api call will fetch and result is same with minor value changes. i set the datasource in if Api call success.

self.datasource = usersDatasource
collectionView?.reloadData()

But cell not reload.

pod file error

Hi
I want to add LBTAComponents in my project but get below error

[!] Unable to satisfy the following requirements:

  • LBTAComponents required by Podfile

Specs satisfying the LBTAComponents dependency were found, but they required a higher minimum deployment target.

please help.

Storyboard issue

Hello Brian, how can I use this pod for storyboard ? I'm trying but I'm getting this fatal error ;

fatal error: init(coder:) has not been implemented: file /Users/***/Desktop/TwitterLBTA/Pods/LBTAComponents/LBTAComponents/Classes/DatasourceController.swift, line 54

Multiple API request on same datasource

so how can i make it work with two api request...i have one for section 0 (fetcUserData where i got json response) and second for section 1 (fetchUserFeed) but olny one of them is showing depending which is called first in controller

Type 'NSAttributedStringKey' (aka 'NSString') has no member 'paragraphStyle'

Hello Brian, first of all thank you for your good job on LBTAComponents. I am using it in my project and it makes the development so much easier ! ๐Ÿ‘

In NSMutableAttribtutedString+Helper.swift I got the following error :

Type 'NSAttributedStringKey' (aka 'NSString') has no member 'paragraphStyle'

capture d ecran 2017-09-23 a 11 08 07

I am using Swift3 and upgraded xcode 8.2 to 9.

Finally I upgraded to swift 4 and replaced NSAttributedStringKey.paragraphStyle with .paragraphStyle.

I close the issue

No such module 'LBTAComponent'

Hi!

I'm following Brian Tutorial for Twitter App now (2018). I try to use LBTAComponents version on that video. I follow all step and got me error on No Such Module LBTAComponents. I already open .xcworkspace. Then I try to use up-to-date version of it, but still the error coming up.

Is there any solution for this? Thanks

UITextViews not rendering on LBTAFormController

I am trying to add a UITextView into a LBTAFormController, using the following

class MakePostViewController: LBTAFormController {

    ...
    var descField = UITextView()

    override func viewDidLoad() {
        super.viewDidLoad()

        // Setting up view layout
        formContainerStackView.axis = .vertical
        formContainerStackView.spacing = 25
        formContainerStackView.layoutMargins = .init(top: 25, left: 25, bottom: 0, right: 25)
        ...
        // Description field
        descField = UITextView(text: "Add a description", font: UIFont.systemFont(ofSize: 16), textColor: #colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0), textAlignment: .natural)
        descField.backgroundColor = #colorLiteral(red: 0.7450980544, green: 0.1568627506, blue: 0.07450980693, alpha: 1)
        formContainerStackView.addArrangedSubview(descField)
        ...

    }
   

However, when I run this code, the UITextView is the only object that doesn't render. All the UIButtons and UITextFields seem to render fine though. Not sure if this is a limitation with the library or if I am doing something wrong here...

Installing pod

I had a problem with installation of the pod. The cocoapods could not find the repository. The issue solved when I hit the command in the terminal 'pod update'.

How update Datasource data with reload

Hi

I would like to reload my data in DatasourceController when the user clicks on the refresh button.

My Datasource shows changing in debug but no effect on collection layout views or Cells

thanks

Constraints not working

Hey Brian thanks for this github repo.
I am facing some issue related to constraints.
here is my code.

import UIKit

class HomeViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    setupView()
}

let topContainer:UIView = {
    let container = UIView()
    container.backgroundColor = UIColor.red
    return container
}()

func setupView() {
    view.addSubview(topContainer)
    
    //this works fine
    view.addConstraintsWithFormat("H:|[v0]|", views: topContainer)
    view.addConstraintsWithFormat("V:|[v0(350)]", views: topContainer)
    
    //This below code not working
    topContainer.anchor(self.topAnchor, left: self.leftAnchor, bottom: nil, right: nil, topConstant: 16, leftConstant: 16, bottomConstant: 0, rightConstant: 0, widthConstant: 350, heightConstant: 350)

}
}

and I am using extension of UIView

extension UIView {
public func addConstraintsWithFormat(_ format: String, views: UIView...) {
    
    var viewsDictionary = [String: UIView]()
    for (index, view) in views.enumerated() {
        let key = "v\(index)"
        viewsDictionary[key] = view
        view.translatesAutoresizingMaskIntoConstraints = false
    }
    
    addConstraints(NSLayoutConstraint.constraints(withVisualFormat: format, options: NSLayoutFormatOptions(), metrics: nil, views: viewsDictionary))
}
 
public func anchor(_ top: NSLayoutYAxisAnchor? = nil, left: NSLayoutXAxisAnchor? = nil, bottom: NSLayoutYAxisAnchor? = nil, right: NSLayoutXAxisAnchor? = nil, topConstant: CGFloat = 0, leftConstant: CGFloat = 0, bottomConstant: CGFloat = 0, rightConstant: CGFloat = 0, widthConstant: CGFloat = 0, heightConstant: CGFloat = 0) {
    translatesAutoresizingMaskIntoConstraints = false
    
    _ = anchorWithReturnAnchors(top, left: left, bottom: bottom, right: right, topConstant: topConstant, leftConstant: leftConstant, bottomConstant: bottomConstant, rightConstant: rightConstant, widthConstant: widthConstant, heightConstant: heightConstant)
}

public func anchorWithReturnAnchors(_ top: NSLayoutYAxisAnchor? = nil, left: NSLayoutXAxisAnchor? = nil, bottom: NSLayoutYAxisAnchor? = nil, right: NSLayoutXAxisAnchor? = nil, topConstant: CGFloat = 0, leftConstant: CGFloat = 0, bottomConstant: CGFloat = 0, rightConstant: CGFloat = 0, widthConstant: CGFloat = 0, heightConstant: CGFloat = 0) -> [NSLayoutConstraint] {
    translatesAutoresizingMaskIntoConstraints = false
    
    var anchors = [NSLayoutConstraint]()
    
    if let top = top {
        anchors.append(topAnchor.constraint(equalTo: top, constant: topConstant))
    }
    
    if let left = left {
        anchors.append(leftAnchor.constraint(equalTo: left, constant: leftConstant))
    }
    
    if let bottom = bottom {
        anchors.append(bottomAnchor.constraint(equalTo: bottom, constant: -bottomConstant))
    }
    
    if let right = right {
        anchors.append(rightAnchor.constraint(equalTo: right, constant: -rightConstant))
    }
    
    if widthConstant > 0 {
        anchors.append(widthAnchor.constraint(equalToConstant: widthConstant))
    }
    
    if heightConstant > 0 {
        anchors.append(heightAnchor.constraint(equalToConstant: heightConstant))
    }
    
    anchors.forEach({$0.isActive = true})
    
    return anchors
}

}

Not running well under Swift 4

Has anyone else tried to run the latest pod under Swift 4? I find some error messages when it runs - some can be fixed but do not know enough about the code to try and fix them all - any others observing this?

How to register Nib file ?

I want to use nib file for cells in LBTAComponents. What should I do to implement this?

I tried to write a method cellNibs ( the same with cellClasses ) to register nibs file :
I debugged it and it ran into register nib before dequeue a cell ( also checked identifier not wrong).
I got this errror :

'could not dequeue a view of kind: UICollectionElementKindCell with identifier inVietNam.HeadingHomeCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'

open var datasource: Datasource? {
        didSet {
            if let cellClasses = datasource?.cellClasses() {
            
                for cellClass in cellClasses {
                    
                    collectionView?.register(cellClass, forCellWithReuseIdentifier: NSStringFromClass(cellClass))
                }
            }
            
            if let cells = datasource?.cellNibs() {
                
                for cell in cells {
                        collectionView?.register(cell.nib, forCellWithReuseIdentifier: cell.nibName)
                    
                }
            }
            
            if let headerClasses = datasource?.headerClasses() {
                for headerClass in headerClasses {
                    collectionView?.register(headerClass, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: NSStringFromClass(headerClass))
                }
            }
            
            if let footerClasses = datasource?.footerClasses() {
                for footerClass in footerClasses {
                    collectionView?.register(footerClass, forSupplementaryViewOfKind: UICollectionElementKindSectionFooter, withReuseIdentifier: NSStringFromClass(footerClass))
                }
            }
            
            collectionView?.reloadData()
        }
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.