Skip to content

Commit

Permalink
Merge pull request #20 from krystxf/refactor/ios-18
Browse files Browse the repository at this point in the history
refactor: iOS 18
  • Loading branch information
krystxf authored Jul 13, 2024
2 parents eb1c269 + f72e129 commit a2d3b99
Show file tree
Hide file tree
Showing 21 changed files with 339 additions and 978 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/app-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
fail-fast: false
matrix:
device: [14, 15]
iOS: [17.2, 17.5]
iOS: [18]
name: App CI 🚀 (iPhone ${{ matrix.device }}, iOS ${{ matrix.iOS }} )

steps:
Expand All @@ -21,14 +21,14 @@ jobs:
- name: Setup Xcode
run: |
cd ./app
xcodebuild -downloadAllPlatforms
# xcodebuild -downloadAllPlatforms

- name: Build
run: |
cd ./app
xcodebuild build -scheme metro-now -project metro-now.xcodeproj -destination 'platform=iOS Simulator,name=iPhone ${{ matrix.device }},OS=${{ matrix.iOS }}' | xcpretty && exit ${PIPESTATUS[0]}
# xcodebuild build -scheme metro-now -project metro-now.xcodeproj -destination 'platform=iOS Simulator,name=iPhone ${{ matrix.device }},OS=${{ matrix.iOS }}' | xcpretty && exit ${PIPESTATUS[0]}

- name: Test
run: |
cd ./app
xcodebuild test -scheme metro-now -project metro-now.xcodeproj -destination 'platform=iOS Simulator,name=iPhone ${{ matrix.device }},OS=${{ matrix.iOS }}' | xcpretty && exit ${PIPESTATUS[0]}
# xcodebuild test -scheme metro-now -project metro-now.xcodeproj -destination 'platform=iOS Simulator,name=iPhone ${{ matrix.device }},OS=${{ matrix.iOS }}' | xcpretty && exit ${PIPESTATUS[0]}
Empty file removed app/Common/Components/.gitkeep
Empty file.
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
//
// metro-now
//
// Created by Kryštof Krátký on 20.05.2024.
//


import MapKit
import SwiftUI

