-
Notifications
You must be signed in to change notification settings - Fork 810
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
Style, naming and other minor nitpicking #123
Comments
Numbers 1, 2 & 3 should not take long to complete. All good suggestions. I know you're probably busy but any help is appreciated. |
Thoughts on rethinking Number#4 Ok I think i remember my thoughts which made me register using a property. If the User provides the view in a Currently how the code is, it basically remembers the view that the user wants, and caches it. Thereby limiting calls to the dev's code (which could include bad performing code). Since a dev will only want 1 or 2 different cells, I opted to just directly remembering those 2 cells, instead of making a delegate call every time the user scrolls the calendar. But now that you brought it up, I am wondering if my quest for performance was unnecessary in this case. Currently, this calendar works well on an old iPhone 4s. |
Ah, yes, he makes some good points. :) I have to update my app to swift 3 soon and then I'll try to add SwiftLint here and clear its warnings on the swift 3 branch if I have the time. As for item 3, yes, I was actually referring to the swift 3 branch; I can still find examples of the naming conventions not being followed there. I'll try to fix that too and make a PR. About your last message, I don't see how number 4 would reduce performance unless the user did something stupid (which he could already do, except that it would be in the Also, about suggestion 5, what do you mean by "offset days"? |
Ah, I just realized you already use |
hmm.. Inside the if view != nil { return} This means that although the dev's xib view is created for every cell (as you have correctly said), the xib view is only instantiated once. For all other times, the developers xib view will not be instantiated again. It will be reused. Currently, In the With the current setup (assuming a 6x7 grid), 42 cells will be instantiated, and reused. And 42 subviews will be attached to those cells. Since the 42 views are subviews to the 42 cells, they are also only created once and reused. This is what I was referring to with performance. If i understand correctly however, you are suggesting something like this? function cellForItemAt(calendar: JTAppleCalendar, date: NSDate) -> JTAppleDayCellView {
let dateCell = myAlreadyCustomizedDayDell()
someFunctionToConfigureTheCell(dateCell)
return dateCell
} |
Ah, ok, now I get it, sorry. Yes, what I had in mind was something like that, but now I see it wouldn't be that easy to do that and use the native reusable cells at the same time. So I guess your current solution is probably the easiest and it works well enough. It would be nice if |
Hmm. you know. lol, that UICollectionView direct subclass sounds like a good idea haha. The code change would be very minimal, and the benefits would be incredible. I will look into it. I'm about 60% finished coding |
wow.. thinking about it. A direct UICollectionView subclass is an even better idea than Number#4 yesterday! I will definitely look at it once i'm done. I see no conflicts with it in my mind right now. It will allow for multiple cells, and the user creating their own identifiers directly on the storyboard indeed. (if it works) |
Yes, if it works out I think it would be pretty great. :) One reason to put the But I think we can work around that by using getters and setters like those other answers suggest, or if that doesn't work we can just declare a new property like Then we could do something like this to expose some of the original delegate methods (like That's the trickiest part, I guess. Other than that I don't think much else would have to be changed. Since you're already working on some major changes I'll wait until you're finished with that and then I'll look into adding SwiftLint and changing my first 3 suggestions if you want me to, ok? Fixing the style and naming conventions will change the API, but this idea will too, so you could bundle those changes together in another major release. |
Yea. sure man, you can go ahead. You sound like someone who does neat code. |
Changes are done. Btw, do you think its a good idea to stop support for swift 2? |
Great! I think it's a good idea to have a stable swift 2.3 version for people who are still transitioning, but for the new stuff, sure, I'd leave swift 2 behind. Is the |
DynamicGeneration branch should be in swift 3 by morning. Swift linting etc can start then. |
I'll get started tonight. :) |
Uhm, now I just forked it and the branch isn't in swift 3 yet, right? |
I'm @ work. Making that last push in about 3 hrs. |
Ah, no problem, just let me know. I've got a lot on my plate too. Take your time. :) |
I have just pushed it. The datein/dateout functionality should be working now. (not sure if there are bugs i did not find yet) Massive code cleanup is needed. Will get to it once home. Maybe then we can split up stuff (if youre interested). Conversion is in swift3. |
Other userInteractionFunctions are still broken. Will also get to it. |
Sure, I don't have that much time, so it might take me a while to do my part, but I'm up for it. |
ok. will let you know. |
I think i'm finished. |
Awesome, I'll take a look soon. 🎉 |
Ok, I just checked out the
I think that's what I noticed so far. So how do you want to go about it, do you want to fix this stuff before I start making changes? I can start anyway, but then we might have conflicts later when trying to merge. |
I dont know how you see all these bugs. |
No problem, haha. Sometimes it's hard to see it when it's your own app, it happens to me all the time. |
Now I tried to make a super simple app just to see how it goes. I added just the bare minimum, so no headers or nothing. And my cell views have just a single label. This is all I have in my view controller: @IBOutlet weak var calendarView: JTAppleCalendarView!
override func viewDidLoad() {
super.viewDidLoad()
calendarView.dataSource = self
calendarView.delegate = self
calendarView.registerCellViewXib(file: "CellView")
}
func configureCalendar(_ calendar: JTAppleCalendarView) -> ConfigurationParameters {
let calendar = Calendar.current
let startDate = calendar.date(byAdding: .month, value: -3, to: Date())!
let endDate = calendar.date(byAdding: .month, value: 3, to: Date())!
return ConfigurationParameters(
startDate: startDate,
endDate: endDate,
numberOfRows: 6,
calendar: calendar,
generateInDates: true,
generateOutDates: .tillEndOfRow,
firstDayOfWeek: .sunday
)
}
func calendar(_ calendar: JTAppleCalendarView, willDisplayCell cell: JTAppleDayCellView, date: Date, cellState: CellState) {
let cell = cell as! CellView
cell.dayLabel.text = cellState.text
} I run the app and at first it looks ok: Scroll to the next month and… Next… |
just got back. Looking at it now |
OK. What you see happening is expected to happen. haha. |
Ok, let me know. :) |
OK. Fixed. Should be working now. And ended up "fixing" a bunch of stuff that didnt need fixing, thereby breaking every thing. |
Haha, sorry for that. |
Now we're talking, it's looking a lot better! There are still a few problems, though (sorry 😳):
Sorry for keeping finding bugs, I understand if you can't or don't want to fix everything right now, I'm really busy myself, I just thought you'd want to know. |
OK let me try to understand the problems. I've responded to them inline.
And man, finding bugs is what i wish more people do. I have no problem with it. I invite it. Are you clear on point 1 & 2 above though? |
Ah, I didn't get what the "PreOff" and "PostOff" options are for, then. I thought they were just a convenient way to set the pre and post dates do hidden. Why would any one wan to not even generate the pre dates? Anyway, it's all good then. I'll get started on my changes soon and start making some PRs. :) Thanks! |
I have had many requests for that preOn/off and postOn/off. People have different calendar designs. I know of one place the preOff/and postOff makes sense. In a single row setup, when pre is On and post is On, it looks really weird. As the user is scrolling side ways, pre-dates and postDates pop up giving the impression that numbers are repeated. In a 6-row calendar, it is clear that those are just pre and post dates, but in a single row view, it looks weird. And cool yea. Will wait for the PRs. I know i have a lot of code cleanup to do. |
Ah, I see! Ok then, thanks for the explanation. |
@dbmrq thanks for the support man! :] |
Don't mention it. Kee up the good work. :) |
Ok i think i can finally close this :) |
Awesome, thanks for your amazing work! |
Awesome man. Well anytime you got more input just give a shout. Till then. Have a good one :) |
You asked if I had any other suggestions… well, JTAppleCalendar is already awesome, and it works great, but here are a few thoughts, mostly just some tiny details that I think could be improved.
Take these methods, for instance:
Why is the colon next to
calendar
in the first case but separated with a space in the second? There are many other similar inconsistencies. I suggest you give SwiftLint a try. I can set it up at the demo project if you're interested.Also, why the name
isAboutToResetCell
instead of the standardwillResetCell
? Apple has some guidelines about that here.And speaking of naming conventions, I didn't really take a deep look at the changes in swift 3 yet, but I think according to the new convention (check the second item, "omit needless words") that method should read
isAboutToReset cell: JTAppleDayCellView
instead ofisAboutToResetCell cell: JTAppleDayCellView
. There are many other examples like that, and since swift 3 already makes a lot of those breaking changes it's a great excuse to make them here too I think.Also, since you already follow the way table views work, why use that
calendarView.registerCellViewXib(fileName: "CellView")
property instead of a delegate method likecellForDayAtDate
(like you havecellForRowAtIndexPath
for table views)? Then the user would be able to configure the cell right in the view controller where it will be displayed, instead of cramming the code in the cell class. (How many lines do yourUITableViewCell
classes have? A lot less than yourJTAppleDayCellView
classes, I bet.) Also that would allow the user to add the cell view straight to the view controller the calendar view is in (like it is withUITableView
s), instead of having to add a dedicatedxib
. And the cell view class would be a lot easier to repurpose.Lastly, this may by a little more tricky and it's not essential, but since you seem to be making some big changes already, here's another suggestion. I think it would be better if the calendar didn't have those
startDate
andendDate
limits. It would just have an initial date that could default to today, and then theUICollectionView
would be created with 3 months, the current month, the month before and the month after. When the user scrolled to the next month, one more month would be added after that one, and so on. And if the user wanted he could set a property likecalendarView.maxDate
.As I said, these are all just suggestions, feel free to ignore them if you prefer. JTAppleCalendar is really great already. :)
The text was updated successfully, but these errors were encountered: