Skip to content

Commit 67aed1c

Browse files
author
Benedikt Wagner
committed
style courses view, add otherIcon
1 parent 97cff69 commit 67aed1c

File tree

8 files changed

+109
-58
lines changed

8 files changed

+109
-58
lines changed

CloudMaster.xcodeproj/project.pbxproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
8D26A31E2C0EE3F400E9B015 /* QuestionImages.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D26A31D2C0EE3F400E9B015 /* QuestionImages.swift */; };
1212
8D26A3202C0EE4A000E9B015 /* QuestionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D26A31F2C0EE4A000E9B015 /* QuestionView.swift */; };
1313
8D26A3222C101C5000E9B015 /* BookmarksView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D26A3212C101C5000E9B015 /* BookmarksView.swift */; };
14+
8D3F7ABE2C202FD100D200CA /* AllCourses.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D3F7ABD2C202FD100D200CA /* AllCourses.swift */; };
1415
8D8D8A862C05A23600ACC61C /* CloudMasterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D8D8A852C05A23600ACC61C /* CloudMasterTests.swift */; };
1516
8D8D8A902C05A23600ACC61C /* CloudMasterUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D8D8A8F2C05A23600ACC61C /* CloudMasterUITests.swift */; };
1617
8D8D8A922C05A23600ACC61C /* CloudMasterUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D8D8A912C05A23600ACC61C /* CloudMasterUITestsLaunchTests.swift */; };
@@ -69,6 +70,7 @@
6970
8D26A31D2C0EE3F400E9B015 /* QuestionImages.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuestionImages.swift; sourceTree = "<group>"; };
7071
8D26A31F2C0EE4A000E9B015 /* QuestionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuestionView.swift; sourceTree = "<group>"; };
7172
8D26A3212C101C5000E9B015 /* BookmarksView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarksView.swift; sourceTree = "<group>"; };
73+
8D3F7ABD2C202FD100D200CA /* AllCourses.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllCourses.swift; sourceTree = "<group>"; };
7274
8D8D8A712C05A23400ACC61C /* CloudMaster Swift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "CloudMaster Swift.app"; sourceTree = BUILT_PRODUCTS_DIR; };
7375
8D8D8A812C05A23600ACC61C /* CloudMasterTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CloudMasterTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
7476
8D8D8A852C05A23600ACC61C /* CloudMasterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudMasterTests.swift; sourceTree = "<group>"; };
@@ -140,6 +142,7 @@
140142
8D26A31B2C0EA9C100E9B015 /* QuestionNavbar.swift */,
141143
8D26A31D2C0EE3F400E9B015 /* QuestionImages.swift */,
142144
8D26A31F2C0EE4A000E9B015 /* QuestionView.swift */,
145+
8D3F7ABD2C202FD100D200CA /* AllCourses.swift */,
143146
);
144147
path = Components;
145148
sourceTree = "<group>";
@@ -599,6 +602,7 @@
599602
8D8D8AE42C05A27800ACC61C /* QuestionLoader.swift in Sources */,
600603
8D8D8ACE2C05A27800ACC61C /* ConfirmPopup.swift in Sources */,
601604
8D8D8AE32C05A27800ACC61C /* FavoriteStorage.swift in Sources */,
605+
8D3F7ABE2C202FD100D200CA /* AllCourses.swift in Sources */,
602606
8D26A3202C0EE4A000E9B015 /* QuestionView.swift in Sources */,
603607
8D8D8AD62C05A27800ACC61C /* ExamSummaryView.swift in Sources */,
604608
8D8D8AD92C05A27800ACC61C /* HomeView.swift in Sources */,
@@ -786,7 +790,7 @@
786790
"$(inherited)",
787791
"@executable_path/Frameworks",
788792
);
789-
MARKETING_VERSION = 1.0.3;
793+
MARKETING_VERSION = 1.0.4;
790794
PRODUCT_BUNDLE_IDENTIFIER = com.ditectrev.cloudmasterswift;
791795
PRODUCT_NAME = "CloudMaster Swift";
792796
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -821,7 +825,7 @@
821825
"$(inherited)",
822826
"@executable_path/Frameworks",
823827
);
824-
MARKETING_VERSION = 1.0.3;
828+
MARKETING_VERSION = 1.0.4;
825829
PRODUCT_BUNDLE_IDENTIFIER = com.ditectrev.cloudmasterswift;
826830
PRODUCT_NAME = "CloudMaster Swift";
827831
PROVISIONING_PROFILE_SPECIFIER = "";
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "seal.png",
5+
"idiom" : "universal",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"author" : "xcode",
19+
"version" : 1
20+
}
21+
}
Loading

