-
-
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
30 changed files
with
1,345 additions
and
10 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
apps/mobile/metro-now/metro-now Mac App/Assets.xcassets/AccentColor.colorset/Contents.json
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,11 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
apps/mobile/metro-now/metro-now Mac App/Assets.xcassets/AppIcon.appiconset/Contents.json
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,59 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "16x16" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "16x16" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "32x32" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "32x32" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "128x128" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "128x128" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "256x256" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "256x256" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "512x512" | ||
}, | ||
{ | ||
"filename" : "icon-1024x1024.png", | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "512x512" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+744 KB
...tro-now/metro-now Mac App/Assets.xcassets/AppIcon.appiconset/icon-1024x1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions
6
apps/mobile/metro-now/metro-now Mac App/Assets.xcassets/Contents.json
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,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
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,74 @@ | ||
// metro-now | ||
// https://github.com/krystxf/metro-now | ||
|
||
import SwiftUI | ||
|
||
struct ContentView: View { | ||
@StateObject private var networkMonitor = NetworkMonitor() | ||
@State private var showNoInternetBanner = false | ||
|
||
@AppStorage( | ||
AppStorageKeys.hasSeenWelcomeScreen.rawValue | ||
) var hasSeenWelcomeScreen = false | ||
@State private var showWelcomeScreen: Bool = false | ||
|
||
var body: some View { | ||
ZStack { | ||
NavigationStack { | ||
ClosestStopPageView() | ||
.toolbar { | ||
// ToolbarItem(placement: .topBarLeading) { | ||
// NavigationLink { | ||
// SettingsPageView() | ||
// } label: { | ||
// Label("Settings", systemImage: "gearshape") | ||
// } | ||
// } | ||
// ToolbarItem(placement: .topBarTrailing) { | ||
// NavigationLink { | ||
// SettingsPageView() | ||
// } label: { | ||
// Label("Search", systemImage: "magnifyingglass") | ||
// } | ||
// } | ||
} | ||
} | ||
.sheet( | ||
isPresented: $showWelcomeScreen, | ||
onDismiss: dismissWelcomeScreen | ||
) { | ||
WelcomePageView(handleDismiss: dismissWelcomeScreen) | ||
.presentationDetents([.medium]) | ||
} | ||
|
||
VStack { | ||
Spacer() | ||
if showNoInternetBanner { | ||
NoInternetBannerView() | ||
.transition(getBannerTransition(.bottom)) | ||
} | ||
} | ||
} | ||
.onAppear { | ||
showWelcomeScreen = !hasSeenWelcomeScreen | ||
} | ||
.onReceive(networkMonitor.$isConnected) { isConnected in | ||
setShowNoInternetBanner(!isConnected) | ||
} | ||
} | ||
|
||
private func setShowNoInternetBanner(_ value: Bool) { | ||
withAnimation { | ||
showNoInternetBanner = value | ||
} | ||
} | ||
|
||
private func dismissWelcomeScreen() { | ||
showWelcomeScreen = false | ||
hasSeenWelcomeScreen = true | ||
} | ||
} | ||
|
||
#Preview { | ||
ContentView() | ||
} |
6 changes: 6 additions & 0 deletions
6
.../mobile/metro-now/metro-now Mac App/Preview Content/Preview Assets.xcassets/Contents.json
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,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
apps/mobile/metro-now/metro-now Mac App/components/banner/banner.utils.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,10 @@ | ||
// metro-now | ||
// https://github.com/krystxf/metro-now | ||
|
||
import SwiftUI | ||
|
||
func getBannerTransition(_ edge: Edge) -> some Transition { | ||
MoveTransition | ||
.move(edge: edge) | ||
.combined(with: .opacity) | ||
} |
49 changes: 49 additions & 0 deletions
49
apps/mobile/metro-now/metro-now Mac App/components/banner/banner.view.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,49 @@ | ||
// metro-now | ||
// https://github.com/krystxf/metro-now | ||
|
||
import SwiftUI | ||
|
||
struct BannerView: View { | ||
let label: String | ||
let systemImage: String | ||
let color: Color | ||
|
||
init( | ||
label: String, | ||
systemImage: String, | ||
color: Color? = nil | ||
) { | ||
self.label = label | ||
self.systemImage = systemImage | ||
self.color = color?.opacity(0.5) ?? Color.accentColor.opacity(0) | ||
} | ||
|
||
var body: some View { | ||
Label(label, systemImage: systemImage) | ||
.font(.footnote.bold()) | ||
.frame(maxWidth: .infinity) | ||
.padding(.vertical, 8) | ||
.background(color) | ||
.background( | ||
.ultraThinMaterial, | ||
in: RoundedRectangle(cornerRadius: 10) | ||
) | ||
.padding() | ||
} | ||
} | ||
|
||
#Preview { | ||
VStack { | ||
Spacer() | ||
BannerView( | ||
label: "No Internet Connection", | ||
systemImage: "antenna.radiowaves.left.and.right.slash", | ||
color: .red | ||
) | ||
|
||
BannerView( | ||
label: "Tips and tricks", | ||
systemImage: "info.circle" | ||
) | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
apps/mobile/metro-now/metro-now Mac App/components/banner/no-internet-banner.view.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,19 @@ | ||
// metro-now | ||
// https://github.com/krystxf/metro-now | ||
|
||
import SwiftUI | ||
|
||
struct NoInternetBannerView: View { | ||
var body: some View { | ||
BannerView( | ||
label: "No Internet Connection", | ||
systemImage: "antenna.radiowaves.left.and.right.slash", | ||
color: .red | ||
) | ||
} | ||
} | ||
|
||
#Preview { | ||
NoInternetBannerView() | ||
Spacer() | ||
} |
99 changes: 99 additions & 0 deletions
99
...tro-now Mac App/components/departure-list-item/departure-list-item-placeholder.view.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,99 @@ | ||
// metro-now | ||
// https://github.com/krystxf/metro-now | ||
|
||
import SwiftUI | ||
|
||
struct ClosestStopPageListItemPlaceholderView: View { | ||
let routeLabel: String? // route label will be blured if not specified | ||
let routeLabelBackground: Color | ||
|
||
init( | ||
routeLabel: String? = nil, | ||
routeLabelBackground: Color = .gray | ||
) { | ||
self.routeLabel = routeLabel | ||
self.routeLabelBackground = routeLabelBackground | ||
} | ||
|
||
var body: some View { | ||
if let routeLabel { | ||
HStack( | ||
alignment: .top, | ||
spacing: 8 | ||
) { | ||
RouteNameIconView( | ||
label: routeLabel, | ||
background: routeLabelBackground | ||
) | ||
|
||
VStack(alignment: .trailing, spacing: 4) { | ||
HStack { | ||
Text("Loading...") | ||
Spacer() | ||
CountdownView(targetDate: .now + 10 * 60) | ||
} | ||
|
||
HStack { | ||
Spacer() | ||
CountdownView( | ||
targetDate: .now + 15 * 60 | ||
) { | ||
"Also in \($0)" | ||
} | ||
} | ||
.foregroundStyle(.secondary) | ||
.font(.footnote) | ||
} | ||
.fontWeight(.semibold) | ||
.redacted(reason: .placeholder) | ||
} | ||
} else { | ||
ClosestStopPageListItemView( | ||
routeLabel: "74", | ||
routeLabelBackground: routeLabelBackground, | ||
headsign: "Loading...", | ||
departure: .now + 10 * 60, | ||
nextHeadsign: "Loading...", | ||
nextDeparture: .now + 15 * 60 | ||
) | ||
.redacted(reason: .placeholder) | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
List { | ||
ClosestStopPageListItemPlaceholderView( | ||
routeLabel: "A", | ||
routeLabelBackground: getRouteColor("A") | ||
) | ||
ClosestStopPageListItemPlaceholderView( | ||
routeLabel: "A", | ||
routeLabelBackground: getRouteColor("A") | ||
) | ||
ClosestStopPageListItemPlaceholderView( | ||
routeLabel: "C", | ||
routeLabelBackground: getRouteColor("C") | ||
) | ||
ClosestStopPageListItemPlaceholderView( | ||
routeLabel: "C", | ||
routeLabelBackground: getRouteColor("C") | ||
) | ||
ClosestStopPageListItemPlaceholderView( | ||
routeLabel: nil, | ||
routeLabelBackground: getRouteColor("49") | ||
) | ||
ClosestStopPageListItemPlaceholderView( | ||
routeLabel: nil, | ||
routeLabelBackground: getRouteColor("149") | ||
) | ||
ClosestStopPageListItemPlaceholderView( | ||
routeLabel: nil, | ||
routeLabelBackground: getRouteColor("P2") | ||
) | ||
ClosestStopPageListItemPlaceholderView( | ||
routeLabel: nil, | ||
routeLabelBackground: getRouteColor("LD") | ||
) | ||
} | ||
} |
Oops, something went wrong.