Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cao issue 22 #37

Merged
merged 4 commits into from
Mar 4, 2021
Merged

Cao issue 22 #37

merged 4 commits into from
Mar 4, 2021

Conversation

caocmai
Copy link
Contributor

@caocmai caocmai commented Feb 25, 2021

Description

I added the ability to change the background color of the dropdown list. I also added so whenever the dropdown list has an image then show that image along with the text in the selection view.

Fixes # 22

Type of change

Strictly added only UI changes.

How Has This Been Tested?

It has been tested on the iPhone 8 and iTouch 7 by the simulator was well as on my device.

  • Xcode: 12.4
  • Model name:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Reviewers:

Please tag relevant people requesting a review

Copy link
Owner

@tejuamirthi tejuamirthi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @caocmai for contributing! It looks good. Please make these above changes and re-request a review.

@@ -215,6 +224,12 @@ class CustomDropDownView<T>: UIView, UITableViewDataSource, UITableViewDelegate,
title: items[indexPath.row].title,
lines: 0)

if selectedCellIndex == "\(indexPath.row)" {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why making the selectedCellIndex a String, can you keep it as an Int and compare? @caocmai

@@ -28,11 +28,20 @@ class CustomDropDownView<T>: UIView, UITableViewDataSource, UITableViewDelegate,
var outsideGesture: UITapGestureRecognizer?
var insideTapGesture: UITapGestureRecognizer?

var selectedCellIndex = ""
var listColor: UIColor = .lightGray
var selectedColor: UIColor = .red
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the default colors should be a bit more usable. Can we use something like .darkGray? Or may be any color you like and is widely acceptable?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the support for the user who want to opt out of having the selected row with different background color to be added.
Just add a bool in the config if they want a different background color or not and use it here.

return view
}()

lazy open var image: UIImageView = {
let image = UIImageView()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the contentMode for the image. They look stretched.


if config.dropDownCollapsable {
toggleDropDown()
tableView.reloadData()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a whole tableview reload? Or the previous selected row and newly selected row can be reloaded if you are doing this for the color. Make sure considering the user opted for having different selected background color or not.

@@ -42,19 +55,20 @@ public class DropDownDisplayView: UIView {
// MARK: - Functions

private func setupTitle(with tag: Int) {
title.tag = tag
// title.tag = tag
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the code you've commented yourself, if that won't be used. Don't remove the old commented code though. Thanks


override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
let ccp = CustomDropDownPresenter<String>(items: items, delegate: self)
let ccp = CustomDropDownPresenter<String>(items: items, delegate: self, listColor: .cyan, selectedColor: .yellow)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. Please use a more reliable set of colors, so that user's can use from the example directly.

@caocmai
Copy link
Contributor Author

caocmai commented Mar 1, 2021

Hi, thanks for the thorough feedback, I think I fixed everything. Also I decided to move the selected and background color of the dropdown in the config area instead of the view.

As regard to the colors, you can change it to whatever you think it's best I was just trying to show that it works, it's not important to me.

Uploaded new changes and requested new review. Thanks

@caocmai caocmai requested a review from tejuamirthi March 1, 2021 16:51
@tejuamirthi
Copy link
Owner

Sorry for getting back late @caocmai

Copy link
Owner

@tejuamirthi tejuamirthi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@tejuamirthi tejuamirthi linked an issue Mar 4, 2021 that may be closed by this pull request
@tejuamirthi tejuamirthi added the enhancement New feature or request label Mar 4, 2021
@tejuamirthi tejuamirthi merged commit 4d216f4 into tejuamirthi:main Mar 4, 2021
Comment on lines +37 to +41
lazy open var stackView: UIStackView = {
let stackView = UIStackView(arrangedSubviews: [self.image, self.title])
stackView.distribution = .fillProportionally
return stackView
}()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#38

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know @caocmai if you'd like to work on this issue too. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FR] DropDown row background color and styling
2 participants