Skip to content

Latest commit

 

History

History
138 lines (102 loc) · 5.47 KB

README.md

File metadata and controls

138 lines (102 loc) · 5.47 KB

Insetter

Maven Central CircleCI

Insetter is a library to help apps handle WindowInsets more easily. The library contains implementations of many of the concepts described in our "Listeners to Layouts" blog post.

There are a number of libraries available:

insetter

javadoc.io

The base library which is written in Java.

insetter-ktx

javadoc.io

A Kotlin extension library, providing Kotlin-specific functionality. This library contains extension functions allowing easy access to the helper functions from the base library.

bottomNav.doOnApplyWindowInsets { view, insets, initialPadding, initialMargins ->
    // padding contains the original padding values after inflation
    view.updatePadding(
        bottom = initialPadding.bottom + insets.systemWindowInsetBottom
    )
}

A Data Binding extension library, providing Data Binding specific functionality. This primarily contains binding adapters, which allow access to the helper functions from your layouts:

<BottomNavigationView
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:paddingVertical="24dp"
    app:paddingBottomSystemWindowInsets="@{true}"
    app:paddingLeftSystemWindowInsets="@{true}" />

📖 You can read more information here.

An extension library which provides versions of commonly used ViewGroups with enhanced inset handling. Currently this library is focusing on building upon ConstraintLayout.

A example of a widget is InsetterConstraintLayout, which enables new attributes to define inset behavior on child views. The behavior enabled through InsetterConstraintLayout is similar to that provided by the insetter-dbx library, but without the requirement of using data-binding.

<dev.chrisbanes.insetter.widgets.constraintlayout.InsetterConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:paddingSystemWindowInsets="left|top|right|bottom"
        android:src="@drawable/rectangle" />

</dev.chrisbanes.insetter.widgets.constraintlayout.InsetterConstraintLayout>

📖 You can read more information here.

⚠️ Attention 🚧

The library is being written to production quality, but it is not adhering to semantic versioning, mean we may change the API if needed, though we'll try not to. We're using this repository to allow quick and easy prototyping. The contents of this library may eventually be moved into Android Jetpack at a later date.

Download

repositories {
    mavenCentral()
}

dependencies {
    // The base library. If you're using either the dbx and/or ktx libraries, you don't need this
    implementation "dev.chrisbanes:insetter:0.2.0"

    // If you're using data-binding use this
    implementation "dev.chrisbanes:insetter-dbx:0.2.0"

    // If you're using Kotlin use this too
    implementation "dev.chrisbanes:insetter-ktx:0.2.0"
  
    // If you would like to use the enhanced widget set, use this
    implementation "dev.chrisbanes:insetter-widgets:0.2.0"
}

Snapshots of the development version are available in Sonatype's snapshots repository. These are updated on every commit.

Contributions

Please contribute! We will gladly review any pull requests. Make sure to read the Contributing page first though.

License

Copyright 2019 Google LLC.

Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for
additional information regarding copyright ownership. The ASF licenses this
file to you 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.