8 Commits

Author SHA1 Message Date
Paddy 600f4c9c76 💄 Refactoring color management and extending to all views
- Thanks to @liza-kl for the color scheme <3
2021-07-08 18:27:49 +02:00
Paddy c49c5186e1 Merge remote-tracking branch 'refs/remotes/origin/main' 2021-05-14 20:39:24 +02:00
Paddy 476e1caf9e 👥 Adding Lisa as contributor 2021-05-14 20:37:57 +02:00
Patrick 1431720850 Update README.md 2021-05-13 01:04:42 +02:00
Lisa be3582c19e Merge pull request #7 from Mueller-Patrick/colorextension
💄 Added a Color Extension with some rgb color codes for ligh…
2021-05-11 15:27:09 +02:00
li54 590e89fb1a 💄 Added a Color Extension with some rgb color codes for light and darkmode 2021-05-11 15:13:07 +02:00
Paddy 543bd190eb Some enhancements to the lecture plan list 2021-04-30 22:33:46 +02:00
Paddy f6e1d979fd 💄 Updating events list view 2021-04-07 21:15:22 +02:00
12 changed files with 337 additions and 49 deletions
+10 -6
View File
@@ -7,6 +7,7 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
42560FA0264AB7E40062053B /* ColorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42560F9F264AB7E40062053B /* ColorExtension.swift */; };
CD17FAD025C9F93B0088D700 /* HomeView.strings in Resources */ = {isa = PBXBuildFile; fileRef = CD17FAD225C9F93B0088D700 /* HomeView.strings */; }; CD17FAD025C9F93B0088D700 /* HomeView.strings in Resources */ = {isa = PBXBuildFile; fileRef = CD17FAD225C9F93B0088D700 /* HomeView.strings */; };
CD2FC0C525A869FE00963178 /* dhbw-standard-icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = CD2FC0C025A869FE00963178 /* dhbw-standard-icon@2x.png */; }; CD2FC0C525A869FE00963178 /* dhbw-standard-icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = CD2FC0C025A869FE00963178 /* dhbw-standard-icon@2x.png */; };
CD2FC0C625A869FE00963178 /* dhbw-standard-icon@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = CD2FC0C125A869FE00963178 /* dhbw-standard-icon@3x.png */; }; CD2FC0C625A869FE00963178 /* dhbw-standard-icon@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = CD2FC0C125A869FE00963178 /* dhbw-standard-icon@3x.png */; };
@@ -27,6 +28,7 @@
CD9FABA3258EC60600D6D0C5 /* DHBW_ServiceUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD9FABA2258EC60600D6D0C5 /* DHBW_ServiceUITests.swift */; }; CD9FABA3258EC60600D6D0C5 /* DHBW_ServiceUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD9FABA2258EC60600D6D0C5 /* DHBW_ServiceUITests.swift */; };
CDA1CBAE25D4591000DB2AE5 /* User+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA1CBA825D4591000DB2AE5 /* User+CoreDataProperties.swift */; }; CDA1CBAE25D4591000DB2AE5 /* User+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA1CBA825D4591000DB2AE5 /* User+CoreDataProperties.swift */; };
CDA1CBB025D4591000DB2AE5 /* Lecturer+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA1CBAA25D4591000DB2AE5 /* Lecturer+CoreDataProperties.swift */; }; CDA1CBB025D4591000DB2AE5 /* Lecturer+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA1CBAA25D4591000DB2AE5 /* Lecturer+CoreDataProperties.swift */; };
CDB1E947261DDA0200EDE9EB /* DateExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDB1E946261DDA0200EDE9EB /* DateExtension.swift */; };
CDCD721A25912E1200FBF2F5 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDCD721925912E1200FBF2F5 /* HomeView.swift */; }; CDCD721A25912E1200FBF2F5 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDCD721925912E1200FBF2F5 /* HomeView.swift */; };
CDCD72242591316500FBF2F5 /* LocalSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDCD72232591316500FBF2F5 /* LocalSettings.swift */; }; CDCD72242591316500FBF2F5 /* LocalSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDCD72232591316500FBF2F5 /* LocalSettings.swift */; };
CDCD7230259135C500FBF2F5 /* FirstOpeningSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDCD722F259135C500FBF2F5 /* FirstOpeningSettings.swift */; }; CDCD7230259135C500FBF2F5 /* FirstOpeningSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDCD722F259135C500FBF2F5 /* FirstOpeningSettings.swift */; };
@@ -60,6 +62,7 @@
/* End PBXContainerItemProxy section */ /* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
42560F9F264AB7E40062053B /* ColorExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorExtension.swift; sourceTree = "<group>"; };
CD17FAD125C9F93B0088D700 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/HomeView.strings; sourceTree = "<group>"; }; CD17FAD125C9F93B0088D700 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/HomeView.strings; sourceTree = "<group>"; };
CD17FAD625C9F9440088D700 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/HomeView.strings; sourceTree = "<group>"; }; CD17FAD625C9F9440088D700 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/HomeView.strings; sourceTree = "<group>"; };
CD2FC0C025A869FE00963178 /* dhbw-standard-icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "dhbw-standard-icon@2x.png"; sourceTree = "<group>"; }; CD2FC0C025A869FE00963178 /* dhbw-standard-icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "dhbw-standard-icon@2x.png"; sourceTree = "<group>"; };
@@ -70,7 +73,6 @@
CD730A34259A860E00E0BB69 /* SettingsAcknowledgements.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsAcknowledgements.swift; sourceTree = "<group>"; }; CD730A34259A860E00E0BB69 /* SettingsAcknowledgements.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsAcknowledgements.swift; sourceTree = "<group>"; };
CD8555BD25C47AE500C4ACD6 /* RaPlaFetcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RaPlaFetcher.swift; sourceTree = "<group>"; }; CD8555BD25C47AE500C4ACD6 /* RaPlaFetcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RaPlaFetcher.swift; sourceTree = "<group>"; };
CD8555C225C47B5300C4ACD6 /* ApiService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApiService.swift; sourceTree = "<group>"; }; CD8555C225C47B5300C4ACD6 /* ApiService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApiService.swift; sourceTree = "<group>"; };
CD9E3F0A25DC3C9A00C77D10 /* DHBW-Service.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "DHBW-Service.entitlements"; sourceTree = "<group>"; };
CD9E3F0E25DC466100C77D10 /* SettingsPushNotifications.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsPushNotifications.swift; sourceTree = "<group>"; }; CD9E3F0E25DC466100C77D10 /* SettingsPushNotifications.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsPushNotifications.swift; sourceTree = "<group>"; };
CD9FAB7D258EC60200D6D0C5 /* DHBW-Service.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "DHBW-Service.app"; sourceTree = BUILT_PRODUCTS_DIR; }; CD9FAB7D258EC60200D6D0C5 /* DHBW-Service.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "DHBW-Service.app"; sourceTree = BUILT_PRODUCTS_DIR; };
CD9FAB80258EC60200D6D0C5 /* DHBW_ServiceApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DHBW_ServiceApp.swift; sourceTree = "<group>"; }; CD9FAB80258EC60200D6D0C5 /* DHBW_ServiceApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DHBW_ServiceApp.swift; sourceTree = "<group>"; };
@@ -88,6 +90,7 @@
CD9FABA4258EC60600D6D0C5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; CD9FABA4258EC60600D6D0C5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
CDA1CBA825D4591000DB2AE5 /* User+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "User+CoreDataProperties.swift"; path = "DHBW-Service/CoreData/Models/User+CoreDataProperties.swift"; sourceTree = SOURCE_ROOT; }; CDA1CBA825D4591000DB2AE5 /* User+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "User+CoreDataProperties.swift"; path = "DHBW-Service/CoreData/Models/User+CoreDataProperties.swift"; sourceTree = SOURCE_ROOT; };
CDA1CBAA25D4591000DB2AE5 /* Lecturer+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "Lecturer+CoreDataProperties.swift"; path = "DHBW-Service/CoreData/Models/Lecturer+CoreDataProperties.swift"; sourceTree = SOURCE_ROOT; }; CDA1CBAA25D4591000DB2AE5 /* Lecturer+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "Lecturer+CoreDataProperties.swift"; path = "DHBW-Service/CoreData/Models/Lecturer+CoreDataProperties.swift"; sourceTree = SOURCE_ROOT; };
CDB1E946261DDA0200EDE9EB /* DateExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateExtension.swift; sourceTree = "<group>"; };
CDCD721925912E1200FBF2F5 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; }; CDCD721925912E1200FBF2F5 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
CDCD72232591316500FBF2F5 /* LocalSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalSettings.swift; sourceTree = "<group>"; }; CDCD72232591316500FBF2F5 /* LocalSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalSettings.swift; sourceTree = "<group>"; };
CDCD722F259135C500FBF2F5 /* FirstOpeningSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirstOpeningSettings.swift; sourceTree = "<group>"; }; CDCD722F259135C500FBF2F5 /* FirstOpeningSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirstOpeningSettings.swift; sourceTree = "<group>"; };
@@ -210,7 +213,6 @@
CD9FAB7F258EC60200D6D0C5 /* DHBW-Service */ = { CD9FAB7F258EC60200D6D0C5 /* DHBW-Service */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
CD9E3F0A25DC3C9A00C77D10 /* DHBW-Service.entitlements */,
CDCD720F25912D3C00FBF2F5 /* App */, CDCD720F25912D3C00FBF2F5 /* App */,
CDCD721025912D4900FBF2F5 /* Views */, CDCD721025912D4900FBF2F5 /* Views */,
CDDCF4792591FE410027CDC5 /* Utility */, CDDCF4792591FE410027CDC5 /* Utility */,
@@ -321,6 +323,8 @@
CDDCF47A2591FE550027CDC5 /* UtilityFunctions.swift */, CDDCF47A2591FE550027CDC5 /* UtilityFunctions.swift */,
CD8555BD25C47AE500C4ACD6 /* RaPlaFetcher.swift */, CD8555BD25C47AE500C4ACD6 /* RaPlaFetcher.swift */,
CD8555C225C47B5300C4ACD6 /* ApiService.swift */, CD8555C225C47B5300C4ACD6 /* ApiService.swift */,
CDB1E946261DDA0200EDE9EB /* DateExtension.swift */,
42560F9F264AB7E40062053B /* ColorExtension.swift */,
); );
path = Utility; path = Utility;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -476,6 +480,7 @@
CDDCF4842592028A0027CDC5 /* Localizer.swift in Sources */, CDDCF4842592028A0027CDC5 /* Localizer.swift in Sources */,
CDD970DF25D453D90061755E /* Lecturer+CoreDataClass.swift in Sources */, CDD970DF25D453D90061755E /* Lecturer+CoreDataClass.swift in Sources */,
CDCD7230259135C500FBF2F5 /* FirstOpeningSettings.swift in Sources */, CDCD7230259135C500FBF2F5 /* FirstOpeningSettings.swift in Sources */,
42560FA0264AB7E40062053B /* ColorExtension.swift in Sources */,
CDA1CBB025D4591000DB2AE5 /* Lecturer+CoreDataProperties.swift in Sources */, CDA1CBB025D4591000DB2AE5 /* Lecturer+CoreDataProperties.swift in Sources */,
CD9FAB8A258EC60600D6D0C5 /* Persistence.swift in Sources */, CD9FAB8A258EC60600D6D0C5 /* Persistence.swift in Sources */,
CD730A35259A860E00E0BB69 /* SettingsAcknowledgements.swift in Sources */, CD730A35259A860E00E0BB69 /* SettingsAcknowledgements.swift in Sources */,
@@ -487,6 +492,7 @@
CD8555BE25C47AE500C4ACD6 /* RaPlaFetcher.swift in Sources */, CD8555BE25C47AE500C4ACD6 /* RaPlaFetcher.swift in Sources */,
CDEA70C025C85999001CFE28 /* LecturePlanItem.swift in Sources */, CDEA70C025C85999001CFE28 /* LecturePlanItem.swift in Sources */,
CD8555C325C47B5300C4ACD6 /* ApiService.swift in Sources */, CD8555C325C47B5300C4ACD6 /* ApiService.swift in Sources */,
CDB1E947261DDA0200EDE9EB /* DateExtension.swift in Sources */,
CD9FAB8D258EC60600D6D0C5 /* DHBW_Service.xcdatamodeld in Sources */, CD9FAB8D258EC60600D6D0C5 /* DHBW_Service.xcdatamodeld in Sources */,
CDCD721A25912E1200FBF2F5 /* HomeView.swift in Sources */, CDCD721A25912E1200FBF2F5 /* HomeView.swift in Sources */,
CDD39B4B259A64150078D05F /* SettingsMain.swift in Sources */, CDD39B4B259A64150078D05F /* SettingsMain.swift in Sources */,
@@ -683,9 +689,8 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "DHBW-Service/DHBW-Service.entitlements";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1.0.1; CURRENT_PROJECT_VERSION = 1.0.2;
DEVELOPMENT_ASSET_PATHS = "\"DHBW-Service/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"DHBW-Service/Preview Content\"";
DEVELOPMENT_TEAM = HS7KNT4MZ2; DEVELOPMENT_TEAM = HS7KNT4MZ2;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
@@ -707,9 +712,8 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "DHBW-Service/DHBW-Service.entitlements";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1.0.1; CURRENT_PROJECT_VERSION = 1.0.2;
DEVELOPMENT_ASSET_PATHS = "\"DHBW-Service/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"DHBW-Service/Preview Content\"";
DEVELOPMENT_TEAM = HS7KNT4MZ2; DEVELOPMENT_TEAM = HS7KNT4MZ2;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "174",
"green" : "174",
"red" : "174"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.153",
"green" : "0.125",
"red" : "0.063"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "255",
"green" : "255",
"red" : "255"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "123",
"green" : "114",
"red" : "98"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "224",
"green" : "224",
"red" : "224"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "79",
"green" : "71",
"red" : "55"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
+13
View File
@@ -0,0 +1,13 @@
//
// ColorExtension.swift
// DHBW-Service
//
// Created by Lisa Kletsko on 11.05.21.
//
import SwiftUI
import Foundation
extension Color {
static let primaryColor = Color("PrimaryColor")
static let darkColor = Color("DarkColor")
static let lightColor = Color("LightColor")
}
+18
View File
@@ -0,0 +1,18 @@
//
// DateExtension.swift
// DHBW-Service
//
// Created by Patrick Müller on 07.04.21.
//
import Foundation
extension Date {
func get(_ components: Calendar.Component..., calendar: Calendar = Calendar.current) -> DateComponents {
return calendar.dateComponents(Set(components), from: self)
}
func get(_ component: Calendar.Component, calendar: Calendar = Calendar.current) -> Int {
return calendar.component(component, from: self)
}
}
+4 -2
View File
@@ -264,6 +264,8 @@ class RaPlaFetcher {
print("Found unknown frequency: " + event.frequency) print("Found unknown frequency: " + event.frequency)
} }
// (offsetAmount * iteration) because for the 1st event, we dont want to add an offset, and
// for every event after that we want to add e.g. 1 week, 2 weeks, 3 weeks etc.
let startDate = Calendar.current.date(byAdding: offsetType, value: (offsetAmount * iteration), to: event.startDate)! let startDate = Calendar.current.date(byAdding: offsetType, value: (offsetAmount * iteration), to: event.startDate)!
let endDate = Calendar.current.date(byAdding: offsetType, value: (offsetAmount * iteration), to: event.endDate)! let endDate = Calendar.current.date(byAdding: offsetType, value: (offsetAmount * iteration), to: event.endDate)!
@@ -288,8 +290,6 @@ class RaPlaFetcher {
} }
// Populate fields // Populate fields
// (offsetAmount * iteration) because for the 1st event, we dont want to add an offset, and
// for every event after that we want to add e.g. 1 week, 2 weeks, 3 weeks etc.
evt.startDate = startDate evt.startDate = startDate
evt.endDate = endDate evt.endDate = endDate
evt.summary = event.summary evt.summary = event.summary
@@ -298,6 +298,8 @@ class RaPlaFetcher {
evt.category = event.category evt.category = event.category
evt.uid = newUID evt.uid = newUID
for lecturer in event.lecturers { for lecturer in event.lecturers {
// TODO: Delete all old lecturer objects
let lect = Lecturer(context: PersistenceController.shared.context) let lect = Lecturer(context: PersistenceController.shared.context)
lect.name = lecturer.name lect.name = lecturer.name
lect.email = lecturer.email lect.email = lecturer.email
+9 -7
View File
@@ -33,7 +33,7 @@ struct HomeView: View {
.padding() .padding()
.background( .background(
RoundedRectangle(cornerRadius: 10) RoundedRectangle(cornerRadius: 10)
.fill(Color.gray) .fill(Color.primaryColor)
) )
Spacer() Spacer()
} }
@@ -41,7 +41,8 @@ struct HomeView: View {
Spacer() Spacer()
VStack { VStack {
Text("information".localized(tableName: "HomeView", plural: false)) Text("information".localized(tableName: "HomeView", plural: false))
.font(.title3) .font(.headline)
.fontWeight(.semibold)
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
HStack { HStack {
VStack(alignment: .leading) { VStack(alignment: .leading) {
@@ -59,7 +60,7 @@ struct HomeView: View {
.padding() .padding()
.background( .background(
RoundedRectangle(cornerRadius: 10) RoundedRectangle(cornerRadius: 10)
.fill(Color.gray) .fill(Color.primaryColor)
) )
Spacer() Spacer()
} }
@@ -228,7 +229,8 @@ struct UpcomingLecturesBlock: View {
var body: some View { var body: some View {
VStack { VStack {
Text(titleKey.localized(tableName: "HomeView")) Text(titleKey.localized(tableName: "HomeView"))
.font(.title) .font(.title2)
.fontWeight(.semibold)
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
VStack { VStack {
if(!eventsList.isEmpty){ if(!eventsList.isEmpty){
@@ -245,7 +247,7 @@ struct UpcomingLecturesBlock: View {
.padding() .padding()
.background( .background(
RoundedRectangle(cornerRadius: 10) RoundedRectangle(cornerRadius: 10)
.fill(Color.gray) .fill(Color.primaryColor)
) )
} }
} }
@@ -274,11 +276,11 @@ struct UpcomingExamsBlock: View {
.padding() .padding()
.background( .background(
RoundedRectangle(cornerRadius: 10) RoundedRectangle(cornerRadius: 10)
.fill(Color.gray) .fill(Color.primaryColor)
) )
.overlay( .overlay(
RoundedRectangle(cornerRadius: 10) RoundedRectangle(cornerRadius: 10)
.stroke(Color.red, lineWidth: 4) .stroke(Color("AccentColor"), lineWidth: 4)
) )
} }
} }
@@ -46,7 +46,6 @@ struct LecturePlanItem: View {
Button(action: { Button(action: {
event.isHidden = !isHidden event.isHidden = !isHidden
self.isHidden = !isHidden self.isHidden = !isHidden
PersistenceController.shared.save()
}){ }){
if(self.isHidden){ if(self.isHidden){
Text("Show") Text("Show")
@@ -55,7 +54,7 @@ struct LecturePlanItem: View {
} }
} }
.padding() .padding()
.foregroundColor(.white) .foregroundColor(.primary)
.background(Color.blue) .background(Color.blue)
.cornerRadius(15) .cornerRadius(15)
Spacer() Spacer()
@@ -64,7 +63,7 @@ struct LecturePlanItem: View {
.padding() .padding()
.background( .background(
RoundedRectangle(cornerRadius: 10) RoundedRectangle(cornerRadius: 10)
.fill(Color.gray) .fill(Color.primaryColor)
) )
Spacer() Spacer()
} }
@@ -74,6 +73,9 @@ struct LecturePlanItem: View {
.onAppear{ .onAppear{
self.isHidden = event.isHidden self.isHidden = event.isHidden
} }
.onDisappear{
PersistenceController.shared.save()
}
} }
} }
+160 -28
View File
@@ -7,39 +7,32 @@
import SwiftUI import SwiftUI
import CoreData import CoreData
import Combine
struct LecturePlanList: View { struct LecturePlanList: View {
@State private var events: [RaPlaEvent] = [] @State private var events: [RaPlaEvent] = []
@State private var daysWithEvents: [Date:[RaPlaEvent]] = [:]
@State private var sortingAscending = true @State private var sortingAscending = true
var body: some View { var body: some View {
NavigationView() { NavigationView() {
List { ScrollView(.vertical) {
ForEach(events, id: \.self) { event in ScrollViewReader { scrollView in
NavigationLink(destination: LecturePlanItem(event: event)){ // Button("Jump to today") {
// withAnimation(){
// scrollView.scrollTo(8, anchor: .center)
// }
// }
// .padding()
ForEach(daysWithEvents.sorted(by: {$0.key < $1.key}), id: \.key) { key, value in
HStack { HStack {
Text(formatDate(date: event.startDate!))
.foregroundColor(getEventForegroundColor(for: event))
Text(event.summary!)
.foregroundColor(getEventForegroundColor(for: event))
Spacer() Spacer()
DayWithEventsBlock(date: key, eventsList: value, parent: self)
if(event.isHidden) { Spacer()
Image(systemName: "eye.slash")
.foregroundColor(.red)
} else {
Image(systemName: "eye")
}
} }
} }
// When an event gets updated from child view, reload it here as this will not trigger the onAppear() function
.onReceive(event.objectWillChange, perform: { _ in
let sectionSortDescriptor = NSSortDescriptor(key: "startDate", ascending: true)
let sortDescriptors = [sectionSortDescriptor]
self.events = []
self.events = RaPlaEvent.getSpecified(sortDescriptors: sortDescriptors)
})
} }
} }
.navigationBarTitle(Text("Lectures")) .navigationBarTitle(Text("Lectures"))
@@ -58,10 +51,8 @@ struct LecturePlanList: View {
} }
.navigationViewStyle(StackNavigationViewStyle()) .navigationViewStyle(StackNavigationViewStyle())
.onAppear{ .onAppear{
let sectionSortDescriptor = NSSortDescriptor(key: "startDate", ascending: true) self.getRaPlaEvents()
let sortDescriptors = [sectionSortDescriptor] self.findNextDay()
self.events = []
self.events = RaPlaEvent.getSpecified(sortDescriptors: sortDescriptors)
} }
} }
} }
@@ -83,13 +74,22 @@ struct LecturePlanList_Previews: PreviewProvider {
} }
extension LecturePlanList { extension LecturePlanList {
private func formatDate(date: Date) -> String { public func formatDate(date: Date) -> String {
let formatter = DateFormatter() let formatter = DateFormatter()
formatter.dateStyle = .short formatter.dateStyle = .short
return formatter.string(from: date) return formatter.string(from: date)
} }
private func getEventForegroundColor(for event: RaPlaEvent) -> Color { public func formatTime(date: Date) -> String {
let formatter = DateFormatter()
formatter.timeStyle = .short
return formatter.string(from: date)
}
/**
Get the correct foreground color for the given event, e.g. primary for normal events and red for exams.
*/
public func getEventForegroundColor(for event: RaPlaEvent) -> Color {
var textColor: Color = .primary var textColor: Color = .primary
if(event.category! == "Prüfung") { if(event.category! == "Prüfung") {
textColor = Color.red textColor = Color.red
@@ -99,4 +99,136 @@ extension LecturePlanList {
return textColor return textColor
} }
/**
DEPRECATED, used to find the element in the list of days that represents the next day
*/
public func findNextDay() {
// As this list is already sorted ascending, we can just return the first event with a start date that is in the future
let sortedEvents = self.events.sorted(by: { $0.startDate! < $1.startDate! })
for event in sortedEvents {
if(event.startDate! > Date()) {
//self.focusedEvent = event
return
}
}
}
/**
Loads required data from CoreData
*/
public func getRaPlaEvents() {
let sectionSortDescriptor = NSSortDescriptor(key: "startDate", ascending: true)
let sortDescriptors = [sectionSortDescriptor]
var calendar = Calendar.current
calendar.timeZone = NSTimeZone.local
let dateFrom = calendar.startOfDay(for: Date())
let fromPredicate = NSPredicate(format: "startDate >= %@", dateFrom as NSDate)
self.events = []
self.daysWithEvents = [:]
self.events = RaPlaEvent.getSpecified(sortDescriptors: sortDescriptors, searchPredicate: fromPredicate)
// Also write events to daysWithEvents map
for event in self.events {
let components = event.startDate!.get(.day, .month, .year)
let day = String(components.day!); let month = String(components.month!); let year = String(components.year!)
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
let dayOnly = dateFormatter.date(from: String(year + "-" + month + "-" + day))!
var eventsList = daysWithEvents[dayOnly]
if(eventsList == nil) {
eventsList = []
}
eventsList!.append(event)
self.daysWithEvents[dayOnly] = eventsList
}
}
public func updateDay(day: Date, events: [RaPlaEvent]) {
self.daysWithEvents[day] = events
}
}
/**
Each of these represents one day block in the view
*/
struct DayWithEventsBlock: View {
@State var date: Date
@State var eventsList: [RaPlaEvent]
@State var parent: LecturePlanList
var body: some View {
VStack {
Text(String(date.get(.day)) + "." + String(date.get(.month)) + "." + String(date.get(.year)))
.font(.title)
.frame(maxWidth: .infinity, alignment: .leading)
VStack {
if(!eventsList.isEmpty){
ForEach(eventsList, id: \.self) { event in
var visibleIconGroup = Group {
Button(action: {
event.isHidden.toggle()
}){
if(event.isHidden) {
Image(systemName: "eye.slash")
.foregroundColor(.red)
} else {
Image(systemName: "eye")
}
}
}
NavigationLink(destination: LecturePlanItem(event: event)) {
HStack {
Text(parent.formatTime(date: event.startDate!))
.foregroundColor(parent.getEventForegroundColor(for: event))
Text(event.summary!)
.foregroundColor(parent.getEventForegroundColor(for: event))
Spacer()
visibleIconGroup
}
.padding()
.background(
RoundedRectangle(cornerRadius: 10)
.fill(Color.darkColor)
)
}
// When an event gets updated from child view, reload it here as this will not trigger the onAppear() function
.onReceive(event.objectWillChange, perform: { _ in
print("receiving event: \(event.isHidden)")
visibleIconGroup = Group {
Button(action: {
event.isHidden.toggle()
}){
if(event.isHidden) {
Image(systemName: "eye.slash")
.foregroundColor(.red)
} else {
Image(systemName: "eye")
}
}
}
// parent.updateDay(day: self.date, events: self.eventsList)
})
}
} else {
Text("noLectures".localized(tableName: "HomeView"))
.frame(maxWidth: .infinity, alignment: .leading)
}
}
}
.padding()
.background(
RoundedRectangle(cornerRadius: 10)
.fill(Color.primaryColor)
)
}
} }
@@ -13,8 +13,9 @@ struct SettingsAcknowledgements: View {
Text("contributors".localized(tableName: "General", plural: false)) Text("contributors".localized(tableName: "General", plural: false))
.font(/*@START_MENU_TOKEN@*/.title/*@END_MENU_TOKEN@*/) .font(/*@START_MENU_TOKEN@*/.title/*@END_MENU_TOKEN@*/)
Spacer() Spacer()
Text("David Huh") Text("David Huh (davidhuh.de)")
Text("Patrick Müller") Text("Lisa Kletsko (li54.de)")
Text("Patrick Müller (mueller-patrick.tech)")
Spacer() Spacer()
} }
} }
+1 -1
View File
@@ -1,7 +1,7 @@
# DHBW-Service-App # DHBW-Service-App
## Introduction ## Introduction
This is a project by two students of the Cooperative State University in Karlsruhe (DHBW Karlsruhe). This is a project by three students of the Cooperative State University in Karlsruhe (DHBW Karlsruhe).
The goal is to develop a native iOS app providing easy and straightforward access to services like RaPla, Dualis and the canteen plan. The goal is to develop a native iOS app providing easy and straightforward access to services like RaPla, Dualis and the canteen plan.
<b>Disclaimer:</b> This project is not affiliated with the DHBW Karlsruhe <b>Disclaimer:</b> This project is not affiliated with the DHBW Karlsruhe