Home IOS Development ios – Mother or father’s offset animation not making use of to youngster Textual content

ios – Mother or father’s offset animation not making use of to youngster Textual content

0
ios – Mother or father’s offset animation not making use of to youngster Textual content

[ad_1]

I’ve received following customized Tab header part, gist of it’s that it makes use of observable worth TabRouterState.view Based mostly on which totally different titles / background colours and offset are utilized. Worth for “view” is an enum. I’ve omitted few properties like padding and clip form to make instance less complicated, as problem doesn’t rely upon them.

import SwiftUI

struct TabHeader: View {
  // Non-public Variables
  non-public var activeTabView = TabRouterState.view
  
  // Decide if introduction view is proven
  non-public var isIntroductionView: Bool {
    return activeTabView == .Introduction
  }
  
  // Get localized title
  non-public var title: LocalizedStringKey {
    swap activeTabView {
    case .House:       return "title-home"
    case .Health:    return "title-fitness"
    case .Diet:  return "title-nutrition"
    default:          return "title-home"
    }
  }
  
  // Get background coloration based mostly on view
  non-public var backgroundColor: Coloration {
    swap activeTabView {
    case .House:       return .purple
    case .Health:    return .orange
    case .Diet:  return .inexperienced
    default:          return .purple
    }
  }
    
  // Physique
  var physique: some View {
    HStack {
      Textual content(title)
        .font(._headingSmBold)
      Spacer()
    }
    .background(backgroundColor)
    .opacity(isIntroductionView ? 0 : 1)
    .offset(y: isIntroductionView ? -150 : 0)
    .animation(.bouncy, worth: activeTabView)
  }
}

Linked is a put up to reddit with identical query that has a video demonstrating how this animation appears to be like. Notice, that tab isn’t proven appropriately whereas in introduction view and animates simply advantageous when going Introduction -> House. Nevertheless, when going Introduction -> (Every other non dwelling view) it appears to be like like title is “frozen in place” i.e. it doesn’t animate with dad and mom offset appropriately. Undecided what causes this and why it really works advantageous with House (I assume one thing to do with it being a default returned in these swap statements?)

https://www.reddit.com/r/SwiftUI/feedback/18dnphw/parents_offset_animation_not_applying_to_child

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here