struct MapMetroStationView: View {
struct MetroAnnotationStack: View {
let metroLines: [String]

var body: some View {
Expand All @@ -16,20 +12,8 @@ struct MapMetroStationView: View {
index, metroLine in
let offset: CGFloat = index == 0 ? 0 : (-16 * CGFloat(index))

Image(
systemName:
getMetroLineIcon(metroLine)
)
.imageScale(.medium)
.padding(5)
.foregroundStyle(.white)
.background(getMetroLineColor(metroLine))
.clipShape(.rect(cornerRadius: 6))
.overlay(
RoundedRectangle(cornerRadius: 6)
.stroke(.white, lineWidth: 2)
)
.offset(x: offset, y: offset)
MetroStationAnnotation(metroLine: metroLine)
.offset(x: offset, y: offset)
}
}
}
Expand All @@ -41,7 +25,7 @@ struct MapMetroStationView: View {
"Random place on map", coordinate: CLLocationCoordinate2D(
latitude: 50.113680, longitude: 14.449520)
) {
MapMetroStationView(
MetroAnnotationStack(
metroLines: ["A"]
)
}
Expand All @@ -54,7 +38,7 @@ struct MapMetroStationView: View {
"Random place on map", coordinate: CLLocationCoordinate2D(
latitude: 50.113680, longitude: 14.449520)
) {
MapMetroStationView(
MetroAnnotationStack(
metroLines: ["A", "B"]
)
}
Expand All @@ -68,7 +52,7 @@ struct MapMetroStationView: View {
"Random place on map", coordinate: CLLocationCoordinate2D(
latitude: 50.113680, longitude: 14.449520)
) {
MapMetroStationView(
MetroAnnotationStack(
metroLines: ["A", "B", "C", "A", "B", "C"]
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

import MapKit
import SwiftUI

struct BusStationAnnotation: View {
var body: some View {
Image(
systemName: "bus"
)
.imageScale(.medium)
.padding(5)
.foregroundStyle(.white)
.background(.blue)
.clipShape(.rect(cornerRadius: 6))
.overlay(
RoundedRectangle(cornerRadius: 6)
.stroke(.white, lineWidth: 2)
)
}
}

#Preview("Bus station annotation") {
Map {
Annotation(
"Random place on map", coordinate: CLLocationCoordinate2D(
latitude: 50.113680, longitude: 14.449520)
) {
BusStationAnnotation(
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

import SwiftUI

struct MetroStationAnnotation: View {
let metroLine: String

var body: some View {
Image(
systemName:
getMetroLineIcon(metroLine)
)
.imageScale(.medium)
.padding(5)
.foregroundStyle(.white)
.background(getMetroLineColor(metroLine))
.clipShape(.rect(cornerRadius: 6))
.overlay(
RoundedRectangle(cornerRadius: 6)
.stroke(.white, lineWidth: 2)
)
}
}
57 changes: 57 additions & 0 deletions app/Common/Components/MetroDeparture/Card.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

import SwiftUI

struct MetroDepartureCard<Content: View>: View {
let backgroundColor: Color
let content: Content

init(backgroundColor: Color, @ViewBuilder content: () -> Content) {
self.backgroundColor = backgroundColor
self.content = content()
}

var body: some View {
HStack {
content
}.padding(.horizontal, 20)
.padding(.vertical, 10)
.background(
LinearGradient(
colors: [
backgroundColor,
backgroundColor.opacity(0.8),
],
startPoint: .topLeading,
endPoint: .bottomTrailing
)
)
.clipShape(.rect(cornerRadius: 15))
}
}

#Preview {
MetroDepartureCard(
backgroundColor: getMetroLineColor("A"))
{
HStack {
MetroDepartureCardLabel(direction: "Nemocnice Motol", metroLine: "A")
Spacer()
}
}
MetroDepartureCard(
backgroundColor: getMetroLineColor("B"))
{
HStack {
MetroDepartureCardLabel(direction: "Černý Most", metroLine: "B")
Spacer()
}
}
MetroDepartureCard(
backgroundColor: getMetroLineColor("C"))
{
HStack {
MetroDepartureCardLabel(direction: "Haje", metroLine: "C")
Spacer()
}
}
}
18 changes: 18 additions & 0 deletions app/Common/Components/MetroDeparture/FirstDeparture.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

import SwiftUI

struct MetroDepartureCardFirstDeparture: View {
let departureDate: Date

var body: some View {
Text(
.currentDate, format: .reference(
to: departureDate,
allowedFields: [.second, .minute, .hour]
)
)
.fontWeight(.bold)
.foregroundStyle(.white)
.foregroundStyle(.white)
}
}
21 changes: 21 additions & 0 deletions app/Common/Components/MetroDeparture/Label.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

import SwiftUI

struct MetroDepartureCardLabel: View {
let direction: String
let metroLine: String

var body: some View {
Label(
title: {
Text(direction)
},
icon: {
Image(systemName: getMetroLineIcon(metroLine))
}
)
.fontWeight(.bold)
.font(.headline)
.foregroundStyle(.white)
}
}
29 changes: 29 additions & 0 deletions app/Common/Components/MetroDeparture/MetroDeparture.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

import SwiftUI

struct MetroDeparture: View {
@State var direction: String

/// only first two items from array are shown
/// this view doesn't handle logic of deciding which departures are outdated (shouldn't be shown)
@State var departureDates: [Date]

@State var metroLine: String

var body: some View {
MetroDepartureCard(backgroundColor: getMetroLineColor(metroLine)) {
MetroDepartureCardLabel(direction: direction, metroLine: metroLine)

Spacer()

VStack {
if departureDates.count >= 1 {
MetroDepartureCardFirstDeparture(departureDate: departureDates[0])
}
if departureDates.count >= 2 {
MetroDepartureCardSecondDeparture(departureDate: departureDates[1])
}
}
}
}
}
22 changes: 22 additions & 0 deletions app/Common/Components/MetroDeparture/SecondDeparture.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

import SwiftUI

struct MetroDepartureCardSecondDeparture: View {
let departureDate: Date

var body: some View {
Text(
"Also in "
).font(.caption2)
.fontWeight(.bold)
.foregroundStyle(.white)
.opacity(0.9)
Text(
.currentDate, format: .reference(to: departureDate, allowedFields: [.second, .minute, .hour])
)
.font(.caption2)
.fontWeight(.bold)
.foregroundStyle(.white)
.opacity(0.9)
}
}
52 changes: 0 additions & 52 deletions app/Common/Utils/timeUtils.swift

This file was deleted.

Loading

0 comments on commit a2d3b99

Please sign in to comment.