From 860eb8db37ff7d81f368913a5dbdb69356928ebf Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 22 Apr 2021 23:29:08 +0700 Subject: [PATCH] Add the ability to double-tap to get random image --- Blear.xcodeproj/project.pbxproj | 2 +- Blear/ContentView.swift | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Blear.xcodeproj/project.pbxproj b/Blear.xcodeproj/project.pbxproj index eef8145..8d4ccbb 100644 --- a/Blear.xcodeproj/project.pbxproj +++ b/Blear.xcodeproj/project.pbxproj @@ -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 */ diff --git a/Blear/ContentView.swift b/Blear/ContentView.swift index 0cc3c54..e8ae46f 100644 --- a/Blear/ContentView.swift +++ b/Blear/ContentView.swift @@ -26,7 +26,7 @@ struct ContentView: View { Spacer() Menu { Button { - image = Self.getRandomImage() + randomImage() } label: { Label("Random Image", systemImage: "photo") } @@ -85,6 +85,9 @@ struct ContentView: View { image: $image, blurAmount: $blurAmount ) + .onTapGesture(count: 2) { + randomImage() + } if !isSaving { controls } @@ -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) { @@ -117,6 +120,10 @@ struct ContentView: View { } } + private func randomImage() { + image = Self.getRandomImage() + } + private func saveImage() { isSaving = true