27
|
1 //
|
|
2 // GuessTheFlagView-ViewModel.swift
|
|
3 // GeoQuiz
|
|
4 //
|
|
5 // Created by Dennis Concepción Martín on 9/11/22.
|
|
6 //
|
|
7
|
|
8 import Foundation
|
|
9 import SwiftUI
|
|
10
|
|
11 extension GuessTheFlagView {
|
|
12
|
|
13 class Layout {
|
|
14
|
|
15 static func showFlag(in flagPath: String, geo: GeometryProxy, _ userController: UserController) -> some View {
|
|
16 switch userController.data.guessTheFlagShape {
|
|
17 case .respectAspectRatio:
|
|
18 return AnyView(
|
|
19 RoundedRectangle(cornerRadius: 20)
|
|
20 .foregroundColor(.white.opacity(0.5))
|
|
21 .frame(width: geo.size.height * 0.3, height: geo.size.height * 0.15)
|
|
22 .overlay(
|
|
23 Image(uiImage: UIImage(contentsOfFile: flagPath)!)
|
|
24 .resizable()
|
|
25 .scaledToFit()
|
|
26 .cornerRadius(20)
|
|
27 .shadow(radius: 10)
|
|
28 .padding()
|
|
29 )
|
|
30 )
|
|
31 case .circular:
|
|
32 return AnyView(
|
|
33 Image(uiImage: UIImage(contentsOfFile: flagPath)!)
|
|
34 .renderingMode(.original)
|
|
35 .resizable()
|
|
36 .scaledToFit()
|
|
37 .frame(height: geo.size.height * 0.16)
|
|
38 .clipShape(Circle())
|
|
39 .shadow(radius: 10)
|
|
40 )
|
|
41 case .rectangular:
|
|
42 return AnyView(
|
|
43 Image(uiImage: UIImage(contentsOfFile: flagPath)!)
|
|
44 .renderingMode(.original)
|
|
45 .resizable()
|
|
46 .scaledToFill()
|
|
47 .frame(width: geo.size.height * 0.3, height: geo.size.height * 0.15)
|
|
48 .clipShape(RoundedRectangle(cornerRadius: 20))
|
|
49 .shadow(radius: 10)
|
|
50 )
|
|
51 }
|
|
52 }
|
|
53 }
|
|
54 }
|