Skip to content

Commit

Permalink
Merge pull request #1 from thealpa/0001-ios-16-update
Browse files Browse the repository at this point in the history
Merge 0001 iOS 16 Update
  • Loading branch information
thealpa authored Sep 10, 2022
2 parents 3afd1cc + 6299e4c commit ea12e3a
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 55 deletions.
22 changes: 18 additions & 4 deletions CVAG.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
3D36831F28CD1D3E006CF87B /* UIScreen+ScreenCorners.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D36831E28CD1D3E006CF87B /* UIScreen+ScreenCorners.swift */; };
3D4012F527E931DE00649196 /* FavoritesDrawerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D4012F427E931DE00649196 /* FavoritesDrawerView.swift */; };
3D4CA70227E8025000154B91 /* Drawer in Frameworks */ = {isa = PBXBuildFile; productRef = 3D4CA70127E8025000154B91 /* Drawer */; };
3D53804527D92D60005860CE /* DrawerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D53804427D92D60005860CE /* DrawerView.swift */; };
Expand All @@ -31,6 +32,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
3D36831E28CD1D3E006CF87B /* UIScreen+ScreenCorners.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIScreen+ScreenCorners.swift"; sourceTree = "<group>"; };
3D4012F427E931DE00649196 /* FavoritesDrawerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoritesDrawerView.swift; sourceTree = "<group>"; };
3D4012F627EA94B100649196 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
3D53804427D92D60005860CE /* DrawerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DrawerView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -67,6 +69,14 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
3D36831D28CD1D19006CF87B /* Helper */ = {
isa = PBXGroup;
children = (
3D36831E28CD1D3E006CF87B /* UIScreen+ScreenCorners.swift */,
);
path = Helper;
sourceTree = "<group>";
};
3D53804127D92CEF005860CE /* Views */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -136,6 +146,7 @@
3D53804127D92CEF005860CE /* Views */,
3D53805027D959A2005860CE /* Stores */,
3D53804B27D9415A005860CE /* Resources */,
3D36831D28CD1D19006CF87B /* Helper */,
3D635F4B27D8178A008906D3 /* Assets.xcassets */,
3D635F4D27D8178A008906D3 /* Preview Content */,
);
Expand Down Expand Up @@ -242,6 +253,7 @@
3DCEB98D27ED4118003FC99C /* StopAnnotationView.swift in Sources */,
3D4012F527E931DE00649196 /* FavoritesDrawerView.swift in Sources */,
3D53804927D93B2E005860CE /* Stop.swift in Sources */,
3D36831F28CD1D3E006CF87B /* UIScreen+ScreenCorners.swift in Sources */,
3D53805427DA3760005860CE /* Drawer.swift in Sources */,
3D59B66A27DE73BE00BA0DFA /* DepartureCellView.swift in Sources */,
3DD72ACC2801BC8000044491 /* Favorites.swift in Sources */,
Expand Down Expand Up @@ -374,12 +386,13 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = CVAG/CVAG.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 39;
CURRENT_PROJECT_VERSION = 40;
DEVELOPMENT_ASSET_PATHS = "\"CVAG/Preview Content\"";
DEVELOPMENT_TEAM = B7HSFEB698;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = CVAG/Info.plist;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.travel";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
Expand All @@ -389,7 +402,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.2;
MARKETING_VERSION = 1.0.3;
PRODUCT_BUNDLE_IDENTIFIER = com.janhuelsmann.CVAG;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -406,12 +419,13 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = CVAG/CVAG.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 39;
CURRENT_PROJECT_VERSION = 40;
DEVELOPMENT_ASSET_PATHS = "\"CVAG/Preview Content\"";
DEVELOPMENT_TEAM = B7HSFEB698;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = CVAG/Info.plist;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.travel";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
Expand All @@ -421,7 +435,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.2;
MARKETING_VERSION = 1.0.3;
PRODUCT_BUNDLE_IDENTIFIER = com.janhuelsmann.CVAG;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"location" : "https://github.com/siteline/SwiftUI-Introspect.git",
"state" : {
"branch" : "master",
"revision" : "72a509c93166540c0adf8323fd2652daade7f9f6"
"revision" : "d3cbf32788250741d397cfb5bcd532c37aa1096d"
}
}
],
Expand Down
11 changes: 1 addition & 10 deletions CVAG/Assets.xcassets/Haltestelle.imageset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,7 @@
"images" : [
{
"filename" : "Haltestelle.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
"idiom" : "universal"
}
],
"info" : {
Expand Down
24 changes: 24 additions & 0 deletions CVAG/Helper/UIScreen+ScreenCorners.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// UIScreen+ScreenCorners.swift
// CVAG
//
// Created by Jan Hülsmann on 10.09.22.
//

import SwiftUI

extension UIScreen {
private static let cornerRadiusKey: String = {
let components = ["Radius", "Corner", "display", "_"]
return components.reversed().joined()
}()

/// The corner radius of the display. Uses a private property of `UIScreen`,
/// and may report 0 if the API changes.
public var displayCornerRadius: CGFloat {
guard let cornerRadius = self.value(forKey: Self.cornerRadiusKey) as? CGFloat else {
return 50.0
}
return cornerRadius
}
}
3 changes: 1 addition & 2 deletions CVAG/Models/Drawer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import SwiftUI

/// Default positions of drawer in __ascending__ order.
//
let drawerDefault: [CGFloat] = [(UIScreen.screenHeight * 0.15), (UIScreen.screenHeight * 0.60), (UIScreen.screenHeight * 0.90)]

public enum drawerType {
Expand All @@ -19,7 +18,7 @@ public enum drawerType {
case high
}

extension UIScreen{
extension UIScreen {
static let screenWidth = UIScreen.main.bounds.size.width
static let screenHeight = UIScreen.main.bounds.size.height
}
6 changes: 2 additions & 4 deletions CVAG/Models/Favorites.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import SwiftUI

class FavoritesModel: ObservableObject {
@AppStorage("favoriteStops") var favorites = FavoriteStops()
@Published var currentFavorite: Stop?

// Load example data on first run
init() {
Expand All @@ -17,10 +19,6 @@ class FavoritesModel: ObservableObject {
}
}

@AppStorage("favoriteStops") var favorites = FavoriteStops()

@Published var currentFavorite: Stop?

private var exampleFavorites: [Stop] = [
Stop(id: 131, name: "Zentralhaltestelle", latitude: 50.8327427033286, longitude: 12.9213850148795),
Stop(id: 216, name: "TU Campus", latitude: 50.8134653801663, longitude: 12.931050887338),
Expand Down
9 changes: 4 additions & 5 deletions CVAG/Stores/DeparturesLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import Foundation

class DeparturesLoader: ObservableObject {
@Published var departures = [Departure]()
@Published var loadingError: Bool = false
@Published var noDepartures: Bool = false
final class DeparturesLoader: ObservableObject {
@Published private(set) var departures = [Departure]()
@Published private(set) var loadingError: Bool = false
@Published private(set) var noDepartures: Bool = false

func loadData(id: Int16) {
// Skip if using placeholder id
Expand Down Expand Up @@ -44,7 +44,6 @@ class DeparturesLoader: ObservableObject {
}
}
} catch {
print("Error")
print(error)
DispatchQueue.main.async {
self.loadingError = true
Expand Down
15 changes: 7 additions & 8 deletions CVAG/Stores/StopLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@
import Foundation

class StopLoader: ObservableObject {
@Published var stops = [Stop]()
@Published private(set) var stops = [Stop]()

init(){
init() {
loadData()
}

func loadData() {
guard let url = Bundle.main.url(forResource: "Stops", withExtension: "json")
else {
print("JSON file not found")
return
}
func loadData() {
guard let url = Bundle.main.url(forResource: "Stops", withExtension: "json") else {
print("JSON file not found")
return
}

let data = try? Data(contentsOf: url)
let stops = try? JSONDecoder().decode([Stop].self, from: data!)
Expand Down
15 changes: 7 additions & 8 deletions CVAG/Views/DepartureCellView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ struct DepartureCellView: View {

var body: some View {
let absoluteTime: String = getAbsoluteTime(actualDeparture: departure.actualDeparture)

let relativeTime: String = getRelativeTime(actualDeparture: departure.actualDeparture)

HStack {
Expand All @@ -29,7 +28,7 @@ struct DepartureCellView: View {
.foregroundColor(Color(red: 0.44, green: 0.1, blue: 0.38))
Image(systemName: "bus.fill")
.font(.headline)
.foregroundColor(Color(.systemBackground))
.foregroundColor(.white)
}
case serviceType.bahn:
ZStack {
Expand All @@ -38,7 +37,7 @@ struct DepartureCellView: View {
.foregroundColor(Color(red: 0.12, green: 0.55, blue: 0.25))
Image(systemName: "tram.fill")
.font(.headline)
.foregroundColor(Color(.systemBackground))
.foregroundColor(.white)
}
case serviceType.tram:
ZStack {
Expand All @@ -47,7 +46,7 @@ struct DepartureCellView: View {
.foregroundColor(Color(red: 0.80, green: 0.07, blue: 0.09))
Image(systemName: "tram.fill")
.font(.headline)
.foregroundColor(Color(.systemBackground))
.foregroundColor(.white)
}
case serviceType.ev:
ZStack {
Expand All @@ -56,7 +55,7 @@ struct DepartureCellView: View {
.foregroundColor(Color(red: 0.93, green: 0.45, blue: 0.01))
Image(systemName: "bus.fill")
.font(.headline)
.foregroundColor(Color(.systemBackground))
.foregroundColor(.white)
}
}
} else {
Expand All @@ -66,7 +65,7 @@ struct DepartureCellView: View {
.foregroundColor(Color(red: 0.80, green: 0.07, blue: 0.09))
Image(systemName: "questionmark")
.font(.headline)
.foregroundColor(Color(.systemBackground))
.foregroundColor(.white)
}
}

Expand Down Expand Up @@ -99,7 +98,7 @@ struct DepartureCellView: View {
}
}

func getAbsoluteTime (actualDeparture: Int) -> String {
func getAbsoluteTime(actualDeparture: Int) -> String {
let date = NSDate(timeIntervalSince1970: Double(actualDeparture/1000))
let calendar = Calendar.current
let hour = calendar.component(.hour, from: date as Date)
Expand All @@ -111,7 +110,7 @@ func getAbsoluteTime (actualDeparture: Int) -> String {
}
}

func getRelativeTime (actualDeparture: Int) -> String {
func getRelativeTime(actualDeparture: Int) -> String {
let date = NSDate(timeIntervalSince1970: Double(actualDeparture/1000))
let currentDate = NSDate.now
let difference = Calendar.current.dateComponents([.minute], from: currentDate, to: date as Date)
Expand Down
4 changes: 2 additions & 2 deletions CVAG/Views/DrawerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SwiftUI
import Drawer
import Introspect

struct DrawerView: View {
struct DrawerView: View, Sendable {

@Binding var selectedStop: Stop
@StateObject var departuresList = DeparturesLoader()
Expand Down Expand Up @@ -76,7 +76,7 @@ struct DrawerView: View {
Drawer(){
ZStack {

RoundedRectangle(cornerRadius: 50.0)
RoundedRectangle(cornerRadius: UIScreen.main.displayCornerRadius, style: .continuous)
.foregroundColor(Color(.systemBackground))
.shadow(radius: 25)

Expand Down
10 changes: 5 additions & 5 deletions CVAG/Views/FavoriteAddButtonView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
import SwiftUI

struct FavoriteAddButtonView: View {

@StateObject var favoritesData = FavoritesModel()
@State var isFavorite: Bool = false
var stop: Stop
var impactGenerator: UIImpactFeedbackGenerator = UIImpactFeedbackGenerator(style: .medium)
@State var isFavorite: Bool = false
@StateObject var favoritesData = FavoritesModel()

var body: some View {

Expand Down Expand Up @@ -41,8 +40,9 @@ struct FavoriteAddButtonView: View {
.font(.system(size: 16, weight: .medium, design: .rounded))
}

}.padding(.horizontal, 20)
.padding(.vertical, 5)
}
.padding(.horizontal, 20)
.padding(.vertical, 5)
}
.foregroundColor(Color(.systemBackground))
.padding()
Expand Down
1 change: 0 additions & 1 deletion CVAG/Views/FavoriteButtonView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import SwiftUI
import AVKit

struct FavoriteButtonView: View {
var stop: Stop
Expand Down
6 changes: 1 addition & 5 deletions CVAG/Views/FavoritesDrawerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import SwiftUI
import Drawer
import Introspect

struct FavoritesDrawerView: View {

Expand All @@ -23,16 +22,13 @@ struct FavoritesDrawerView: View {
var impactGenerator: UIImpactFeedbackGenerator = UIImpactFeedbackGenerator(style: .medium)
var dislodgeGenerator: UIImpactFeedbackGenerator = UIImpactFeedbackGenerator(style: .light)

//Workaround
@State var showGrid: Bool = true

let columns: [GridItem] = Array(repeating: .init(.flexible()), count: 2)

var body: some View {
Drawer(){
ZStack {

RoundedRectangle(cornerRadius: 50.0)
RoundedRectangle(cornerRadius: UIScreen.main.displayCornerRadius, style: .continuous)
.foregroundColor(Color(.systemBackground))
.shadow(radius: 25)

Expand Down

0 comments on commit ea12e3a

Please sign in to comment.