diff --git a/Files/AreaToCard.swift b/Files/AreaToCard.swift new file mode 100644 index 0000000..dea2d02 --- /dev/null +++ b/Files/AreaToCard.swift @@ -0,0 +1,79 @@ +// The MIT License (MIT) +// Copyright © 2019 Ivan Vorobei (hello@ivanvorobei.by) +// +// 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") + .color(.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.") + .color(Color.white) + .multilineTextAlignment(.center) + .animation(.spring()) + .cornerRadius(0) + .lineLimit(0) + + 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") + .color(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 + diff --git a/README.md b/README.md index 8143ad8..0988aba 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ If you like the project, do not forget to `put star ★` ## Navigate - [Animatable Cards](#animatable-cards) +- [Area to Card](#area-to-card) - [Transition And Blur](#transition-and-blur) - [2048 Game](#2048-game) - [SFSymbols](#sfsymbols) @@ -53,7 +54,7 @@ Also include: ## Animatable Cards - + ### Gester @@ -91,6 +92,36 @@ In preview I am use `Spring` animation for all cards: ```swift .animation(.spring()) + +``` + +## Area to Card + + + +### Frame + +Size of area attach to state of property `show`: + +``` +.frame(width: show ? 350 : 290, height: show ? 420 : 260) +``` + +### Button + +For change state using `@State` as property: + +``` +@State var show = false +``` + +### SFSymbols + +For button using `SFSymbols` pack with ready-use icons. Also support customisable weight: + +``` +Image(systemName: show ? "slash.circle.fill" : "slash.circle") + .font(Font.title.weight(.semibold)) ``` ## Transition And Blur diff --git a/Resources/Previews/animatable-cards.gif b/Resources/Previews/animatable-cards.gif new file mode 100644 index 0000000..0f4d63b Binary files /dev/null and b/Resources/Previews/animatable-cards.gif differ diff --git a/Resources/Previews/area-card.gif b/Resources/Previews/area-card.gif new file mode 100644 index 0000000..29aae50 Binary files /dev/null and b/Resources/Previews/area-card.gif differ