Optimize tabbar selection
This commit is contained in:
parent
ab06c0ab17
commit
cfee153050
|
@ -158,9 +158,6 @@ struct IceCubesApp: App {
|
||||||
TabView(selection: .init(get: {
|
TabView(selection: .init(get: {
|
||||||
selectedTab
|
selectedTab
|
||||||
}, set: { newTab in
|
}, set: { newTab in
|
||||||
var transaction = Transaction()
|
|
||||||
transaction.disablesAnimations = true
|
|
||||||
withTransaction(transaction) {
|
|
||||||
if newTab == selectedTab {
|
if newTab == selectedTab {
|
||||||
/// Stupid hack to trigger onChange binding in tab views.
|
/// Stupid hack to trigger onChange binding in tab views.
|
||||||
popToRootTab = .other
|
popToRootTab = .other
|
||||||
|
@ -168,7 +165,13 @@ struct IceCubesApp: App {
|
||||||
popToRootTab = selectedTab
|
popToRootTab = selectedTab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedTab = newTab
|
selectedTab = newTab
|
||||||
|
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
HapticManager.shared.fireHaptic(of: .tabSelection)
|
||||||
|
SoundEffectManager.shared.playSound(of: .tabSelection)
|
||||||
|
|
||||||
if selectedTab == .notifications,
|
if selectedTab == .notifications,
|
||||||
let token = appAccountsManager.currentAccount.oauthToken
|
let token = appAccountsManager.currentAccount.oauthToken
|
||||||
{
|
{
|
||||||
|
@ -176,8 +179,7 @@ struct IceCubesApp: App {
|
||||||
watcher.unreadNotificationsCount = 0
|
watcher.unreadNotificationsCount = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HapticManager.shared.fireHaptic(of: .tabSelection)
|
|
||||||
SoundEffectManager.shared.playSound(of: .tabSelection)
|
|
||||||
})) {
|
})) {
|
||||||
ForEach(availableTabs) { tab in
|
ForEach(availableTabs) { tab in
|
||||||
tab.makeContentView(popToRootTab: $popToRootTab)
|
tab.makeContentView(popToRootTab: $popToRootTab)
|
||||||
|
|
Loading…
Reference in New Issue