Skip to content

Latest commit

 

History

History
82 lines (61 loc) · 3.04 KB

README.md

File metadata and controls

82 lines (61 loc) · 3.04 KB

Aspecto Graphics

Maven Central Build status AndroidWeekly

Aspecto is a grid layout that perfectly preserves each item's aspect ratio for the Jetpack Compose / Compose Multiplatform.

✨ Just as the 🪄 Patronus charm protects its caster, Aspecto protects image layouts from distortion!

Showcase

Comparison-2

Aspecto.-.Compose.Multiplatform.mp4

Features

  • Aspect Ratio Preservation - Maintains natural dimensions of images
  • Smart Row Distribution - Magically arranges items for optimal space utilization
  • Efficient Updates - Uses incremental calculations for smooth performance
  • Height Protection - Guards against overly tall items disrupting layouts
  • Responsive Layout - Adapts gracefully to different screen sizes

Multiplatform Support

  • Android
  • iOS

Installation

Add the dependency to your project:

Compose Multiplatform

implementation("com.vipulasri.aspecto:aspecto:<latest-version>")

Android Only

implementation("com.vipulasri.aspecto:aspecto-android:<latest-version>")

Usage

AspectoGrid(
    modifier = Modifier.fillMaxWidth(),
    contentPadding = PaddingValues(16.dp)
) {
    items(
        items = images,
        key = { it.id },
        aspectRatio = { it.width.toFloat() / it.height }
    ) { image ->
        // content
    }
}

Android & iOS samples. Both samples use the same shared code to demonstrate the Compose Multiplatform capabilities.

Inspired by

License

Copyright 2025 Vipul Asri

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.