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

@ -2,41 +2,82 @@
// DailyGiftPage.swift // DailyGiftPage.swift
// AllIn // AllIn
// //
// Created by étudiant on 02/02/2024. // Created by Emre on 02/02/2024.
// //
import SwiftUI import SwiftUI
struct DailyGiftPage: View { struct DailyGiftPage: View {
enum Step {
case first
case end
}
@State private var step: Step = .first
@Binding var show: Bool @Binding var show: Bool
var body: some View { var body: some View {
LinearGradient( GeometryReader { geometry in
gradient: Gradient(colors: [ LinearGradient(
Color.black.opacity(0.5), gradient: Gradient(colors: [
Color.black.opacity(0.9) Color.black.opacity(0.6),
]), Color.black.opacity(0.9)
startPoint: .top, ]),
endPoint: .bottom startPoint: .top,
) endPoint: .bottom
.edgesIgnoringSafeArea(.all) )
.edgesIgnoringSafeArea(.all)
VStack{
Text("Récompense quotidienne") VStack {
.font(.title) Text("Récompense quotidienne")
.foregroundColor(.white) .textStyle(weight: .bold, color: .white, size: 25)
.padding()
Group {
Button("Fermer") { switch step {
show.toggle() 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() .frame(width: geometry.size.width, height: geometry.size.height)
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(10)
} }
} }
} }
struct DailyGiftPage_Previews: PreviewProvider { struct DailyGiftPage_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
DailyGiftPage(show: .constant(false)) DailyGiftPage(show: .constant(false))

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

Loading…
Cancel
Save