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