JetLime Documentation

repository·main·Indexed 20 days ago

https://github.com/pushpalroy/jetlime

A highly customizable UI library for Compose Multiplatform that enables developers to implement vertical and horizontal timeline views across Android, iOS, Desktop, and Web platforms. It features components like JetLimeColumn and JetLimeRow, supports infinite scroll via paginated components, and provides flexible styling for event points, RTL support, and extended event layouts with dual content slots.

Tokens
6.5K
Snippets
22
Records
31
Agent score
69%

What's inside JetLime

  1. Overview of JetLime features

    main

    JetLime is a UI library for Compose Multiplatform designed to display timeline views. It supports Android, iOS, Desktop (JVM), and Web (JS & WASM).

    Key Capabilities:

    • Layouts: Supports both vertical (JetLimeColumn) and horizontal (JetLimeRow) timelines.
    • Point Placement: Flexible placement options including START, CENTER, and END with continuous line joins.
    • Styling: Supports dashed, gradient, or solid lines using Brush and PathEffect.
    • RTL Support: Built-in Right-to-Left (RTL) support for JetLimeRow and JetLimeExtendedEvent to ensure content visibility and mirrored layouts.
    • Advanced Events: JetLimeExtendedEvent provides dual content slots (left/right), icons, and animations.
    • Pagination: Built-in infinite scroll support via JetLimePaginatedColumn and JetLimePaginatedRow without additional dependencies.
    • Defaults: Uses JetLimeDefaults for sensible API defaults.
  2. What is JetLime?

    main
    JetLime is a Kotlin Multiplatform (KMP) UI library designed for Jetpack Compose. It provides specialized composables for building both vertical and horizontal timelines, supporting customizable point styles (START, CENTER, END) and extended event layouts that feature dual content areas.
  3. Overview of the com.pushpal.jetlime package

    main
    The com.pushpal.jetlime package is the core module for building timelines in Jetpack Compose. It provides the necessary composables, styling systems, event rendering logic, and helper utilities required to construct both vertical and horizontal timelines.
  4. Core components of the JetLime package

    main

    The com.pushpal.jetlime package provides the core building blocks for creating timelines in Jetpack Compose. It includes composables for rendering, styling systems, and event models.

    Key abstractions include:

    • Event Models: JetLimeEvent and JetLimeExtendedEvent represent the data points in a timeline.
    • Layout Containers: JetLimeColumn and JetLimeRow are the primary composables used to render vertical and horizontal timelines.
    • Styling: JetLimeEventStyle and JetLimeStyle allow for customization of the visual appearance of events and timeline elements.
    • Positioning: EventPosition and PointPlacement control where events are placed relative to the timeline axis.
  5. Key components in com.pushpal.jetlime

    main

    The following components are the primary building blocks of the JetLime library:

    Event Models

    • JetLimeEvent: The standard model for a timeline event.
    • JetLimeExtendedEvent: An extended version of the event model, typically used for more complex or detailed timeline entries.

    Layout Components

    • JetLimeColumn: Used for constructing vertical timelines.
    • JetLimeRow: Used for constructing horizontal timelines.

    Styling and Positioning

    • JetLimeEventStyle: Defines the visual appearance of individual events.
    • JetLimeStyle: General styling configuration for the timeline.
    • EventPosition: Controls where events are positioned relative to the timeline axis.
  6. Customize JetLimeEvent Style

    main

    Use JetLimeEventDefaults.eventStyle() to style the individual event points. You must pass the position (provided by the timeline lambda) to the style.

    Key properties:

    • pointColor: Background color of the point circle.
    • pointFillColor: Fill color drawn over the pointColor.
    • pointRadius: Radius of the point circle (Dp).
    • pointStrokeWidth: Width of the circle border (Dp).
    • pointStrokeColor: Color of the circle border.
    • pointType: Determines the shape/style (EMPTY, FILLED, or CUSTOM).
    • pointPlacement: Controls where the point renders relative to the item (START, CENTER, or END).
    • pointAnimation: Configures the point's animation (use JetLimeEventDefaults.pointAnimation() for default).
    JetLimeEvent(
      style = JetLimeEventDefaults.eventStyle(
        position = position,
        pointColor = Color(0xFF2889D6),
        pointFillColor = Color(0xFFD5F2FF),
        pointRadius = 14.dp,
        pointAnimation = JetLimeEventDefaults.pointAnimation(),
        pointType = EventPointType.filled(0.8f),
        pointStrokeWidth = 2.dp,
        pointStrokeColor = MaterialTheme.colorScheme.onBackground,
      ),
    ) {
      // Content
    }
  7. Generate and Export GPG Signing Key for Maven Central

    main

    To publish to Maven Central, you must generate a GPG key and export it in a specific format for the CI environment.

    1. Generate the key: Use gpg --full-generate-key. Recommended settings: RSA, 4096 bits, no expiry.
    2. Publish the public key: Send your key to a keyserver so Maven Central can verify it using your 8-character key ID.
    3. Export for CI: The publishing workflow requires a single-line, stripped version of your secret key (no armor headers, no newlines).
    # Generate key
    gpg --full-generate-key
    
    # Publish public key (replace 1A2B3C4D with your 8-char ID)
    gpg --list-keys --keyid-format=short
    gpg --keyserver keyserver.ubuntu.com --send-keys 1A2B3C4D
    
    # Export secret key for SIGNING_IN_MEMORY_KEY
    gpg --armor --export-secret-keys 1A2B3C4D \
      | tail -n +2 \
      | grep -v "^-----END" \
      | grep -v "^=" \
      | tr -d '\n'
  8. Customize JetLimeColumn and JetLimeRow Styles

    main

    Use JetLimeDefaults.columnStyle() or JetLimeDefaults.rowStyle() to configure the timeline appearance.

    Common properties:

    • contentDistance: Distance from the line to the content (Dp).
    • itemSpacing: Gap between event items (Dp).
    • lineThickness: Thickness of the timeline line (Dp).
    • lineBrush: The Brush used to draw the line (e.g., JetLimeDefaults.lineSolidBrush() or JetLimeDefaults.lineGradientBrush()).
    • lineVerticalAlignment (Column only): LEFT or RIGHT (Default: LEFT).
    • lineHorizontalAlignment (Row only): TOP or BOTTOM (Default: TOP).
    • pathEffect: Used for dashed or dotted lines via PathEffect.dashPathEffect.
    // Column Example
    JetLimeColumn(
      style = JetLimeDefaults.columnStyle(
        contentDistance = 32.dp,
        itemSpacing = 16.dp,
        lineThickness = 2.dp,
        lineBrush = JetLimeDefaults.lineSolidBrush(color = Color(0xFF2196F3)),
        lineVerticalAlignment = RIGHT,
      ),
    ) { /* ... */ }
    
    // Row Example
    JetLimeRow(
      style = JetLimeDefaults.rowStyle(
        contentDistance = 32.dp,
        itemSpacing = 16.dp,
        lineThickness = 2.dp,
        lineBrush = JetLimeDefaults.lineSolidBrush(color = Color(0xFF2196F3)),
        lineHorizontalAlignment = BOTTOM,
      ),
    ) { /* ... */ }
  9. Use Extended Events in a Vertical Timeline

    main

    To draw additional content on the side of the timeline line, use JetLimeExtendedEvent inside a JetLimeColumn. You can specify additionalContent to render content on the left side of the timeline.

    JetLimeColumn(
      modifier = Modifier.padding(16.dp),
      itemsList = ItemsList(items),
      key = { _, item -> item.id },
      style = JetLimeDefaults.columnStyle(contentDistance = 24.dp),
    ) { index, item, position ->
      JetLimeExtendedEvent(
        style = JetLimeEventDefaults.eventStyle(
          position = position
        ),
        additionalContent = {
          // Additional content here
        }
      ) {
        // Main content here
      }
    }
  10. Implement a Paginated Timeline (Infinite Scroll)

    main

    Use JetLimePaginatedColumn (or JetLimePaginatedRow) to load items page by page. The component triggers onLoadMore when the user scrolls near the end of the list, provided isLoading is false and hasMoreItems is true.

    Key behaviors:

    • The timeline line remains continuous as long as hasMoreItems is true.
    • The line terminates once hasMoreItems is set to false.
    • A default progress indicator is shown during loading. To customize it, use loadingContent. To hide it, set loadingContent = null.
    val items = remember { mutableStateListOf<Item>() }
    var isLoading by remember { mutableStateOf(false) }
    var hasMore by remember { mutableStateOf(true) }
    val scope = rememberCoroutineScope()
    
    // Trigger the first page
    LaunchedEffect(Unit) { if (items.isEmpty()) loadNextPage() }
    
    JetLimePaginatedColumn(
      itemsList = ItemsList(items),
      key = { _, item -> item.id },
      isLoading = isLoading,
      hasMoreItems = hasMore,
      onLoadMore = {
        scope.launch {
          isLoading = true
          val page = repository.loadNextPage()
          items.addAll(page.items)
          hasMore = !page.isLast
          isLoading = false
        }
      },
      loadingContent = null, // or { MyLoader() }
    ) { index, item, position ->
      JetLimeEvent(
        style = JetLimeEventDefaults.eventStyle(position = position)
      ) {
        // Content here
      }
    }
  11. Configure GitHub Secrets for Maven Central Publishing

    main

    Add the following five secrets to your GitHub repository (Settings → Secrets and variables → Actions → New repository secret) to enable the publish.yml workflow:

    Secret nameValue
    MAVEN_CENTRAL_USERNAMEToken username from Sonatype
    MAVEN_CENTRAL_PASSWORDToken password from Sonatype
    SIGNING_KEY_IDShort 8-char GPG key ID (e.g. 1A2B3C4D)
    SIGNING_IN_MEMORY_KEYSingle-line output from the GPG export command
    SIGNING_PASSWORDPassphrase used when creating the GPG key