Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ struct FloorMapSettingView: View {
// 基本情報設定セクション
self.basicInfoSection

// プリセット選択セクション
self.presetSection

Spacer(minLength: 80)
}
.padding()
Expand Down Expand Up @@ -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)
}
}
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -70,7 +68,6 @@ class FloorMapSettingViewModel: ObservableObject {
#if DEBUG
print("🚀 FloorMapSettingViewModel: init called")
#endif
self.setupFloorPresets()
}

func setModelContext(_ context: ModelContext) {
Expand All @@ -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("必要な情報がすべて入力されていません")
Expand Down Expand Up @@ -185,7 +160,6 @@ class FloorMapSettingViewModel: ObservableObject {
self.buildingName = ""
self.floorWidth = 10.0
self.floorDepth = 15.0
self.selectedPreset = nil

// ナビゲーションを戻る
NavigationRouterModel.shared.pop()
Expand All @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down
Loading