Skip to content

Latest commit

Β 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CalendarWeek

All the calendar flow implemented for you.

πŸ’‰ Inject your views and customize everything.

πŸ’‘ Use your own model (simply conforming to CalendarModel)

Actions

  • To change days
    • Tap on the desired day.
    • Swipe its day content.
  • To change weeks
    • Swipe the week.

Usage

Create a model that conform to CalendarModel, and have a property let day: Day

class Card: Identifiable, CalendarModel {
    let text: String
    let day: Day // CalendarModel conformance

    init(text: String, day: Day) {
        self.text = text
        self.day = day
    }
}

Create an array of this model

@State var cards = [
    Card(
        text: "Card 1",
        day: Day(from: .now)
    ),
    Card(
        text: "Card 2",
        day: Day(
            from: Calendar.current.date(
                byAdding: .day,
                value: 1,
                to: .now
            )!
        )
    ),
    Card(
        text: "Card 3",
        day: Day(
            from: Calendar.current.date(
                byAdding: .day,
                value: 2,
                to: .now
            )!
        )
    )
]

Create the CalendarView

CalendarView(
    models: cards,
    daySpacing: 20,
    headerView: { day in
        HeaderView(selectedDay: day) // your view here
    },
    dayView: { day in
        DayComponentView(day: day) // your view here
    },
    weekBackground: {
        RoundedRectangle(cornerRadius: 20).fill(Color.pink.opacity(0.25)) // normal background here
    },
    dayContentView: {
        CardView(model: $0) // your view here
    },
    dayEmptyStateView: {
        EmptyCardView() // your view here
    }
)

Note: you need to implement your own views for:

  • Header
  • Day inside the week
  • Background of the week
  • Content of the Day
  • Empty state when there is no content for the Day

About

πŸ“… A SwiftUI calendar view, displayed by week. Use it with your own custom Models and custom Views linked to each day.

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages