Skip to content

Commit

Permalink
Add the ability to double-tap to get random image
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 27, 2021
1 parent 0021ead commit 860eb8d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Blear.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@
repositoryURL = "https://github.com/microsoft/appcenter-sdk-apple";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 4.0.0;
minimumVersion = 4.1.1;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
11 changes: 9 additions & 2 deletions Blear/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct ContentView: View {
Spacer()
Menu {
Button {
image = Self.getRandomImage()
randomImage()
} label: {
Label("Random Image", systemImage: "photo")
}
Expand Down Expand Up @@ -85,6 +85,9 @@ struct ContentView: View {
image: $image,
blurAmount: $blurAmount
)
.onTapGesture(count: 2) {
randomImage()
}
if !isSaving {
controls
}
Expand All @@ -93,7 +96,7 @@ struct ContentView: View {
.alert2(isPresented: $isShowingShakeTip) {
Alert(
title: Text("Tip"),
message: Text("Shake the device to get a random image.")
message: Text("Double-tap the image or shake the device to get another random image.")
)
}
.alert2(isPresented: $isShowingWallpaperTip) {
Expand All @@ -117,6 +120,10 @@ struct ContentView: View {
}
}

private func randomImage() {
image = Self.getRandomImage()
}

private func saveImage() {
isSaving = true

Expand Down

0 comments on commit 860eb8d

Please sign in to comment.