CloudMaster/Features/Courses/Views/CoursesView.swift

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,7 @@ struct CoursesView: View {
88

99
var body: some View {
1010
VStack {
11-
SearchBar(text: $searchText)
12-
.padding()
13-
14-
List(Course.allCourses.filter({ searchText.isEmpty ? true : $0.fullName.lowercased().contains(searchText.lowercased()) })) { course in
15-
CourseRow(course: course, isBookmarked: favorites.contains(course)) {
16-
if favorites.contains(course) {
17-
favorites.remove(course)
18-
} else {
19-
favorites.insert(course)
20-
}
21-
FavoritesStorage.shared.saveFavorites(favorites)
22-
}
23-
}
24-
.listStyle(PlainListStyle())
11+
AllCourses(favorites: $favorites)
2512
}
2613
.navigationBarTitle("All Courses", displayMode: .inline)
2714
.navigationBarItems(trailing: updateButton)

CloudMaster/Features/Home/Views/HomeView.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ extension HomeView {
8888
}
8989
}
9090

91-
9291
struct StyledCourseRow: View {
9392
let course: Course
9493

@@ -105,11 +104,13 @@ struct StyledCourseRow: View {
105104
.font(.headline)
106105
Text(course.fullName)
107106
.font(.subheadline)
107+
.lineLimit(1) // Ensure the text doesn't exceed one line
108108
}
109109

110110
Spacer()
111111
}
112112
.padding()
113+
.frame(height: 60) // Set a fixed height for the row
113114
.background(
114115
RoundedRectangle(cornerRadius: 10)
115116
.stroke(gradientForCompany(course.company), lineWidth: 2)
@@ -125,6 +126,8 @@ struct StyledCourseRow: View {
125126
return "azureIcon"
126127
case .gcp:
127128
return "gcpIcon"
129+
case .other:
130+
return "otherIcon"
128131
}
129132
}
130133

@@ -138,7 +141,11 @@ struct StyledCourseRow: View {
138141
return LinearGradient(gradient: Gradient(colors: [color1, color2]), startPoint: .leading, endPoint: .trailing)
139142
case .gcp:
140143
return LinearGradient(gradient: Gradient(colors: [.red, .green, .yellow, .blue]), startPoint: .leading, endPoint: .trailing)
144+
case .other:
145+
let color1 = Color.purple
146+
let color2 = Color.pink
147+
let color3 = Color.orange
148+
return LinearGradient(gradient: Gradient(colors: [color1, color2, color3]), startPoint: .leading, endPoint: .trailing)
141149
}
142150
}
143151
}
144-

CloudMaster/Features/Intro/Views/IntroView.swift

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,8 @@ struct SecondPage: View {
119119
.frame(alignment: .leading)
120120
.multilineTextAlignment(.center)
121121
.padding()
122-
123-
SearchBar(text: $searchText)
124-
.padding()
125-
126-
List(Course.allCourses.filter({ searchText.isEmpty ? true : $0.fullName.lowercased().contains(searchText.lowercased()) })) { course in
127-
CourseRow(course: course, isBookmarked: favorites.contains(course)) {
128-
if favorites.contains(course) {
129-
favorites.remove(course)
130-
} else {
131-
favorites.insert(course)
132-
}
133-
}
134-
}
135-
.listStyle(PlainListStyle())
122+
123+
AllCourses(favorites: $favorites)
136124

137125
Spacer()
138126

@@ -160,29 +148,3 @@ struct SearchBar: View {
160148
}
161149
}
162150
}
163-
164-
struct CourseRow: View {
165-
let course: Course
166-
let isBookmarked: Bool
167-
let toggleBookmark: () -> Void
168-
169-
var body: some View {
170-
HStack {
171-
VStack(alignment: .leading, spacing: 4) {
172-
Text(course.company.rawValue)
173-
.font(.caption)
174-
Text(course.shortName)
175-
.font(.headline)
176-
Text(course.fullName)
177-
.font(.subheadline)
178-
}
179-
180-
Spacer()
181-
182-
Button(action: toggleBookmark) {
183-
Image(systemName: isBookmarked ? "star.fill" : "star")
184-
.foregroundColor(Color.customSecondary)
185-
}
186-
}
187-
}
188-
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import SwiftUI
2+
3+
struct AllCourses: View {
4+
@Binding var favorites: Set<Course>
5+
@State private var searchText = ""
6+
7+
var filteredCourses: [Course] {
8+
Course.allCourses.filter { course in
9+
searchText.isEmpty ? true : course.fullName.lowercased().contains(searchText.lowercased())
10+
}
11+
}
12+
13+
var body: some View {
14+
VStack {
15+
SearchBar(text: $searchText)
16+
.padding()
17+
18+
List {
19+
ForEach(CourseCompany.allCases, id: \.self) { company in
20+
let companyCourses = filteredCourses.filter { $0.company == company }
21+
if !companyCourses.isEmpty {
22+
Section(header: Text(company.rawValue.uppercased()).font(.title3)) {
23+
ForEach(companyCourses) { course in
24+
CourseRow(
25+
course: course,
26+
isBookmarked: favorites.contains(course),
27+
toggleBookmark: {
28+
if favorites.contains(course) {
29+
favorites.remove(course)
30+
} else {
31+
favorites.insert(course)
32+
}
33+
FavoritesStorage.shared.saveFavorites(favorites)
34+
}
35+
)
36+
}
37+
}
38+
}
39+
}
40+
}
41+
.listStyle(PlainListStyle())
42+
}
43+
}
44+
}
45+
46+
struct CourseRow: View {
47+
let course: Course
48+
let isBookmarked: Bool
49+
let toggleBookmark: () -> Void
50+
51+
var body: some View {
52+
HStack {
53+
VStack(alignment: .leading, spacing: 4) {
54+
Text(course.company.rawValue)
55+
.font(.caption)
56+
Text(course.shortName)
57+
.font(.headline)
58+
Text(course.fullName)
59+
.font(.subheadline)
60+
}
61+
62+
Spacer()
63+
64+
Button(action: toggleBookmark) {
65+
Image(systemName: isBookmarked ? "star.fill" : "star")
66+
.foregroundColor(Color.customSecondary)
67+
}
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)