import SwiftUI // Root home container — 5-tab bottom bar matching Android bottom_nav_menu.xml struct HomeView: View { @State private var vm = HomeViewModel() @State private var selectedTab = 0 var body: some View { TabView(selection: $selectedTab) { DashboardView() .tabItem { Label("Dashboard", systemImage: "house.fill") } .tag(0) AccountsView() .tabItem { Label("Accounts", systemImage: "building.columns.fill") } .tag(1) ContactsView() .tabItem { Label("Contacts", systemImage: "person.2.fill") } .tag(2) TransferView() .tabItem { Label("Transfer", systemImage: "arrow.up.right") } .tag(3) placeholderTab("More", icon: "ellipsis") .tabItem { Label("More", systemImage: "ellipsis") } .tag(4) } .environment(vm) .task { await vm.refreshIfNeeded() } // When a contact's "Send" button is tapped, jump to the Transfer tab .onChange(of: vm.pendingTransferContact) { _, contact in if contact != nil { selectedTab = 3 } } // When a QR code is scanned from Dashboard, jump to the Transfer tab .onChange(of: vm.pendingTransferQRData) { _, qrData in if qrData != nil { selectedTab = 3 } } // When a BML gateway QR is scanned from Dashboard, jump to the Transfer tab .onChange(of: vm.pendingBmlQrUrl) { _, url in if url != nil { selectedTab = 3 } } } @ViewBuilder private func placeholderTab(_ title: String, icon: String) -> some View { NavigationStack { VStack(spacing: 16) { Image(systemName: icon) .font(.system(size: 44)) .foregroundStyle(.secondary) Text(title) .font(.title2.bold()) .foregroundStyle(.secondary) } .frame(maxWidth: .infinity, maxHeight: .infinity) .background(Color(.systemBackground)) .navigationTitle(title) } } } #Preview { HomeView() .environment(AppViewModel()) }