You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
3.0 KiB
79 lines
3.0 KiB
// The MIT License (MIT)
|
|
// Copyright © 2019 Ivan Varabei (varabeis@icloud.com)
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
// in the Software without restriction, including without limitation the rights
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
// furnished to do so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in all
|
|
// copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
// SOFTWARE.
|
|
|
|
import SwiftUI
|
|
|
|
struct ContentView : View {
|
|
@State var show = false
|
|
|
|
var body: some View {
|
|
VStack() {
|
|
Text("Card in SwiftUI")
|
|
.foregroundColor(.white)
|
|
.fontWeight(.bold)
|
|
.font(.largeTitle)
|
|
.padding(.top, show ? 30 : 20)
|
|
.padding(.bottom, show ? 20 : 0)
|
|
|
|
Text("Animatable cards with Spring, custom frame and some paddings. Also use SFSymbol for icon in the bottom button. Tap to button fo see fill style of this icon.")
|
|
.foregroundColor(.white)
|
|
.multilineTextAlignment(.center)
|
|
.animation(.spring())
|
|
.cornerRadius(0)
|
|
.lineLimit(.none)
|
|
|
|
Spacer()
|
|
|
|
Button(action: {
|
|
self.show.toggle()
|
|
}) {
|
|
HStack {
|
|
Image(systemName: show ? "slash.circle.fill" : "slash.circle")
|
|
.foregroundColor(Color(hue: 0.498, saturation: 0.609, brightness: 1.0))
|
|
.font(Font.title.weight(.semibold))
|
|
.imageScale(.small)
|
|
Text(show ? "to Card" : "to Area")
|
|
.foregroundColor(Color(hue: 0.498, saturation: 0.609, brightness: 1.0))
|
|
.fontWeight(.bold)
|
|
.font(.title)
|
|
.cornerRadius(0)
|
|
}
|
|
}
|
|
.padding(.bottom, show ? 20 : 15)
|
|
|
|
}
|
|
.padding()
|
|
.padding(.top, 15)
|
|
.frame(width: show ? 350 : 290, height: show ? 420 : 260)
|
|
.background(Color.blue)
|
|
.cornerRadius(30)
|
|
.animation(.spring())
|
|
}
|
|
}
|
|
|
|
#if DEBUG
|
|
struct ContentView_Previews : PreviewProvider {
|
|
static var previews: some View {
|
|
ContentView()
|
|
}
|
|
}
|
|
#endif
|
|
|
|
|