-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
200 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
22
app/Common/Components/MetroDeparture/SecondDeparture.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.