---
title: "Lottie animasyonu ile kullanıcı ilerlemesini göster"
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\}

- Adapty Flutter SDK 4.4 veya sonraki bir sürüme güncelleyin. Önceki 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ı [getirmeye](flutter-get-pb-paywalls) ve [görüntülemeye](flutter-present-paywalls) hazırlayın.
- Özel elementler için uygulamanızın yerel kodunu, [Flutter kılavuzundaki](flutter-flow-custom-elements#before-you-start) gibi yapılandırın.
- iOS'ta, `https://github.com/airbnb/lottie-spm.git` adresinden Swift Package Manager ile Xcode'da `Runner` hedefine Lottie'yi ekleyin.
- Android'de, uygulama modülünüzde [Jetpack Compose'u yapılandırın](flutter-flow-custom-elements#set-up-jetpack-compose). Bu tarifte animasyon görünümü bir composable'dır. Gradle ile `androidx.compose.foundation:foundation` ve `com.airbnb.android:lottie-compose` kaynaklarından uygulamanıza Compose Foundation ve Jetpack Compose için Lottie'yi 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ı Flutter'ın `assets` klasöründen değil, iOS ve Android projelerinizden okur:

- **iOS**: Dosyayı Xcode'da `Runner` hedefine ekleyin.
- **Android**: Dosyayı `android/app/src/main/assets` dizinine, yani Android uygulama modülünüzün `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ı, `streak_ring` için `streak_ring.json` örneğinde olduğu gibi özel öğenin ID'siyle eşleşmelidir.

## 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, boştan `progress` değerine kadar doldurur.

</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ı baştan `progress` değerine kadar doldurur.

</TabItem>
</Tabs>

## 4. Animasyonu özel elemente bağlayın \{#match-the-animation-to-the-custom-element\}

[Uygulama genelindeki resolver](flutter-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, eklemeniz veya değiştirmeniz gerekenleri göstermektedir. Uygulamanızda henüz uygulama genelinde bir [resolver](flutter-flow-custom-elements#write-a-resolver-to-match-custom-elements-and-views) yoksa, kodun tamamını kopyalayabilirsiniz:

<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` case'ini diğer `lottie_animation` case'lerinden önce yerleştirin; Swift yalnızca eşleşen ilk case'i ç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öner 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](flutter-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` custom element'lerinizin animasyonlarını görmeye devam eder.

</TabItem>
</Tabs>

Streak modeliyle resolver'ı oluşturun ve uygulama başlangıcında bunu uygulama genelinde geçerli resolver olarak ayarlayın:

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

```swift showLineNumbers title="ios/Runner/AppDelegate.swift"

@main
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
  // the streak model that your app updates
  let streakStore = StreakStore()

  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    AdaptyUI.setCustomElementsResolver(CustomElementsResolver(streakStore: streakStore))
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }

  func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
    GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
  }
}
```

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

```kotlin showLineNumbers title="Kotlin"

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

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

`App` sınıfını `android/app/src/main/AndroidManifest.xml` dosyasında adlandırın; bunun için [Çözücüyü SDK'ya aktarma](flutter-flow-custom-elements#pass-the-resolver-to-the-sdk) bölümüne bakın.

</TabItem>
</Tabs>

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

Dart kodunuz streak'i tutar ve native görünümler bunu streak modelinden okur. Modeli güncellemek için streak'i [platform channel](https://docs.flutter.dev/platform-integration/platform-channels) aracılığıyla native kodunuza gönderin. iOS ve Android kodunuzda channel'ı dinleyin:

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

`AppDelegate` sınıfınızın `didInitializeImplicitFlutterEngine` metoduna vurgulanan satırları ekleyin:

```swift showLineNumbers title="ios/Runner/AppDelegate.swift" {3-14}
func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
  GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
  let streakChannel = FlutterMethodChannel(
    name: "custom_elements/streak",
    binaryMessenger: engineBridge.applicationRegistrar.messenger()
  )
  streakChannel.setMethodCallHandler { [streakStore] call, result in
    guard call.method == "setStreak", let days = call.arguments as? Int else {
      return result(FlutterMethodNotImplemented)
    }
    // the channel calls this handler on the main thread
    MainActor.assumeIsolated { streakStore.currentStreak = days }
    result(nil)
  }
}
```

:::note
Bu tarifte yer alan `AppDelegate` kodu, `FlutterImplicitEngineDelegate` kullanan Flutter 3.41 ve sonraki sürümlerin iOS şablonunu takip eder. `AppDelegate` sınıfınız bu protokolü benimsemiyorsa, protokolü ve `didInitializeImplicitFlutterEngine` metodunu dışarıda bırakın. Bunun yerine `application(_:didFinishLaunchingWithOptions:)` içinde, `return super.application(...)` satırından önce, root view controller'ın messenger'ını kullanarak kanalı oluşturun. Şablonunuzdaki `GeneratedPluginRegistrant` çağrısını olduğu gibi koruyun:

```swift showLineNumbers title="ios/Runner/AppDelegate.swift"
GeneratedPluginRegistrant.register(with: self)
let controller = window?.rootViewController as! FlutterViewController
let streakChannel = FlutterMethodChannel(
  name: "custom_elements/streak",
  binaryMessenger: controller.binaryMessenger
)
```
:::

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

`MainActivity` sınıfınızda `configureFlutterEngine` metodunu override edin:

```kotlin showLineNumbers title="Kotlin"

class MainActivity : FlutterFragmentActivity() {
    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        super.configureFlutterEngine(flutterEngine)
        val streakStore = (application as App).streakStore
        MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "custom_elements/streak")
            .setMethodCallHandler { call, result ->
                if (call.method == "setStreak") {
                    streakStore.currentStreak.value = call.arguments as Int
                    result.success(null)
                } else {
                    result.notImplemented()
                }
            }
    }
}
```

</TabItem>
</Tabs>

Dart kodunuzda, uygulama başlangıcında ve streak her değiştiğinde streak'i gönderin:

```dart showLineNumbers title="Flutter"

// your iOS and Android code listens to this channel
const streakChannel = MethodChannel('custom_elements/streak');

// call at app launch, and each time the streak changes
Future<void> sendStreak(int days) async {
  await streakChannel.invokeMethod('setStreak', days);
}
```

## 6. Cihazda test etme \{#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.

Yedek paywall yerine animasyonun neden göründüğünü öğrenmek için Flutter kılavuzundaki [Cihazda test etme](flutter-flow-custom-elements#test-on-a-device) bölümündeki talimatları izleyin.