Skip to content

Commit

Permalink
solutions are highlighted when cycling
Browse files Browse the repository at this point in the history
  • Loading branch information
antingle committed May 1, 2022
1 parent 01cd44a commit e5724c4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
8 changes: 6 additions & 2 deletions Calculator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,13 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Calculator/Calculator.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"Calculator/Preview Content\"";
DEVELOPMENT_TEAM = 4UQS8N4WUS;
ENABLE_HARDENED_RUNTIME = NO;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Calculator/Info.plist;
Expand All @@ -319,7 +321,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.5.0;
MARKETING_VERSION = 0.5.1;
PRODUCT_BUNDLE_IDENTIFIER = anthonyingle.Calculator;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -333,11 +335,13 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Calculator/Calculator.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"Calculator/Preview Content\"";
DEVELOPMENT_TEAM = 4UQS8N4WUS;
ENABLE_HARDENED_RUNTIME = NO;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Calculator/Info.plist;
Expand All @@ -347,7 +351,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.5.0;
MARKETING_VERSION = 0.5.1;
PRODUCT_BUNDLE_IDENTIFIER = anthonyingle.Calculator;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
8 changes: 4 additions & 4 deletions Calculator/Calculator.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
12 changes: 6 additions & 6 deletions Calculator/CalculatorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct CalculatorView: View {
.onTapGesture {
expression += item.solution
}
.foregroundColor(historyIndex != -1 ? (item.id == history[historyIndex].id ? .blue : .white) : .white)

// copy solution button
Button {
Expand Down Expand Up @@ -84,10 +85,10 @@ struct CalculatorView: View {
onTextChange: { newExpression in
if !history.isEmpty &&
(newExpression == "+" ||
newExpression == "*" ||
newExpression == "/" ||
newExpression == "^" ||
newExpression == "%")
newExpression == "*" ||
newExpression == "/" ||
newExpression == "^" ||
newExpression == "%")
{
expression.insert(contentsOf: history[0].solution, at: expression.startIndex)
}
Expand All @@ -110,9 +111,8 @@ struct CalculatorView: View {
if historyIndex > 0 {
expression.removeLast(history[historyIndex - 1].solution.count)
}
expression += history[historyIndex].solution
expression += history[historyIndex].solution
}

},
// on DOWN ARROW key
onMoveDown: {
Expand Down

0 comments on commit e5724c4

Please sign in to comment.