Skip to content

Commit b6b2d3f

Browse files
committed
πŸŽƒ Halloween Tweaks
- Made some small changes and tweaks to improve performance and handling on iOS 15
1 parent 3a389f6 commit b6b2d3f

10 files changed

Lines changed: 183 additions & 24 deletions

File tree

β€ŽiOSSC.xcodeproj/project.pbxprojβ€Ž

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
/* Begin PBXBuildFile section */
1010
131E86DA26432DFC002EF7C7 /* InputField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 131E86D926432DFC002EF7C7 /* InputField.swift */; };
1111
132160AD2539BE74003D3489 /* iOSSCApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 132160AC2539BE74003D3489 /* iOSSCApp.swift */; };
12-
132160AF2539BE74003D3489 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 132160AE2539BE74003D3489 /* ContentView.swift */; };
1312
132160B12539BE76003D3489 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 132160B02539BE76003D3489 /* Assets.xcassets */; };
1413
132160B42539BE76003D3489 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 132160B32539BE76003D3489 /* Preview Assets.xcassets */; };
1514
136BCFBF2539C77100C77D96 /* Student.swift in Sources */ = {isa = PBXBuildFile; fileRef = 136BCFBE2539C77100C77D96 /* Student.swift */; };
@@ -25,6 +24,9 @@
2524
136BCFE42539DAB900C77D96 /* APIResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 136BCFE32539DAB900C77D96 /* APIResponse.swift */; };
2625
13709B57253C381000C422B8 /* SFSafeSymbols in Frameworks */ = {isa = PBXBuildFile; productRef = 13709B56253C381000C422B8 /* SFSafeSymbols */; };
2726
1373EE6B253CACD20088AB0F /* SwiftUIRefresh in Frameworks */ = {isa = PBXBuildFile; productRef = 1373EE6A253CACD20088AB0F /* SwiftUIRefresh */; };
27+
1380D10F272FD9A800B05ECF /* LogoutButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1380D10E272FD9A800B05ECF /* LogoutButton.swift */; };
28+
1380D111272FDC9D00B05ECF /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1380D110272FDC9D00B05ECF /* ContentView.swift */; };
29+
1380D113272FDDBE00B05ECF /* BigButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1380D112272FDDBE00B05ECF /* BigButton.swift */; };
2830
138E845A253AF7C800B1B8AD /* BackgroundView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138E8459253AF7C800B1B8AD /* BackgroundView.swift */; };
2931
138E845D253AF7F000B1B8AD /* GradeMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138E845C253AF7F000B1B8AD /* GradeMode.swift */; };
3032
138E8461253AFD1500B1B8AD /* HSDSans.otf in Resources */ = {isa = PBXBuildFile; fileRef = 138E8460253AFD1500B1B8AD /* HSDSans.otf */; };
@@ -40,7 +42,6 @@
4042
131E86D926432DFC002EF7C7 /* InputField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputField.swift; sourceTree = "<group>"; };
4143
132160A92539BE74003D3489 /* iOSSC.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iOSSC.app; sourceTree = BUILT_PRODUCTS_DIR; };
4244
132160AC2539BE74003D3489 /* iOSSCApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSSCApp.swift; sourceTree = "<group>"; };
43-
132160AE2539BE74003D3489 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
4445
132160B02539BE76003D3489 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4546
132160B32539BE76003D3489 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
4647
132160B52539BE76003D3489 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -54,6 +55,9 @@
5455
136BCFD32539D0EA00C77D96 /* Grade.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Grade.swift; sourceTree = "<group>"; };
5556
136BCFD62539D5CB00C77D96 /* APIManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIManager.swift; sourceTree = "<group>"; };
5657
136BCFE32539DAB900C77D96 /* APIResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIResponse.swift; sourceTree = "<group>"; };
58+
1380D10E272FD9A800B05ECF /* LogoutButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogoutButton.swift; sourceTree = "<group>"; };
59+
1380D110272FDC9D00B05ECF /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
60+
1380D112272FDDBE00B05ECF /* BigButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BigButton.swift; sourceTree = "<group>"; };
5761
138E8459253AF7C800B1B8AD /* BackgroundView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackgroundView.swift; sourceTree = "<group>"; };
5862
138E845C253AF7F000B1B8AD /* GradeMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GradeMode.swift; sourceTree = "<group>"; };
5963
138E8460253AFD1500B1B8AD /* HSDSans.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = HSDSans.otf; sourceTree = "<group>"; };
@@ -140,7 +144,7 @@
140144
isa = PBXGroup;
141145
children = (
142146
139812D8253A347100CEB9D4 /* LoginView.swift */,
143-
132160AE2539BE74003D3489 /* ContentView.swift */,
147+
1380D110272FDC9D00B05ECF /* ContentView.swift */,
144148
138E8471253B139A00B1B8AD /* LoadingScreen.swift */,
145149
);
146150
path = View;
@@ -153,6 +157,8 @@
153157
138E8459253AF7C800B1B8AD /* BackgroundView.swift */,
154158
138E8465253B00A200B1B8AD /* Placeholder.swift */,
155159
131E86D926432DFC002EF7C7 /* InputField.swift */,
160+
1380D10E272FD9A800B05ECF /* LogoutButton.swift */,
161+
1380D112272FDDBE00B05ECF /* BigButton.swift */,
156162
);
157163
path = ViewModel;
158164
sourceTree = "<group>";
@@ -270,13 +276,15 @@
270276
138E845D253AF7F000B1B8AD /* GradeMode.swift in Sources */,
271277
136BCFC82539C7FB00C77D96 /* Attempts.swift in Sources */,
272278
136BCFD12539C99300C77D96 /* ModuleRow.swift in Sources */,
279+
1380D113272FDDBE00B05ECF /* BigButton.swift in Sources */,
273280
136BCFD42539D0EA00C77D96 /* Grade.swift in Sources */,
281+
1380D111272FDC9D00B05ECF /* ContentView.swift in Sources */,
274282
139812D5253A2C7F00CEB9D4 /* Color.swift in Sources */,
275283
131E86DA26432DFC002EF7C7 /* InputField.swift in Sources */,
276284
136BCFC52539C7D900C77D96 /* WorkExperience.swift in Sources */,
277285
138E8472253B139A00B1B8AD /* LoadingScreen.swift in Sources */,
278286
136BCFE42539DAB900C77D96 /* APIResponse.swift in Sources */,
279-
132160AF2539BE74003D3489 /* ContentView.swift in Sources */,
287+
1380D10F272FD9A800B05ECF /* LogoutButton.swift in Sources */,
280288
139812D9253A347100CEB9D4 /* LoginView.swift in Sources */,
281289
136BCFCB2539C81B00C77D96 /* Module.swift in Sources */,
282290
136BCFBF2539C77100C77D96 /* Student.swift in Sources */,
@@ -411,19 +419,21 @@
411419
buildSettings = {
412420
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
413421
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
422+
CODE_SIGN_IDENTITY = "Apple Development";
414423
CODE_SIGN_STYLE = Automatic;
415424
DEVELOPMENT_ASSET_PATHS = "\"iOSSC/Preview Content\"";
416425
DEVELOPMENT_TEAM = NSG52Q9F89;
417426
ENABLE_PREVIEWS = YES;
418427
INFOPLIST_FILE = iOSSC/Info.plist;
419-
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
428+
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
420429
LD_RUNPATH_SEARCH_PATHS = (
421430
"$(inherited)",
422431
"@executable_path/Frameworks",
423432
);
424433
MARKETING_VERSION = 0.1.1;
425434
PRODUCT_BUNDLE_IDENTIFIER = me.kuhlti.iOSSC;
426435
PRODUCT_NAME = "$(TARGET_NAME)";
436+
PROVISIONING_PROFILE_SPECIFIER = "";
427437
SWIFT_VERSION = 5.0;
428438
TARGETED_DEVICE_FAMILY = 1;
429439
};
@@ -434,19 +444,21 @@
434444
buildSettings = {
435445
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
436446
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
447+
CODE_SIGN_IDENTITY = "Apple Development";
437448
CODE_SIGN_STYLE = Automatic;
438449
DEVELOPMENT_ASSET_PATHS = "\"iOSSC/Preview Content\"";
439450
DEVELOPMENT_TEAM = NSG52Q9F89;
440451
ENABLE_PREVIEWS = YES;
441452
INFOPLIST_FILE = iOSSC/Info.plist;
442-
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
453+
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
443454
LD_RUNPATH_SEARCH_PATHS = (
444455
"$(inherited)",
445456
"@executable_path/Frameworks",
446457
);
447458
MARKETING_VERSION = 0.1.1;
448459
PRODUCT_BUNDLE_IDENTIFIER = me.kuhlti.iOSSC;
449460
PRODUCT_NAME = "$(TARGET_NAME)";
461+
PROVISIONING_PROFILE_SPECIFIER = "";
450462
SWIFT_VERSION = 5.0;
451463
TARGETED_DEVICE_FAMILY = 1;
452464
};

β€ŽiOSSC/Assets.xcassets/AppIcon.appiconset/Contents.jsonβ€Ž

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@
180180
"scale" : "3x",
181181
"size" : "29x29"
182182
},
183+
{
184+
"idiom" : "watch",
185+
"role" : "notificationCenter",
186+
"scale" : "2x",
187+
"size" : "33x33",
188+
"subtype" : "45mm"
189+
},
183190
{
184191
"filename" : "Icon-82.png",
185192
"idiom" : "watch",
@@ -196,6 +203,13 @@
196203
"size" : "44x44",
197204
"subtype" : "40mm"
198205
},
206+
{
207+
"idiom" : "watch",
208+
"role" : "appLauncher",
209+
"scale" : "2x",
210+
"size" : "46x46",
211+
"subtype" : "41mm"
212+
},
199213
{
200214
"filename" : "Icon-101.png",
201215
"idiom" : "watch",
@@ -204,6 +218,13 @@
204218
"size" : "50x50",
205219
"subtype" : "44mm"
206220
},
221+
{
222+
"idiom" : "watch",
223+
"role" : "appLauncher",
224+
"scale" : "2x",
225+
"size" : "51x51",
226+
"subtype" : "45mm"
227+
},
207228
{
208229
"filename" : "Icon-172.png",
209230
"idiom" : "watch",
@@ -228,6 +249,13 @@
228249
"size" : "108x108",
229250
"subtype" : "44mm"
230251
},
252+
{
253+
"idiom" : "watch",
254+
"role" : "quickLook",
255+
"scale" : "2x",
256+
"size" : "117x117",
257+
"subtype" : "45mm"
258+
},
231259
{
232260
"filename" : "Icon-1025.png",
233261
"idiom" : "watch-marketing",

β€ŽiOSSC/Extensions/Color.swiftβ€Ž

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,38 @@ extension Color {
1717
opacity: alpha
1818
)
1919
}
20+
21+
// by: https://stackoverflow.com/a/64103125/4179020
22+
var components: (red: CGFloat, green: CGFloat, blue: CGFloat, opacity: CGFloat) {
23+
#if canImport(UIKit)
24+
typealias NativeColor = UIColor
25+
#elseif canImport(AppKit)
26+
typealias NativeColor = NSColor
27+
#endif
28+
29+
var r: CGFloat = 0
30+
var g: CGFloat = 0
31+
var b: CGFloat = 0
32+
var o: CGFloat = 0
33+
34+
guard NativeColor(self).getRed(&r, green: &g, blue: &b, alpha: &o) else {
35+
return (0, 0, 0, 0)
36+
}
37+
return (r, g, b, o)
38+
}
39+
40+
func lighter(by percentage: CGFloat = 30.0) -> Color {
41+
return self.adjust(by: abs(percentage) )
42+
}
43+
44+
func darker(by percentage: CGFloat = 30.0) -> Color {
45+
return self.adjust(by: -1 * abs(percentage) )
46+
}
47+
48+
func adjust(by percentage: CGFloat = 30.0) -> Color {
49+
return Color(red: min(Double(self.components.red + percentage/100), 1.0),
50+
green: min(Double(self.components.green + percentage/100), 1.0),
51+
blue: min(Double(self.components.blue + percentage/100), 1.0),
52+
opacity: Double(self.components.opacity))
53+
}
2054
}

