Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/android controller functions #3

Merged

Conversation

shamsudeeen-yusuf
Copy link
Contributor

No description provided.

Copy link

changeset-bot bot commented Aug 27, 2024

⚠️ No Changeset found

Latest commit: f8b03d1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

private const val COMMAND_SET_LOOP = "setLoop"
private const val COMMAND_SET_LOOP_ID = 7

private const val COMMAND_SET_PROGRESS = "setProgress"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this command is used for ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove this. was trying to use it for segment

setFrame: setFrameWithUIManager,
freeze: freezeWithUIManager,
unfreeze: unfreezeWithUIManager,
}));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think useImperativeHandle should accept a dependency array, which would include all the methods that port the commands to the native side. https://react.dev/reference/react/useImperativeHandle#parameters.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to add them as they are not states

Comment on lines +197 to +198
loop={false}
autoplay={false}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for hardcoding these props to false? Aren't they false by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this stands as the default value.
but the props spread overrides it

};

export const DotLottie = forwardRef(
({ source, ...props }: DotlottieReactNativeProps, ref) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If any of the props, like source or loop, are updated, will those changes be reflected in the native environment? I'm assuming they won't, since we need to call setLoop, setSource on the dotLottie instance, right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it does immediately

Comment on lines 34 to 40
setStartStateMachine: () => void;
setStopStateMachine: () => void;
setLoadStateMachine: (stateMachineId: string) => void;
setPostEvent: (event: string) => void;
setAddStateMachineEventListener: () => void;
setRemoveStateMachineEventListener: () => void;
setResize: (width: number, height: number) => void;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this set prefix is something required on react-native side? I think without set prefix for these functions makes more sense to me.

  startStateMachine: () => void;
  stopStateMachine: () => void;
  loadStateMachine: (stateMachineId: string) => void;
  postEvent: (event: string) => void;
  addStateMachineEventListener: () => void;
  removeStateMachineEventListener: () => void;
  resize: (width: number, height: number) => void;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove that. just naming conventions

setStopStateMachine: () => void;
setLoadStateMachine: (stateMachineId: string) => void;
setPostEvent: (event: string) => void;
setAddStateMachineEventListener: () => void;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of these methods accepts parameters on the native code. Is it something we could do on react-native side?

fun addStateMachineEventListener(listener: StateMachineEventListener)
fun removeStateMachineEventListener(listener: StateMachineEventListener)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do everything on the native side and listen to it on a method prop in react native. so the listener is on the native side

Comment on lines +90 to +120
object : DotLottieEventListener {
override fun onLoad() {
onReceiveNativeEvent("onLoad", null)
}
override fun onComplete() {

onReceiveNativeEvent("onComplete", null)
}
override fun onLoadError() {

onReceiveNativeEvent("onLoadError", null)
}
override fun onPlay() {
onReceiveNativeEvent("onPlay", null)
}
override fun onStop() {
onReceiveNativeEvent("onRender", null)
}
override fun onPause() {
onReceiveNativeEvent("onPause", null)
}
override fun onFreeze() {
onReceiveNativeEvent("onFreeze", null)
}
override fun onUnFreeze() {
onReceiveNativeEvent("onUnFreeze", null)
}
override fun onDestroy() {
onReceiveNativeEvent("onDestroy", null)
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets create eventListeners same as dotLottieController with remember. I think current approach will create new DotLottieEventListener on every composition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no it won't because it's on the class so it is created only once

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool we can resolve this

setMarker: (marker: string) => void;
loadTheme: (themeId: string) => void;
loadAnimation: (animationId: string) => void;
setManifest: () => void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shamsudeeen-yusuf I don't think that there is a native method called setManifest

@theashraf theashraf merged commit 3e24262 into LottieFiles:main Oct 8, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants