Skip to content

Commit c4967b6

Browse files
authored
Merge pull request #262 from rfcbf/feature/adjust_onboarding
feat: adjust onboarding
2 parents ae9562f + d7bad8d commit c4967b6

File tree

14 files changed

+179
-113
lines changed

14 files changed

+179
-113
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}

MacMagazine/Features/OnboardingLibrary/Sources/OnboardingLibrary/Resources/Assets.xcassets/alternativa_sem_fundo.imageset/Contents.json renamed to MacMagazine/Features/OnboardingLibrary/Sources/OnboardingLibrary/Resources/Assets.xcassets/icons without background/alternativa_without_background.imageset/Contents.json

File renamed without changes.

MacMagazine/Features/OnboardingLibrary/Sources/OnboardingLibrary/Resources/Assets.xcassets/alternativa_sem_fundo.imageset/alternativa_sem_fundo.png renamed to MacMagazine/Features/OnboardingLibrary/Sources/OnboardingLibrary/Resources/Assets.xcassets/icons without background/alternativa_without_background.imageset/alternativa_sem_fundo.png

File renamed without changes.

MacMagazine/Features/OnboardingLibrary/Sources/OnboardingLibrary/Resources/Assets.xcassets/normal_sem_fundo.imageset/Contents.json renamed to MacMagazine/Features/OnboardingLibrary/Sources/OnboardingLibrary/Resources/Assets.xcassets/icons without background/normal_without_background.imageset/Contents.json

File renamed without changes.

MacMagazine/Features/OnboardingLibrary/Sources/OnboardingLibrary/Resources/Assets.xcassets/normal_sem_fundo.imageset/normal_sem_fundo.png renamed to MacMagazine/Features/OnboardingLibrary/Sources/OnboardingLibrary/Resources/Assets.xcassets/icons without background/normal_without_background.imageset/normal_sem_fundo.png

File renamed without changes.

MacMagazine/Features/OnboardingLibrary/Sources/OnboardingLibrary/ViewModels/OnboardingCoordinator.swift

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import SwiftUI
66

