GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - tobiasschuerg/android-week-view: Android library for displaying an overview of events for a week like in a schedule(us) or timetable(uk).

BranchesTags
Open more actions menu

Latest commit

 

History

353 Commits
353 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.idea
.idea
 
 
app
app
 
 
baselineprofile
baselineprofile
 
 
gradle
gradle
 
 
library
library
 
 
meta
meta
 
 
scripts
scripts
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
CLAUDE.md
CLAUDE.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle.kts
build.gradle.kts
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
jitpack.yml
jitpack.yml
 
 
settings.gradle.kts
settings.gradle.kts
 
 

Repository files navigation

Build

Android Week View

Kotlin Android library for displaying weekly schedules and timetables using Jetpack Compose.

Initially created for Schedule Deluxe, this library provides a flexible week view component for calendar apps, timetables, and schedule management.

Screenshots

University Work School Conference (3-day)

Features

  • Jetpack Compose implementation (Compose-only since 3.0)
  • Two layouts: a calendar timeline, or a school timetable of fixed periods
  • Three event types: timed, all-day, and multi-day (spanning bars)
  • Automatic overlap handling for concurrent events
  • Pinch-to-zoom that keeps the time under your fingers in place
  • Current time indicator and day highlighting
  • Configurable event display, spacing, and time range
  • Flexible day counts (3-day, 5-day, 7-day, etc.)
  • Navigation handled externally for full control (e.g. HorizontalPager, buttons)
  • Ships a baseline profile, so scrolling and zooming are smooth from the first launch

Usage

Add to your Compose UI

@Composable
fun MyWeekView(events: List<Event>) {
    val dateRange = LocalDateRange(
        LocalDate.now().with(DayOfWeek.MONDAY),
        LocalDate.now().with(DayOfWeek.FRIDAY),
    )
    val weekData = remember(events) {
        WeekData(dateRange, LocalTime.of(8, 0), LocalTime.of(18, 0), events)
    }

    WeekView(
        weekData = weekData,
        weekViewConfig = WeekViewConfig(),
        eventConfig = EventConfig(),
        actions = WeekViewActions(
            onEventClick = { event -> /* Handle click */ },
            onEventLongPress = { event -> /* Handle long press */ },
        ),
    )
}

Create events

// Timed event
val meeting = Event.Single(
    id = "1",
    date = LocalDate.of(2026, 1, 15),
    title = "Team Meeting",
    shortTitle = "Meeting",
    timeSpan = TimeSpan.of(LocalTime.of(10, 0), Duration.ofHours(1)),
    backgroundColor = Color.Blue,
    textColor = Color.White,
)

// All-day event
val holiday = Event.AllDay(
    id = "2",
    date = LocalDate.of(2026, 1, 16),
    title = "National Holiday",
    shortTitle = "Holiday",
    backgroundColor = Color.Green,
    textColor = Color.White,
)

// Multi-day event (renders as a spanning bar)
val conference = Event.MultiDay(
    id = "3",
    date = LocalDate.of(2026, 1, 20),
    title = "Tech Conference",
    shortTitle = "Conf",
    lastDate = LocalDate.of(2026, 1, 22),
    backgroundColor = Color.Magenta,
    textColor = Color.White,
)

val weekData = WeekData(dateRange, LocalTime.of(8, 0), LocalTime.of(18, 0), listOf(meeting, holiday, conference))

WeekData is immutable: to change what the week view shows, pass a new instance. Timed events outside the given time range widen the visible hours.

Event IDs must be unique across all event types in a WeekData. If your events come from several sources (for example two database tables with their own auto-increment keys), prefix the IDs, e.g. "lesson-12" and "holiday-12".

School periods

By default the week view is a calendar: rows are hours and every entry is as tall as it lasts. Pass WeekLayout.Periods to show a school timetable instead, with one row per period and all lessons equally tall:

val periods = listOf(
    Period("1", TimeSpan(LocalTime.of(8, 0), LocalTime.of(8, 45))),
    Period("2", TimeSpan(LocalTime.of(8, 50), LocalTime.of(9, 35))),
    Period("Break", TimeSpan(LocalTime.of(9, 35), LocalTime.of(9, 55)), isBreak = true),
    Period("3", TimeSpan(LocalTime.of(9, 55), LocalTime.of(10, 40))),
)

WeekView(
    weekData = weekData,
    weekViewConfig = WeekViewConfig(),
    layout = WeekLayout.Periods(periods),
    actions = WeekViewActions(
        onEmptyPeriodClick = { date, period -> /* e.g. add a lesson here */ },
    ),
)
  • Events stay ordinary Event.Singles with their real times. Each one fills every period it overlaps, so a double lesson covers two rows and a lesson starting a few minutes late still fills its row. An event that overlaps no period goes to the nearest one rather than disappearing.
  • Breaks (isBreak = true) are optional thin rows with their label across the week. Gaps between periods without a break row are simply left out.
  • The axis shows each period's label, plus its start and end time (showTimes = false hides them).
  • Lessons grow to fill the viewport and zoom with a pinch; periodHeight and breakHeight set their base size. scrollToTime and the current-time line work as on the timeline.
  • There are no grid lines: every empty lesson cell shows a dashed placeholder in gridLineColor instead, and onEmptyPeriodClick makes the placeholders clickable.
  • Since the axis already shows each period's times, consider EventConfig(showTimeStart = false, showTimeEnd = false): the lessons then show their name and room centred in the cell.
  • Break rows are tinted with breakBackground from WeekViewDefaults.colors().

