Skip to content

Commit

Permalink
Make ProfileView look good on visionOS and in dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Supereg committed Feb 2, 2024
1 parent ebb9e13 commit dba8c2b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ jobs:
scheme: SpeziViews-Package
buildandtestwatchos:
name: Build and Test Swift Package watchOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
artifactname: SpeziViews-Package-watchOS.xcresult
runsonlabels: '["macOS", "self-hosted"]'
scheme: SpeziViews-Package
destination: 'platform=watchOS Simulator,name=Apple Watch Series 9 (45mm)'
buildandtestvisionos:
name: Build and Test Swift Package visionOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
artifactname: SpeziViews-Package-visionOS.xcresult
runsonlabels: '["macOS", "self-hosted"]'
scheme: SpeziViews-Package
destination: 'platform=visionOS Simulator,name=Apple Vision Pro'
buildandtesttvos:
name: Build and Test Swift Package tvOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
artifactname: SpeziViews-Package-tvOS.xcresult
runsonlabels: '["macOS", "self-hosted"]'
Expand Down
27 changes: 14 additions & 13 deletions Sources/SpeziPersonalInfo/UserProfileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// SPDX-License-Identifier: MIT
//

// TODO: support this on tvOS!

Check failure on line 9 in Sources/SpeziPersonalInfo/UserProfileView.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint / SwiftLint

Todo Violation: TODOs should be resolved (support this on tvOS!) (todo)
#if !os(tvOS)
import SwiftUI

Expand All @@ -16,9 +17,11 @@ public struct UserProfileView: View {
private let imageLoader: () async -> Image?

@State private var image: Image?


// TODO: doesnt look good on visionOS

@Environment(\.colorScheme)
private var colorScheme


public var body: some View {
GeometryReader { context in
ZStack {
Expand All @@ -31,7 +34,7 @@ public struct UserProfileView: View {
Circle()
.foregroundColor(Color(.systemGray3))
Text(name.formatted(.name(style: .abbreviated)))
.foregroundColor(.init(UIColor.systemBackground))
.foregroundColor(colorScheme == .dark ? .secondary : Color(.systemBackground))
.font(
.system(
size: min(context.size.height, context.size.width) * 0.45,
Expand Down Expand Up @@ -69,8 +72,8 @@ public struct UserProfileView: View {
UserProfileView(
name: PersonNameComponents(givenName: "Paul", familyName: "Schmiedmayer")
)
.frame(width: 100, height: 100)
.padding()
.frame(width: 100, height: 100)
.padding()
}

#Preview {
Expand All @@ -82,10 +85,9 @@ public struct UserProfileView: View {
familyName: "Aalami"
)
)
.frame(width: 100, height: 100)
.padding()
.background(Color(.systemBackground))
.colorScheme(.dark)
.frame(width: 100, height: 100)
.padding()
.preferredColorScheme(.dark)
}

#Preview {
Expand All @@ -96,9 +98,8 @@ public struct UserProfileView: View {
return Image(systemName: "person.crop.circle")
}
)
.frame(width: 50, height: 100)
.padding()
.frame(width: 50, height: 100)
.padding()
}
#endif
#endif

2 changes: 2 additions & 0 deletions Tests/SpeziViewsTests/SnapshotTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ final class SnapshotTests: XCTestCase {

assertSnapshot(of: largeRow, as: .image(layout: .device(config: .iPhone13Pro)), named: "iphone-XA3")
assertSnapshot(of: largeRow, as: .image(layout: .device(config: .iPadPro11)), named: "ipad-XA3")
#elseif os(visionOS)

#endif
}
}
5 changes: 5 additions & 0 deletions Tests/UITests/TestApp/TestApp.entitlements.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This source file is part of the Stanford Spezi open-source project

SPDX-FileCopyrightText: 2024 Stanford University and the project authors (see CONTRIBUTORS.md)

SPDX-License-Identifier: MIT

0 comments on commit dba8c2b

Please sign in to comment.