Ensure account and tab switching is done without animations

This commit is contained in:
Thomas Ricouard 2023-02-09 18:48:31 +01:00
parent dae7b85d3d
commit 5ab9566ca5
4 changed files with 23 additions and 9 deletions

View file

@ -133,14 +133,18 @@ struct IceCubesApp: App {
TabView(selection: .init(get: {
selectedTab
}, set: { newTab in
if newTab == selectedTab {
/// Stupid hack to trigger onChange binding in tab views.
popToRootTab = .other
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
popToRootTab = selectedTab
var transaction = Transaction()
transaction.disablesAnimations = true
withTransaction(transaction) {
if newTab == selectedTab {
/// Stupid hack to trigger onChange binding in tab views.
popToRootTab = .other
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
popToRootTab = selectedTab
}
}
selectedTab = newTab
}
selectedTab = newTab
HapticManager.shared.fireHaptic(of: .tabSelection)
})) {
ForEach(availableTabs) { tab in

View file

@ -75,7 +75,9 @@ struct SideBarView<Content: View>: View {
if account.id == appAccounts.currentAccount.id {
selectedTab = .profile
} else {
withAnimation {
var transation = Transaction()
transation.disablesAnimations = true
withTransaction(transation) {
appAccounts.currentAccount = account
}
}

View file

@ -74,7 +74,11 @@ public struct AppAccountView: View {
{
routerPath.navigate(to: .accountSettingsWithAccount(account: account, appAccount: viewModel.appAccount))
} else {
appAccounts.currentAccount = viewModel.appAccount
var transation = Transaction()
transation.disablesAnimations = true
withTransaction(transation) {
appAccounts.currentAccount = viewModel.appAccount
}
}
}
}

View file

@ -75,7 +75,11 @@ public struct AppAccountsSelectorView: View {
{
routerPath.navigate(to: .accountDetailWithAccount(account: account))
} else {
appAccounts.currentAccount = viewModel.appAccount
var transation = Transaction()
transation.disablesAnimations = true
withTransaction(transation) {
appAccounts.currentAccount = viewModel.appAccount
}
}
HapticManager.shared.fireHaptic(of: .buttonPress)