Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Commit

Permalink
Feature/widget views (#472)
Browse files Browse the repository at this point in the history
* Add empty widget view

* Add tuition widget

* Add Cafeteria Widget

* Cycle through menu items in cafeteria widget

* Add allergenics label to cafeteria widget

* Add study room widget

* Add widget sizes, improve widget visibility

* Improve design of tuition fee widget

* Implement different size options for CafeteriaWidgetView, remove animations

* Make tuition widget compatible with all sizes, improve its design

* Make study room widget compatible with all sizes, improve its design

* Beautify study room widget

* Beautify tuition widget

* Change study room widget color to white / dark gray

* Change tuition fee widget color to white / dark gray

* Add text widget view

* Use text widget view in study room widget

* Use widget color in widget loading view

* Update project file

* Beautify cafeteria widget

* Remove Color extension

* Fix count of available study rooms in large study room widget

* Add grades widget

* Add profile toolbar to widget screen

* Add calendar widget

* Fix preview

* Add map background to study room widget

* Improve study room widget design

* Improve tuition widget design

* Refactor TuitionWidgetInfoView

* Improve cafeteria widget design

* Improve grade widget design

* Make calendar widget title size consistent with other widgets

* Change symbol for widget screen

* Improve widget frame previews

* Add time based widget recommendations

* Use protocols for widget recommender strategies

* Add location strategy for widget recommendations

* Add spatio-temporal strategy for widget recommendations

* Add support for app usage data storage

* Collect usage data for calendar, grades, cafeteria, study room, and tuition view
  • Loading branch information
robynkoelle authored Aug 23, 2022
1 parent b4746ec commit 30abc9d
Show file tree
Hide file tree
Showing 51 changed files with 2,273 additions and 142 deletions.
11 changes: 11 additions & 0 deletions Analytics.xcdatamodeld/Analytics.xcdatamodel/contents
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="20086" systemVersion="21F79" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="AppUsageData" representedClassName="AppUsageData" syncable="YES" codeGenerationType="class">
<attribute name="location" optional="YES" attributeType="String"/>
<attribute name="time" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="view" optional="YES" attributeType="String"/>
</entity>
<elements>
<element name="AppUsageData" positionX="-54" positionY="-9" width="128" height="74"/>
</elements>
</model>
166 changes: 159 additions & 7 deletions Campus-iOS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions Campus-iOS/AnalyticsComüo/AnalyticsController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// Analytics.swift
// Campus-iOS
//
// Created by Robyn Kölle on 16.08.22.
//

import Foundation
import MapKit

struct AnalyticsController {

static func visitedView(view: CampusAppView) {
let time = Date()

guard let location = CLLocationManager().location else {
return
}

let data = AppUsageData(context: PersistenceController.shared.container.viewContext)
data.latitude = location.coordinate.latitude
data.longitude = location.coordinate.longitude
data.time = time
data.view = view.rawValue

PersistenceController.shared.save()
}
}
15 changes: 15 additions & 0 deletions Campus-iOS/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,21 @@ struct CampusApp: App {
Label("Places", systemImage: "mappin.and.ellipse")
}
.navigationViewStyle(.stack)

NavigationView {
WidgetScreen(model: model)
.navigationTitle("My Widgets")
.toolbar {
ToolbarItemGroup(placement: .navigationBarTrailing) {
ProfileToolbar(model: model)
}
}
}
.tag(4)
.tabItem {
Label("My Widgets", systemImage: "rectangle.3.group")
}
.navigationViewStyle(.stack)
}
}
}
20 changes: 20 additions & 0 deletions Campus-iOS/Assets.xcassets/darkGray.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "0.288",
"green" : "0.280",
"red" : "0.281"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
38 changes: 38 additions & 0 deletions Campus-iOS/Assets.xcassets/widgetColor.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "1.000",
"green" : "1.000",
"red" : "1.000"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.200",
"green" : "0.200",
"red" : "0.200"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
9 changes: 9 additions & 0 deletions Campus-iOS/Base/Enums/Enums.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,12 @@ enum Role: String {
}
}
}

