From 0a50dfabae8b149ff601e15dff4a9019fdb4b51e Mon Sep 17 00:00:00 2001 From: Abdelrahman Ashraf Date: Mon, 15 Jan 2024 13:16:14 +0700 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20remove=20the=20Directio?= =?UTF-8?q?n=20enum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dotlottie-ffi/src/dotlottie_player.udl | 8 +------- dotlottie-rs/src/dotlottie_player.rs | 21 ++++++--------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/dotlottie-ffi/src/dotlottie_player.udl b/dotlottie-ffi/src/dotlottie_player.udl index a7aa1ed6..330d2048 100644 --- a/dotlottie-ffi/src/dotlottie_player.udl +++ b/dotlottie-ffi/src/dotlottie_player.udl @@ -4,15 +4,10 @@ namespace dotlottie_player { enum Mode { "Forward", "Reverse", - "ForwardBounce", + "Bounce", "ReverseBounce" }; -enum Direction { - "Forward", - "Reverse" -}; - dictionary Config { boolean autoplay; boolean loop_animation; @@ -45,5 +40,4 @@ interface DotLottiePlayer { boolean render(); boolean resize(u32 width, u32 height); void clear(); - Direction direction(); }; \ No newline at end of file diff --git a/dotlottie-rs/src/dotlottie_player.rs b/dotlottie-rs/src/dotlottie_player.rs index c91f96ed..d8b4c621 100644 --- a/dotlottie-rs/src/dotlottie_player.rs +++ b/dotlottie-rs/src/dotlottie_player.rs @@ -12,12 +12,11 @@ pub enum PlaybackState { pub enum Mode { Forward, Reverse, - ForwardBounce, + Bounce, ReverseBounce, } -#[derive(PartialEq, Clone, Copy)] -pub enum Direction { +enum Direction { Forward, Reverse, } @@ -46,7 +45,7 @@ impl DotLottieRuntime { let direction = match config.mode { Mode::Forward => Direction::Forward, Mode::Reverse => Direction::Reverse, - Mode::ForwardBounce => Direction::Forward, + Mode::Bounce => Direction::Forward, Mode::ReverseBounce => Direction::Reverse, }; @@ -61,10 +60,6 @@ impl DotLottieRuntime { } } - pub fn direction(&self) -> Direction { - self.direction - } - pub fn is_loaded(&self) -> bool { self.is_loaded } @@ -117,7 +112,7 @@ impl DotLottieRuntime { let end_frame = self.total_frames() - 1.0; match self.config.mode { - Mode::Forward | Mode::ForwardBounce => { + Mode::Forward | Mode::Bounce => { self.set_frame(start_frame); } Mode::Reverse | Mode::ReverseBounce => { @@ -187,7 +182,7 @@ impl DotLottieRuntime { next_frame } } - Mode::ForwardBounce => match self.direction { + Mode::Bounce => match self.direction { Direction::Forward => { if next_frame >= total_frames { self.direction = Direction::Reverse; @@ -295,7 +290,7 @@ impl DotLottieRuntime { let end_frame = self.total_frames() - 1.0; match self.config.mode { - Mode::Forward | Mode::ForwardBounce => { + Mode::Forward | Mode::Bounce => { self.set_frame(first_frame); self.direction = Direction::Forward; } @@ -449,10 +444,6 @@ impl DotLottiePlayer { pub fn config(&self) -> Config { self.runtime.read().unwrap().config() } - - pub fn direction(&self) -> Direction { - self.runtime.read().unwrap().direction() - } } unsafe impl Send for DotLottiePlayer {}