Skip to content

Clothparency/android-widgets

Repository files navigation


Logo Clear Fashion


Clear Fashion widgets for Android


Display your Clear Fashion widgets on your native android app.

Check the latest release here:

https://github.com/Clothparency/android-widgets/releases/latest

GitHub license

Installation

Using Gradle

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

allprojects {
  repositories {
    // ...
    maven { url 'https://jitpack.io' }
  }
}

Step 2. Add the dependency

dependencies {
  implementation 'com.github.Clothparency:android-widgets:1.0.0'
}

Using Maven

Step 1. Add the JitPack repository to your build file

<repositories>
  <repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
  </repository>
</repositories>

Step 2. Add the dependency

<dependency>
   <groupId>com.github.Clothparency</groupId>
   <artifactId>android-widgets</artifactId>
   <version>1.0.0</version>
</dependency>

Using SBT

Step 1. Add the JitPack repository to your build file

Add it in your build.sbt at the end of resolvers:

resolvers += "jitpack" at "https://jitpack.io"

Step 2. Add the dependency

libraryDependencies += "com.github.Clothparency" % "android-widgets" % "1.0.0"	

Using Leiningen

Step 1. Add the JitPack repository to your build file

Add it in your project.clj at the end of repositories:

:repositories [["jitpack" "https://jitpack.io"]]

Step 2. Add the dependency

:dependencies [[com.github.Clothparency/android-widgets "1.0.0"]]	

Implementation

This package exposes a composable function: ClearFashionWidget

If your application uses Jetpack Compose you can simply add it inside any composable scopes as so:

// ...

import com.clearfashion.sdk.widgets.ClearFashionWidget
import com.clearfashion.sdk.widgets.type.ClearFashionWidgetLanguage

// ...

ClearFashionWidget(
  brandId = "The id of your brand as given by Clear Fashion",
  productId = "The identifier of your product as given by Clear Fashion",
  lang = ClearFashionWidgetLanguage.EN // The widget also supports `ClearFashionWidgetLanguage.FR` which is the default value
)

Using Views

If your application is view based, you can add the widget in the activity where you want it to be displayed:

// ...

import com.clearfashion.sdk.widgets.ClearFashionWidget
import com.clearfashion.sdk.widgets.type.ClearFashionWidgetLanguage

// ...

ClearFashionWidget(
  activity = this,
  brandId = "The id of your brand as given by Clear Fashion",
  productId = "The identifier of your product as given by Clear Fashion",
  lang = ClearFashionWidgetLanguage.EN // The widget also supports `ClearFashionWidgetLanguage.FR` which is the default value
)

Using Fragments

If your application is fragment based, in the fragment XML file where you want to put the widget, add a compose view for the widget to live in:

<androidx.compose.ui.platform.ComposeView
  android:id="@+id/cf_widget_compose_view"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"/>

And then in the onCreateView method, add the following:

// ...

import com.clearfashion.sdk.widgets.ClearFashionWidget
import com.clearfashion.sdk.widgets.type.ClearFashionWidgetLanguage

// ...

override fun onCreate(savedInstanceState: Bundle?) {

  // ...

  ClearFashionWidget(
    composeView = binding.cfWidgetComposeView,
    brandId = "The id of your brand as given by Clear Fashion",
    productId = "The identifier of your product as given by Clear Fashion",
    lang = ClearFashionWidgetLanguage.EN // The widget also supports `ClearFashionWidgetLanguage.FR` which is the default value
  )

  // ...

}

For more informations on how to integrate a composable function in your code, please read: https://developer.android.com/jetpack/compose/interop/interop-apis



Logo Clear Fashion