---
title: "Lottie animasyonuyla kullanıcı ilerlemesini gösterin"
description: "Günlük seri gibi her kullanıcının ilerlemesini bir flow ekranında Lottie animasyonu olarak görüntüleyin."
---

> For the complete documentation index, see [llms.txt](https://adapty.io/docs/tr/llms.txt).

> **AI agents**: to search Adapty docs faster and with fewer tokens, install the Adapty skills: `npx adapty skills install --yes`

Kullanıcının ilerlemesini bir Lottie animasyonu olarak göstermek için bu tarifi takip edin — örneğin, günlük serisini göstermek için dolan bir halka. Uygulamanız animasyonu bir [özel element](flow-custom-elements) içinde yerel bir Lottie görünümü olarak render eder.

<DocVideo id="custom-element-lottie-demo.mp4" width="300px" alt="Tamamlanmış flow: kullanıcı 'Serimi gör' düğmesine basar ve bir sonraki ekranda halka 7 günden 4'ünü gösterecek şekilde dolar." />

## Başlamadan önce \{#before-you-start\}

- Uygulamanızı Adapty Kotlin Multiplatform SDK 4.4.0-beta.1 veya daha yeni bir sürüme güncelleyin. Daha eski SDK sürümleri, her özel element için [yedek içeriği](flow-custom-elements#set-fallback-content) gösterir.
- Uygulamanızı flow'ları [getirmek](kmp-get-pb-paywalls) ve [görüntülemek](kmp-present-paywalls) için ayarlayın.
- Uygulamanızın native kodunu özel elementler için [Kotlin Multiplatform kılavuzundaki](kmp-flow-custom-elements#before-you-start) gibi yapılandırın.
- iOS'ta, `https://github.com/airbnb/lottie-spm.git` adresinden Swift Package Manager aracılığıyla Xcode'da uygulama hedefinize Lottie ekleyin.
- Android'de, Jetpack Compose dahil olmak üzere [Android projenizi ayarlayın](kmp-flow-custom-elements#set-up-your-android-project). Bu tarifte animasyon görünümü bir composable'dır. Uygulamanız Compose Multiplatform kullanmıyorsa, `androidMain` bağımlılıklarına `androidx.compose.foundation:foundation` adresinden, sürüm belirtmeksizin Compose Foundation ekleyin. Sürümü `io.adapty:android-ui`'nin Compose BOM'u belirler. Jetpack Compose için Lottie'yi `com.airbnb.android:lottie-compose` adresinden ekleyin.

`.json` formatında bir Lottie animasyonu hazırlayın ya da örnek [`streak_ring.json`](https://raw.githubusercontent.com/adaptyteam/adapty-docs/refs/heads/main/Downloads/streak_ring.json) dosyasını indirin. Uygulama animasyonu baştan oynatır ve ilerlemeyle orantılı olarak durdurur; örneğin %50 için tam ortasında durur. Tam ilerlemeyi göstermek için animasyonun şu özelliklere sahip olması gerekir:

- İlk karede hiç ilerleme olmamalı, son karede ise tam ilerleme gösterilmeli.
- Sabit bir hız, yumuşatma (easing) olmadan. Animasyon yavaş başlayıp hızlanırsa, yarı yolda gerçek ilerlemenin yarısından daha azını gösterir.

## 1. Ekrana özel öğeyi ekleyin \{#1-add-the-custom-element-to-the-screen\}

Flow & Paywall Builder'da, bir flow ekranına [özel element ekleyin](flow-custom-elements#add-and-configure) ve animasyon için yapılandırın:

- **Type**: `lottie_animation`.
- **ID**: `streak_ring`. Bu tarifde ID, aynı zamanda animasyon dosyasının adıdır.
- **Height**: Varsayılan **Fixed** yüksekliği koruyun. Animasyon, özel elementin boyutuna göre ölçeklenir.

Özel elementin içine, halkanın hareketsiz bir görüntüsünü içeren bir [**Image**](custom-media#image) ekleyin. Kullanıcılar, uygulamanızın animasyonu oynatamayan sürümlerinde bunu [yedek içerik](flow-custom-elements#set-fallback-content) olarak görür.

## 2. Animasyon dosyasını uygulamanıza ekleyin \{#add-the-animation-file-to-your-app\}

Yerel kodunuz, animasyon dosyasını paylaşılan kodunuzun Compose Multiplatform kaynaklarından değil, iOS ve Android projelerinizden okur:

- **iOS**: Dosyayı Xcode'da uygulama hedefinize ekleyin.
- **Android**: Dosyayı `composeApp/src/androidMain/assets` dizinine, yani `androidMain` kaynak setinin `assets` klasörüne koyun. Dosyayı bir alt klasöre değil, bu klasörün kök dizinine yerleştirin.

`.json` uzantısı olmadan dosya adı, özel öğenin ID'siyle eşleşmelidir; örneğin `streak_ring` için `streak_ring.json`.

## 3. Animasyon görünümünü oluşturun \{#create-the-animation-view\}

Streak için bir model ve animasyonu oynatacak bir görünüm oluşturun. Uygulamanız streak değiştiğinde modeli günceller. Görünüm modeli okuduğundan, ekran açıldığında halka mevcut streak'i gösterir:

<Tabs groupId="platform" queryString>
<TabItem value="ios" label="iOS (Swift)" default>

```swift showLineNumbers title="Swift"

// The streak that your app keeps up to date
@MainActor
final class StreakStore: ObservableObject {
    @Published var currentStreak = 0 // days in a row
}

struct StreakRingView: View {
    let animation: LottieAnimation
    @ObservedObject var streakStore: StreakStore

    // 7 days fill the ring: from 0 for an empty ring to 1 for a full one
    private var progress: AnimationProgressTime {
        min(AnimationProgressTime(streakStore.currentStreak) / 7, 1)
    }

    var body: some View {
        LottieView(animation: animation)
            .resizable()
            .playing(.fromProgress(0, toProgress: progress, loopMode: .playOnce))
    }
}
```

`.playing(.fromProgress(0, toProgress: progress, loopMode: .playOnce))` halkayı bir kez doldurur, boştan `progress` değerine kadar.

</TabItem>
<TabItem value="android" label="Android (Kotlin)">

```kotlin showLineNumbers title="Kotlin"

// the streak that your app keeps up to date
class StreakStore {
    val currentStreak = MutableStateFlow(0) // days in a row
}

@Composable
fun StreakRing(animationFile: String, streakStore: StreakStore) {
    val composition by rememberLottieComposition(LottieCompositionSpec.Asset(animationFile))
    val streak by streakStore.currentStreak.collectAsState()

    // 7 days fill the ring: from 0 for an empty ring to 1 for a full one
    val progress = minOf(streak / 7f, 1f)

    LottieAnimation(
        composition = composition,
        modifier = Modifier.fillMaxSize(), // scale the animation to fit the custom element
        clipSpec = LottieClipSpec.Progress(0f, progress),
    )
}
```

`clipSpec = LottieClipSpec.Progress(0f, progress)` halkayı sıfırdan `progress` değerine kadar doldurur.

</TabItem>
</Tabs>

## 4. Animasyonu özel elemente eşleştirin \{#match-the-animation-to-the-custom-element\}

[Uygulama genelindeki resolver](kmp-flow-custom-elements#pass-the-resolver-to-the-sdk)'ınıza streak modeli için bir özellik ekleyin. Ardından `lottie_animation` Türü ve `streak_ring` ID'si için animasyon görünümünü döndürün. Vurgulanan satırlar neyin ekleneceğini veya değiştirileceğini göstermektedir. Uygulamanızda henüz uygulama genelinde bir [resolver](kmp-flow-custom-elements#write-a-resolver-to-match-custom-elements-and-views) yoksa kodun tamamını kopyalayın:

<Tabs groupId="platform" queryString>
<TabItem value="ios" label="iOS (Swift)" default>

```swift showLineNumbers title="Swift" {6,14-18}

struct CustomElementsResolver: AdaptyUICustomElementsResolver {
    let streakStore: StreakStore

    func view(
        forType type: String,
        id: String,
        context: AdaptyUICustomElementContext
    ) -> AnyView? {
        switch type {
        case "lottie_animation" where id == "streak_ring":
            guard let animation = LottieAnimation.named(id) else {
                return nil // no animation file: show the fallback
            }
            return AnyView(StreakRingView(animation: animation, streakStore: streakStore))
        // the other cases of your resolver
        default:
            return nil
        }
    }
}
```

`streak_ring` durumunu diğer `lottie_animation` durumlarından önce yerleştirin; Swift yalnızca eşleşen ilk durumu çalıştırır. Uygulama paketinde ilgili ID için dosya yoksa, çözümleyici `nil` döndürür ve kullanıcılar yedek içeriği görür.

</TabItem>
<TabItem value="android" label="Android (Kotlin)">

```kotlin showLineNumbers title="Kotlin" {8,22-28}

class CustomElementsResolver(
    context: Context,
    private val streakStore: StreakStore,
) : AdaptyCustomElementsResolver {
    // the animation files in the assets folder, listed once
    private val animationFiles: Set<String> = try {
        context.assets.list("").orEmpty().toSet()
    } catch (e: IOException) {
        emptySet() // no list of files: every Lottie element shows the fallback
    }

    override fun resolve(type: String, id: String): AdaptyCustomElementContent? =
        when (type) {
            "lottie_animation" -> {
                // the ID names the animation file, such as streak_ring.json
                val file = "$id.json"
                when {
                    file !in animationFiles -> null // no file for this ID: show the fallback
                    id == "streak_ring" ->
                        AdaptyCustomElementContent.compose { StreakRing(file, streakStore) }
                    // the other animations of your resolver
                    else -> null
                }
            }
            // the other Types of your resolver
            else -> null
        }
}
```

`assets` klasöründe ilgili ID için dosya yoksa, resolver `null` döndürür ve kullanıcılar yedek içeriği görür. Resolver'ınız zaten [her animasyon dosyası için bir view döndürüyorsa](kmp-flow-custom-elements#write-a-resolver-to-match-custom-elements-and-views), ID `streak_ring` olmadığında `null` yerine o view'ı döndürün. Bu sayede kullanıcılar diğer `lottie_animation` özel elementlerinin animasyonlarını görmeye devam eder.

</TabItem>
</Tabs>

Resolver'ı streak modeliyle oluşturun ve uygulama başlatılırken uygulama genelinde geçerli resolver olarak ayarlayın:

<Tabs groupId="platform" queryString>
<TabItem value="ios" label="iOS (Swift)" default>

In `iOSApp.swift`, add a property for the streak model to your `AppDelegate` class, and set the resolver in the `application(_:didFinishLaunchingWithOptions:)` method. The highlighted lines show what to add. Keep the rest of the `AppDelegate` class as it is:

```swift showLineNumbers title="iosApp/iosApp/iOSApp.swift" {1,5-6,12}

class AppDelegate: UIResponder, UIApplicationDelegate {
    // the streak model that your app updates
    let streakStore = StreakStore()

    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        AdaptyUI.setCustomElementsResolver(CustomElementsResolver(streakStore: streakStore))
        // the rest of your launch code
        return true
    }
}
```

</TabItem>
<TabItem value="android" label="Android (Kotlin)">

In `MainApplication.kt`, add a property for the streak model, and set the resolver in the `onCreate` method. The highlighted lines show what to add. Keep the rest of the `MainApplication` class as it is:

```kotlin showLineNumbers title="MainApplication.kt" {7-8,12}
package com.example.app

class MainApplication : Application() {
    // the streak model that your app updates
    val streakStore = StreakStore()

    override fun onCreate() {
        super.onCreate()
        AdaptyUI.setCustomElementsResolver(CustomElementsResolver(this, streakStore))
    }
}
```

</TabItem>
</Tabs>

## 5. Ortak kodunuzdan streak'i gönderin \{#send-the-streak-from-your-shared-code\}

Ortak kodunuz streak'i tutar ve native view'lar bunu streak modelinden okur. Ortak kodunuz Swift kodunuzu veya `MainApplication` sınıfını çağıramaz. Modeli güncellemek için ortak kodunuzda bir arayüz tanımlayın ve bunu her platformun streak modelinde uygulayın.

`commonMain` içinde arayüzü ve mevcut platformun streak modelini tutan bir nesneyi tanımlayın:

```kotlin showLineNumbers title="commonMain"
// the streak model of each platform implements this interface
interface StreakReceiver {
    fun setStreak(days: Int)
}

object StreakBridge {
    // the platform code sets the receiver at app launch
    var receiver: StreakReceiver? = null

    // call at app launch, and each time the streak changes
    fun sendStreak(days: Int) {
        receiver?.setStreak(days)
    }
}
```

Her platformun streak modelinde arayüzü uygulayın ve modeli uygulama başlangıcında receiver olarak ayarlayın:

<Tabs groupId="platform" queryString>
<TabItem value="ios" label="iOS (Swift)" default>

`StreakStore`'ı, `ComposeApp` gibi paylaşılan framework'ünüzdeki `StreakReceiver` protokolüne uygun hale getirin. Kotlin/Native, Kotlin'deki `Int` türünü Swift'te `Int32` olarak eşler. Eklemeniz gereken satırlar vurgulananlar:

```swift showLineNumbers title="Swift" {1,5,8-13}

// The streak that your app keeps up to date
@MainActor
final class StreakStore: ObservableObject, StreakReceiver {
    @Published var currentStreak = 0 // days in a row

    // your shared code can call this method on any thread
    nonisolated func setStreak(days: Int32) {
        Task { @MainActor in
            self.currentStreak = Int(days)
        }
    }
}
```

`AppDelegate` sınıfınızın `application(_:didFinishLaunchingWithOptions:)` metodunda, resolver'dan hemen sonra streak modelini receiver olarak ayarlayın:

```swift showLineNumbers title="iosApp/iosApp/iOSApp.swift" {2}
AdaptyUI.setCustomElementsResolver(CustomElementsResolver(streakStore: streakStore))
StreakBridge.shared.receiver = streakStore
```

`iOSApp.swift` dosyasına da `ComposeApp`'i import edin.

</TabItem>
<TabItem value="android" label="Android (Kotlin)">

`StreakStore`'un `StreakReceiver` arayüzünü uygulamasını sağlayın. Vurgulanan satırlar eklenecek kısımları göstermektedir:

```kotlin showLineNumbers title="Kotlin" {2,5-7}
// the streak that your app keeps up to date
class StreakStore : StreakReceiver {
    val currentStreak = MutableStateFlow(0) // days in a row

    override fun setStreak(days: Int) {
        currentStreak.value = days
    }
}
```

`MainApplication` sınıfınızın `onCreate` metodunda, resolver'dan hemen sonra streak modelini receiver olarak ayarlayın:

```kotlin showLineNumbers title="MainApplication.kt" {2}
AdaptyUI.setCustomElementsResolver(CustomElementsResolver(this, streakStore))
StreakBridge.receiver = streakStore
```

</TabItem>
</Tabs>

Paylaşılan kodunuzda, uygulama başlangıcında ve streak her değiştiğinde `StreakBridge.sendStreak` metodunu çağırın. Paylaşılan kodun, platform kodu alıcıyı ayarlamadan önce gönderdiği bir streak modele ulaşmaz.

## 6. Cihazda test edin \{#test-on-a-device\}

Flow & Paywall Builder, uygulama kodunuzu çalıştıramadığından canvas yalnızca yedek içeriği gösterir. Animasyonu önizlemek için:

1. [Flow'u yayınlayın](builder-save-publish). Önbelleğe alınmış sürüm yerine en son yayınlanan sürümü görmek için cihazı bir [test cihazı](test-devices) olarak kaydedin.
2. Resolver'ı içeren bir uygulama derlemesi çalıştırın. Streak'i 0 güne ayarlayın, ekranı açın ve halkının boş kaldığını doğrulayın. 4 ve 7 gün ile tekrarlayın ve halkının her değere kadar dolduğunu doğrulayın.

Yedek içeriği test etmek için animasyon dosyasını derlemeden kaldırın ve ekranı tekrar açın.

Animasyon yerine neden yedek göründüğünü öğrenmek için Kotlin Multiplatform kılavuzundaki [Cihazda test edin](kmp-flow-custom-elements#test-on-a-device) bölümündeki talimatları izleyin.