diff --git a/tg_test.xcodeproj/project.pbxproj b/tg_test.xcodeproj/project.pbxproj index d6960dc..1484002 100644 --- a/tg_test.xcodeproj/project.pbxproj +++ b/tg_test.xcodeproj/project.pbxproj @@ -241,6 +241,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = TS8C84TZ9K; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; @@ -272,6 +273,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = TS8C84TZ9K; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; diff --git a/tg_test.xcodeproj/xcuserdata/chenyicheng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/tg_test.xcodeproj/xcuserdata/chenyicheng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..c79ad7d --- /dev/null +++ b/tg_test.xcodeproj/xcuserdata/chenyicheng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,21 @@ + + + + + + + + + + + diff --git a/tg_test/ContentView.swift b/tg_test/ContentView.swift index 0c13463..978bae5 100644 --- a/tg_test/ContentView.swift +++ b/tg_test/ContentView.swift @@ -9,13 +9,27 @@ import SwiftUI struct ContentView: View { var body: some View { - VStack { - Image(systemName: "globe") - .imageScale(.large) - .foregroundStyle(.tint) - Text("Hello, world!") + TabView { + HomeView() + .tabItem { + Label("Home", systemImage: "house.fill") + } + + SearchView() + .tabItem { + Label("Search", systemImage: "magnifyingglass") + } + + NotificationsView() + .tabItem { + Label("Notifications", systemImage: "bell.fill") + } + + ProfileView() + .tabItem { + Label("Profile", systemImage: "person.fill") + } } - .padding() } } diff --git a/tg_test/HomeView.swift b/tg_test/HomeView.swift new file mode 100644 index 0000000..18b312b --- /dev/null +++ b/tg_test/HomeView.swift @@ -0,0 +1,74 @@ +// +// HomeView.swift +// tg_test +// + +import SwiftUI + +struct HomeView: View { + private let sampleItems = [ + "Getting Started with SwiftUI", + "Understanding NavigationStack", + "Building Tab Bars", + "Customizing UI Components" + ] + + var body: some View { + NavigationStack { + List { + Section { + VStack(alignment: .leading, spacing: 8) { + Text("Welcome to iOS Dev! 🚀") + .font(.title2) + .bold() + Text("This is your Home Tab. Explore how lists and navigation links work below.") + .font(.subheadline) + .foregroundStyle(.secondary) + } + .padding(.vertical, 8) + } + + Section("Tutorial Highlights") { + ForEach(sampleItems, id: \.self) { item in + NavigationLink(destination: DetailView(title: item)) { + Label(item, systemImage: "book.fill") + } + } + } + } + .navigationTitle("Home") + } + } +} + +struct DetailView: View { + let title: String + + var body: some View { + VStack(spacing: 16) { + Image(systemName: "doc.text.fill") + .font(.system(size: 60)) + .foregroundStyle(.blue) + + Text(title) + .font(.title2) + .bold() + .multilineTextAlignment(.center) + + Text("This is a detail view demonstrating push navigation inside SwiftUI's NavigationStack.") + .font(.body) + .foregroundStyle(.secondary) + .multilineTextAlignment(.center) + .padding(.horizontal) + + Spacer() + } + .padding() + .navigationTitle("Detail") + .navigationBarTitleDisplayMode(.inline) + } +} + +#Preview { + HomeView() +} diff --git a/tg_test/NotificationsView.swift b/tg_test/NotificationsView.swift new file mode 100644 index 0000000..b91f0d4 --- /dev/null +++ b/tg_test/NotificationsView.swift @@ -0,0 +1,56 @@ +// +// NotificationsView.swift +// tg_test +// + +import SwiftUI + +struct AppNotification: Identifiable { + let id = UUID() + let title: String + let message: String + let time: String + let icon: String +} + +struct NotificationsView: View { + private let notifications: [AppNotification] = [ + AppNotification(title: "Welcome aboard!", message: "Thanks for starting your iOS development journey.", time: "2m ago", icon: "sparkles"), + AppNotification(title: "Build Successful", message: "Your tab navigation app built with 0 errors.", time: "1h ago", icon: "checkmark.circle.fill"), + AppNotification(title: "New SwiftUI Feature", message: "Check out the latest navigation features.", time: "1d ago", icon: "star.fill") + ] + + var body: some View { + NavigationStack { + List(notifications) { item in + HStack(alignment: .top, spacing: 12) { + Image(systemName: item.icon) + .font(.title2) + .foregroundStyle(.blue) + .frame(width: 32) + + VStack(alignment: .leading, spacing: 4) { + HStack { + Text(item.title) + .font(.headline) + Spacer() + Text(item.time) + .font(.caption) + .foregroundStyle(.secondary) + } + + Text(item.message) + .font(.subheadline) + .foregroundStyle(.secondary) + } + } + .padding(.vertical, 4) + } + .navigationTitle("Notifications") + } + } +} + +#Preview { + NotificationsView() +} diff --git a/tg_test/ProfileView.swift b/tg_test/ProfileView.swift new file mode 100644 index 0000000..39767f9 --- /dev/null +++ b/tg_test/ProfileView.swift @@ -0,0 +1,60 @@ +// +// ProfileView.swift +// tg_test +// + +import SwiftUI + +struct ProfileView: View { + @State private var notificationsEnabled = true + @State private var darkModeEnabled = false + + var body: some View { + NavigationStack { + List { + Section { + HStack(spacing: 16) { + Image(systemName: "person.crop.circle.fill") + .font(.system(size: 60)) + .foregroundStyle(.blue) + + VStack(alignment: .leading, spacing: 4) { + Text("iOS Developer") + .font(.title3) + .bold() + Text("developer@example.com") + .font(.subheadline) + .foregroundStyle(.secondary) + } + } + .padding(.vertical, 8) + } + + Section("Preferences") { + Toggle("Enable Notifications", isOn: $notificationsEnabled) + Toggle("Dark Mode", isOn: $darkModeEnabled) + } + + Section("App Information") { + HStack { + Text("Version") + Spacer() + Text("1.0.0") + .foregroundStyle(.secondary) + } + HStack { + Text("Framework") + Spacer() + Text("SwiftUI") + .foregroundStyle(.secondary) + } + } + } + .navigationTitle("Profile") + } + } +} + +#Preview { + ProfileView() +} diff --git a/tg_test/SearchView.swift b/tg_test/SearchView.swift new file mode 100644 index 0000000..c1b88f5 --- /dev/null +++ b/tg_test/SearchView.swift @@ -0,0 +1,56 @@ +// +// SearchView.swift +// tg_test +// + +import SwiftUI + +struct SearchView: View { + @State private var searchText = "" + private let categories = ["SwiftUI", "Xcode", "iOS 18", "Design", "Swift", "Animations"] + + var filteredCategories: [String] { + if searchText.isEmpty { + return categories + } else { + return categories.filter { $0.localizedCaseInsensitiveContains(searchText) } + } + } + + var body: some View { + NavigationStack { + ScrollView { + VStack(alignment: .leading, spacing: 16) { + Text("Browse Categories") + .font(.headline) + .padding(.horizontal) + + LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible())], spacing: 12) { + ForEach(filteredCategories, id: \.self) { category in + VStack { + Image(systemName: "folder.fill") + .font(.largeTitle) + .foregroundStyle(.blue) + Text(category) + .font(.callout) + .bold() + } + .frame(maxWidth: .infinity) + .padding() + .background(Color(.secondarySystemBackground)) + .clipShape(RoundedRectangle(cornerRadius: 12)) + } + } + .padding(.horizontal) + } + .padding(.top) + } + .navigationTitle("Search") + .searchable(text: $searchText, prompt: "Search topics...") + } + } +} + +#Preview { + SearchView() +}