Quivr / iOS-Week-View

QVRWeekView is a framework which provides a calendar view that can be customized to display between 1 to 7 days in both portrait and landscape mode. Includes customization features to customize colours, fonts and sizes.
MIT License
39 stars 21 forks source link

minHour and maxHour properties to limit visible hours #5

Open ezmegy opened 7 years ago

ezmegy commented 7 years ago

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 commented 7 years ago

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 commented 6 years ago

Did you manage to do it yet?

ezmegy commented 6 years ago

Nah, got flooded at work :(

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

psiabeta commented 6 years ago

Hi, have you been able to implement this?

firat-can-slnk commented 5 years ago

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 commented 5 years ago

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.