Skip to content

Commit

Permalink
Merge pull request #121 from AWSary/game
Browse files Browse the repository at this point in the history
new game, guess aws service name
  • Loading branch information
tigpt authored Feb 3, 2024
2 parents 0b07fa9 + 53f7668 commit 0784e9d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
13 changes: 11 additions & 2 deletions ios/Shared/DataModels/AwsServices.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@ import Foundation
var fm = FileManager.default
var subUrl: URL?
var mainUrl: URL? = Bundle.main.url(forResource: "aws_services", withExtension: "json")
var lastRandom: awsService = awsService(id: 10, name: "DeepRacer", longName: "AWS DeepRacer", shortDesctiption: "DeepRacer", imageURL: "https://static.tig.pt/awsary/logos/[email protected]", youtube_id: "")

class AwsServices: ObservableObject {
@Published var services = [awsService]()


func getNameOfLastRandom() -> String {
return lastRandom.longName
}

func getLastRandom() -> awsService {
return lastRandom
}

func getRandomElement() -> awsService{
return services.randomElement()!
lastRandom = services.randomElement()!
return lastRandom
}
init() {
refresh()
Expand Down
38 changes: 35 additions & 3 deletions ios/Shared/MainViews/Game.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,41 @@
import SwiftUI

struct Game: View {
var body: some View {
Text("Hello, World from GAME!")
}
@ObservedObject var awsServices = AwsServices()
@State private var showServiceName = false

var body: some View {
var lastRandomService: awsService = awsServices.getLastRandom()
VStack{
Spacer()
Text("Name the AWS service")
.font(.title).bold()
AWSserviceImagePlaceHolderView(service: lastRandomService, showLabel: false)
.frame(minHeight: 140)
if (showServiceName){
Text(awsServices.getNameOfLastRandom()).font(.title)
.multilineTextAlignment(.center)
} else {
Text(" ").font(.title)
}
Spacer()
if(showServiceName){
Button(action: {
if (showServiceName){
lastRandomService = awsServices.getRandomElement()
showServiceName = false
}
}, label: {
Text("Generate a new Random Service")
})
}else {
Button(action: {showServiceName = true}, label: {
Text("Reveal")
})
}
Spacer()
}
}
}

#Preview {
Expand Down

0 comments on commit 0784e9d

Please sign in to comment.