Customization

Week View Configuration

val weekViewConfig = WeekViewConfig(
    scalingFactor = 1.2f,
    showCurrentTimeIndicator = true,
    highlightCurrentDay = true,
)

Colors

The week view takes its colors from the current MaterialTheme, so it follows light and dark mode. Override single colors with WeekViewDefaults.colors():

WeekView(
    weekData = weekData,
    weekViewConfig = WeekViewConfig(),
    colors = WeekViewDefaults.colors(gridLineColor = Color.LightGray),
)

Event Configuration

val eventConfig = EventConfig(
    showSubtitle = true,
    showTimeStart = true,
    showTimeEnd = true,
    eventSpacingDp = 1, // gap between adjacent events (0 to disable)
)

Events adapt their layout to the available height automatically, dropping fields by priority (name > start time > end time > location > teacher) rather than clipping whatever renders first. The decision uses the real line heights, so it stays correct under any system font scale:

  • The name is always shown and shrinks to fit when the entry is very low or narrow.
  • Start and end time are never combined into one line (that does not fit a five-day phone column). When the entry is tall enough they are stacked with the name - start above, end pinned to the bottom right; when it isn't, they move into the top-left and bottom-right corners as smaller labels, keeping only the start time once both would crowd out the name; only very low entries drop them entirely. Labels that don't fit a narrow overlap column even at their smallest size are hidden rather than clipped.
  • Location and teacher are added back in as the entry gets taller.
  • The title wraps onto a second line instead of eliding once there's room to spare.
  • Without a start time above the title (e.g. showTimeStart = false) the fields are centred vertically in the entry instead of starting at the top.

Custom Event Design

Pass eventContent to replace how timed entries look. The week view still positions and sizes each entry, handles clicks and sets its accessibility description; the slot only draws inside it, including the background and shape. EventContentScope provides the event, the entry's width and height, the EventConfig and the locale.

WeekView(
    weekData = weekData,
    weekViewConfig = WeekViewConfig(),
    eventContent = { scope ->
        Box(
            Modifier
                .fillMaxSize()
                .background(scope.event.backgroundColor, RoundedCornerShape(8.dp))
                .padding(4.dp),
        ) {
            Text(scope.event.title)
        }
    },
)

The library ships three ready-made styles. All of them fit the fields to the entry height as described above; they only differ in container and colors:

Style Look
FilledEventContent (default) Filled with the event's background color, text in its text color
TintedEventContent Light tint of the event color with a full-color bar on the left
OutlinedEventContent Theme surface with a border in the event color
WeekView(
    weekData = weekData,
    weekViewConfig = WeekViewConfig(),
    eventContent = { TintedEventContent(it) },
)

Built-in styles can also be mixed with your own, e.g. a custom design for some events only. All-day and multi-day events are not affected.

Scroll position and zoom

rememberWeekViewState keeps the zoom level and scroll position across rotation and process death. Pass initialTime to open the week view at a given time, and scroll there later with scrollToTime or animateScrollToTime:

val state = rememberWeekViewState(initialTime = LocalTime.of(8, 0))
val scope = rememberCoroutineScope()

WeekView(weekData = weekData, weekViewConfig = WeekViewConfig(), state = state)
Button(onClick = { scope.launch { state.animateScrollToTime(LocalTime.now()) } }) { Text("Now") }

Pinch-zooming keeps the time under the fingers in place.

Callbacks

val actions = WeekViewActions(
    onEventClick = { event -> /* Handle event tap */ },
    onEventLongPress = { event -> /* Handle long press */ },
    onScalingFactorChange = { factor -> /* Persist zoom level */ },
    onDayClick = { date -> /* Handle day header tap */ },
    onEmptyPeriodClick = { date, period -> /* Empty lesson cell tapped (WeekLayout.Periods only) */ },
)

Installation

Step 1: Add JitPack repository

In your settings.gradle.kts:

dependencyResolutionManagement {
    repositories {
        // ... other repositories
        maven { url = uri("https://jitpack.io") }
    }
}

Step 2: Add the dependency

In your app build.gradle.kts, replacing <version> with the latest release shown by the JitPack badge above:

dependencies {
    implementation("com.github.tobiasschuerg:android-week-view:<version>")

    // Required for Compose
    implementation(platform("androidx.compose:compose-bom:<compose-bom-version>"))
    implementation("androidx.compose.ui:ui")
    implementation("androidx.compose.material3:material3")
}

Releases

Changes for each version are listed on the GitHub Releases page.

Sample App

The app/ module contains a sample app with five built-in timetables (University, Work, School, Conference, Special Cases) demonstrating different layouts, overlapping events, all-day/multi-day events, a 3-day view, and rendering edge cases like very short entries and long titles. Switch between them via the top app bar menu.

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Run ./gradlew ktlintFormat before committing
  4. Add tests for new functionality
  5. Submit a pull request

Links

  • JitPack: https://jitpack.io/#tobiasschuerg/android-week-view
  • Sample App: See app/ module in this repository
  • Issues: https://github.com/tobiasschuerg/android-week-view/issues

About

Android library for displaying an overview of events for a week like in a schedule(us) or timetable(uk).

Topics

androidandroid-librarycalendarhacktoberfestkotlinschedulestundenplantimetableweek-view

Resources

Readme
MIT license
Activity

Stars

61 stars

Watchers

2 watching

Forks

12 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.