mirror of
https://github.com/ivanvorobei/SwiftUI.git
synced 2026-03-27 03:41:21 +01:00
Update
This commit is contained in:
32
Other Projects/SwiftUI + Redux/SwiftUIDemo/views/users/component/Badge.swift
Executable file
32
Other Projects/SwiftUI + Redux/SwiftUIDemo/views/users/component/Badge.swift
Executable file
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// GreenBadge.swift
|
||||
// SwiftUIDemo
|
||||
//
|
||||
// Created by Thomas Ricouard on 06/06/2019.
|
||||
// Copyright © 2019 Thomas Ricouarf. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct Badge : View {
|
||||
let text: String
|
||||
let color: Color
|
||||
@Binding var show: Bool
|
||||
|
||||
var animation: Animation {
|
||||
Animation
|
||||
.spring(initialVelocity: 5)
|
||||
.speed(2)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Text(text)
|
||||
.color(.white)
|
||||
.padding()
|
||||
.background(color)
|
||||
.cornerRadius(8)
|
||||
.scaleEffect(show ? 1: 0.5)
|
||||
.opacity(show ? 1 : 0)
|
||||
.animation(animation)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user