import SwiftUI


// 弹窗视图

struct PopupView: View {
    @Binding var isShowing: Bool
    @State private var movingDotPosition: CGFloat = 0.0
    @State var resource: GifResource? = nil
    var body: some View {
        ZStack {
            Color.black.opacity(0.2)
                

            VStack (spacing: 10){
                GifImage(resource: resource,
                         contentMode: .scaleAspectFit,
                         isAnimating: .constant(true))
                    .frame(width: 103, height: 48)
                    
                Spacer()
                
                Text("按照动画方式旋转手机\n可校准指南针")
                    .font(.body)
                    .foregroundColor(.black)
                    .multilineTextAlignment(.center)
                    .lineLimit(2)
                
                Spacer()
                
                Button(action: {
                    isShowing = false
                }) {
                    Text("确定")
                        .font(.system(size: 16))
                        .frame(width: 280 * 0.5, height: 50)
                        .foregroundColor(.white)
                        .background(Color.customdeepblue)
                        .cornerRadius(15)
                }
            }
            .padding(.all,20.0)
            .frame(width: 280, height: 280 * 0.87)
            .background(Color.white)
            .cornerRadius(20)
            .task {
                resource = try? await UIImage.decodeGif(fromBundle: "wuqiong")
            }
        }
    }
}

