Skip to content

Instantly share code, notes, and snippets.

@krzyzanowskim
Created June 16, 2025 08:07
Show Gist options
  • Save krzyzanowskim/e1b57dee5bad536e47edf8d10337bf99 to your computer and use it in GitHub Desktop.
Save krzyzanowskim/e1b57dee5bad536e47edf8d10337bf99 to your computer and use it in GitHub Desktop.
import SwiftUI
@main
struct TravelPhotographyApp: App {
var body: some Scene {
WindowGroup {
RootView()
}
.commands {
TextEditingCommands()
}
}
}
struct RootView: View {
var body: some View {
TabView {
Tab("Trips", systemImage: "map") {
TripDetailView()
}
Tab("Planner", systemImage: "calendar") {
PlannerSplitView()
}
Tab("Inspector", systemImage: "location") {
InspectorView()
}
Tab("Health", systemImage: "heart") {
HealthTabView()
}
Tab("Settings", systemImage: "gear") {
SettingsTabView()
}
}
}
}
// MARK: - Trip Detail Views
struct TripDetailView: View {
var body: some View {
NavigationStack {
ZStack(alignment: .bottomTrailing) {
TripList()
ToTopButton()
}
.toolbar {
ToolbarItemGroup(placement: .primaryAction) {
UpButton()
DownButton()
}
ToolbarItem(placement: .primaryAction) {
SettingsButton()
}
}
}
}
}
struct TripList: View {
var body: some View {
ScrollView {
LazyVStack(spacing: 16) {
ForEach(1...20, id: \.self) { index in
VStack(alignment: .leading, spacing: 8) {
Text("Trip \(index)")
.font(.headline)
Text("Sample trip description for trip number \(index)")
.font(.caption)
.foregroundStyle(.secondary)
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding()
.background(.regularMaterial, in: RoundedRectangle(cornerRadius: 8))
}
}
.padding()
}
.navigationTitle("Trips")
}
}
struct UpButton: View {
var body: some View {
Button("Up", systemImage: "chevron.up") {
// Handle up action
}
}
}
struct DownButton: View {
var body: some View {
Button("Down", systemImage: "chevron.down") {
// Handle down action
}
}
}
struct SettingsButton: View {
var body: some View {
Button("List Settings", systemImage: "ellipsis") {
// Handle settings action
}
}
}
// MARK: - Inspector Views
struct InspectorView: View {
var body: some View {
NavigationStack {
InspectorMap()
.toolbar {
ToolbarItem(placement: .primaryAction) {
SaveLocationButton()
.buttonStyle(.borderedProminent)
.tint(.pink)
}
}
}
}
}
struct InspectorMap: View {
var body: some View {
VStack {
Image(systemName: "map")
.font(.system(size: 100))
.foregroundStyle(.blue)
Text("InspectorMap")
.font(.title2)
.padding()
Text("Map view would be displayed here")
.foregroundStyle(.secondary)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(.regularMaterial)
.navigationTitle("Inspector")
}
}
struct SaveLocationButton: View {
var body: some View {
Button("Save Location") {
// Handle save location
}
}
}
// MARK: - Planner Views
struct PlannerSplitView: View {
@State private var query: String = ""
var body: some View {
NavigationSplitView {
List {
ForEach(1...10, id: \.self) { index in
NavigationLink("Location \(index)") {
Text("Detail for Location \(index)")
}
}
}
.navigationTitle("Locations")
} detail: {
VStack {
Image(systemName: "calendar")
.font(.system(size: 80))
.foregroundStyle(.green)
Text("Planner Detail")
.font(.title2)
Text("Select a location from the sidebar")
.foregroundStyle(.secondary)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(.regularMaterial)
}
.searchable(
text: $query,
prompt: "What are you looking for?"
)
}
}
// MARK: - Health Views
struct HealthTabView: View {
@State private var text: String = ""
var body: some View {
TabView {
Tab("Summary", systemImage: "heart") {
NavigationStack {
VStack {
Image(systemName: "heart.fill")
.font(.system(size: 60))
.foregroundStyle(.red)
Text("Health Summary")
.font(.title2)
.padding()
Text("Your health data summary would appear here")
.foregroundStyle(.secondary)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(.regularMaterial)
.navigationTitle("Summary")
}
}
Tab("Sharing", systemImage: "person.2") {
NavigationStack {
VStack {
Image(systemName: "person.2.fill")
.font(.system(size: 60))
.foregroundStyle(.blue)
Text("Health Sharing")
.font(.title2)
.padding()
Text("Manage your health data sharing settings")
.foregroundStyle(.secondary)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(.regularMaterial)
.navigationTitle("Sharing")
}
}
Tab(role: .search) {
NavigationStack {
VStack {
Image(systemName: "magnifyingglass")
.font(.system(size: 60))
.foregroundStyle(.purple)
Text("Health Search")
.font(.title2)
.padding()
Text("Search your health data")
.foregroundStyle(.secondary)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(.regularMaterial)
.navigationTitle("Search")
}
}
}
.searchable(text: $text)
}
}
// MARK: - Settings Views
struct SettingsTabView: View {
@State private var selection: SectionTab = .general
var body: some View {
TabView(selection: $selection.animation()) {
Tab("General", systemImage: "gear", value: .general) {
NavigationStack {
Form {
Section("App Settings") {
Toggle("Enable Notifications", isOn: .constant(true))
Toggle("Dark Mode", isOn: .constant(false))
Toggle("Location Services", isOn: .constant(true))
}
Section("Privacy") {
Button("Reset All Settings") {
// Handle reset
}
.foregroundStyle(.red)
}
}
.navigationTitle("General")
}
}
Tab("Sections", systemImage: "list.bullet", value: .sections) {
NavigationStack {
List {
Section("Visible Sections") {
Toggle("Trips", isOn: .constant(true))
Toggle("Health Data", isOn: .constant(true))
Toggle("Photos", isOn: .constant(false))
}
Section("Section Order") {
Text("Drag to reorder sections")
.foregroundStyle(.secondary)
}
}
.navigationTitle("Sections")
}
}
}
}
}
enum SectionTab: Hashable {
case general
case sections
}
// MARK: - Utility Views
struct ToTopButton: View {
var body: some View {
Button("To Top", systemImage: "chevron.up") {
scrollToTop()
}
.padding()
.glassEffect()
}
func scrollToTop() {
// Scroll to top of view implementation would go here
print("Scrolling to top...")
}
}
// MARK: - View Extensions
extension View {
func glassEffect() -> some View {
self
.background(.ultraThinMaterial, in: Circle())
.shadow(radius: 4)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment