Skip to content

Commit

Permalink
Add hoverProfile
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Jan 7, 2024
1 parent 042eb21 commit 9fa023f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/apps/SettingsWindow/src/View/ProfilesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ struct ProfilesView: View {
@ObservedObject private var settings = LibKrbn.Settings.shared
@State private var moveDisabled: Bool = true
@State private var showingSheet = false
@State private var hoverProfile: LibKrbn.Profile?
@State private var editingProfile: LibKrbn.Profile?

var body: some View {
Expand Down Expand Up @@ -59,6 +60,9 @@ struct ProfilesView: View {
.foregroundColor(.accentColor)

Text(profile.name)
.if(hoverProfile == profile) {
$0.font(.body.weight(.bold))
}
}
}
)
Expand Down Expand Up @@ -103,6 +107,15 @@ struct ProfilesView: View {
}
.padding(.vertical, 5.0)
.moveDisabled(moveDisabled)
.onHover { hovering in
if hovering {
hoverProfile = profile
} else {
if hoverProfile == profile {
hoverProfile = nil
}
}
}
}
.onMove { indices, destination in
if let first = indices.first {
Expand Down
6 changes: 5 additions & 1 deletion src/apps/share/swift/LibKrbn/Models/Profile.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

extension LibKrbn {
struct Profile: Identifiable {
struct Profile: Identifiable, Equatable {
var id = UUID()
var index: Int
var name: String
Expand All @@ -12,5 +12,9 @@ extension LibKrbn {
self.name = name
self.selected = selected
}

public static func == (lhs: Profile, rhs: Profile) -> Bool {
lhs.id == rhs.id
}
}
}

0 comments on commit 9fa023f

Please sign in to comment.