From 936b45318da8effc5a699f0bcac3984b18bab9b7 Mon Sep 17 00:00:00 2001 From: harutiro Date: Tue, 4 Nov 2025 08:05:03 +0900 Subject: [PATCH] refactor: Remove unused preset section and related camera functionality from FloorMapSettingView - Deleted the preset selection section and its associated view model properties. - Removed the camera capture button and its functionality. - This cleanup enhances the clarity and maintainability of the FloorMapSettingView. --- .../FloorMapSettingView.swift | 99 ------------------- .../FloorMapSettingViewModel.swift | 86 ---------------- 2 files changed, 185 deletions(-) diff --git a/UWBViewerSystem/Presentation/Scenes/FloorMapTab/FloorMapSettingPage/FloorMapSettingView.swift b/UWBViewerSystem/Presentation/Scenes/FloorMapTab/FloorMapSettingPage/FloorMapSettingView.swift index 660e05f..4864750 100644 --- a/UWBViewerSystem/Presentation/Scenes/FloorMapTab/FloorMapSettingPage/FloorMapSettingView.swift +++ b/UWBViewerSystem/Presentation/Scenes/FloorMapTab/FloorMapSettingPage/FloorMapSettingView.swift @@ -25,9 +25,6 @@ struct FloorMapSettingView: View { // 基本情報設定セクション self.basicInfoSection - // プリセット選択セクション - self.presetSection - Spacer(minLength: 80) } .padding() @@ -156,22 +153,6 @@ struct FloorMapSettingView: View { .foregroundColor(.blue) .cornerRadius(8) } - - Button(action: { - print("🔘 FloorMapSettingView: カメラで撮影ボタンがクリックされました") - self.viewModel.captureImageFromCamera() - }) { - HStack { - Image(systemName: "camera") - Text("カメラで撮影") - } - .frame(maxWidth: .infinity) - .padding() - .background(Color.green.opacity(0.1)) - .foregroundColor(.green) - .cornerRadius(8) - } - .disabled(!self.viewModel.isCameraAvailable) } } } @@ -253,32 +234,6 @@ struct FloorMapSettingView: View { .shadow(radius: 2) } - // MARK: - Preset Section - - private var presetSection: some View { - VStack(alignment: .leading, spacing: 16) { - Text("プリセット") - .font(.headline) - .foregroundColor(.primary) - - LazyVGrid(columns: Array(repeating: GridItem(.flexible()), count: 2), spacing: 12) { - ForEach(self.viewModel.floorPresets, id: \.id) { preset in - FloorPresetCard( - preset: preset, - isSelected: self.viewModel.selectedPreset?.id == preset.id, - onTap: { - self.viewModel.selectPreset(preset) - } - ) - } - } - } - .padding() - .background(Color.secondary.opacity(0.1)) - .cornerRadius(12) - .shadow(radius: 2) - } - // MARK: - Navigation Buttons private var navigationButtons: some View { @@ -315,60 +270,6 @@ struct FloorMapSettingView: View { } } -// MARK: - Floor Preset Card - -struct FloorPresetCard: View { - let preset: FloorMapPreset - let isSelected: Bool - let onTap: () -> Void - - var body: some View { - Button(action: self.onTap) { - VStack(alignment: .leading, spacing: 8) { - HStack { - Image(systemName: self.preset.iconName) - .foregroundColor(self.isSelected ? .blue : .secondary) - .font(.title2) - - Spacer() - - if self.isSelected { - Image(systemName: "checkmark.circle.fill") - .foregroundColor(.blue) - } - } - - Text(self.preset.name) - .font(.headline) - .foregroundColor(.primary) - .multilineTextAlignment(.leading) - - Text(self.preset.description) - .font(.caption) - .foregroundColor(.secondary) - .multilineTextAlignment(.leading) - - HStack { - Text("\(self.preset.width, specifier: "%.1f")m") - Text("×") - Text("\(self.preset.depth, specifier: "%.1f")m") - } - .font(.caption) - .foregroundColor(.secondary) - } - .padding() - .frame(maxWidth: .infinity, alignment: .leading) - .background(self.isSelected ? Color.blue.opacity(0.1) : Color.gray.opacity(0.1)) - .cornerRadius(12) - .overlay( - RoundedRectangle(cornerRadius: 12) - .stroke(self.isSelected ? Color.blue : Color.clear, lineWidth: 2) - ) - } - .buttonStyle(PlainButtonStyle()) - } -} - // MARK: - Preview struct FloorMapSettingView_Previews: PreviewProvider { diff --git a/UWBViewerSystem/Presentation/Scenes/FloorMapTab/FloorMapSettingPage/FloorMapSettingViewModel.swift b/UWBViewerSystem/Presentation/Scenes/FloorMapTab/FloorMapSettingPage/FloorMapSettingViewModel.swift index e2c6085..a38c967 100644 --- a/UWBViewerSystem/Presentation/Scenes/FloorMapTab/FloorMapSettingPage/FloorMapSettingViewModel.swift +++ b/UWBViewerSystem/Presentation/Scenes/FloorMapTab/FloorMapSettingPage/FloorMapSettingViewModel.swift @@ -30,8 +30,6 @@ class FloorMapSettingViewModel: ObservableObject { @Published var buildingName: String = "テストビル" @Published var floorWidth: Double = 10.0 @Published var floorDepth: Double = 10.0 - @Published var selectedPreset: FloorMapPreset? - @Published var floorPresets: [FloorMapPreset] = [] @Published var isImagePickerPresented: Bool = false #if canImport(UIKit) @@ -70,7 +68,6 @@ class FloorMapSettingViewModel: ObservableObject { #if DEBUG print("🚀 FloorMapSettingViewModel: init called") #endif - self.setupFloorPresets() } func setModelContext(_ context: ModelContext) { @@ -93,28 +90,6 @@ class FloorMapSettingViewModel: ObservableObject { self.isImagePickerPresented = true } - func captureImageFromCamera() { - guard self.isCameraAvailable else { - self.showError("カメラが利用できません") - return - } - - #if canImport(UIKit) - self.imagePickerSourceType = .camera - #endif - self.isImagePickerPresented = true - } - - func selectPreset(_ preset: FloorMapPreset) { - self.selectedPreset = preset - self.floorWidth = preset.width - self.floorDepth = preset.depth - - if self.floorName.isEmpty { - self.floorName = preset.name - } - } - func saveFloorMapSettings() async -> Bool { guard self.canProceedToNext else { self.showError("必要な情報がすべて入力されていません") @@ -185,7 +160,6 @@ class FloorMapSettingViewModel: ObservableObject { self.buildingName = "" self.floorWidth = 10.0 self.floorDepth = 15.0 - self.selectedPreset = nil // ナビゲーションを戻る NavigationRouterModel.shared.pop() @@ -203,55 +177,6 @@ class FloorMapSettingViewModel: ObservableObject { } #endif - // MARK: - Private Methods - - private func setupFloorPresets() { - self.floorPresets = [ - FloorMapPreset( - name: "小規模オフィス", - description: "10-20人程度のオフィス", - width: 8.0, - depth: 12.0, - iconName: "building.2" - ), - FloorMapPreset( - name: "中規模オフィス", - description: "20-50人程度のオフィス", - width: 15.0, - depth: 20.0, - iconName: "building.2.fill" - ), - FloorMapPreset( - name: "大規模オフィス", - description: "50人以上のオフィス", - width: 25.0, - depth: 30.0, - iconName: "building.columns" - ), - FloorMapPreset( - name: "会議室", - description: "中規模の会議室", - width: 6.0, - depth: 8.0, - iconName: "person.3" - ), - FloorMapPreset( - name: "展示ホール", - description: "展示会・イベント会場", - width: 30.0, - depth: 40.0, - iconName: "building.columns.fill" - ), - FloorMapPreset( - name: "カスタム", - description: "手動で寸法を設定", - width: 10.0, - depth: 10.0, - iconName: "slider.horizontal.3" - ), - ] - } - private func loadSavedSettings() { // PreferenceRepositoryから保存された設定を読み込む let settings = self.preferenceRepository.loadLastFloorSettings() @@ -375,17 +300,6 @@ class FloorMapSettingViewModel: ObservableObject { } } -// MARK: - Supporting Types - -struct FloorMapPreset: Identifiable { - let id = UUID() - let name: String - let description: String - let width: Double - let depth: Double - let iconName: String -} - // FloorMapInfoはCommonTypes.swiftで定義済み enum FloorMapSettingError: Error, LocalizedError {