Skip to content
This repository has been archived by the owner on Jul 2, 2023. It is now read-only.

Is there a way to use UniqueCommentTextProvider in SettingsViewController #16

Closed
10000TB opened this issue Jun 6, 2018 · 4 comments
Closed

Comments

@10000TB
Copy link

10000TB commented Jun 6, 2018

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!!

@DianQK
Copy link
Owner

DianQK commented Jun 6, 2018

hmm?
now UniqueCommentTextProvider is used for UICollectionView. If you want to add UniqueCommentTextProvider to UITableViewCell,we can use SingleTableViewCellProvider, SingleUITableViewCellProvider or AnimatablePartionSectionTableViewProvider.

for example:

class SingleCommentTextTableViewProvider: SingleUITableViewCellProvider {

    let textLabel = UILabel()

    override init() {
        super.init()
        ...
    }

}

If you want to create UniqueCommentTextProvider for UITableView & UICollectionView, this is maybe not support. Maybe you need add more wrap class.
But I will think about this feature on 3.x. (maybe not, because UITableView and UICollectionView have different method).

@10000TB
Copy link
Author

10000TB commented Jun 7, 2018

Thanks @DianQK .
I was trying to do that by subclassing SingleUITableViewCellProvider , but it seems that it does not have sizeForItemAt as SingleUICollectionViewCellProvider has, which is being used to set appropriate height.

@10000TB
Copy link
Author

10000TB commented Jun 7, 2018

Correct me if i am wrong :) :
I am guessing that SingleUITableViewCellProvider is missing a function, like sizeForItem: atIndexPath: or heightForItem: atIndexPath, which needs to set open var itemHeight: ((UITableView) -> CGFloat?)? based on cell index, and the height of actual string in the cell label.

@DianQK
Copy link
Owner

DianQK commented Jun 8, 2018

Hi @10000TB ,
When we use SingleUITableViewCellProvider, I think we can ignore IndexPath. But if you need, just override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath, value: SingleTableViewCellProvider) -> CGFloat?.

You can see this implement on SingleUITableViewCellProvider:

open func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath, value: SingleTableViewCellProvider) -> CGFloat? {
    return self.itemHeight?(tableView)
}

@DianQK DianQK closed this as completed Jun 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants