Skip to content

Commit

Permalink
Calendar & Feedback Form Improvements (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobkoerber authored Apr 10, 2024
1 parent ff56645 commit b0d6cde
Show file tree
Hide file tree
Showing 75 changed files with 852 additions and 401 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/deploy_beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ jobs:
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:'
cache-path: '${{ runner.tool_cache }}/flutter/:channel:-:arch:'

- if: matrix.platform == 'android'
uses: actions/setup-java@v3
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/deploy_web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ jobs:
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:'
cache-path: '${{ runner.tool_cache }}/flutter/:channel:-:arch:'

- name: Install Flutter Packages
run: flutter pub get
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/lint_test_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ jobs:
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:'
cache-path: '${{ runner.tool_cache }}/flutter/:channel:-:arch:'

- name: Install Flutter Packages
run: flutter pub get
Expand Down
2 changes: 2 additions & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
-keep class org.joda.** {*;}
-dontwarn org.joda.**
-keep class org.ocpsoft.prettytime.i18n.**
-keepnames class ** implements org.ocpsoft.prettytime.TimeUnit
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package de.tum.`in`.tumcampus.util

import android.graphics.Color

fun argbToColor(argb: Long): Int {
val alpha = ((argb shr 24) and 0xFF) / 255f
val red = ((argb shr 16) and 0xFF) / 255f
val green = ((argb shr 8) and 0xFF) / 255f
val blue = (argb and 0xFF) / 255f
return Color.argb(alpha, red, green, blue)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,32 @@ import android.graphics.Color
import androidx.core.content.ContextCompat
import com.google.gson.annotations.SerializedName
import de.tum.`in`.tumcampus.R
import de.tum.`in`.tumcampus.util.argbToColor
import org.joda.time.DateTime

data class WidgetCalendarItem(
@SerializedName("nr")
val id: String,
val title: String,
@SerializedName("dtstart")
val startDate: DateTime,
@SerializedName("dtend")
val endDate: DateTime,
val location: String,
val status: String,
var isFirstOnDay: Boolean = false
@SerializedName("nr")
val id: String,
val title: String,
@SerializedName("dtstart")
val startDate: DateTime,
@SerializedName("dtend")
val endDate: DateTime,
val location: String,
val status: String,
val color: Long?,
var isFirstOnDay: Boolean = false
) {
fun getEventColor(context: Context): Int {
return when (type) {
CalendarEventType.CANCELED -> Color.parseColor("#F44336")
CalendarEventType.LECTURE -> Color.parseColor("#4CAF50")
CalendarEventType.EXERCISE -> Color.parseColor("#9800FF")
else -> ContextCompat.getColor(context, R.color.color_primary);
return if (color == null) {
when (type) {
CalendarEventType.CANCELED -> Color.parseColor("#F44336")
CalendarEventType.LECTURE -> Color.parseColor("#4CAF50")
CalendarEventType.EXERCISE -> Color.parseColor("#9800FF")
else -> ContextCompat.getColor(context, R.color.color_primary)
}
} else {
argbToColor(color)
}
}

Expand Down
2 changes: 1 addition & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version '8.3.1' apply false
id "com.android.application" version '8.3.2' apply false
id "org.jetbrains.kotlin.android" version "1.9.20" apply false
id "com.google.gms.google-services" version "4.4.0" apply false
id "com.google.firebase.crashlytics" version "2.9.9" apply false
Expand Down
Binary file modified assets/images/tower.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 17 additions & 11 deletions ios/CalendarWidget/CalendarEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ struct CalendarEntry: Codable, Identifiable {
let status: String
let startDate: Date
let endDate: Date
let location: String
let location: String?
let color: Int?

enum CodingKeys: String, CodingKey {
case id = "nr"
case startDate = "dtstart"
case endDate = "dtend"
case title, location, status
case title, location, status, color
}

var isCanceled: Bool {
Expand All @@ -40,15 +41,20 @@ struct CalendarEntry: Codable, Identifiable {
}

var eventColor: Color {
switch type {
case .canceled:
return Color(red: 244 / 255, green: 67 / 255, blue: 54 / 255)
case .lecture:
return Color(red: 76 / 255, green: 175 / 255, blue: 80 / 255)
case .exercise:
return Color(red: 255 / 255, green: 152 / 255, blue: 0 / 255)
default:
return .accent
if (color == nil) {
switch type {
case .canceled:
return Color(red: 244 / 255, green: 67 / 255, blue: 54 / 255)
case .lecture:
return Color(red: 76 / 255, green: 175 / 255, blue: 80 / 255)
case .exercise:
return Color(red: 255 / 255, green: 152 / 255, blue: 0 / 255)
default:
return .accent
}
}
else {
return Color(argb: UInt32(color!))
}
}
}
12 changes: 9 additions & 3 deletions ios/CalendarWidget/CalendarEventView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,15 @@ struct CalendarEventView: View {

let timeText = "\(timeFormatter.string(from: event.startDate)) - \(timeFormatter.string(from: event.endDate))"

Text("\(timeText) | \(event.location)")
.font(.caption2)
.lineLimit(1)
if (event.location != nil) {
Text("\(timeText) | \(event.location!)")
.font(.caption2)
.lineLimit(1)
} else {
Text(timeText)
.font(.caption2)
.lineLimit(1)
}
}
.padding(6)
.foregroundStyle(.white)
Expand Down
10 changes: 5 additions & 5 deletions ios/CalendarWidget/CalendarWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ struct Provider: TimelineProvider {
CalendarWidgetEntry(
date: Date(),
entries: [
CalendarEntry(id: "0", title: "Lineare Algebra für Informatik", status: "Test", startDate: Date.now, endDate: Date.now, location: "Galileo Audimax"),
CalendarEntry(id: "0", title: "Einführung in die Buchführung", status: "Test", startDate: Date.now, endDate: Date.now, location: "Audimax")
CalendarEntry(id: "0", title: "Lineare Algebra für Informatik", status: "Test", startDate: Date.now, endDate: Date.now, location: "Galileo Audimax", color: nil),
CalendarEntry(id: "0", title: "Einführung in die Buchführung", status: "Test", startDate: Date.now, endDate: Date.now, location: "Audimax", color: nil)
],
size: context.family
)
}

func getSnapshot(in context: Context, completion: @escaping (CalendarWidgetEntry) -> ()) {
if context.isPreview{
let entry = placeholder(in: context)
Expand All @@ -42,7 +42,7 @@ struct Provider: TimelineProvider {
}
}
}

func getTimeline(in context: Context, completion: @escaping (Timeline<CalendarWidgetEntry>) -> ()) {
getSnapshot(in: context) { (entry) in
let timeline = Timeline(entries: [entry], policy: .atEnd)
Expand All @@ -53,7 +53,7 @@ struct Provider: TimelineProvider {

struct CalendarWidget: Widget {
let kind: String = "CalendarWidget"

var body: some WidgetConfiguration {
StaticConfiguration(kind: kind, provider: Provider()) { entry in
if #available(iOS 17.0, *) {
Expand Down
19 changes: 19 additions & 0 deletions ios/CalendarWidget/ColorExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// ColorExtension.swift
// CalendarWidgetExtension
//
// Created by Jakob Körber on 03.04.24.
//

import Foundation
import SwiftUI

extension Color {
init(argb: UInt32) {
let alpha = Double((argb >> 24) & 0xFF) / 255.0
let red = Double((argb >> 16) & 0xFF) / 255.0
let green = Double((argb >> 8) & 0xFF) / 255.0
let blue = Double(argb & 0xFF) / 255.0
self.init(red: red, green: green, blue: blue, opacity: alpha)
}
}
26 changes: 13 additions & 13 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ PODS:
- Firebase/Crashlytics (10.22.0):
- Firebase/CoreOnly
- FirebaseCrashlytics (~> 10.22.0)
- firebase_core (2.27.2):
- firebase_core (2.29.0):
- Firebase/CoreOnly (= 10.22.0)
- Flutter
- firebase_crashlytics (3.4.20):
- firebase_crashlytics (3.5.1):
- Firebase/Crashlytics (= 10.22.0)
- firebase_core
- Flutter
- FirebaseCore (10.22.0):
- FirebaseCoreInternal (~> 10.0)
- GoogleUtilities/Environment (~> 7.12)
- GoogleUtilities/Logger (~> 7.12)
- FirebaseCoreExtension (10.23.0):
- FirebaseCoreExtension (10.24.0):
- FirebaseCore (~> 10.0)
- FirebaseCoreInternal (10.23.0):
- FirebaseCoreInternal (10.24.0):
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- FirebaseCrashlytics (10.22.0):
- FirebaseCore (~> 10.5)
Expand All @@ -29,12 +29,12 @@ PODS:
- GoogleUtilities/Environment (~> 7.8)
- nanopb (< 2.30911.0, >= 2.30908.0)
- PromisesObjC (~> 2.1)
- FirebaseInstallations (10.23.0):
- FirebaseInstallations (10.24.0):
- FirebaseCore (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/UserDefaults (~> 7.8)
- PromisesObjC (~> 2.1)
- FirebaseSessions (10.23.0):
- FirebaseSessions (10.24.0):
- FirebaseCore (~> 10.5)
- FirebaseCoreExtension (~> 10.0)
- FirebaseInstallations (~> 10.0)
Expand Down Expand Up @@ -188,14 +188,14 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
device_info_plus: 97af1d7e84681a90d0693e63169a5d50e0839a0d
Firebase: 797fd7297b7e1be954432743a0b3f90038e45a71
firebase_core: cc49b6648d6dd7570d9273a616cb1205260db91e
firebase_crashlytics: a5050259f9e6989a44c131dbf14887a434b4395a
firebase_core: aaadbddb3cb2ee3792b9804f9dbb63e5f6f7b55c
firebase_crashlytics: 4271b5bb77f6169ac7c2a9d62ad0e6aa5f84c2fe
FirebaseCore: 0326ec9b05fbed8f8716cddbf0e36894a13837f7
FirebaseCoreExtension: cb88851781a24e031d1b58e0bd01eb1f46b044b5
FirebaseCoreInternal: 6a292e6f0bece1243a737e81556e56e5e19282e3
FirebaseCoreExtension: af5fd85e817ea9d19f9a2659a376cf9cf99f03c0
FirebaseCoreInternal: bcb5acffd4ea05e12a783ecf835f2210ce3dc6af
FirebaseCrashlytics: e568d68ce89117c80cddb04073ab9018725fbb8c
FirebaseInstallations: 42d6ead4605d6eafb3b6683674e80e18eb6f2c35
FirebaseSessions: f06853e30f99fe42aa511014d7ee6c8c319f08a3
FirebaseInstallations: 8f581fca6478a50705d2bd2abd66d306e0f5736e
FirebaseSessions: 2651b464e241c93fd44112f995d5ab663c970487
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_native_splash: edf599c81f74d093a4daf8e17bd7a018854bc778
flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be
Expand All @@ -206,7 +206,7 @@ SPEC CHECKSUMS:
GoogleUtilities: d053d902a8edaa9904e1bd00c37535385b8ed152
home_widget: 0434835a4c9a75704264feff6be17ea40e0f0d57
isar_flutter_libs: b69f437aeab9c521821c3f376198c4371fa21073
map_launcher: e325db1261d029ff33e08e03baccffe09593ffea
map_launcher: 5fde49ac9a52672bf99da746599f507b4490d7b5
nanopb: 438bc412db1928dac798aa6fd75726007be04262
package_info_plus: 58f0028419748fad15bf008b270aaa8e54380b1c
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
Expand Down
4 changes: 4 additions & 0 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
28C6B8A32B6AEB8700DD5E9A /* CalendarWidgetExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 28C6B8962B6AEB8500DD5E9A /* CalendarWidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
28C6B8AB2B6AF13100DD5E9A /* CalendarEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28C6B8A92B6AEDEC00DD5E9A /* CalendarEntry.swift */; };
28CAF3FA2B6CF54100C1F412 /* CalendarEventType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28CAF3F92B6CF54100C1F412 /* CalendarEventType.swift */; };
28ECAB0A2BBD8C7D008A3F17 /* ColorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28ECAB092BBD8C7D008A3F17 /* ColorExtension.swift */; };
28F2C3202B29C62C00DC87B4 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 28F2C31F2B29C62C00DC87B4 /* GoogleService-Info.plist */; };
3208B3C6E6BD767EB8753CBA /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B38658BC54648274DCF4104 /* Pods_Runner.framework */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
Expand Down Expand Up @@ -89,6 +90,7 @@
28C6B8A92B6AEDEC00DD5E9A /* CalendarEntry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarEntry.swift; sourceTree = "<group>"; };
28CAF3F92B6CF54100C1F412 /* CalendarEventType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarEventType.swift; sourceTree = "<group>"; };
28CBEFE12ACB1A25002DCDEC /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
28ECAB092BBD8C7D008A3F17 /* ColorExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorExtension.swift; sourceTree = "<group>"; };
28F2C31F2B29C62C00DC87B4 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
420655E10FFEF68E399A0BDC /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -137,6 +139,7 @@
28CAF3F92B6CF54100C1F412 /* CalendarEventType.swift */,
2844DDE22B964B6C00E20EDA /* CalendarEventView.swift */,
28169AD22B9BBE7200FCCFDC /* CalendarWidgetContent.swift */,
28ECAB092BBD8C7D008A3F17 /* ColorExtension.swift */,
2844DDE42B964BAE00E20EDA /* DateExtension.swift */,
28C6B89E2B6AEB8700DD5E9A /* Assets.xcassets */,
28C6B8A02B6AEB8700DD5E9A /* Info.plist */,
Expand Down Expand Up @@ -464,6 +467,7 @@
2862C8472B6C205600EF5825 /* CalendarWidgetEntry.swift in Sources */,
2844DDE52B964BAE00E20EDA /* DateExtension.swift in Sources */,
2844DDE32B964B6C00E20EDA /* CalendarEventView.swift in Sources */,
28ECAB0A2BBD8C7D008A3F17 /* ColorExtension.swift in Sources */,
28CAF3FA2B6CF54100C1F412 /* CalendarEventType.swift in Sources */,
28C6B89B2B6AEB8500DD5E9A /* CalendarWidgetBundle.swift in Sources */,
28C6B89D2B6AEB8500DD5E9A /* CalendarWidget.swift in Sources */,
Expand Down
2 changes: 2 additions & 0 deletions lib/base/enums/user_preference.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ enum UserPreference {
studyRoom(int),
homeWidgets(List<String>),
theme(int),
calendarColors(String),
browser(bool),
failedGrades(bool),
weekends(bool),
locale(String);

final Type type;
Expand Down
26 changes: 12 additions & 14 deletions lib/base/errorHandling/error_handling_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ mixin ErrorHandlingView {
errorMessage,
context,
style: Theme.of(context).textTheme.titleLarge?.copyWith(
color: titleColor ?? Theme.of(context).primaryColor,
color: titleColor ?? context.primaryColor,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
Expand Down Expand Up @@ -86,7 +86,7 @@ mixin ErrorHandlingView {
errorMessage,
context,
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
color: titleColor ?? Theme.of(context).primaryColor,
color: titleColor ?? context.primaryColor,
),
textAlign: TextAlign.center,
),
Expand All @@ -100,20 +100,18 @@ mixin ErrorHandlingView {
),
);
case ErrorHandlingViewType.descriptionOnly:
return Center(
child: _errorMessageText(
errorMessage,
context,
style: TextStyle(color: bodyColor),
),
return _errorMessageText(
errorMessage,
context,
style: TextStyle(color: bodyColor),
textAlign: TextAlign.center,
);
case ErrorHandlingViewType.redDescriptionOnly:
return Center(
child: _errorMessageText(
errorMessage,
context,
style: const TextStyle(color: Colors.red),
),
return _errorMessageText(
errorMessage,
context,
style: const TextStyle(color: Colors.red),
textAlign: TextAlign.center,
);
}
}
Expand Down
2 changes: 2 additions & 0 deletions lib/base/extensions/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ extension ContextTheme on BuildContext {
double get halfPadding => 5.0;

double get padding => 15.0;

Color get primaryColor => Theme.of(this).primaryColor;
}

extension Localization on BuildContext {
Expand Down
Loading

0 comments on commit b0d6cde

Please sign in to comment.