Use native camera aspect ratio instead of forced 4:3
- Let MijickCamera determine the preview aspect ratio - Ring light padding on horizontal sides (left/right) - Smaller vertical padding between controls and camera - Camera preview fills available space naturally
This commit is contained in:
parent
22586d6693
commit
7e5c4a021f
@ -16,26 +16,12 @@ struct RingLightCameraScreen: MCameraScreen {
|
|||||||
|
|
||||||
// MARK: - Layout Constants
|
// MARK: - Layout Constants
|
||||||
|
|
||||||
/// Camera aspect ratio (4:3 for photos)
|
|
||||||
private let cameraAspectRatio: CGFloat = 4.0 / 3.0
|
|
||||||
|
|
||||||
/// Capture button inner padding
|
/// Capture button inner padding
|
||||||
private let captureButtonInnerPadding: CGFloat = 8
|
private let captureButtonInnerPadding: CGFloat = 8
|
||||||
|
|
||||||
/// Control bar height for layout calculations
|
|
||||||
private let controlBarHeight: CGFloat = 100
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
GeometryReader { geometry in
|
GeometryReader { geometry in
|
||||||
let safeArea = geometry.safeAreaInsets
|
let safeArea = geometry.safeAreaInsets
|
||||||
let availableWidth = geometry.size.width
|
|
||||||
let availableHeight = geometry.size.height
|
|
||||||
|
|
||||||
// Calculate camera size to fit within available space with ring padding
|
|
||||||
let cameraSize = calculateCameraSize(
|
|
||||||
availableWidth: availableWidth - (effectiveRingSize * 2),
|
|
||||||
availableHeight: availableHeight - (effectiveRingSize * 2) - controlBarHeight - safeArea.top
|
|
||||||
)
|
|
||||||
|
|
||||||
ZStack {
|
ZStack {
|
||||||
// Ring light background - fills entire screen
|
// Ring light background - fills entire screen
|
||||||
@ -47,50 +33,33 @@ struct RingLightCameraScreen: MCameraScreen {
|
|||||||
// Top control bar
|
// Top control bar
|
||||||
topControlBar
|
topControlBar
|
||||||
.padding(.top, safeArea.top + Design.Spacing.small)
|
.padding(.top, safeArea.top + Design.Spacing.small)
|
||||||
|
.padding(.horizontal, Design.Spacing.large)
|
||||||
|
|
||||||
Spacer()
|
// Camera preview - uses native camera aspect ratio
|
||||||
|
// The ring light is the padding around it
|
||||||
// Camera preview - centered with fixed aspect ratio
|
|
||||||
createCameraOutputView()
|
createCameraOutputView()
|
||||||
.frame(width: cameraSize.width, height: cameraSize.height)
|
|
||||||
.clipShape(RoundedRectangle(cornerRadius: Design.CornerRadius.large))
|
.clipShape(RoundedRectangle(cornerRadius: Design.CornerRadius.large))
|
||||||
|
.padding(.horizontal, effectiveRingSize)
|
||||||
|
.padding(.vertical, Design.Spacing.medium)
|
||||||
.overlay {
|
.overlay {
|
||||||
// Grid overlay on top of camera
|
// Grid overlay on top of camera
|
||||||
if settings.isGridVisible {
|
if settings.isGridVisible {
|
||||||
GridOverlay(isVisible: true)
|
GridOverlay(isVisible: true)
|
||||||
.clipShape(RoundedRectangle(cornerRadius: Design.CornerRadius.large))
|
.padding(.horizontal, effectiveRingSize)
|
||||||
|
.padding(.vertical, Design.Spacing.medium)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer()
|
|
||||||
|
|
||||||
// Bottom control bar
|
// Bottom control bar
|
||||||
bottomControlBar
|
bottomControlBar
|
||||||
.padding(.bottom, safeArea.bottom + Design.Spacing.medium)
|
.padding(.bottom, safeArea.bottom + Design.Spacing.small)
|
||||||
|
.padding(.horizontal, Design.Spacing.xLarge)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.ignoresSafeArea()
|
.ignoresSafeArea()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Camera Size Calculation
|
|
||||||
|
|
||||||
/// Calculates camera size maintaining aspect ratio within available space
|
|
||||||
private func calculateCameraSize(availableWidth: CGFloat, availableHeight: CGFloat) -> CGSize {
|
|
||||||
let targetWidth = availableWidth
|
|
||||||
let targetHeight = targetWidth * cameraAspectRatio
|
|
||||||
|
|
||||||
if targetHeight <= availableHeight {
|
|
||||||
// Width-constrained
|
|
||||||
return CGSize(width: targetWidth, height: targetHeight)
|
|
||||||
} else {
|
|
||||||
// Height-constrained
|
|
||||||
let height = availableHeight
|
|
||||||
let width = height / cameraAspectRatio
|
|
||||||
return CGSize(width: width, height: height)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Ring Size
|
// MARK: - Ring Size
|
||||||
|
|
||||||
private var effectiveRingSize: CGFloat {
|
private var effectiveRingSize: CGFloat {
|
||||||
@ -129,7 +98,6 @@ struct RingLightCameraScreen: MCameraScreen {
|
|||||||
onSettingsTapped()
|
onSettingsTapped()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(.horizontal, Design.Spacing.large)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Bottom Control Bar
|
// MARK: - Bottom Control Bar
|
||||||
@ -159,7 +127,6 @@ struct RingLightCameraScreen: MCameraScreen {
|
|||||||
Color.clear
|
Color.clear
|
||||||
.frame(width: 44, height: 44)
|
.frame(width: 44, height: 44)
|
||||||
}
|
}
|
||||||
.padding(.horizontal, Design.Spacing.xLarge)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Control Button Helper
|
// MARK: - Control Button Helper
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user