-
-
Notifications
You must be signed in to change notification settings - Fork 552
Added mirror toggle to webcam preview #1049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
fd9757a
9efbe5a
327e1ab
f7c8bdf
9b54e7c
9b8b9f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7616,6 +7616,10 @@ | |
| } | ||
| } | ||
| }, | ||
| "Enable toggle to flip webcam" : { | ||
| "comment" : "A label for a toggle that enables or disables the option to flip the webcam.", | ||
| "isCommentAutoGenerated" : true | ||
| }, | ||
| "Enable window shadow" : { | ||
| "localizations" : { | ||
| "ar" : { | ||
|
|
@@ -20234,6 +20238,10 @@ | |
| }, | ||
| "Visibility" : { | ||
|
|
||
| }, | ||
| "Webcam" : { | ||
| "comment" : "A label displayed above a button that allows the user to configure webcam settings.", | ||
| "isCommentAutoGenerated" : true | ||
| }, | ||
| "Welcome" : { | ||
| "localizations" : { | ||
|
|
@@ -20936,5 +20944,5 @@ | |
| } | ||
| } | ||
| }, | ||
| "version" : "1.0" | ||
| "version" : "1.1" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the Strings Catalog format version and shouldn't be modified. |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,9 @@ struct SettingsView: View { | |
| NavigationLink(value: "Shelf") { | ||
| Label("Shelf", systemImage: "books.vertical") | ||
| } | ||
| NavigationLink(value: "Webcam") { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename to Mirror to match the feature name |
||
| Label("Webcam", systemImage: "camera") | ||
| } | ||
| NavigationLink(value: "Shortcuts") { | ||
| Label("Shortcuts", systemImage: "keyboard") | ||
| } | ||
|
|
@@ -74,6 +77,8 @@ struct SettingsView: View { | |
| Charge() | ||
| case "Shelf": | ||
| Shelf() | ||
| case "Webcam": | ||
| WebcamSettings() | ||
| case "Shortcuts": | ||
| Shortcuts() | ||
| case "Advanced": | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move all mirror settings here. I think its the setting to enable the mirror and the mirror shape. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // | ||
| // WebcamSettings.swift | ||
| // boringNotch | ||
| // | ||
| // Created by Anmol Malhotra on 2026-02-24. | ||
| // | ||
|
|
||
| import SwiftUI | ||
| import Defaults | ||
|
|
||
| struct WebcamSettings: View { | ||
|
|
||
| @Default(.enableFlipWebcamToggle) private var enableFlipWebcamToggle | ||
|
|
||
| var body: some View { | ||
| Form { | ||
| Defaults.Toggle(key: .enableFlipWebcamToggle) { | ||
| Text("Enable toggle to flip webcam") | ||
| } | ||
| } | ||
| .formStyle(.grouped) | ||
| .frame(maxWidth: .infinity, maxHeight: .infinity) | ||
| .padding() | ||
| .navigationTitle("Webcam") | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,16 +15,36 @@ struct CameraPreviewView: View { | |
|
|
||
| // Track if authorization request is in progress to avoid multiple requests | ||
| @State private var isRequestingAuthorization: Bool = false | ||
|
|
||
| // Track the current state of mirror effect and the mirror icon in camera preview | ||
| @Default(.isMirrored) private var isMirrored | ||
| @Default(.enableFlipWebcamToggle) private var enableFlipWebcamToggle | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am open to discussion about this, but I don't think we need a toggle button overlay at all. My suggestion was that rather than having a visible toggle button, we just make this a setting in settings as I don't think this will be frequently changed. |
||
|
|
||
| var body: some View { | ||
| GeometryReader { geometry in | ||
| ZStack { | ||
| if let previewLayer = webcamManager.previewLayer { | ||
| CameraPreviewLayerView(previewLayer: previewLayer) | ||
| .scaleEffect(x: -1, y: 1) | ||
| .clipShape(RoundedRectangle(cornerRadius: Defaults[.mirrorShape] == .rectangle ? MusicPlayerImageSizes.cornerRadiusInset.opened : 100)) | ||
| .frame(width: geometry.size.width, height: geometry.size.width) | ||
| .opacity(webcamManager.isSessionRunning ? 1 : 0) | ||
| ZStack(alignment: .bottomTrailing) { | ||
| CameraPreviewLayerView(previewLayer: previewLayer) | ||
| .scaleEffect(x: isMirrored ? -1 : 1, y: 1) | ||
| .clipShape(RoundedRectangle(cornerRadius: Defaults[.mirrorShape] == .rectangle ? MusicPlayerImageSizes.cornerRadiusInset.opened : 100)) | ||
| .frame(width: geometry.size.width, height: geometry.size.width) | ||
| .opacity(webcamManager.isSessionRunning ? 1 : 0) | ||
|
|
||
| // The mirror toggle button should only be visible if the webcam session is running and the setting to enable it is turned on | ||
| if enableFlipWebcamToggle && webcamManager.isSessionRunning { | ||
| Button { | ||
| isMirrored.toggle() | ||
| } label: { | ||
| Image(systemName: isMirrored ? "arrow.left.and.right.circle.fill" : "arrow.left.and.right.circle") | ||
| .font(.system(size: 14, weight: .semibold)) | ||
| .foregroundStyle(.white.opacity(0.9)) | ||
| .padding(6) | ||
| .background(.black.opacity(0.35), in: Circle()) | ||
| } | ||
| .buttonStyle(.plain) | ||
| .padding(8) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if !webcamManager.isSessionRunning { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an autogenerated file and should not be updated (by you or by AI). Discard the changes in this file and rebuild the app to allow Xcode to generate these keys.