- Add SidebarRootView: iPad/Mac (Designed for iPad) uses a NavigationSplitView sidebar listing all 7 tabs, sharing every existing screen (rootView) untouched - Branch by device idiom (DeviceLayout.isPad) so iPhone keeps its tab bar UI, logic, and Live Activity behavior pixel-for-pixel, including landscape - AppRouter gains sidebar mode: cross-tab routing (기록 확인/통계 보기) selects the target tab directly instead of detouring through the More tab - Hide iPhone-only settings on iPad/Mac: 탭바 구성 section and the main grid's per-row column picker are meaningless with a sidebar/adaptive grid - Main tab wide-screen layout: pinned goal cards flow in an adaptive grid (340-520pt cards) instead of full-width paging; action buttons auto-fill columns at 150-220pt so nothing stretches on large displays - Verified on iPad Pro 11" simulator (sidebar, settings, stats routing, timetable) and iPhone 17 Pro (unchanged tab bar); both build clean Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013yKDMhuF39GVYy3FMcGHh7
80 lines
2.4 KiB
Swift
80 lines
2.4 KiB
Swift
//
|
|
// SidebarRootView.swift
|
|
// Haru_Danim
|
|
//
|
|
// iPad · Mac(Designed for iPad) 전용 사이드바 내비게이션.
|
|
// iPhone의 MainTabView와 화면(rootView)은 그대로 공유하고 껍데기만 NavigationSplitView로 바꾼다.
|
|
// iPhone 쪽 UI/로직은 이 파일이 전혀 건드리지 않는다.
|
|
//
|
|
|
|
import SwiftUI
|
|
import SwiftData
|
|
import UIKit
|
|
|
|
/// 넓은 화면(iPad, Mac Designed for iPad) 전용 분기 판정.
|
|
/// 크기 클래스 대신 기기 종류로 판정해 iPhone(가로 모드 포함)은 항상 기존 UI를 유지한다.
|
|
enum DeviceLayout {
|
|
static let isPad = UIDevice.current.userInterfaceIdiom == .pad
|
|
}
|
|
|
|
struct SidebarRootView: View {
|
|
@State private var router: AppRouter
|
|
|
|
init() {
|
|
let router = AppRouter()
|
|
router.usesSidebar = true
|
|
_router = State(initialValue: router)
|
|
}
|
|
|
|
private var selectedTab: AppTab {
|
|
AppTab(rawValue: router.tabSelection) ?? .main
|
|
}
|
|
|
|
/// 사이드바 선택과 라우터의 탭 선택(String)을 잇는 다리
|
|
private var sidebarSelection: Binding<AppTab?> {
|
|
Binding {
|
|
AppTab(rawValue: router.tabSelection) ?? .main
|
|
} set: { newValue in
|
|
if let newValue {
|
|
router.tabSelection = newValue.rawValue
|
|
}
|
|
}
|
|
}
|
|
|
|
var body: some View {
|
|
NavigationSplitView {
|
|
List(selection: sidebarSelection) {
|
|
Section {
|
|
ForEach(AppTab.allCases) { tab in
|
|
Label {
|
|
Text(tab.label)
|
|
} icon: {
|
|
Image(systemName: tab.symbol)
|
|
.foregroundStyle(AppTheme.green)
|
|
}
|
|
.tag(tab)
|
|
}
|
|
}
|
|
}
|
|
.listStyle(.sidebar)
|
|
.navigationTitle("하루 다님")
|
|
.navigationSplitViewColumnWidth(min: 190, ideal: 230, max: 300)
|
|
} detail: {
|
|
NavigationStack {
|
|
selectedTab.rootView
|
|
}
|
|
// 탭을 바꾸면 상세 스택을 처음 화면으로 초기화
|
|
.id(selectedTab)
|
|
}
|
|
.environment(router)
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
SidebarRootView()
|
|
.modelContainer(for: [
|
|
Tag.self, Action.self, TimeSession.self,
|
|
CountEntry.self, Goal.self, Quest.self,
|
|
], inMemory: true)
|
|
}
|