Skip to content

Commit 5417542

Browse files
Merge pull request #34 from Ditectrev/fix/33-az-104-image-download-fails
Fix/33 az 104 image download fails
2 parents 2f848ff + d85820a commit 5417542

File tree

9 files changed

+122
-113
lines changed

9 files changed

+122
-113
lines changed

CloudMaster/Constants/Courses.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ enum CodingKeys: String, CodingKey {
1313
}
1414

1515
struct Course: Codable, Hashable, Identifiable {
16-
let id = UUID() // Add this line
16+
var id = UUID() // Add this line
1717
let fullName: String
1818
let shortName: String
1919
let description: String

CloudMaster/Features/Common/DownloadOverlayView.swift

+41-47
Original file line numberDiff line numberDiff line change
@@ -3,69 +3,63 @@ import SwiftUI
33
struct DownloadOverlayView: View {
44
@Binding var isShowing: Bool
55
@StateObject var viewModel: DownloadViewModel
6-
6+
77
var body: some View {
88
if isShowing {
99
ZStack {
1010
Color.black.opacity(0.8)
1111
.edgesIgnoringSafeArea(.all)
12-
12+
1313
VStack {
14+
Text("\(viewModel.completedDownloads) / \(Int(viewModel.totalCourses)) courses")
15+
.font(.title2)
16+
.foregroundColor(.white)
17+
1418
CircularProgressView(progress: $viewModel.overallProgress)
1519
.frame(width: 250, height: 250)
1620
.shadow(radius: 10)
17-
18-
HStack {
19-
if viewModel.totalCourses > 1 {
20-
Text("\(viewModel.completedDownloads) / \(Int(viewModel.totalCourses)) courses")
21-
.font(.headline)
22-
.foregroundColor(.white)
23-
.padding(.top, 10)
24-
}
25-
}
26-
27-
Text(viewModel.statusMessage)
28-
.font(.subheadline)
29-
.bold()
30-
.foregroundColor(.white)
31-
.padding(.top, 5)
3221

22+
Text(viewModel.statusMessage)
23+
.font(.subheadline)
24+
.bold()
25+
.foregroundColor(.gray)
26+
.padding(.top, 10)
3327
}
3428
}
3529
}
3630
}
37-
}
38-
39-
struct CircularProgressView: View {
40-
@Binding var progress: Double
41-
42-
var body: some View {
43-
ZStack {
44-
Circle()
45-
.stroke(lineWidth: 10.0)
46-
.opacity(0.5)
47-
.foregroundColor(Color.customSecondary)
48-
49-
Circle()
50-
.trim(from: 0.0, to: CGFloat(min(self.progress, 1.0)))
51-
.stroke(style: StrokeStyle(lineWidth: 10.0, lineCap: .round, lineJoin: .round))
52-
.foregroundColor(Color.customAccent)
53-
.rotationEffect(Angle(degrees: 270.0))
54-
.animation(.linear, value: progress)
55-
56-
if progress < 1.0 {
57-
Text(String(format: "%.0f %%", min(self.progress, 1.0) * 100.0))
58-
.font(.largeTitle)
59-
.bold()
60-
} else {
61-
withAnimation(.spring()) {
62-
Image(systemName: "checkmark.circle.fill")
63-
.resizable()
64-
.foregroundColor(Color.correct)
65-
.frame(width: 50, height: 50)
31+
32+
struct CircularProgressView: View {
33+
@Binding var progress: Double
34+
35+
var body: some View {
36+
ZStack {
37+
Circle()
38+
.stroke(lineWidth: 10.0)
39+
.opacity(0.5)
40+
.foregroundColor(Color.customSecondary)
41+
42+
Circle()
43+
.trim(from: 0.0, to: CGFloat(min(self.progress, 1.0)))
44+
.stroke(style: StrokeStyle(lineWidth: 10.0, lineCap: .round, lineJoin: .round))
45+
.foregroundColor(Color.customAccent)
46+
.rotationEffect(Angle(degrees: 270.0))
47+
.animation(.linear, value: progress)
48+
49+
if progress < 1.0 {
50+
Text(String(format: "%.0f %%", min(self.progress, 1.0) * 100.0))
51+
.font(.largeTitle)
52+
.bold()
53+
} else {
54+
withAnimation(.spring()) {
55+
Image(systemName: "checkmark.circle.fill")
56+
.resizable()
57+
.foregroundColor(Color.correct)
58+
.frame(width: 50, height: 50)
59+
}
6660
}
6761
}
62+
.padding(40)
6863
}
69-
.padding(40)
7064
}
7165
}

CloudMaster/Features/Course/Views/CourseView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ struct CourseView: View {
130130
)
131131
)
132132
.alert(isPresented: $viewModel.showAlert) {
133-
Alert(title: Text("Download Error"), message: Text(viewModel.alertMessage ?? ""), dismissButton: .default(Text("OK")))
133+
Alert(title: Text("Download Error"), message: Text(viewModel.alertMessage), dismissButton: .default(Text("OK")))
134134
}
135135
}
136136

CloudMaster/Features/Courses/Views/CoursesView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct CoursesView: View {
1919
)
2020
)
2121
.alert(isPresented: $viewModel.showAlert) {
22-
Alert(title: Text("Download Error"), message: Text(viewModel.alertMessage ?? ""), dismissButton: .default(Text("OK")))
22+
Alert(title: Text("Download Error"), message: Text(viewModel.alertMessage), dismissButton: .default(Text("OK")))
2323
}
2424
}
2525

CloudMaster/Features/Intro/Views/IntroView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct IntroView: View {
3434
viewModel.downloadCourses(favorites)
3535
}
3636
}
37-
.onChange(of: viewModel.downloadCompleted) { completed in
37+
.onChange(of: viewModel.downloadCompleted) { completed, _ in
3838
if completed {
3939
isAppConfigured = true
4040
}

CloudMaster/Features/Shared/Components/QuestionView.swift

-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ struct QuestionView: View {
8787
}
8888

8989
private func adjustedFontSize(for text: String) -> CGFloat {
90-
let maxWidth = UIScreen.main.bounds.width - 32
9190
let baseFontSize: CGFloat = 20
9291
let minFontSize: CGFloat = 14
9392

CloudMaster/Features/Training/Views/TrainingView.swift

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ struct TrainingView: View {
2222
VStack {
2323
if !questionLoader.questions.isEmpty {
2424
let questions = Array(questionLoader.questions)
25-
let totalQuestions = questions.count
2625
let question = questions[currentQuestionIndex]
2726

2827
QuestionNavbar(

0 commit comments

Comments
 (0)