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

Possible to animate title/body text? #66

Closed
iori57 opened this issue Oct 18, 2020 · 5 comments
Closed

Possible to animate title/body text? #66

iori57 opened this issue Oct 18, 2020 · 5 comments

Comments

@iori57
Copy link

iori57 commented Oct 18, 2020

I'm trying to create a top overlay similar to iOS native callkit green bar when there's ongoing call. Up to a point where it looks pretty similar however I couldn't find a way to animate the text so that it fades in and out just like the callkit bar. Is it possible to do that with the current version (I'm on v3.0.3)?

Thanks, this is a great library!

@isadon
Copy link
Owner

isadon commented Oct 18, 2020

Hi. Thanks for the feedback. Do you have a gif of what you currently have so far so that I can see what is left to do in what you are trying to accomplish?

@iori57
Copy link
Author

iori57 commented Oct 18, 2020

Hi, yes here's a youtube video showing what I trying to accomplish: https://youtu.be/JGJNN5VeOdw?t=1623 (start at 27:03 if the link is not working). We are trying to show the native callkit green bar at the top when the app is in foreground - a use case is when there's an on hold ongoing sim call, we would like the user to be able to click on the green bar to go back to the call, which wouldn't show on our app screen if our voip app is making a call at the same time.

a few posts in from the good folks at stack overflow (https://stackoverflow.com/questions/37571066/showing-in-call-status-bar-double-height-for-a-custom-voip-app-in-ios) suggests that using TSMessages is one way to accomplish it, so I shouldn't be the only one looking :)

Cheers!

@isadon
Copy link
Owner

isadon commented Oct 18, 2020

As per this in the README:

Want to further customize a notification message right before its presented? Do the following:

   let rControl = RMController()
   rControl.delegate = self

   ...

   // Now lets implement the RMControllerDelegate customize(message:controller:) method which
   // RMController calls right before presenting:
   func customize(message: RMessage) {
   message.alpha = 0.4
   message.addSubview(aView)
  }

Set yourself up as a delegate of RMController and then in the callback:

func customize(message: RMessage) {
  // Optionally guard message == (the message I'm looking for) so the animations don't happen for all.

  // Customize is called before presenting but we can fire off an animation to occur 1s or two after presenting below
  DispatchQueue.main.asyncAfter(.now() + timeInSecs) { [weak self] 
      guard let self = self else { return }
     // Your animate code here on the titleLabel + body label of message arg
  })
}

Can you try that and see if it works? If not you can modify RMControllerDelegate to call back with a didPresent method..

@iori57
Copy link
Author

iori57 commented Oct 18, 2020

Sorry just started learning iOS and swift, seems like titleLabel is private and I am not sure if there's something obvious I need to do to access it from the message inside func customize(message: RMessage) ?

@isadon
Copy link
Owner

isadon commented Oct 26, 2020

@iori57 the titleLabel isn't private for the purposes of setting the text on it. You can go ahead and set the text on it..

@isadon isadon closed this as completed Dec 11, 2020
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

No branches or pull requests

2 participants