β€ŽiOSSC/Model/Grade.swiftβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ extension Grade {
1919
}
2020

2121
var emoji: String? {
22-
return range?.returnValue(from: ["πŸ₯³", "☺️", "πŸ™‚", "πŸ₯΅", "🀬"])
22+
return range?.returnValue(from: ["πŸ₯³", "☺️", "😐", "πŸ₯΅", "🀬"])
2323
}
2424

2525
var color: Color? {

β€ŽiOSSC/View/ContentView.swiftβ€Ž

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,22 @@ struct ContentView: View {
3434
NavigationView {
3535
List {
3636
ForEach(manager.modules, id: \.id, content: { module in
37-
ModuleRow(for: module, in: $mode).listRowBackground(Color.clear)
37+
ModuleRow(for: module, in: $mode)
38+
.listRowBackground(Color.clear)
3839
})
3940
}
4041
.navigationTitle("iOSSC")
4142
.background(
4243
BackgroundView()
4344
)
44-
.navigationBarItems(leading: summaryLabel, trailing: HStack { logoutButton })
45+
.toolbar(content: {
46+
ToolbarItem(placement: .navigationBarLeading) {
47+
summaryLabel
48+
}
49+
ToolbarItem(placement: .navigationBarTrailing) {
50+
logoutButton
51+
}
52+
})
4553
.pullToRefresh(isShowing: $pullToRefreshShowing) {
4654
manager.refresh {
4755
pullToRefreshShowing = false
@@ -55,10 +63,7 @@ struct ContentView: View {
5563
Haptic.impact(.medium).generate()
5664
manager.logout()
5765
}
58-
.foregroundColor(.black)
59-
.padding(.vertical, 4)
60-
.padding(.horizontal, 14)
61-
.background(Capsule().foregroundColor(Color.white))
66+
.foregroundColor(.white)
6267
}
6368

6469
var summaryLabel: some View {

β€ŽiOSSC/View/LoginView.swiftβ€Ž

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,13 @@ struct LoginView: View {
9696

9797
private var footer: some View {
9898
VStack {
99-
Button("Login", action: login)
100-
.frame(height: 47)
101-
.frame(maxWidth: .infinity)
102-
.foregroundColor(.white)
103-
.background(Rectangle().foregroundColor(Color(hex: 0xE60028)))
104-
.cornerRadius(5)
99+
Button("Login") {
100+
manager.login(username, password)
101+
Haptic.impact(.medium).generate()
102+
}
103+
.buttonStyle(
104+
BigButton(Color(hex: 0xE60028), Color(hex: 0xE60028).darker())
105+
)
105106

106107
Text("Β© 2021 AndrΓ© Kuhlmann")
107108
.ignoresSafeArea()
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// BigButton.swift
3+
// iOSSC
4+
//
5+
// Created by AndrΓ© Kuhlmann on 01.11.21.
6+
//
7+
8+
import SwiftUI
9+
10+
struct BigButton: ButtonStyle {
11+
@State var backgroundColor: Color
12+
@State var pressedBackgroundColor: Color
13+
@State var textColor: Color
14+
15+
init(_ backgroundColor: Color, _ pressedBackgroundColor: Color, _ textColor: Color = .white) {
16+
self.backgroundColor = backgroundColor
17+
self.pressedBackgroundColor = pressedBackgroundColor
18+
self.textColor = textColor
19+
}
20+
21+
func makeBody(configuration: Self.Configuration) -> some View {
22+
configuration.label
23+
.frame(maxWidth: .infinity)
24+
.font(.system(size: 16, weight: .bold))
25+
.padding(.top, 15)
26+
.padding(.bottom, 14)
27+
.foregroundColor(textColor)
28+
.background(configuration.isPressed ? pressedBackgroundColor : backgroundColor)
29+
.cornerRadius(4)
30+
}
31+
}
32+
33+
struct BigButton_Previews: PreviewProvider {
34+
static var previews: some View {
35+
Button("BigButton Style") {
36+
print("Hello World!")
37+
}
38+
.buttonStyle(BigButton(Color(hex: 0xE60028), Color(hex: 0xE60028).darker()))
39+
.previewLayout(.fixed(width: 400, height: 80))
40+
}
41+
}

β€ŽiOSSC/ViewModel/InputField.swiftβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ struct InputField_Previews: PreviewProvider {
5151
static var previews: some View {
5252
InputField("Placeholder", text: .constant(""))
5353
.padding()
54-
.background(Color.red)
54+
.background(Color.gray)
55+
.previewLayout(.fixed(width: 300, height: 70))
5556
}
5657
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// LogoutButton.swift
3+
// iOSSC
4+
//
5+
// Created by AndrΓ© Kuhlmann on 01.11.21.
6+
//
7+
8+
import SwiftUI
9+
10+
struct LogoutButton: View {
11+
@State var action: () -> ()
12+
13+
var body: some View {
14+
Button("Logout") {
15+
self.action()
16+
}
17+
.multilineTextAlignment(.center)
18+
.foregroundColor(.black)
19+
.background(
20+
Capsule()
21+
.padding(.horizontal, -12)
22+
.padding(.vertical, -4)
23+
.foregroundColor(.white)
24+
)
25+
}
26+
}
27+
28+
struct LogoutButton_Previews: PreviewProvider {
29+
static var previews: some View {
30+
ZStack {
31+
Rectangle()
32+
LogoutButton(action: {
33+
print("Pressed")
34+
})
35+
}
36+
.previewLayout(
37+
.fixed(width: 200, height: 100)
38+
)
39+
}
40+
}

β€ŽiOSSC/iOSSCApp.swiftβ€Ž

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
import SwiftUI
9+
import SFSafeSymbols
910

1011
let env: APIManager.Environment = .production
1112

@@ -28,17 +29,13 @@ struct iOSSCApp: App {
2829
.environmentObject(manager)
2930
}
3031

31-
// Toaster
32-
33-
3432
// Development Label
3533
if (env == .development) {
3634
VStack {
3735
HStack {
3836
Text("Development Mode")
3937
.foregroundColor(.red)
4038
.font(.caption)
41-
.fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/)
4239
Spacer()
4340
}
4441
.padding(.horizontal, 21)

0 commit comments

Comments
Β (0)