mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-01-10 16:25:26 +00:00
Ensure account and tab switching is done without animations
This commit is contained in:
parent
dae7b85d3d
commit
5ab9566ca5
4 changed files with 23 additions and 9 deletions
|
@ -133,14 +133,18 @@ struct IceCubesApp: App {
|
||||||
TabView(selection: .init(get: {
|
TabView(selection: .init(get: {
|
||||||
selectedTab
|
selectedTab
|
||||||
}, set: { newTab in
|
}, set: { newTab in
|
||||||
if newTab == selectedTab {
|
var transaction = Transaction()
|
||||||
/// Stupid hack to trigger onChange binding in tab views.
|
transaction.disablesAnimations = true
|
||||||
popToRootTab = .other
|
withTransaction(transaction) {
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
|
if newTab == selectedTab {
|
||||||
popToRootTab = 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)
|
HapticManager.shared.fireHaptic(of: .tabSelection)
|
||||||
})) {
|
})) {
|
||||||
ForEach(availableTabs) { tab in
|
ForEach(availableTabs) { tab in
|
||||||
|
|
|
@ -75,7 +75,9 @@ struct SideBarView<Content: View>: View {
|
||||||
if account.id == appAccounts.currentAccount.id {
|
if account.id == appAccounts.currentAccount.id {
|
||||||
selectedTab = .profile
|
selectedTab = .profile
|
||||||
} else {
|
} else {
|
||||||
withAnimation {
|
var transation = Transaction()
|
||||||
|
transation.disablesAnimations = true
|
||||||
|
withTransaction(transation) {
|
||||||
appAccounts.currentAccount = account
|
appAccounts.currentAccount = account
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,11 @@ public struct AppAccountView: View {
|
||||||
{
|
{
|
||||||
routerPath.navigate(to: .accountSettingsWithAccount(account: account, appAccount: viewModel.appAccount))
|
routerPath.navigate(to: .accountSettingsWithAccount(account: account, appAccount: viewModel.appAccount))
|
||||||
} else {
|
} else {
|
||||||
appAccounts.currentAccount = viewModel.appAccount
|
var transation = Transaction()
|
||||||
|
transation.disablesAnimations = true
|
||||||
|
withTransaction(transation) {
|
||||||
|
appAccounts.currentAccount = viewModel.appAccount
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,11 @@ public struct AppAccountsSelectorView: View {
|
||||||
{
|
{
|
||||||
routerPath.navigate(to: .accountDetailWithAccount(account: account))
|
routerPath.navigate(to: .accountDetailWithAccount(account: account))
|
||||||
} else {
|
} else {
|
||||||
appAccounts.currentAccount = viewModel.appAccount
|
var transation = Transaction()
|
||||||
|
transation.disablesAnimations = true
|
||||||
|
withTransaction(transation) {
|
||||||
|
appAccounts.currentAccount = viewModel.appAccount
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HapticManager.shared.fireHaptic(of: .buttonPress)
|
HapticManager.shared.fireHaptic(of: .buttonPress)
|
||||||
|
|
Loading…
Reference in a new issue