-
Notifications
You must be signed in to change notification settings - Fork 385
Allow for quick toggle between open/closed issues #2687
base: master
Are you sure you want to change the base?
Conversation
That’s inspired work! Sent with GitHawk |
Awesome @Huddie 3 f/u
|
This PR will not include anything on the inbox but if you’re interested in that open an issue maybe with a design? If one manually types is:open/closed, it will pass that along in the query, this does not effect the original query string. It’s a segment control so yes, it’s to toggle between open and closed. Maybe I’ll put together a custom multi-select. Won’t be getting around to this for a week at least. Sent with GitHawk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Really cool that you were able to whip this up so quickly 💪
// MARK: BaseListViewControllerHeaderDataSource | ||
|
||
func headerModel(for adapter: ListSwiftAdapter) -> ListSwiftPair { | ||
return ListSwiftPair.pair("header", { [weak self, previousSearchString] in | ||
SearchBarSectionController( | ||
placeholder: Constants.Strings.search, | ||
delegate: self, | ||
query: previousSearchString | ||
query: previousSearchString, | ||
items: ["Open", "Closed"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Localization? Also... what would this look like if these would be awfully long? Not sure if that would scale...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well localization of those would never be done here, it would be done before adding to the segment control. Aka, user passes in array of strings, we localize and add to control.
@@ -29,7 +29,8 @@ IndicatorInfoProvider { | |||
private let type: RepositoryIssuesType | |||
private let searchKey: ListDiffable = "searchKey" as ListDiffable | |||
private let debouncer = Debouncer() | |||
private var previousSearchString = "is:open " | |||
private var previousSearchString = "" | |||
private var prefix = "is:open " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does the GitHub highlighter think prefix
is a keyword? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷 Problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No should be good 😊
segmentControl.addTarget(self, action: #selector(updateSegement), for: .valueChanged) | ||
|
||
setSegmentControl() | ||
segmentControlLeadingConstraint.deactivate() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you need this constraint for if you deactivate
it before the init
returns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deactivated on start due to the search bar not being in editing mode. Once you start editing the constraint becomes activated
for title in items { | ||
segmentControl.insertSegment( | ||
withTitle: title, | ||
at: segmentControl.numberOfSegments, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm reading this as it will always insert it at the end as the numberOfSegments
is updated every time this is called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes correct, the order in which you pass in the array is the order it will appear.
segmentControl.backgroundColor = .clear | ||
segmentControl.tintColor = .clear | ||
|
||
let normalFont: [AnyHashable: Any] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use [NSAttributedStringKey: Any]
here instead and can then infer the type going forward. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing!
} | ||
|
||
// create a 1x1 image with this color | ||
private func imageWithColor(color: UIColor) -> UIImage { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have this somewhere else already by chance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ill search
// create a 1x1 image with this color | ||
private func imageWithColor(color: UIColor) -> UIImage { | ||
let rect = CGRect(x: 0.0, y: 0.0, width: 1.0, height: 1.0) | ||
UIGraphicsBeginImageContext(rect.size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to use UIGraphicsImageRenderer
here instead, which removes the need to have to deal with optionals.
Oh and one more question... what if I want to search for both closed and open issues? That doesn't seem to be possible anymore. |
Gonna switch out the segment control for a custom control that allows mutli selection. End result will look the same + allow multiple selection thereby open and closed or none |
@Huddie Have you had the time to look into adding it? Or someone else should take hold of this PR? |
I will try to finish this week. Otherwise I’ll let you know and it would be awesome if you or someone else picked it Sent with GitHawk |
Currently, a WIP, looking for some feedback.
Closes #374
Quick description:
During Editing:
Segment Bar recedes allowing easy typing
When Finished Editing:
Segment Bar appears allowing a quick move between closed/open issues
It currently does update the state properly and the list does refresh properly