Skip to content

Commit

Permalink
fixed bug where cursor did not move to end on click of numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
antingle committed May 6, 2022
1 parent 98ae70e commit 7dabeb0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Calculator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,8 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.8.0;
MACOSX_DEPLOYMENT_TARGET = 12.3;
MARKETING_VERSION = 0.8.1;
PRODUCT_BUNDLE_IDENTIFIER = anthonyingle.Calculator;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down Expand Up @@ -423,7 +424,8 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.8.0;
MACOSX_DEPLOYMENT_TARGET = 12.3;
MARKETING_VERSION = 0.8.1;
PRODUCT_BUNDLE_IDENTIFIER = anthonyingle.Calculator;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
4 changes: 3 additions & 1 deletion Calculator/Views/CalculatorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ struct CalculatorView: View {
VStack {
// MARK: - History View
// A view to show all previous solutions and expressions
HistoryView(expression: $expression, historyIndex: $historyIndex)
HistoryView(expression: $expression,
historyIndex: $historyIndex,
shouldMoveCursorToEnd: $shouldMoveCursorToEnd)

// MARK: - TextField View
// An NSTextField wrapped as a SwiftUI view
Expand Down
3 changes: 3 additions & 0 deletions Calculator/Views/HistoryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct HistoryView: View {
@EnvironmentObject private var historyStore: HistoryStore
@Binding var expression: String
@Binding var historyIndex: Int
@Binding var shouldMoveCursorToEnd: Bool

var body: some View {
// MARK TODO: Make this file more readable
Expand All @@ -30,6 +31,7 @@ struct HistoryView: View {
.frame(maxWidth: .infinity, alignment: .trailing)
.font(.title2)
.onTapGesture {
shouldMoveCursorToEnd = true
expression += item.solution
}
.foregroundColor(historyIndex != -1 ? (item.id == historyStore.history[historyIndex].id ? .accentColor : .primary) : .primary)
Expand All @@ -55,6 +57,7 @@ struct HistoryView: View {
.font(.body)
.foregroundColor(.gray)
.onTapGesture {
shouldMoveCursorToEnd = true
expression += item.expression
}
// MARK TODO: Make this an option?
Expand Down

0 comments on commit 7dabeb0

Please sign in to comment.