aboutsummaryrefslogtreecommitdiff
path: root/Map/Presentation/Base Components/EvolutionPicker
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2025-09-16 12:01:07 +0200
committerRuben Beltran del Rio <git@r.bdr.sh>2025-09-16 12:01:07 +0200
commitd3e21e6050fd8cfde6ff7c68d9f8dfedf7b6301f (patch)
tree3e9d76f8f4be7febedbd1dac01f1adc1c4c1b7db /Map/Presentation/Base Components/EvolutionPicker
parent45e5a80ae378a72720114641c39148c199c6332d (diff)
Add glass
Diffstat (limited to 'Map/Presentation/Base Components/EvolutionPicker')
-rw-r--r--Map/Presentation/Base Components/EvolutionPicker/EvolutionPicker.swift6
-rw-r--r--Map/Presentation/Base Components/EvolutionPicker/EvolutionPickerMenu.swift9
-rw-r--r--Map/Presentation/Base Components/EvolutionPicker/GlassEvolutionPicker.swift77
3 files changed, 85 insertions, 7 deletions
diff --git a/Map/Presentation/Base Components/EvolutionPicker/EvolutionPicker.swift b/Map/Presentation/Base Components/EvolutionPicker/EvolutionPicker.swift
index 5748e59..da67054 100644
--- a/Map/Presentation/Base Components/EvolutionPicker/EvolutionPicker.swift
+++ b/Map/Presentation/Base Components/EvolutionPicker/EvolutionPicker.swift
@@ -21,7 +21,7 @@ struct EvolutionPicker: View {
@FocusState var isFocused: Bool
@Binding var selectedEvolution: StageType
-
+
var body: some View {
Button(
@@ -60,9 +60,9 @@ struct EvolutionPicker: View {
)
.buttonStyle(.borderless)
.background(isShowingMenu ? Color.Theme.UI.foreground : Color.clear)
- .cornerRadius(4.0)
+ .cornerRadius(Dimensions.EvolutionPicker.radius)
.overlay(
- RoundedRectangle(cornerRadius: 4.0)
+ RoundedRectangle(cornerRadius: Dimensions.EvolutionPicker.radius)
.stroke(
isShowingMenu
? Color.Theme.UI.foreground : (isHovered ? Color.Theme.UI.foreground : Color.clear),
diff --git a/Map/Presentation/Base Components/EvolutionPicker/EvolutionPickerMenu.swift b/Map/Presentation/Base Components/EvolutionPicker/EvolutionPickerMenu.swift
index 73837a0..b9d76c6 100644
--- a/Map/Presentation/Base Components/EvolutionPicker/EvolutionPickerMenu.swift
+++ b/Map/Presentation/Base Components/EvolutionPicker/EvolutionPickerMenu.swift
@@ -5,7 +5,9 @@ struct EvolutionPickerMenu: View {
@Binding var selectedEvolution: StageType
private func select(_ stageType: StageType) {
- selectedEvolution = stageType
+ withAnimation {
+ selectedEvolution = stageType
+ }
}
var body: some View {
@@ -46,9 +48,8 @@ struct EvolutionPickerMenu: View {
}
}
}
- .padding(Dimensions.Spacing.coziest)
- .ignoresSafeArea()
-
+ .padding(.horizontal, Dimensions.Spacing.coziest)
+ .padding(.vertical, Dimensions.Spacing.regular)
}
}
diff --git a/Map/Presentation/Base Components/EvolutionPicker/GlassEvolutionPicker.swift b/Map/Presentation/Base Components/EvolutionPicker/GlassEvolutionPicker.swift
new file mode 100644
index 0000000..3b6f199
--- /dev/null
+++ b/Map/Presentation/Base Components/EvolutionPicker/GlassEvolutionPicker.swift
@@ -0,0 +1,77 @@
+// Copyright (C) 2024 Rubén Beltrán del Río
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see https://map.tranquil.systems.
+import SwiftUI
+
+@available(macOS 26, *)
+struct GlassEvolutionPicker: View {
+
+ @State var isShowingMenu = false
+ @FocusState var isFocused: Bool
+
+ @Binding var selectedEvolution: StageType
+
+ var body: some View {
+
+ Button(
+ action: {
+ isShowingMenu = !isShowingMenu
+ },
+ label: {
+ HStack(spacing: Dimensions.Spacing.loose) {
+ Text(Stage.title(selectedEvolution))
+ .font(.Theme.Body.emphasized)
+ ZStack {
+ Image(systemName: "chevron.up")
+ .resizable()
+ .scaledToFit()
+ .frame(
+ width: Dimensions.EvolutionPicker.controlSize,
+ height: Dimensions.EvolutionPicker.controlSize
+ )
+ .offset(CGSize(width: 0, height: -Dimensions.EvolutionPicker.controlSpacing))
+ Image(systemName: "chevron.down")
+ .resizable()
+ .scaledToFit()
+ .frame(
+ width: Dimensions.EvolutionPicker.controlSize,
+ height: Dimensions.EvolutionPicker.controlSize
+ )
+ .offset(CGSize(width: 0, height: Dimensions.EvolutionPicker.controlSpacing))
+ }
+ }
+ .padding(.horizontal, Dimensions.Spacing.regular)
+ .padding(.vertical, Dimensions.Spacing.cozy)
+ }
+ )
+ .buttonStyle(.glass)
+ .buttonBorderShape(.capsule)
+ .cornerRadius(Dimensions.EvolutionPicker.radius)
+ .popover(
+ isPresented: $isShowingMenu,
+ content: {
+ EvolutionPickerMenu(selectedEvolution: $selectedEvolution)
+ }
+ )
+ .onChange(of: selectedEvolution) {
+ isShowingMenu = false
+ }
+ .animation(.bouncy, value: selectedEvolution)
+ }
+}
+
+#Preview {
+ @Previewable @State var selectedEvolution: StageType = .behavior
+ EvolutionPicker(selectedEvolution: $selectedEvolution)
+}