Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion boringNotch/components/Webcam/WebcamView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ 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
@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.


var body: some View {
GeometryReader { geometry in
ZStack {
if let previewLayer = webcamManager.previewLayer {
CameraPreviewLayerView(previewLayer: previewLayer)
.scaleEffect(x: -1, y: 1)
.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)
Expand All @@ -44,6 +46,22 @@ struct CameraPreviewView: View {
}
}
}
// 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

.overlay(alignment: .bottomTrailing) {
if 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(.borderless)
.padding(8)
}
}
.onTapGesture {
handleCameraTap()
}
Expand Down