Skip to content

Commit

Permalink
iPhone rendering off when rotated
Browse files Browse the repository at this point in the history
  • Loading branch information
mfikes committed Jan 28, 2024
1 parent c353f8c commit 92061dc
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions Impedance Converter/Impedance Converter/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ struct ContentView: View {
@SceneStorage("ContentView.viewModel") var storedViewModel: String?

@State private var showUndoConfirmation = false
@State private var isLandscape: Bool = UIDevice.current.orientation.isLandscape

init() {
UISegmentedControl.appearance().selectedSegmentTintColor = UIColor(Color.baseSegmentControlTintColor)
Expand All @@ -38,8 +37,8 @@ struct ContentView: View {
ZStack {
Color.baseAppBackgroundColor.edgesIgnoringSafeArea(.all)

if isLandscape {
// Landscape layout
if UIDevice.current.userInterfaceIdiom == .pad {
// iPad layout
VStack {
ModePickerView(viewModel: viewModel)
ScrollView {
Expand All @@ -64,7 +63,7 @@ struct ContentView: View {
.padding(10)
}
} else {
// Portrait layout
// iPhone layout
VStack {
ModePickerView(viewModel: viewModel)
ScrollView {
Expand All @@ -91,9 +90,6 @@ struct ContentView: View {
}
.dynamicTypeSize(.medium)
.onAppear {
NotificationCenter.default.addObserver(forName: UIDevice.orientationDidChangeNotification, object: nil, queue: .main) { _ in
self.isLandscape = UIDevice.current.orientation.isLandscape
}
SmoothAnimation.isAnimationDisabled = true
if let storedViewModel = storedViewModel,
let restoredViewModel = ViewModel.decodeFromJSON(storedViewModel) {
Expand Down

0 comments on commit 92061dc

Please sign in to comment.