Skip to content

Commit

Permalink
improved notes
Browse files Browse the repository at this point in the history
  • Loading branch information
AdinAck committed Apr 22, 2023
1 parent f690599 commit 67fa98f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
29 changes: 18 additions & 11 deletions LEGv8-Simulator/Views/Registers/RegisterRowView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,26 @@ struct RegisterRowView: View {
@State private var displayMode: String = "H"
@State private var isPresented: Bool = false
@State private var note: String = ""
@State private var noteVisisble: Bool = false
@FocusState private var noteFocused: Bool
@State private var noteButtonVisible: Bool = false

var body: some View {
HStack {
Text(name)
.font(.custom("Menlo Regular", size: 12))
.frame(width: 30)

TextField("Note...", text: $note)
.opacity(noteVisisble ? 1 : 0)
.onHover { hovering in
if note == "" {
withAnimation {
noteVisisble = hovering
}
}
}
Button {
noteFocused.toggle()
} label: {
Image(systemName: "pencil.line")
}
.buttonStyle(.borderless)
.opacity(noteButtonVisible ? 1 : 0)

TextField("", text: $note)
.foregroundColor(.secondary)
.focused($noteFocused)

Spacer()

Expand Down Expand Up @@ -60,7 +64,7 @@ struct RegisterRowView: View {
}
.buttonStyle(.borderless)
.popover(isPresented: $isPresented) {
if let history = interpreter.history.registers[name]?.values.sorted { a, b in a > b } {
if let history = interpreter.history.registers[name]?.values.sorted(by: { a, b in a > b }) {
HistoryView(displayMode: displayMode, history: history)
.frame(width: 500, height: 300)
.animation(.default, value: history)
Expand All @@ -81,6 +85,9 @@ struct RegisterRowView: View {
.frame(width: 50)
.padding(.trailing)
}
.onHover { hovering in
noteButtonVisible = hovering
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion LEGv8-Simulator/Views/Settings/AboutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import SwiftUI

struct AboutView: View {
let version: String = "1.3 (Release)"
let version: String = "1.3.1 (Release)"

var body: some View {
HStack {
Expand Down

0 comments on commit 67fa98f

Please sign in to comment.