mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-28 15:44:32 +00:00
Applied latest changes from boring.notch
This commit is contained in:
parent
13a2ff0e20
commit
bad481588b
5 changed files with 453 additions and 0 deletions
107
DynamicIsland/components/Onboarding/OnboardingView.swift
Normal file
107
DynamicIsland/components/Onboarding/OnboardingView.swift
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
//
|
||||
// OnboardingView.swift
|
||||
// DynamicIsland
|
||||
//
|
||||
// Created by Alexander on 2025-06-23.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import AVFoundation
|
||||
|
||||
enum OnboardingStep {
|
||||
case welcome
|
||||
case cameraPermission
|
||||
case calendarPermission
|
||||
case musicPermission
|
||||
case finished
|
||||
}
|
||||
|
||||
private let calendarService = CalendarService()
|
||||
|
||||
struct OnboardingView: View {
|
||||
@State private var step: OnboardingStep = .welcome
|
||||
let onFinish: () -> Void
|
||||
let onOpenSettings: () -> Void
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
switch step {
|
||||
case .welcome:
|
||||
WelcomeView {
|
||||
withAnimation(.easeInOut(duration: 0.6)) {
|
||||
step = .cameraPermission
|
||||
}
|
||||
}
|
||||
.transition(.opacity)
|
||||
|
||||
case .cameraPermission:
|
||||
PermissionRequestView(
|
||||
icon: Image(systemName: "camera.fill"),
|
||||
title: "Enable Camera Access",
|
||||
description: "Dynamic Island includes a mirror feature that lets you quickly check your appearance using your camera, right from the notch. Camera access is required only to show this live preview. You can turn the mirror feature on or off at any time in the app.",
|
||||
privacyNote: "Your camera is never used without your consent, and nothing is recorded or stored.",
|
||||
onAllow: {
|
||||
Task {
|
||||
await requestCameraPermission()
|
||||
withAnimation(.easeInOut(duration: 0.6)) {
|
||||
step = .calendarPermission
|
||||
}
|
||||
}
|
||||
},
|
||||
onSkip: {
|
||||
withAnimation(.easeInOut(duration: 0.6)) {
|
||||
step = .calendarPermission
|
||||
}
|
||||
}
|
||||
)
|
||||
.transition(.opacity)
|
||||
|
||||
case .calendarPermission:
|
||||
PermissionRequestView(
|
||||
icon: Image(systemName: "calendar"),
|
||||
title: "Enable Calendar Access",
|
||||
description: "Dynamic Island can show all your upcoming events in one place. Access to your calendar is needed to display your schedule.",
|
||||
privacyNote: "Your calendar data is only used to show your events and is never shared.",
|
||||
onAllow: {
|
||||
Task {
|
||||
await requestCalendarPermission()
|
||||
withAnimation(.easeInOut(duration: 0.6)) {
|
||||
step = .musicPermission
|
||||
}
|
||||
}
|
||||
},
|
||||
onSkip: {
|
||||
withAnimation(.easeInOut(duration: 0.6)) {
|
||||
step = .musicPermission
|
||||
}
|
||||
}
|
||||
)
|
||||
.transition(.opacity)
|
||||
|
||||
case .musicPermission:
|
||||
MusicControllerSelectionView(
|
||||
onContinue: {
|
||||
withAnimation(.easeInOut(duration: 0.6)) {
|
||||
step = .finished
|
||||
}
|
||||
}
|
||||
)
|
||||
.transition(.opacity)
|
||||
|
||||
case .finished:
|
||||
OnboardingFinishView(onFinish: onFinish, onOpenSettings: onOpenSettings)
|
||||
}
|
||||
}
|
||||
.frame(width: 400, height: 600)
|
||||
}
|
||||
|
||||
// MARK: - Permission Request Logic
|
||||
|
||||
func requestCameraPermission() async {
|
||||
await AVCaptureDevice.requestAccess(for: .video)
|
||||
}
|
||||
|
||||
func requestCalendarPermission() async {
|
||||
await calendarService.requestAccess()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue