Skip to content

Added mirror toggle to webcam preview#1049

Open
anmolmalhotra97 wants to merge 6 commits intoTheBoredTeam:devfrom
anmolmalhotra97:feature/mirror-toggle-for-webcam-preview
Open

Added mirror toggle to webcam preview#1049
anmolmalhotra97 wants to merge 6 commits intoTheBoredTeam:devfrom
anmolmalhotra97:feature/mirror-toggle-for-webcam-preview

Conversation

@anmolmalhotra97
Copy link

@anmolmalhotra97 anmolmalhotra97 commented Feb 21, 2026

Add Mirror Toggle to Webcam Preview

Introduced a mirroring toggle feature for the CameraPreviewView.

What was changed: -

  • Added a new Webcam Setting: A toggle switch, "Enable toggle to flip webcam," has been added to the Webcam settings view. This setting controls the visibility of the new in-preview flip button.
  • Introduced a Conditional Flip Button: A new flip button is now overlaid on the webcam preview. This button is only visible if the corresponding setting is enabled and the webcam is active.
  • Implemented Persistent Mirroring: The webcam's mirrored state is toggled exclusively by the new flip button. This state is now persistently stored, so the user's preference is remembered across app launches.

Why was it changed:-

  • To provide users with more control over their webcam feed, allowing them to choose between a mirrored or true-to-life perspective.
  • The decision to make the flip button's visibility optional caters to users who prefer a minimalist interface while still providing powerful, persistent control over the webcam's orientation.

Related Issues
Label: Enhancement -> #1002

Screenshots / Screen Recordings

Screen.Recording.2026-02-24.at.01.07.29.mov

Screen Recording


image
Notch Open


image
Webcam Mode


Screenshot 2026-02-24 at 01 25 15
Flip button not visible in the webcam feed, since disabled in webcam settings


Screenshot 2026-02-24 at 01 25 26
Flip button is visible in the webcam feed, since enabled in the webcam settings


image
Normal Webcam (Non-flipped/mirrored)
Note: Bottom right corner has a flip/mirror button


image
Flipped Webcam Feed


image
Regular Webcam Feed (click to Flip Button)


image
Mirrored Webcam Feed (click to return to normal)

Introduce a mirroring toggle for CameraPreviewView. Adds an @State isMirrored (default true) and uses it to control the preview layer's horizontal scaleEffect (x: -1 or 1). Adds a bottom-right overlay button (visible only when the webcam session is running) to toggle the mirror, updates the SF Symbol based on state, and provides a help tooltip. Keeps existing layout, clipping and opacity behaviour.
Remove the .help(...) modifier from the webcam mirror/flip button in WebcamView.swift. This stops the hover tooltip (which used localization keys) from appearing and simplifies the UI; no other behaviour changes were made.
@anmolmalhotra97
Copy link
Author

Hi @Alexander5015 ,
I have added a mirror toggle feature to the webcam feed.

Please review this PR and let me know if you have any recommendations.

Copy link
Member

@Alexander5015 Alexander5015 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve left some feedback. Also, as a side note: as additional changes may land in dev before this is merged, please periodically rebase the branch on dev to keep it updated.

}
}
}
// The mirror toggle button should only be visible if the webcam session is running
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can make this a setting in Settings, unless you believe there’s a strong case for keeping it here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Alexander5015 ,

Would something like this work?

Image

// 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
@State private var isMirrored: Bool = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be stored in Defaults to make it persistent

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the code to cater to this suggestion.

- Rename WebcamSettings to WebcamSettingsView and register it in the Xcode project.
- Introduce an enableFlipWebcamToggle UI flow: switch to using Defaults.
- Toggle in the settings, show/hide a mirror button in the camera preview only when the toggle is enabled and the session is running, and improve the mirror button icon and styling.
- Rename the Defaults key mirrorWebcam to isMirrored (default false) and update usages.
- Add localization entries for the new toggle and the Webcam label and bump Localizable.xcstrings version.
- Update project.pbxproj to include the new/renamed source file references.
@anmolmalhotra97
Copy link
Author

@Alexander5015, I have updated the codebase as per your suggestions.
I have also updated the PR description.

Please review and provide feedback.

Copy link
Member

Choose a reason for hiding this comment

The 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.

NavigationLink(value: "Shelf") {
Label("Shelf", systemImage: "books.vertical")
}
NavigationLink(value: "Webcam") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to Mirror to match the feature name


// Track the current state of mirror effect and the mirror icon in camera preview
@Default(.isMirrored) private var isMirrored
@Default(.enableFlipWebcamToggle) private var enableFlipWebcamToggle
Copy link
Member

@Alexander5015 Alexander5015 Mar 1, 2026

Choose a reason for hiding this comment

The 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.

Copy link
Member

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.

}
},
"version" : "1.0"
"version" : "1.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the Strings Catalog format version and shouldn't be modified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants