Add haptic feedback on more buttons fix #315
This commit is contained in:
parent
b1520c549e
commit
fbf1c30b7c
|
@ -29,6 +29,8 @@ struct IceCubesApp: App {
|
|||
@State private var popToRootTab: Tab = .other
|
||||
@State private var sideBarLoadedTabs: Set<Tab> = Set()
|
||||
|
||||
private let feedbackGenerator = UISelectionFeedbackGenerator()
|
||||
|
||||
private var availableTabs: [Tab] {
|
||||
appAccountsManager.currentClient.isAuth ? Tab.loggedInTabs() : Tab.loggedOutTab()
|
||||
}
|
||||
|
@ -127,6 +129,7 @@ struct IceCubesApp: App {
|
|||
}
|
||||
}
|
||||
selectedTab = newTab
|
||||
feedbackGenerator.selectionChanged()
|
||||
})) {
|
||||
ForEach(availableTabs) { tab in
|
||||
tab.makeContentView(popToRootTab: $popToRootTab)
|
||||
|
|
|
@ -9,6 +9,8 @@ public struct AppAccountsSelectorView: View {
|
|||
@ObservedObject var routerPath: RouterPath
|
||||
|
||||
@State private var accountsViewModel: [AppAccountViewModel] = []
|
||||
|
||||
let feedbackGenerator = UIImpactFeedbackGenerator()
|
||||
|
||||
private let accountCreationEnabled: Bool
|
||||
private let avatarSize: AvatarView.Size
|
||||
|
@ -20,6 +22,8 @@ public struct AppAccountsSelectorView: View {
|
|||
self.routerPath = routerPath
|
||||
self.accountCreationEnabled = accountCreationEnabled
|
||||
self.avatarSize = avatarSize
|
||||
|
||||
feedbackGenerator.prepare()
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
|
@ -38,6 +42,7 @@ public struct AppAccountsSelectorView: View {
|
|||
}
|
||||
}
|
||||
.onAppear {
|
||||
feedbackGenerator.impactOccurred(intensity: 0.3)
|
||||
refreshAccounts()
|
||||
}
|
||||
.onChange(of: currentAccount.account?.id) { _ in
|
||||
|
@ -66,6 +71,8 @@ public struct AppAccountsSelectorView: View {
|
|||
} else {
|
||||
appAccounts.currentAccount = viewModel.appAccount
|
||||
}
|
||||
|
||||
feedbackGenerator.impactOccurred(intensity: 0.7)
|
||||
} label: {
|
||||
HStack {
|
||||
if viewModel.account?.id == currentAccount.account?.id {
|
||||
|
|
|
@ -7,7 +7,9 @@ public extension View {
|
|||
func statusEditorToolbarItem(routerPath: RouterPath, visibility: Models.Visibility) -> some ToolbarContent {
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button {
|
||||
let feedback = UISelectionFeedbackGenerator()
|
||||
routerPath.presentedSheet = .newStatusEditor(visibility: visibility)
|
||||
feedback.selectionChanged()
|
||||
} label: {
|
||||
Image(systemName: "square.and.pencil")
|
||||
}
|
||||
|
@ -17,7 +19,9 @@ public extension View {
|
|||
|
||||
public struct StatusEditorToolbarItem: ToolbarContent {
|
||||
@EnvironmentObject private var routerPath: RouterPath
|
||||
|
||||
let visibility: Models.Visibility
|
||||
let feedbackGenerator = UISelectionFeedbackGenerator()
|
||||
|
||||
public init(visibility: Models.Visibility) {
|
||||
self.visibility = visibility
|
||||
|
@ -27,6 +31,7 @@ public struct StatusEditorToolbarItem: ToolbarContent {
|
|||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button {
|
||||
routerPath.presentedSheet = .newStatusEditor(visibility: visibility)
|
||||
feedbackGenerator.selectionChanged()
|
||||
} label: {
|
||||
Image(systemName: "square.and.pencil")
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ public enum TimelineFilter: Hashable, Equatable {
|
|||
case remoteLocal(server: String)
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(title())
|
||||
hasher.combine(title)
|
||||
}
|
||||
|
||||
public static func availableTimeline(client: Client) -> [TimelineFilter] {
|
||||
|
@ -20,7 +20,7 @@ public enum TimelineFilter: Hashable, Equatable {
|
|||
return [.home, .local, .federated, .trending]
|
||||
}
|
||||
|
||||
public func title() -> String {
|
||||
public var title: String {
|
||||
switch self {
|
||||
case .federated:
|
||||
return "Federated"
|
||||
|
|
Loading…
Reference in New Issue