Merge branch 'master' into master

This commit is contained in:
nishiths23
2019-06-23 21:39:52 +02:00
committed by GitHub
5 changed files with 98 additions and 2 deletions

View File

@@ -0,0 +1,81 @@
import PlaygroundSupport
import SwiftUI
struct PureGeniusView: View {
var body: some View {
ZStack {
Rectangle()
.fill()
.foregroundColor(.init(hue: 0.57, saturation: 0.25, brightness: 1))
Circle()
.frame(width: 320, height: 320)
.foregroundColor(.init(hue: 0.8, saturation: 0.25, brightness: 0.75))
VStack {
PGWordView(word: ["P", "U", "R", "E"]).offset(x: 0, y: 20)
PGWordView(word: ["G", "E", "N", "I", "U", "S"]).offset(x: 0, y: -20)
}
}
}
}
struct PGWordView: View {
var word: [String]
var body: some View {
HStack {
ForEach(word.identified(by: \.self)) { letter in
PGLetterView(text: letter)
}
}
}
}
struct PGLetterView: View {
var text: String
var body: some View {
ZStack {
MovingLetterView(text: text, color: .init(hue: 0.14, saturation: 0.56, brightness: 0.98))
MovingLetterView(text: text, color: .init(hue: 0.37, saturation: 0.52, brightness: 0.7))
}
}
}
struct MovingLetterView: View {
var text: String
var color: Color
@State var position: CGPoint = .zero
@State var activeTimer: Timer = nil
private let animationDuration: Double = 2
private let maxOffset: CGFloat = 10
private var timer: Timer {
return Timer.scheduledTimer(withTimeInterval: self.animationDuration * 0.25, repeats: true) {_ in
let x = CGFloat(arc4random_uniform(UInt32(self.maxOffset))) - (self.maxOffset / 2)
let y = CGFloat(arc4random_uniform(UInt32(self.maxOffset))) - (self.maxOffset / 2)
self.position = CGPoint.init(x: x, y: y)
}
}
var body: some View {
Text(text)
.color(self.color)
.font(Font.custom("Baskerville-Bold", size: 40))
.bold()
.offset(by: self.position)
.animation(.basic(duration: self.animationDuration, curve: .easeInOut))
.onAppear {
self.activeTimer = self.timer
}
.onDisappear {
self.activeTimer = nil
}
}
}
extension View {
public func offset(by offset: CGPoint) -> Self.Modified<_OffsetEffect> {
self.offset(x: offset.x, y: offset.y)
}
}
PlaygroundPage.current.liveView = UIHostingController(rootView: PureGeniusView())

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios'>
<timeline fileName='timeline.xctimeline'/>
</playground>

View File

@@ -1,11 +1,14 @@
## `SwiftUI` Examples Projects
<a href="https://itunes.apple.com/app/id1446635818" target="_blank"><img align="left" src="https://github.com/ivanvorobei/SwiftUI/blob/master/Resources/icon.png" width="92"/></a>
<a href="https://itunes.apple.com/app/id1446635818" target="_blank"><img align="left" src="https://github.com/ivanvorobei/SwiftUI/blob/master/Resources/icon.png" width="190"/></a>
Examples projects using `SwiftUI` & `Combine`.
Include Layout, UI, Animations, Gestures, Draw and Data. See projects files in `Examples` folder. If you have project, make a pull request or create issue with link to repo.
Interested in UI and animations in `UIKit`? See project [awesome-ios-ui](https://github.com/ivanvorobei/awesome-ios-ui).
Interested in UI and animations in `UIKit`?
See project [awesome-ios-ui](https://github.com/ivanvorobei/awesome-ios-ui) or visit
[![xcode-shop.com](https://github.com/ivanvorobei/SPPermission/blob/master/Resources/Buttons/Xcode%20Shop%20Button%20-%201.svg)](https://xcode-shop.com/ui-elements)
## Navigate
@@ -31,6 +34,7 @@ Interested in UI and animations in `UIKit`? See project [awesome-ios-ui](https:/
- [Jike](#jike)
- [Flux](#flux)
- [SwiftUI Download Progress View](#SwiftUIDownloadView)
- [PureGenius](#puregenius)
Also include:
- Movie
@@ -45,6 +49,10 @@ Also include:
## Projects
#### Cards
<img src="https://hsto.org/webt/xh/3t/eq/xh3teq68fx1bujdlsgpon4jtijo.gif" width="280">
#### Transition And Blur
<img src="Resources/TransitionBlur.png" width="700">
@@ -133,6 +141,9 @@ Also include:
### SwiftUIDownloadView
<img src="Resources/SwiftUIDownloadView.gif" width="294">
#### PureGenius
<img src="Resources/PureGenius.gif" width="260">
#### Authors

BIN
Resources/Cards.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
Resources/PureGenius.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 KiB