Browse Source

home: improve UI for visionOS

osy 2 years ago
parent
commit
f4bfa50fef

+ 5 - 1
Platform/Shared/BigButtonStyle.swift

@@ -33,7 +33,7 @@ struct BigButtonStyle: ButtonStyle {
         let foregroundDisabledColor = Color(NSColor.disabledControlTextColor)
         let foregroundPressedColor = Color(NSColor.selectedControlTextColor)
         #else
-        let defaultColor = Color(UIColor.secondarySystemBackground)
+        let defaultColor = Color(UIColor.tertiarySystemFill)
         let pressedColor = Color(UIColor.systemFill)
         let foregroundColor = Color(UIColor.label)
         let foregroundDisabledColor = Color(UIColor.systemGray)
@@ -44,6 +44,10 @@ struct BigButtonStyle: ButtonStyle {
             ZStack {
                 RoundedRectangle(cornerRadius: 10.0)
                     .fill(configuration.isPressed ? pressedColor : defaultColor)
+                    #if os(iOS)
+                    .hoverEffect()
+                    .scaleEffect(configuration.isPressed ? 0.95 : 1)
+                    #endif
                 configuration.label
                     .foregroundColor(isEnabled ? (configuration.isPressed ? foregroundPressedColor : foregroundColor) : foregroundDisabledColor)
             }.frame(width: width, height: height)

+ 1 - 1
Platform/Shared/ContentView.swift

@@ -37,7 +37,7 @@ struct ContentView: View {
     var body: some View {
         VMNavigationListView()
         .overlay(data.showSettingsModal ? AnyView(EmptyView()) : AnyView(BusyOverlay()))
-        #if os(macOS)
+        #if os(macOS) || os(visionOS)
         .frame(minWidth: 800, idealWidth: 1200, minHeight: 600, idealHeight: 800)
         #endif
         .disabled(data.busy && !data.showNewVMSheet && !data.showSettingsModal)

+ 3 - 1
Platform/Shared/InListButtonStyle.swift

@@ -53,8 +53,10 @@ struct InListButtonStyle: ButtonStyle {
                 Spacer()
             }
             .foregroundColor(isEnabled ? (configuration.isPressed ? foregroundPressedColor : foregroundColor) : foregroundDisabledColor)
-            .contentShape(Rectangle())
+            .contentShape(RoundedRectangle(cornerRadius: 10.0))
             .listRowBackground(configuration.isPressed ? pressedColor : defaultColor)
+            .hoverEffect()
+            .scaleEffect(configuration.isPressed ? 0.95 : 1)
             #endif
         }
     }

+ 6 - 0
Platform/Shared/VMCardView.swift

@@ -46,6 +46,7 @@ struct VMCardView: View {
             .truncationMode(.tail)
             Spacer()
             if vm.isStopped {
+                #if !os(visionOS) // tap target too small
                 Button {
                     data.run(vm: vm)
                 } label: {
@@ -53,6 +54,7 @@ struct VMCardView: View {
                         .font(.largeTitle)
                         .labelStyle(.iconOnly)
                 }
+                #endif
             } else if vm.isBusy {
                 Spinner(size: .large)
             }
@@ -62,6 +64,10 @@ struct VMCardView: View {
         .onDoubleClick {
             data.run(vm: vm)
         }
+        #else
+        .simultaneousGesture(TapGesture(count: 2).onEnded {
+            data.run(vm: vm)
+        })
         #endif
     }
 }

+ 18 - 0
Platform/Shared/VMDetailsView.swift

@@ -149,17 +149,35 @@ struct Screenshot: View {
             Rectangle()
                 .fill(Color(red: 230/255, green: 229/255, blue: 235/255))
                 .blendMode(.hardLight)
+            #if os(visionOS)
+                .overlay {
+                    if vm.isStopped {
+                        Image(systemName: "play.circle.fill")
+                            .resizable()
+                            .frame(width: 100, height: 100)
+                    }
+                }
+                .hoverEffect()
+                .onTapGesture {
+                    data.run(vm: vm)
+                }
+            #endif
             if vm.isBusy {
                 Spinner(size: .large)
             } else if vm.isStopped {
+                #if !os(visionOS)
                 Button(action: { data.run(vm: vm) }, label: {
                     Label("Run", systemImage: "play.circle.fill")
                         .labelStyle(.iconOnly)
                         .font(Font.system(size: 96))
                         .foregroundColor(Color.black)
                 }).buttonStyle(.plain)
+                #endif
             }
         }.aspectRatio(CGSize(width: 16, height: 9), contentMode: large ? .fill : .fit)
+        #if os(visionOS)
+        .frame(maxWidth: 500)
+        #endif
     }
 }
 

+ 1 - 1
Platform/Shared/VMNavigationListView.swift

@@ -47,7 +47,7 @@ struct VMNavigationListView: View {
             if !vm.isLoaded {
                 UTMUnavailableVMView(vm: vm)
             } else {
-                if #available(iOS 16, macOS 13, *) {
+                if #available(iOS 16, macOS 13, visionOS 1, *) {
                     VMCardView(vm: vm)
                         .modifier(VMContextMenuModifier(vm: vm))
                         .tag(vm)

+ 3 - 0
Platform/iOS/UTMApp.swift

@@ -23,5 +23,8 @@ struct UTMApp: App {
         }.commands {
             VMCommands()
         }
+        #if os(visionOS)
+        .windowResizability(.contentMinSize)
+        #endif
     }
 }

+ 3 - 0
Platform/iOS/VMSettingsView.swift

@@ -88,7 +88,9 @@ struct VMSettingsView: View {
                     }
                 }
             }
