Add animation in each step

pull/18/head
Emre KARTAL 1 year ago
parent 58047e8f48
commit ff67f2d1d0

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "GiftEarn.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "Gift.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

@ -10,7 +10,7 @@ import DependencyInjection
struct ContentView: View {
@State private var show = true
@State private var show = false
@Inject var authService: IAuthService
@ObservedObject var loggedState = AppStateContainer.shared.loggedState
@ -30,11 +30,17 @@ struct ContentView: View {
}
.onAppear {
authService.refreshAuthentication()
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
withAnimation {
show = true
}
}
}
.overlay(
Group {
if show {
DailyGiftPage(show: $show)
.transition(.opacity)
}
}
)

@ -2,41 +2,82 @@
// DailyGiftPage.swift
// AllIn
//
// Created by étudiant on 02/02/2024.
// Created by Emre on 02/02/2024.
//
import SwiftUI
struct DailyGiftPage: View {
enum Step {
case first
case end
}
@State private var step: Step = .first
@Binding var show: Bool
var body: some View {
LinearGradient(
gradient: Gradient(colors: [
Color.black.opacity(0.5),
Color.black.opacity(0.9)
]),
startPoint: .top,
endPoint: .bottom
)
.edgesIgnoringSafeArea(.all)
VStack{
Text("Récompense quotidienne")
.font(.title)
.foregroundColor(.white)
.padding()
GeometryReader { geometry in
LinearGradient(
gradient: Gradient(colors: [
Color.black.opacity(0.6),
Color.black.opacity(0.9)
]),
startPoint: .top,
endPoint: .bottom
)
.edgesIgnoringSafeArea(.all)
Button("Fermer") {
show.toggle()
VStack {
Text("Récompense quotidienne")
.textStyle(weight: .bold, color: .white, size: 25)
Group {
switch step {
case .first:
Image("giftImage")
.transition(.opacity)
case .end:
ZStack {
Image("giftEarnImage")
.transition(.opacity)
HStack {
Text("+ 123")
.textStyle(weight: .black, color: .white, size: 55)
Image("allcoinWhiteIcon")
.resizable()
.frame(width: 40, height: 40)
}
}
}
}
.frame(width: geometry.size.width * 0.8, height: geometry.size.height * 0.4)
.onTapGesture {
withAnimation {
switch step {
case .first:
step = .end
case .end:
step = .first
show.toggle()
}
}
}
Text("Votre récompense quotidienne est débloquée tous les jours à 00:00 UTC et vous permet dobtenir entre 10 et 150 Allcoins.")
.textStyle(weight: .medium, color: .white, size: 13)
.multilineTextAlignment(.center)
.padding(.horizontal, geometry.size.width * 0.13)
.opacity(0.67)
}
.padding()
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(10)
.frame(width: geometry.size.width, height: geometry.size.height)
}
}
}
struct DailyGiftPage_Previews: PreviewProvider {
static var previews: some View {
DailyGiftPage(show: .constant(false))

@ -139,7 +139,6 @@ struct LoginView: View {
focusedField = nil
}
}
}
}

Loading…
Cancel
Save