77
@MainActor
88
@Observable
9-
public final class OnboardingCoordinator {
9+
public final class OnboardingCoordinator: @MainActor Identifiable {
10+
public var id: String { "onboarding" }
11+
1012
// Current screen state
1113
public var currentScreen: OnboardingScreen = .welcome
1214

@@ -17,8 +19,9 @@ public final class OnboardingCoordinator {
1719
public let permissionManager: PermissionManager
1820
public let analytics: AnalyticsManager
1921

20-
// UserDefaults key
22+
// UserDefaults keys
2123
private static let hasCompletedOnboardingKey = "hasCompletedOnboarding"
24+
private static let hasSeenFeaturesKey = "hasSeenOnboardingFeatures"
2225

2326
public init(
2427
permissionManager: PermissionManager,
@@ -34,6 +37,10 @@ public final class OnboardingCoordinator {
3437
withAnimation(.easeInOut(duration: 0.3)) {
3538
currentScreen = screen
3639
}
40+
41+
if screen == .permissions {
42+
markFeaturesAsSeen()
43+
}
3744
}
3845

3946
func skipToPermissions() {
@@ -42,6 +49,8 @@ public final class OnboardingCoordinator {
4249
screen: currentScreen.analyticsName
4350
))
4451

52+
markFeaturesAsSeen()
53+
4554
withAnimation(.easeInOut(duration: 0.3)) {
4655
currentScreen = .permissions
4756
}
@@ -61,6 +70,16 @@ public final class OnboardingCoordinator {
6170
onComplete?()
6271
}
6372

73+
// MARK: - Features Seen State
74+
75+
private func markFeaturesAsSeen() {
76+
UserDefaults.standard.set(true, forKey: Self.hasSeenFeaturesKey)
77+
}
78+
79+
private static var hasSeenFeatures: Bool {
80+
UserDefaults.standard.bool(forKey: hasSeenFeaturesKey)
81+
}
82+
6483
// MARK: - Onboarding State Management
6584

6685
/// Create coordinator if onboarding is needed, returns nil if not needed
@@ -71,12 +90,19 @@ public final class OnboardingCoordinator {
7190
// Check if onboarding was completed
7291
let hasCompleted = UserDefaults.standard.bool(forKey: hasCompletedOnboardingKey)
7392

74-
// If never completed, create coordinator starting at welcome
93+
// If never completed, create coordinator
7594
if !hasCompleted {
7695
let coordinator = OnboardingCoordinator(
7796
permissionManager: permissionManager,
7897
analytics: analytics
7998
)
99+
100+
// If user already saw features, go directly to permissions
101+
if hasSeenFeatures {
102+
coordinator.currentScreen = .permissions
103+
}
104+
// Otherwise, start from welcome
105+
80106
return coordinator
81107
}
82108

@@ -86,7 +112,7 @@ public final class OnboardingCoordinator {
86112
permissionManager: permissionManager,
87113
analytics: analytics
88114
)
89-
// Start at permissions screen
115+
// Start at permissions screen (already completed before, no need to see features again)
90116
coordinator.currentScreen = .permissions
91117
return coordinator
92118
}
@@ -98,6 +124,7 @@ public final class OnboardingCoordinator {
98124
/// Reset onboarding state (for debug/testing)
99125
public static func resetOnboarding() {
100126
UserDefaults.standard.removeObject(forKey: hasCompletedOnboardingKey)
127+
UserDefaults.standard.removeObject(forKey: hasSeenFeaturesKey)
101128
}
102129
}
103130

MacMagazine/Features/OnboardingLibrary/Sources/OnboardingLibrary/Views/Components/OnboardingBackground.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public struct OnboardingBackground: View {
1010
(theme.main.background.color ?? Color.secondary)
1111
.ignoresSafeArea()
1212

13-
Image("normal_sem_fundo", bundle: .module)
13+
Image("normal_without_background", bundle: .module)
1414
.resizable()
1515
.scaledToFit()
1616
.frame(width: 520)
@@ -20,13 +20,13 @@ public struct OnboardingBackground: View {
2020
.blur(radius: 5)
2121
.accessibilityHidden(true)
2222

23-
Image("alternativa_sem_fundo", bundle: .module)
23+
Image("alternativa_without_background", bundle: .module)
2424
.resizable()
2525
.scaledToFit()
2626
.frame(width: 360)
2727
.rotationEffect(.degrees(18))
2828
.offset(x: -170, y: 220)
29-
.opacity(colorScheme == .dark ? 0.4 : 0.9)
29+
.opacity(colorScheme == .dark ? 0.14 : 0.14)
3030
.blur(radius: 5)
3131
.accessibilityHidden(true)
3232

MacMagazine/Features/OnboardingLibrary/Sources/OnboardingLibrary/Views/Components/OnboardingLogoView.swift

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ public struct OnboardingLogoView: View {
55
let width: CGFloat
66
let height: CGFloat
77

8-
public init(width: CGFloat = 152,
9-
height: CGFloat = 152) {
8+
private var cornerRadius: CGFloat {
9+
min(width, height) * 0.184
10+
}
11+
12+
public init(
13+
width: CGFloat = 152,
14+
height: CGFloat = 152
15+
) {
1016
self.width = width
1117
self.height = height
1218
}
@@ -15,17 +21,31 @@ public struct OnboardingLogoView: View {
1521
Image("normal", bundle: .module)
1622
.resizable()
1723
.scaledToFit()
18-
.frame(width: self.width, height: self.height)
19-
.clipShape(RoundedRectangle(cornerRadius: 28, style: .continuous))
24+
.frame(width: width, height: height)
25+
.clipShape(RoundedRectangle(cornerRadius: cornerRadius, style: .continuous))
2026
.overlay {
21-
RoundedRectangle(cornerRadius: 28, style: .continuous)
27+
RoundedRectangle(cornerRadius: cornerRadius, style: .continuous)
2228
.stroke(.white.opacity(0.15), lineWidth: 1)
2329
}
2430
.background {
25-
RoundedRectangle(cornerRadius: 28, style: .continuous)
31+
RoundedRectangle(cornerRadius: cornerRadius, style: .continuous)
2632
.fill(.regularMaterial)
2733
.shadow(radius: 18, y: 10)
2834
}
2935
.accessibilityHidden(true)
3036
}
3137
}
38+
39+
// MARK: - Preview
40+
41+
#if DEBUG
42+
#Preview("Logo Sizes") {
43+
VStack(spacing: 40) {
44+
OnboardingLogoView(width: 152, height: 152)
45+
OnboardingLogoView(width: 80, height: 80)
46+
OnboardingLogoView(width: 60, height: 60)
47+
}
48+
.padding()
49+
.background(Color.gray.opacity(0.3))
50+
}
51+
#endif

MacMagazine/Features/OnboardingLibrary/Sources/OnboardingLibrary/Views/Components/PermissionView.swift renamed to MacMagazine/Features/OnboardingLibrary/Sources/OnboardingLibrary/Views/Components/PermissionCard.swift

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public struct PermissionCard: View {
2525

2626
public var body: some View {
2727
VStack(alignment: .leading, spacing: 12) {
28+
// Header com ícone e título
2829
HStack(spacing: 12) {
2930
Image(systemName: icon)
3031
.font(.title2)
@@ -37,22 +38,25 @@ public struct PermissionCard: View {
3738
.foregroundStyle(.primary)
3839

3940
Spacer()
40-
41-
statusView
4241
}
43-
.accessibilityElement(children: .combine)
4442

43+
// Descrição
4544
Text(description)
4645
.font(.subheadline)
4746
.foregroundStyle(.secondary)
4847
.fixedSize(horizontal: false, vertical: true)
48+
49+
// Botão de status
50+
statusView
51+
.frame(maxWidth: .infinity, alignment: .trailing)
4952
}
5053
.padding(16)
5154
.frame(maxWidth: .infinity, alignment: .leading)
5255
.background(
5356
RoundedRectangle(cornerRadius: 16, style: .continuous)
5457
.fill(.ultraThinMaterial)
5558
)
59+
.accessibilityElement(children: .combine)
5660
}
5761

5862
@ViewBuilder
@@ -84,32 +88,37 @@ public struct PermissionCard: View {
8488
}
8589
.buttonStyle(.plain)
8690
.disabled(isProcessing)
91+
.accessibilityLabel("Permitir \(title)")
92+
.accessibilityHint("Toque para autorizar esta permissão")
8793

8894
case .granted:
8995
HStack(spacing: 6) {
9096
Image(systemName: "checkmark.circle.fill")
91-
.font(.caption)
97+
.font(.subheadline)
9298
Text("Autorizado")
93-
.font(.caption.weight(.medium))
99+
.font(.subheadline.weight(.semibold))
94100
}
95101
.foregroundStyle(.white)
96-
.padding(.horizontal, 12)
97-
.padding(.vertical, 6)
102+
.padding(.horizontal, 16)
103+
.padding(.vertical, 8)
98104
.background(Color.green)
99105
.clipShape(Capsule())
106+
.accessibilityLabel("\(title) autorizado")
100107

101108
case .denied:
102109
HStack(spacing: 6) {
103110
Image(systemName: "xmark.circle.fill")
104-
.font(.caption)
111+
.font(.subheadline)
105112
Text("Negado")
106-
.font(.caption.weight(.medium))
113+
.font(.subheadline.weight(.semibold))
107114
}
108115
.foregroundStyle(.white)
109-
.padding(.horizontal, 12)
110-
.padding(.vertical, 6)
116+
.padding(.horizontal, 16)
117+
.padding(.vertical, 8)
111118
.background(Color.gray)
112119
.clipShape(Capsule())
120+
.accessibilityLabel("\(title) negado")
121+
.accessibilityHint("Você pode alterar nas Configurações do dispositivo")
113122
}
114123
}
115124
}
@@ -124,7 +133,7 @@ public enum PermissionCardStatus {
124133

125134
// MARK: - Preview
126135

127-
#Preview("Permission Card - Not Determined") {
136+
#Preview("Permission Card - All States") {
128137
VStack(spacing: 16) {
129138
PermissionCard(
130139
title: "Notificações",

MacMagazine/Features/OnboardingLibrary/Sources/OnboardingLibrary/Views/OnboardingContainerView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public struct OnboardingContainerView: View {
1919
public var body: some View {
2020
NavigationStack {
2121
ZStack {
22-
OnboardingBackground()
22+
// OnboardingBackground()
2323

2424
Group {
2525
switch coordinator.currentScreen {
@@ -48,7 +48,7 @@ public struct OnboardingContainerView: View {
4848
OnboardingSheetPreviewHost()
4949
}
5050

51-
#Preview("Sheet - iPad", traits: .landscapeLeft) {
51+
#Preview("Sheet - Landscape", traits: .landscapeLeft) {
5252
OnboardingSheetPreviewHost()
5353
}
5454

0 commit comments

Comments
 (0)