add basic nav bar
This commit is contained in:
parent
2eada97489
commit
62632ad8d6
7 changed files with 289 additions and 6 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Bucket
|
||||
uuid = "15409E4D-CAD3-4F4A-966E-BCD436D02E27"
|
||||
type = "1"
|
||||
version = "2.0">
|
||||
<Breakpoints>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.SymbolicBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "0FA65527-3D03-4E13-8178-2FD8EE7ED3FD"
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
symbolName = ""
|
||||
moduleName = "">
|
||||
<Locations>
|
||||
</Locations>
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
</Breakpoints>
|
||||
</Bucket>
|
||||
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
74
tg_test/HomeView.swift
Normal file
74
tg_test/HomeView.swift
Normal file
|
|
@ -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()
|
||||
}
|
||||
56
tg_test/NotificationsView.swift
Normal file
56
tg_test/NotificationsView.swift
Normal file
|
|
@ -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()
|
||||
}
|
||||
60
tg_test/ProfileView.swift
Normal file
60
tg_test/ProfileView.swift
Normal file
|
|
@ -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()
|
||||
}
|
||||
56
tg_test/SearchView.swift
Normal file
56
tg_test/SearchView.swift
Normal file
|
|
@ -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()
|
||||
}
|
||||
Loading…
Reference in a new issue