[Feature Request] Add "lottie-react-native" compatibility mode
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Inizia con la richiesta del flag di compatibilità di LottieGen e con l’interfaccia ILottieMediaSource descritte nell’issue. Innanzitutto stabilisci se FrameToProgress è sufficiente o se sono necessari anche il numero di frame e la durata. Il lavoro è completo quando un flag versionato fa sì che le classi runtime e le implementazioni generate siano conformi all’interfaccia lottie-react-native concordata senza esportare l’interfaccia COM.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Overview
The C++/WinRT implementation of lottie-react-native is a wrapper around AnimatedVisualPlayer to support playback of Lottie animations in React Native.
On the native side, it expects consuming applications to implement ILottieSourceProvider and supply the player with a mapping between animation names and implementations of IAnimatedVisualSource (such as those created by LottieGen).
// LottieReactNative
interface ILottieSourceProvider
{
Microsoft.UI.Xaml.Controls.IAnimatedVisualSource GetSourceFromName(String name);
}
// Consuming app implements mapping
IAnimatedVisualSource MySourceProvider::GetSourceFromName(hstring name) {
if (name == L"MyAnimation") return winrt::AnimatedVisuals::MyAnimation();
if (name == L"Foo") return winrt::AnimatedVisuals::Foo();
...
}
// Consuming app registers Lottie player with React and supplies it with the name mapper
App() {
...
PackageProviders().Append(winrt::LottieReactNative::ReactPackageProvider(winrt::MySourceProvider());
}
On the JS side, the app can then use Lottie like:
<LottieView source="MyAnimation" />
This works fairly well except that the LottieView API, which is shared with iOS and Android, accepts calls like play(from, to) where from and to are frame numbers, not the normalized time values that AnimatedVisualPlayer expects. As such, our Windows implementation needs a way to convert.
We added an interface to LottieReactNative that we can query in the player. We then tell LottieGen to add the interface to its generated objects. This interface matches the code that LottieGen is already designed to generate.
// LottieReactNative
interface ILottieMediaSource
{
Double FrameToProgress(Double frame);
};
void LottieView::Play(int64_t from, int64_t to) {
auto lottieMediaSource = m_player.Source().try_as<ILottieMediaSource>();
if (lottieMediaSource) {
lottieMediaSource.Play( lottieMediaSource.FrameToProgress(from), lottieMediaSource.FrameToProgress(to) );
} else {
// TODO: Don't know how to convert frames to time. Maybe fall back to default framerate?
}
}
// Generated code in app project
// Created with: lottiegen -AdditionalInterface ILottieMediaSource ...
runtimeclass MyAnimation : [default] IAnimatedVisualSource, ILottieMediaSource {
MyAnimation();
};
class MyAnimation ... {
...
double FrameToProgress(double frame);
...
}
Problem
As you can see, there's an expectation here that the code LottieGen creates will adhere to the schema of the interface exposed by lottie-react-native. That's not guaranteed. If a future version of LottieGen unknowingly introduces a breaking change, apps would not be able to consume that new version unless lottie-react-native is also updated with a new interface. Since LottieGen is currently unaware of these needs, such a change would come easily.
Solution
We can codify the requirements of lottie-react-native into LottieGen to prevent breaking changes. Add a flag to the tool, say -LottieReactNative 1.0, that has the following effects:
- Each generated runtimeclass is configured to extend the interface
LottieReactNative.ILottieMediaSource(the same as if we had specified using -AdditionalInterface - The code in the generated implementations adheres to that interface
Note that the COM interface itself is NOT exported. The expectation is that lottie-react-native will be exporting the interface. LottieGen just needs to create animations that match it.
TODO: Settle on what the interface should be. Is Double FrameToProgress(Double frame); enough? Should we go ahead and add Int64 FrameCount { get; } and Double Duration {get;}?
- Lingua principale
- C#
- Stelle
- 723
- Fork
- 79
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di CommunityToolkit/Lottie-Windows
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
CommunityToolkit/Lottie-Windows#582 · 1 reazione ·
-
file:// uris not supportedAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
Please update to .NET 9Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
Tutte le issue di CommunityToolkit/Lottie-Windows
Issue simili
-
area-Tools-ILLink untriaged
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
dotnet/runtime#138255 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 2 giorni
-
area-fundamentals bug untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
dotnet/extensions#7979 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
QuantConnect/Lean#10236 ·
I maintainer di solito rispondono entro 1 giorno
-
priority:P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100