Created
July 3, 2020 10:48
-
-
Save chriseidhof/0f1667dc4acaeedde1059cc5b6b79293 to your computer and use it in GitHub Desktop.
SwiftUI bugs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// Bug1 | |
// | |
// Created by Chris Eidhof on 03.07.20. | |
// | |
import SwiftUI | |
struct ContentView: View { | |
@Namespace var ns | |
@State var selected: Bool = false | |
var body: some View { | |
let rect = Rectangle() | |
.fill(Color.red) | |
.frame(width: selected ? 200 : 100, height: selected ? 150 : 75) | |
.onTapGesture { | |
withAnimation(.easeInOut(duration: 3)) { | |
selected.toggle() | |
} | |
} | |
return VStack { | |
if !selected { | |
rect | |
.matchedGeometryEffect(id: "x", in: ns, isSource: false) | |
} | |
Spacer() | |
ScrollView { | |
HStack { | |
if selected { | |
rect | |
.matchedGeometryEffect(id: "x", in: ns, isSource: false) | |
} | |
} | |
} | |
.background(Color.gray) | |
.frame(height: 220) | |
}.frame(maxWidth: .infinity, maxHeight: .infinity) | |
} | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
ContentView() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment