2

I am trying to make a transition from leading.

.fullScreenCover(isPresented: $isLoginSuccess) {
    HomeView()
}

It's using the default transition, from bottom. Unable to change the transition with .transition(.move(edge: .leading))

Supriyo Dey
  • 230
  • 1
  • 12
  • Does this answer your question? [Alternative animation for fullscreen cover / modal - iOS 14](https://stackoverflow.com/questions/62593549/alternative-animation-for-fullscreen-cover-modal-ios-14) – timbre timbre Oct 31 '22 at 14:08
  • you can't. but you can create a custom fullscreen cover. See link above – timbre timbre Oct 31 '22 at 14:09

1 Answers1

1

fullScreenCover is using the system animation when presenting (also because it plays under the hoods with UIKit, if I'm not mistaken), while transition modifier affects the appearance of a view when for example you use if or switch statements in the body of a view itself.

In your case you could wrap both login and home views in same body and use an if to show either the login or the home.

struct Root: View {
  @State var isLoginSuccess = false

  var body: some View {
    if isLoginSuccess {
      HomeView()
        .transition(.move(edge: .leading))
    } else {
      LoginView()
        .transition(.move(edge: .trailing))
    }
  }
}

Then, when modifying the state, remember to wrap under withAnimation like:

withAnimation {
  isLoginSuccess = true
}
Rico Crescenzio
  • 3,952
  • 1
  • 14
  • 28