+            #if !os(visionOS)
             .navigationTitle("Settings")
+            #endif
             .navigationViewStyle(.stack)
             .navigationBarItems(leading: HStack {
                 if #available(iOS 15, *) {
@@ -211,6 +213,7 @@ struct RoundRectIconLabelStyle: LabelStyle {
                         .frame(width: 32, height: 32)
                         .foregroundColor(color)
                     configuration.icon.foregroundColor(.white)
+                        .imageScale(.medium)
                 }
             })
     }

+ 4 - 4
UTM.xcodeproj/project.pbxproj

@@ -3619,7 +3619,7 @@
 				SWIFT_OBJC_BRIDGING_HEADER = "Services/Swift-Bridging-Header.h";
 				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
 				SWIFT_VERSION = 5.0;
-				TARGETED_DEVICE_FAMILY = "1,2";
+				TARGETED_DEVICE_FAMILY = "1,2,7";
 			};
 			name = Debug;
 		};
@@ -3646,7 +3646,7 @@
 				SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
 				SWIFT_OBJC_BRIDGING_HEADER = "Services/Swift-Bridging-Header.h";
 				SWIFT_VERSION = 5.0;
-				TARGETED_DEVICE_FAMILY = "1,2";
+				TARGETED_DEVICE_FAMILY = "1,2,7";
 			};
 			name = Release;
 		};
@@ -3936,7 +3936,7 @@
 				SWIFT_OBJC_BRIDGING_HEADER = "Services/Swift-Bridging-Header.h";
 				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
 				SWIFT_VERSION = 5.0;
-				TARGETED_DEVICE_FAMILY = "1,2";
+				TARGETED_DEVICE_FAMILY = "1,2,7";
 			};
 			name = Debug;
 		};
@@ -3970,7 +3970,7 @@
 				SWIFT_ACTIVE_COMPILATION_CONDITIONS = WITH_QEMU_TCI;
 				SWIFT_OBJC_BRIDGING_HEADER = "Services/Swift-Bridging-Header.h";
 				SWIFT_VERSION = 5.0;
-				TARGETED_DEVICE_FAMILY = "1,2";
+				TARGETED_DEVICE_FAMILY = "1,2,7";
 			};
 			name = Release;
 		};