Created
November 1, 2022 10:32
-
-
Save wizard1066/5732ddbefac542247d704f0e1f69edec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ContentView: View { | |
@State private var sourceType: UIImagePickerController.SourceType = .camera | |
@State private var selectedImage: UIImage? | |
@State private var isImagePickerDisplay = false | |
@State private var sync2 = speaking() | |
@State var strings:[String] = [] | |
var body: some View { | |
NavigationView { | |
VStack { | |
if selectedImage != nil { | |
Image(uiImage: selectedImage!) | |
.resizable() | |
.aspectRatio(contentMode: .fit) | |
.clipShape(Circle()) | |
.frame(width: 512, height: 512) | |
.onTapGesture { | |
scanText() | |
sync2.speaker(words: strings) | |
} | |
} else { | |
Image(systemName: "camera") | |
.resizable() | |
.aspectRatio(contentMode: .fit) | |
.clipShape(Circle()) | |
.frame(width: 512, height: 512) | |
} | |
HStack { | |
Button("Camera") { | |
self.strings.removeAll() | |
self.sourceType = .camera | |
self.isImagePickerDisplay.toggle() | |
}.padding() | |
Button("photo") { | |
self.strings.removeAll() | |
self.sourceType = .photoLibrary | |
self.isImagePickerDisplay.toggle() | |
}.padding() | |
} | |
} | |
.navigationBarTitle("Demo") | |
.sheet(isPresented: self.$isImagePickerDisplay) { | |
ImagePickerView(selectedImage: self.$selectedImage, sourceType: self.sourceType) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment