Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/33 az 104 image download fails #34

Merged
merged 3 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Binary file not shown.
2 changes: 1 addition & 1 deletion CloudMaster/Constants/Courses.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ enum CodingKeys: String, CodingKey {
}

struct Course: Codable, Hashable, Identifiable {
let id = UUID() // Add this line
var id = UUID() // Add this line
let fullName: String
let shortName: String
let description: String
Expand Down
88 changes: 41 additions & 47 deletions CloudMaster/Features/Common/DownloadOverlayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,69 +3,63 @@ import SwiftUI
struct DownloadOverlayView: View {
@Binding var isShowing: Bool
@StateObject var viewModel: DownloadViewModel

var body: some View {
if isShowing {
ZStack {
Color.black.opacity(0.8)
.edgesIgnoringSafeArea(.all)

VStack {
Text("\(viewModel.completedDownloads) / \(Int(viewModel.totalCourses)) courses")
.font(.title2)
.foregroundColor(.white)

CircularProgressView(progress: $viewModel.overallProgress)
.frame(width: 250, height: 250)
.shadow(radius: 10)

HStack {
if viewModel.totalCourses > 1 {
Text("\(viewModel.completedDownloads) / \(Int(viewModel.totalCourses)) courses")
.font(.headline)
.foregroundColor(.white)
.padding(.top, 10)
}
}

Text(viewModel.statusMessage)
.font(.subheadline)
.bold()
.foregroundColor(.white)
.padding(.top, 5)

Text(viewModel.statusMessage)
.font(.subheadline)
.bold()
.foregroundColor(.gray)
.padding(.top, 10)
}
}
}
}
}

struct CircularProgressView: View {
@Binding var progress: Double

var body: some View {
ZStack {
Circle()
.stroke(lineWidth: 10.0)
.opacity(0.5)
.foregroundColor(Color.customSecondary)

Circle()
.trim(from: 0.0, to: CGFloat(min(self.progress, 1.0)))
.stroke(style: StrokeStyle(lineWidth: 10.0, lineCap: .round, lineJoin: .round))
.foregroundColor(Color.customAccent)
.rotationEffect(Angle(degrees: 270.0))
.animation(.linear, value: progress)

if progress < 1.0 {
Text(String(format: "%.0f %%", min(self.progress, 1.0) * 100.0))
.font(.largeTitle)
.bold()
} else {
withAnimation(.spring()) {
Image(systemName: "checkmark.circle.fill")
.resizable()
.foregroundColor(Color.correct)
.frame(width: 50, height: 50)
struct CircularProgressView: View {
@Binding var progress: Double
var body: some View {
ZStack {
Circle()
.stroke(lineWidth: 10.0)
.opacity(0.5)
.foregroundColor(Color.customSecondary)

Circle()
.trim(from: 0.0, to: CGFloat(min(self.progress, 1.0)))
.stroke(style: StrokeStyle(lineWidth: 10.0, lineCap: .round, lineJoin: .round))
.foregroundColor(Color.customAccent)
.rotationEffect(Angle(degrees: 270.0))
.animation(.linear, value: progress)

if progress < 1.0 {
Text(String(format: "%.0f %%", min(self.progress, 1.0) * 100.0))
.font(.largeTitle)
.bold()
} else {
withAnimation(.spring()) {
Image(systemName: "checkmark.circle.fill")
.resizable()
.foregroundColor(Color.correct)
.frame(width: 50, height: 50)
}
}
}
.padding(40)
}
.padding(40)
}
}
2 changes: 1 addition & 1 deletion CloudMaster/Features/Course/Views/CourseView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ struct CourseView: View {
)
)
.alert(isPresented: $viewModel.showAlert) {
Alert(title: Text("Download Error"), message: Text(viewModel.alertMessage ?? ""), dismissButton: .default(Text("OK")))
Alert(title: Text("Download Error"), message: Text(viewModel.alertMessage), dismissButton: .default(Text("OK")))
}
}

Expand Down
2 changes: 1 addition & 1 deletion CloudMaster/Features/Courses/Views/CoursesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct CoursesView: View {
)
)
.alert(isPresented: $viewModel.showAlert) {
Alert(title: Text("Download Error"), message: Text(viewModel.alertMessage ?? ""), dismissButton: .default(Text("OK")))
Alert(title: Text("Download Error"), message: Text(viewModel.alertMessage), dismissButton: .default(Text("OK")))
}
}

Expand Down
2 changes: 1 addition & 1 deletion CloudMaster/Features/Intro/Views/IntroView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct IntroView: View {
viewModel.downloadCourses(favorites)
}
}
.onChange(of: viewModel.downloadCompleted) { completed in
.onChange(of: viewModel.downloadCompleted) { completed, _ in
if completed {
isAppConfigured = true
}
Expand Down
1 change: 0 additions & 1 deletion CloudMaster/Features/Shared/Components/QuestionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ struct QuestionView: View {
}

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

Expand Down
1 change: 0 additions & 1 deletion CloudMaster/Features/Training/Views/TrainingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ struct TrainingView: View {
VStack {
if !questionLoader.questions.isEmpty {
let questions = Array(questionLoader.questions)
let totalQuestions = questions.count
let question = questions[currentQuestionIndex]

QuestionNavbar(
Expand Down
Loading
Loading