From 1dc8ab5d764d72c4281e05dbb39dc221380b4b64 Mon Sep 17 00:00:00 2001 From: Deniz Duezgoeren Date: Wed, 23 Oct 2019 20:20:31 +0200 Subject: [PATCH] Setup screen scrolls up when keyboard would block textfields; fixed bug that would prevent a substitution from being shown if it contained a question mark (e.g.: 'INF7?inf999') --- AvH Plan.xcodeproj/project.pbxproj | 2 + AvH Plan/DataFetcher.swift | 28 ++++++--- AvH Plan/FirstTimeViewController.swift | 59 +++++++++++++++++++ AvH Plan/PlanViewController.swift | 6 +- .../UICollectionViewSubstitutionLayout.swift | 14 +++++ 5 files changed, 96 insertions(+), 13 deletions(-) create mode 100644 AvH Plan/UICollectionViewSubstitutionLayout.swift diff --git a/AvH Plan.xcodeproj/project.pbxproj b/AvH Plan.xcodeproj/project.pbxproj index 0aea41c..54d8b83 100644 --- a/AvH Plan.xcodeproj/project.pbxproj +++ b/AvH Plan.xcodeproj/project.pbxproj @@ -46,6 +46,8 @@ isa = PBXBuildRule; compilerSpec = com.apple.compilers.proxy.script; fileType = pattern.proxy; + inputFiles = ( + ); isEditable = 1; outputFiles = ( ); diff --git a/AvH Plan/DataFetcher.swift b/AvH Plan/DataFetcher.swift index 4a16d8e..a50c0c2 100644 --- a/AvH Plan/DataFetcher.swift +++ b/AvH Plan/DataFetcher.swift @@ -109,17 +109,29 @@ class DataFetcher { return table.insert(group <- s.group, course <- s.course, additional <- s.additional, date <- s.date, time <- s.time, room <- s.room, teacher <- s.teacher, subst_type <- s.type, group_priority <- Int64(s.groupPriority), date_priority <- Int64(s.datePriority), website_priority <- Int64(s.websitePriority)) } - private func isPersonal(with g: String, and c: String, for s: SubstModel) -> Bool { - if !g.isEmpty && c.isEmpty { - if !s.group.isEmpty { - if g.contains(s.group) || s.group.contains(g) { + private func isPersonal(with group: String, and course: String, for substitution: SubstModel) -> Bool { + if !group.isEmpty && course.isEmpty { + if !substitution.group.isEmpty { + if group.contains(substitution.group) || substitution.group.contains(group) { return true } } - } else if !g.isEmpty && !c.isEmpty { - if s.group != "" && s.course != "" { - if (g.contains(s.group) || s.group.contains(g)) && c.contains(s.course) { - return true + } else if !group.isEmpty && !course.isEmpty { + if substitution.group != "" && substitution.course != "" { + + if let qmark = substitution.course.firstIndex(of: "?") { + if group.contains(substitution.group) || substitution.group.contains(group) { + + if course.contains(substitution.course[.. String { diff --git a/AvH Plan/UICollectionViewSubstitutionLayout.swift b/AvH Plan/UICollectionViewSubstitutionLayout.swift new file mode 100644 index 0000000..cfa839f --- /dev/null +++ b/AvH Plan/UICollectionViewSubstitutionLayout.swift @@ -0,0 +1,14 @@ +// +// UICollectionViewSubstitutionLayout.swift +// AvH Plan +// +// Created by Deniz Duezgoeren on 22.10.19. +// Copyright © 2019 Deniz Duezgoeren. All rights reserved. +// + +import UIKit + +class UICollectionViewSubstitutionLayout: UICollectionViewFlowLayout { + + override func +}