/* Views for which we gather usage data for the widget recommendations. */
enum CampusAppView: String, CaseIterable {
case cafeteria = "cafeteria",
calendar = "calendar",
grades = "grades",
studyRoom = "studyRoom",
tuition = "tuition"
}
60 changes: 37 additions & 23 deletions Campus-iOS/CalendarComponent/Entity/CalendarEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ struct CalendarEvent: Identifiable, Equatable, Entity {
var status: String?
var title: String?
var url: URL?

/*
<event>
<nr>886515989</nr>
<status>FT</status>
<url>https://campus.tum.de/tumonline/lv.detail?cLvNr=950369994</url>
<title>Programmoptimierung (IN2053) VI</title>
<description>fix; Abhaltung; </description>
<dtstart>2019-01-16 10:00:00</dtstart>
<dtend>2019-01-16 12:00:00</dtend>
<location>00.13.009A, Seminarraum (5613.EG.009A)</location>
</event>
*/
<event>
<nr>886515989</nr>
<status>FT</status>
<url>https://campus.tum.de/tumonline/lv.detail?cLvNr=950369994</url>
<title>Programmoptimierung (IN2053) VI</title>
<description>fix; Abhaltung; </description>
<dtstart>2019-01-16 10:00:00</dtstart>
<dtend>2019-01-16 12:00:00</dtend>
<location>00.13.009A, Seminarraum (5613.EG.009A)</location>
</event>
*/

enum CodingKeys: String, CodingKey {
case descriptionText = "description"
Expand All @@ -54,7 +54,7 @@ struct CalendarEvent: Identifiable, Equatable, Entity {

var kvkEvent: Event {
var event = Event(ID: self.id.description)

event.start = self.startDate ?? Date()
event.end = self.endDate ?? Date()

Expand Down Expand Up @@ -115,15 +115,15 @@ struct CalendarEvent: Identifiable, Equatable, Entity {
endDate: Date? = nil,
location: String? = nil) {

self.id = id
self.status = status
self.url = url
self.title = title
self.descriptionText = descriptionText
self.startDate = startDate
self.endDate = endDate
self.location = location
}
self.id = id
self.status = status
self.url = url
self.title = title
self.descriptionText = descriptionText
self.startDate = startDate
self.endDate = endDate
self.location = location
}

init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
Expand All @@ -146,7 +146,7 @@ struct CalendarEvent: Identifiable, Equatable, Entity {
self.endDate = endDate
self.location = location
}

private static let dateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.locale = Locale.current
Expand All @@ -165,3 +165,17 @@ class CustomEventDesign: EventViewGeneral {
fatalError("init(coder:) has not been implemented")
}
}

extension CalendarEvent {

static let mockEvent = CalendarEvent(
id: 1,
status: "FT",
url: URL(string: "https://campus.tum.de/tumonline/lv.detail?cLvNr=950369994"),
title: "Programmoptimierung (IN2053) VI",
descriptionText: "fix; Abhaltung; ",
startDate: Date(),
endDate: Date().addingTimeInterval(60 * 60),
location: "00.13.009A, Seminarraum (5613.EG.009A)"
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,9 @@ class CalendarViewModel: ObservableObject {
}
})
}

var eventsByDate: [Date? : [CalendarEvent]] {
let dictionary = Dictionary(grouping: events, by: { $0.startDate })
return dictionary
}
}

3 changes: 3 additions & 0 deletions Campus-iOS/CalendarComponent/Views/CalendarContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ struct CalendarContentView: View {
ProfileToolbar(model: viewModel.model)
}
}
.task {
AnalyticsController.visitedView(view: .calendar)
}
}

static func getSafeAreaFrame(geometry: GeometryProxy) -> CGRect {
Expand Down
Loading

0 comments on commit 30abc9d

Please sign in to comment.