Created
July 19, 2020 20:58
-
-
Save azamsharp/b532857c89fe9c9b651c966797055482 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
struct ContentView: View { | |
@Namespace var musicPlayerNS | |
@State private var showMusicPlayer: Bool = false | |
var frame: CGFloat { | |
showMusicPlayer ? 400 : 44 | |
} | |
var body: some View { | |
VStack { | |
Spacer() | |
VStack { | |
HStack { | |
Image("cover") | |
.resizable() | |
.frame(width: frame, height: frame) | |
.cornerRadius(4) | |
.padding(8) | |
if showMusicPlayer == false { | |
Text("Baby Blue") | |
.matchedGeometryEffect(id: "showMusic", in: musicPlayerNS) | |
Spacer() | |
Image(systemName: "play.fill") | |
.padding(.trailing, 10) | |
Image(systemName: "forward.fill") | |
.padding(.trailing, 10) | |
} | |
}.background(Color(#colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1))) | |
if showMusicPlayer { | |
Text("Baby Blue") | |
.matchedGeometryEffect(id: "showMusic", in: musicPlayerNS) | |
.font(.title) | |
.padding() | |
.foregroundColor(Color.white) | |
Spacer() | |
} | |
} | |
.onTapGesture { | |
withAnimation(.spring()) { | |
showMusicPlayer.toggle() | |
} | |
} | |
} | |
} | |
} | |
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