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

minHour and maxHour properties to limit visible hours #5

Open
ezmegy opened this issue Aug 28, 2017 · 6 comments
Open

minHour and maxHour properties to limit visible hours #5

ezmegy opened this issue Aug 28, 2017 · 6 comments

Comments

@ezmegy
Copy link

ezmegy commented Aug 28, 2017

Hi,

Did you think about implementing this?
Any cons against it maybe?

I'll most likely need this feature and I think I'll give it a try (unless you plan to do it in the near future) just wanted double-check with you first.

Thanks!

@reilem
Copy link
Member

reilem commented Aug 28, 2017

I wasn't planning on adding this myself, but it seems like it could be a useful addition. Feel free to give it a go!

@psteinroe
Copy link

Did you manage to do it yet?

@ezmegy
Copy link
Author

ezmegy commented Sep 19, 2017

Nah, got flooded at work :(

I would probably still give it a go some time but not in the next 2-3 weeks...

@psiabeta
Copy link

psiabeta commented Jul 2, 2018

Hi, have you been able to implement this?

@firat-can-slnk
Copy link

It would be great if it was possible to limit the visible Hours, I tried to solve this with hoursInDay in DateSupport.swift but I only got it to start from 0.
So maxHour is working but minHour is not.

DateSupport.swift
public static var hoursInDay: CGFloat = 16

The Hour Sidebar can start with e.g. 6:00 if you edit the df.string and date of updateLabels in HourSideBarView.swift
HourSideBarView.swift

func updateLabels () {
        hourLabels.sort { (label1, label2) -> Bool in
            return label1.order < label2.order
        }

        var date = DateSupport.getZeroDate()
        let df = DateFormatter()
        df.dateFormat = TextVariables.hourLabelDateFormat
        for label in hourLabels {
            let customDate: String = String(Int(df.string(from: date))! + 6) // Start at 06:00
            label.text = customDate
            date.add(hours: 1)
        }
    }

@reilem
Copy link
Member

reilem commented Mar 19, 2019

I hadn't thought about using hoursInDay actually. I'm surprised that that works haha.

I don't have lots of time to work on this type of stuff. But maybe this can help you guys:

I think a "best practice" method however would be to generate an HourSideBarView that only contains labels that you want to be displayed instead of simply hiding the ones you don't want. This would require a rework of how the HourSideBarView is created because right now it is generated using a xib. This could also open up a lot of potential design questions. Use auto-layout, or just a hardcoded calculation? etc.

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

No branches or pull requests

5 participants